[CODE] Player Shops

From: Michael Gallagher (m_gally@hotmail.com)
Date: 06/05/00

Actually here's most of the code. As i said before, it may have some stuff
missing, but this will get you started anyway, and btw this is in my early
days of coding, so the code ain't very neat. This was 219 line the first
time i wrote it so i had to shave it down a bit. I'm going to assume your
not newbie coder and don't need your hand held through all this, cause
there's a good bit of code here. I put this into bpl15, and the usual
disclaimer applies, this isn't my responsibility.


you'll need to add a player variable, i added "int shop[3];" allowing up to
three shops to each player. Just put that in player_special_data_saved.


if do_start() add:
   ch->player_specials->saved.shop[1] = 0;
   ch->player_specials->saved.shop[2] = 0;
   ch->player_specials->saved.shop[3] = 0;


define GET_SHOP1(ch), GET_SHOP2(ch) and GET_SHOP3(ch) as the new variables
you've added.


edit do_stat_character so you can see what shops a player has, btw the
number saved is actually the vnum of the keeper of the shop. It makes things
easier. A also put into set so you can set player's shops.


I put shops into score, so players can see if they have a shop, It isn't
that great coz they never see the vnum's of the mobs, it's there anyway.


I made it so owners can buy stuff without paying and i made a function for
players to see shop stats, simple stuff. After this:

  } else if (CMD_IS("list")) {
    shopping_list(argument, ch, keeper, shop_nr);
    return (TRUE);

i added:

  } else if (CMD_IS("owner") && (IS_SHOP_OWNER(ch, keeper) || IS_GOD(ch))) {
    shopping_owner(ch, keeper, shop_index + shop_nr);
    return (TRUE);

where shopping_owner() is the function which shows info to the owner.
Obviously god's should be able to use this command too for quick reference.


just a few handy defines, like IS_SHOP_OWNER(ch, keeper) it checks to see if
GET_MOB_VNUM(keeper) == GET_SHOP1(ch), or shop2 or 3 even.


this is where all the saving comes in, i'll just list off the functions
which i added, i basically copied House save functions are edited them a

int Shop_get_filename(int shop_nr, char *filename, int bank);
int Shop_load(int shop_nr);
int Shop_save(struct obj_data * obj, FILE * fp);
void Shop_delete_file(int vnum);
void Shop_boot(void);
void Shop_save_all(void);
void Shop_crashsave(int shop_nr);

I was going to put Shop_boot() here, but i don't have the room, just to let
you know, i saved shop's gold and objects in two seperate files, it was the
only way i knew how to do it at that time (*embarrased*).


in do_order you should have something like this:

      if (((vict->master != ch) || !AFF_FLAGGED(vict, AFF_CHARM)) &&
!IS_SHOP_OWNER(ch, vict))
        act("$n doesn't answer.", FALSE, vict, 0, 0, TO_ROOM);
      else {
        send_to_char(OK, ch);
        command_interpreter(vict, message);


There's a good bit of code here, but it's pretty simple, allow the player to
give away his shop (i.e. "give shop1 <victim>").


owner needs to be put in command interpreter with do_not_here


in heartbeat() make sure Shop_save_all() runs every once in a while to save
all the shops in case of crash.


in db_boot put in Shop_boot


put this in do_simple_move

  for (owner = world[ch->in_room].people; owner; owner =
owner->next_in_room) {
   if (IS_SHOP_OWNER(owner, ch)) {
     send_to_char("Sorry you can't order a keeper to leave his shop!\r\n",


number of shop flags needs to be 3

That is more or less it, i hope you like it
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |

This archive was generated by hypermail 2b30 : 04/10/01 PDT