Re: mobact.c

From: Welcor (
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
> 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 :)
> At first I found that the thief was trying to steal from himself, so I
> a debug message. So then I looked at some other for loops in mobact and
> the 'found' logic and tried to work that in also, but all I end up with
> 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)
           if (vict && GET_LEVEL(vict) < LVL_IMMORT && !number(0, 4) ) {
             npc_steal(ch, vict);
             found = TRUE;

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

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

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.


   | FAQ: |
   | Archives: |
   | Newbie List:   |

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