[Package Index | Mudlib Index | Effect Index]
Description
With the exception of the office, the shopkeeper contains the most complex code. This npc is intended to mimic a player as closely as possible. It adds and removes stock, and uses the cash register in the same way as a player. It moves through the shop to the correct area to perform its tasks. It logs sales and purchases in the same way as an employee. The exceptions, as far as a customer is concerned, are that money and items are implicitly given to the npc when a transaction is initiated.
Probably the most 'intelligent' functions of the npc are to do with money. Historically, the npc was limited to the lowest denomination and was therefore limited by the amount of this coin in the customer's possession, or the contents of the register. It also meant that a large transaction could result in several hundred coins being exchanged.
The npc now has the ability to take the appropriate coins from a player during a sale, and to get the correct amount of money from the register depending upon its contents. It will start with the highest value coins and work downwards until it has the correct amount of money to pay for the goods received. Unfortunately, the npc cannot yet handle change, and will therefore return the goods to the customer if unable to get the correct money from the register.
The npc will work between the hours specified by the creator, and can also be sent home by an employee. The npc will also return home if attacked. In this instance, the attacker will be banned from the shop automatically, and fired if they are an employee.
The npc will conduct some standard tests on items before they are bought from a customer. These are mainly basic stuff like checking the item is stocked by the shop. Any custom rules (such as not buying unpickled bits, uncharged magic wands, certain types of 'things') can be specified by the creator. Obviously, this may have an impact on code-maintenance if players change the list of stocked items regularly. However, I haven't had to change these rules significantly in the last year or so at Tarnach's.
See also:
/include/player_shop.h, /std/shops/player_shop/office.c, /std/shops/player_shop/mgr_office.c, /std/shops/player_shop/storeroom.c, /std/shops/player_shop/shop_front.c and /std/shops/player_shop/shopkeeper.c
Written by Ringo
Started 1st August 1999
#include "path.h" inherit "/std/shops/player_shop/shopkeeper"; void setup() { set_name( "betty" ); set_short( "Miss Betty Scuttle" ); basic_setup( "human" , "fighter" , 15 ); set_gender( "female" ); add_alias( ({ "scuttle", "betty scuttle", "miss betty scuttle" }) ); set_long( "This is Miss Scuttle, an amiable middle-aged lady who " "helps out in the shop from time to time.\n" ); set_office( PATH + "office" ); set_dearie( ({ "love", "my dear", "dear", "honey" }) ); set_work_hours( ({0,0,23,59,}) ); } object *item_test( mixed * items ) { object *give_back_wand= ({}), *give_back_unpickled = ({}); foreach( object ob in items ) { if ( ob->query_magic_wand() && !ob->query_charges() ) { give_back_wand += ({ ob }); } } if ( sizeof( give_back_wand ) ) { do_command( "'I'm sorry, we don't buy uncharged magic wands." ); } foreach( object ob in items ) { if ( ( ob->query_property( "corpse bit" ) && !ob->no_decay() && !ob->query_cured() ) || ob->query_decay_speed() ) { give_back_unpickled += ({ ob }); } } if ( sizeof( give_back_unpickled ) ) { do_command( "'We can't accept unpickled items." ); } return ( give_back_wand + give_back_unpickled ); }
.
string query_office()Query the path to the office.
object * item_test(mixed * items)Test items before buying. This function adds more shop-specific checks to see if we should buy something not covered by the standard checks. The function should take a parameter of an mixed array, being the objects the customer is trying to sell. It should return an array of the objects we are not buying. Any response by the npc should be handled within the function. All other processing will be handled by the inheritable. If you need such processing, create this function within your own object.
object *item_test( mixed * items ) { object *give_back = ({}); foreach( object ob in items ) { if ( ( ob->query_property( "corpse bit" ) && !ob->no_decay() && !ob->query_cured() ) || ob->query_decay_speed() ) { give_back += ({ ob }); } } if ( sizeof( give_back ) ) { do_command( "'We can't accept unpickled items, my dear." ); } return ( give_back ); }
void set_dearie(string * dearie)Set the pleasantries to be used by this npc, i.e.
set_dearie( ({ "dearie", "my dear", ... }) );
void set_office(string path)Set the path of the main office.
void set_work_hours(int * hours)Set the working hours for this shopkeeper. Will set the hours that this shopkeeper will work. This is an array of the format ({start_hour,start_min,end_hour,end_min})