Re: Dynamic Shops

From: Axel Trocha (trocha@gmx.de)
Date: 10/23/02


what about checking if a shopkeeper is in room first - something like
following:

shop_keeper = NULL;

for (tch = world[ch->in_room].people; tch; tch = next_tch) {
  next_tch = tch->next_in_room;
  if (IS_NPC(tch))
    if (!MOB_FLAGGED(tch, MOB_SHOPKEEPER)) {
      shop_keeper = tch;
      break;
    }
}

if (!shop_keeper) {
  send_to_char("You can't do that here!\r\n", ch);
  return;
}

..[now do your shopkeeper-code]...


Axel

On Wed, Oct 23, 2002 at 05:58:25PM -0500, David Cole wrote:
> Hello,
>
> I've rewritten the entire shop system to work in a completely different way.
> First off if a mob is mob flagged as MOB_SHOPKEEPER then it is a shop
> keeper. Second what ever is in the mobs inventory is what is he selling,
> with certain perks and checks and what not.
>
> the problem I seem to be having is in my for() loop to check if a mob in a
> room is actually a shop keeper:
>
>   for (tch = world[ch->in_room].people; tch; tch = next_tch) {
>     next_tch = tch->next_in_room;
>
>  if (IS_PC(tch))
>    continue;
>
>     if (!MOB_FLAGGED(tch, MOB_SHOPKEEPER)) {
>       send_to_char("You can't do that here!\r\n", ch);
>       return;
>  }
> bla bla bla....
>
> ok, so if a mob is flagged its cool else, its not, but what happens is it
> gets to the first mob and it stops cause of the return and says you can't do
> that here, which is good, but bad cause it never finds the shopkeeper, but
> if I change return to continue it says you can't do that here for each mob
> in the room that isn't a shop keeper, understand my dilemma?
>
> curious if anyone else had take this approach to shops and if so if they
> have found a solution to something this trivial? Or if someone can point me
> at what I'm doing wrong?
>
> Thanks,
> Dave

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT