[CODE] hunt_victim

From: Andrey Fidrya (andrey@alex-ua.com)
Date: 05/31/99


There is broken code in graph.c, hunt_victim():
===
  /* make sure the char still exists */
  for (found = FALSE, tmp = character_list; tmp && !found; tmp = tmp->next)
    if (HUNTING(ch) == tmp)
      found = TRUE;
  if (!found) {
    do_say(ch, "Damn!  My prey is gone!!", 0, 0);
    HUNTING(ch) = NULL;
    return;
  }
===
For example, the following situation can occur:
Player rents out and is extracted from world. When another player logs in,
there's possibility of malloc assigning him old player's memory address.
Mob will hunt innocent player then.
This function isn't used by stock CircleMUD, but is used by snippets and
is broken. I suggest deleting quoted lines from hunt_victim() completely and
adding the following lines to handler.c, extract_char:
===
  clearKillers(ch);        /* Forget all enemies */

+ /* Inform hunters... */
+ for (temp = character_list; temp; temp = temp->next)
+   if (HUNTING(temp) == ch)
+     HUNTING(temp) = NULL;

  if (!IS_NPC(ch)) {
    save_char(ch);
===
Its safer and track_victim() will not waste large amounts of time.

Btw, its very easy to add MOB_TRACKER flag to stock Circle.
I wonder why it wasn't done yet. Here is my version of tracking mobiles
(replace SKILL_TRACK check with MOB_TRACKER bit check):

mobact.c:
===
[ Examine call for special procedure ... ]

/* If the mob has no specproc, do the default actions */
if (FIGHTING(ch) || !AWAKE(ch))
  continue;

/* 1st step: Mobile trackers */
if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch) && !IS_CHARMED(ch) &&
    GET_EFF_SKILL(ch, SKILL_TRACK) && !AFF_FLAGGED(ch, SPELL_BLINDNESS)) {
  found = FALSE;
  for (names = MEMORY(ch); names && !found; names = names->next) {
    for (d = descriptor_list; d; d = d->next) {
      if (!d->character)
        continue;
      if (names->id == GET_IDNUM(d->character) &&
          d->character->in_room != ch->in_room &&
          world[d->character->in_room].zone == world[ch->in_room].zone) {
            if (GET_POS(ch) == POS_RESTING || GET_POS(ch) == POS_SITTING)
              do_stand(ch, NINE_NULLS);
            HUNTING(ch) = d->character;
            hunt_victim(ch);
            found = TRUE;
            break;
          }
    }
    if (found)
      continue;
  }
}

/* Scavenger (picking up objects) */
[...]
===

Adding ROOM_NOMOB check to hunt_victim() won't hurt too.

Zmey // 3MoonsWorld (rmud.net.ru:4000)


     +------------------------------------------------------------+
     | 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 : 12/15/00 PST