Re: mobact.c

From: Welcor (welcor@dune.net)
Date: 01/20/02


----- Original Message -----
From: "Zizazat Lazuras" <zizazat@HOTMAIL.COM>
> Background: I am trying to do away with the need for special procedures
for
> mobs to emulate class behaviors. So, for example, a thief mob will steal
> gold, a wizard will cast spells etc. I am trying to work with thief/steal
> first as I thought it was the least complicated :)
<snip>
> At first I found that the thief was trying to steal from himself, so I
added
> a debug message. So then I looked at some other for loops in mobact and
saw
> the 'found' logic and tried to work that in also, but all I end up with
now
> is a thief who thinks he should steal from himself.
>
> Can someone please help me with my bad logic?

I restructured the code a bit below (mostly cosmetic, read below).

   switch (GET_CLASS(ch)) {
     case CLASS_THIEF:
       if (GET_POS(ch) == POS_STANDING && (!MOB_FLAGGED(ch, MOB_SPEC)) ) {
         for (found = FALSE, vict = world[ch->in_room].people;
              vict && !found;
              vict = vict->next_in_room)
           if (vict == ch)
              continue;
           if (vict && GET_LEVEL(vict) < LVL_IMMORT && !number(0, 4) ) {
             npc_steal(ch, vict);
             found = TRUE;
           }
       }
     break;
   }

I figure you've only tested this with an immortal, beacuse the source of
your problems are in two places. You are certain the loop will always
include the mob itself (after all, it MUST be part of the .people list).
The message would be sent every time the thief _didn't_ steal (because
it would then find itself), and sometimes when it _did_ (because it was
first in the list).

The other reason for your problems is the beginning of npc_steal() in
spec_procs.c:

  if (IS_NPC(victim))
    return;
  if (GET_LEVEL(victim) >= LVL_IMMORT)
    return;
  if (!CAN_SEE(ch, victim))
    return;

Thus, if you test it with an immortal, no coins will be stolen, ever.
Try removing one or more of these checks, as you deem it appropriate.

Welcor

--
   +---------------------------------------------------------------+
   | 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