[an error occurred while processing this directive]
[<a href="index.shtml">Package Index</a></code> | <a href="index_std.shtml">Mudlib Index</a></code> | <a href="index_eff.shtml">Effect Index</a></code>]<br><h2>File /std/shops/player_shop/shopkeeper.c</h2>
The standard inheritable object for player-run shop npc shopkeepers.

<p><b>Description</b></p>
<p>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.
</p>
<p>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.
</p>
<p>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. 
</p>
<p>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. 
</p>
<p>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. 
</p>
<p><b>See also:</b><br><a href="include.player_shop.h.shtml">/include/player_shop.h</a>, <a href="std.shops.player_shop.office.c.shtml">/std/shops/player_shop/office.c</a>, <a href="std.shops.player_shop.mgr_office.c.shtml">/std/shops/player_shop/mgr_office.c</a>, <a href="std.shops.player_shop.storeroom.c.shtml">/std/shops/player_shop/storeroom.c</a>, <a href="std.shops.player_shop.shop_front.c.shtml">/std/shops/player_shop/shop_front.c</a> and <a href="std.shops.player_shop.shopkeeper.c.shtml">/std/shops/player_shop/shopkeeper.c</a><p>Written by Ringo<p>Started 1st August 1999
<h3>Example</h3>
<pre>#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 );
}
</pre>
<h2>Inherits</h2>
This class inherits the following classes <a href="obj.monster.c.shtml">/obj/monster.c</a><h2>Includes</h2>
This class includes the following files <a href="include.move_failures.h.shtml">/include/move_failures.h</a>, /include/shops/bank.h, <a href="include.money.h.shtml">/include/money.h</a>, <a href="include.living.h.shtml">/include/living.h</a> and <a href="include.player_shop.h.shtml">/include/player_shop.h</a><h2>Method index</h2>
<dl><ul>
<li><a href="#item_test">item_test</a>(mixed *)<br/>
Test items before buying.
<li><a href="#query_office">query_office</a>()<br/>
Query the path to the office.
<li><a href="#set_dearie">set_dearie</a>(string *)<br/>
Set the pleasantries to be used by this npc, i.
<li><a href="#set_office">set_office</a>(string)<br/>
Set the path of the main office.
<li><a href="#set_work_hours">set_work_hours</a>(int *)<br/>
Set the working hours for this shopkeeper.
</ul><h2>Public Functions</h2>
These are functions that everyone can access.<p>
.<ul><a name="query_office">
query_office</a><pre>
string query_office()
</pre></br>
Query the path to the office.
<br/><ul>
<li><b>Returns:</b>
<br/>The path to the office.

</dl>


<h2>Protected Functions</h2>
These are functions that only objects inheriting the class can access.<p>
<ul><a name="item_test">
item_test</a><pre>
object * item_test(mixed * items)
</pre></br>
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.

<br/><ul>
<li><b>Parameters:</b>
<br/>items - The objects to test
<li><b>Returns:</b>
<br/>object The objects to give back to the customer

<li><b>Example:</b>
<br/><pre>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 );
}
</pre></dl>

<ul><a name="set_dearie">
set_dearie</a><pre>
void set_dearie(string * dearie)
</pre></br>
Set the pleasantries to be used by this npc, i.e.
<br/><ul>
<li><b>Parameters:</b>
<br/>dearie - An array of strings to be used

<li><b>Example:</b>
<br/><pre>set_dearie( ({ "dearie", "my dear", ... }) );</pre></dl>

<ul><a name="set_office">
set_office</a><pre>
void set_office(string path)
</pre></br>
Set the path of the main office.
<br/><ul>
<li><b>Parameters:</b>
<br/>path - The full path & filename.

</dl>

<ul><a name="set_work_hours">
set_work_hours</a><pre>
void set_work_hours(int * hours)
</pre></br>
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})
<br/><ul>
<li><b>Parameters:</b>
<br/>hours - an array as above

</dl>


[an error occurred while processing this directive]

