[snippet] Mob Track

From: Joe Frohne (frohne@POST.ITS.MCW.EDU)
Date: 02/02/98


With all this talk about tracking mobs, thought I would throw this out
there. I made these instructions for a friend a long time ago.  I know I
have made some changes to this and there was one bug/feature I fixed.
However, this should give you an idea of how to go about mobs tracking.

Enjoy
Moradin of Awakened Dawn

Mob Tracking Code
by: Moradin of Awakened Dawn

in structs.h under mobile flags add, whatever next is

        #define MOB_TRACK       (1 << 18)   /* Mob Tracks */

in constants.c under MOB_x action bits add before end "\n"

        "TRACK",

in handler.h add

/* ******* characters ********* */

struct char_data *get_char_room(char *name, int room);
struct char_data *get_char_num(int nr);
struct char_data *get_char_idnum(int nr);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

in handler.c add this function


/* search the world for a char idnum, and return a pointer if found */
struct char_data *get_char_idnum(int nr)
{
  struct char_data *i;

  for (i = character_list; i; i = i->next)
    if (GET_IDNUM(i) == nr)
      return i;

  return NULL;
}

In mobact.c  where this functions starts void mobile_activity(void)
add the following variables to the appropriate lists

add *vtrack to the list of struct char_data
add godir in list of int


NEXT.....
add the following below where it says /* Add new mobile actions here */
and before where it says }  /* end for() */

    /* Tracking Mobs */
    if (MOB_FLAGGED(ch, MOB_TRACK) && MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) {
      found = FALSE;

      for (names = MEMORY(ch); names && !found; names = names->next)
        if(vtrack = get_char_idnum(names->id)){
            found = TRUE;
            godir = find_first_step(ch->in_room, vtrack->in_room);

            switch (godir) {
            case BFS_ERROR:
              break;
            case BFS_ALREADY_THERE:
              break;
            case BFS_NO_PATH:
              break;
            default:
              perform_move(ch, godir, 1);
              break;
            }
        }
    }

This is the basics of mob tracking players, each mob must be flaged as a
memory mob and as a tracker.  Mobs can track into death rooms and can
not track through doors or !mob rooms.  As long as the player is in the
mob's memory, it will keep trying to track them.  Once a player quits or
is killed, it will track the next character in the memory list.

This is just a rough outline and probably needs to be tweaked, but its
hard to test by myself controlling many characters. :-)

Also, I found the PULSE_MOBLE a bit slow in structs.h so I changed it to 5.
This made em track faster and attack faster.

I think this is it, if it throws some errors or whatever, let me know.  I
may have missed something, but I tried to include everything I did.


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



This archive was generated by hypermail 2b30 : 12/15/00 PST