Re: Track!

From: UNREGISTERED VERSION (lk4150@krull.dk)
Date: 06/15/96


Here is a way to keep a track running, without having to keep
typing track <victim>.
Well here is the way I did it, it may be possible to do it more effectively
but I haven't had the time to optimize it yet.
The code is based on the macro HUNTING(ch) to store the char you are
tracking, and the flag PLR_FLAG which indicate that you are tracking.

1. define PLR_TRACK in structs.h

2. Add the following lines to the end of the function look_at_room,
   in act.informative.c

  if (PLR_FLAGGED(ch, PLR_TRACK))
    find_track_plr (ch);

3. Add the follwing two functions to graph.c (do_track replacing the
original).
There are some things in the functions that aren't original so if you get
compiler errors with undefined stuff, just remove those commands from the
functions.

ACMD(do_track)
{
  struct char_data *vict;
  int dir, num;

  if (!GET_SKILL(ch, SKILL_TRACK)) {
    send_to_char("You have no idea how.\r\n", ch);
    return;
  }

  if (!IS_WARRIOR(ch) && !IS_THIEF(ch) && !IS_MONK(ch) && !IS_SAMURAI(ch) &&
      !IS_BARBARIAN(ch) && !IS_RANGER(ch)) {
    send_to_char("You have absolutely no sense for tracking.\r\n", ch);
    return;
  }
  one_argument(argument, arg);
  if (!*arg) {
    if (PLR_FLAGGED(ch,PLR_TRACK))
    {
       send_to_char("You stop tracking.\r\n",ch);
       REMOVE_BIT(PLR_FLAGS(ch),PLR_TRACK);
       HUNTING(ch) = 0;
       return;
    }
    else
    {
      send_to_char("Whom are you trying to track?\r\n", ch);
      return;
    }
  }

  if (!(vict = get_char_vis(ch, arg))) {
      send_to_char("No-one around by that name.\r\n", ch);
      return;
    }

  if (IS_AFFECTED(vict, AFF_NOTRACK)) {
    send_to_char("You sense no trail.\r\n", ch);
    return;
  }
  dir = find_first_step(ch->in_room, vict->in_room);

  switch (dir) {
  case BFS_ERROR:
    send_to_char("Hmm.. something seems to be wrong.\r\n", ch);
    if (PLR_FLAGGED(ch,PLR_TRACK))
      REMOVE_BIT(PLR_FLAGS(ch),PLR_TRACK);
    break;
  case BFS_ALREADY_THERE:
    send_to_char("You're already in the same room!!\r\n", ch);
    if (PLR_FLAGGED(ch,PLR_TRACK))
      REMOVE_BIT(PLR_FLAGS(ch),PLR_TRACK);
    break;
  case BFS_NO_PATH:
    sprintf(buf, "You can't sense a trail to %s from here.\r\n",
            HMHR(vict));
    send_to_char(buf, ch);
    if (PLR_FLAGGED(ch,PLR_TRACK))
      REMOVE_BIT(PLR_FLAGS(ch),PLR_TRACK);
    break;
  default:
    num = number(0, 101);       /* 101% is a complete failure */
    if (GET_SKILL(ch, SKILL_TRACK) < num)
      do {
        dir = number(0, NUM_OF_DIRS - 1);
      } while (!CAN_GO(ch, dir));
    if (!PLR_FLAGGED(ch,PLR_TRACK)) {
      SET_BIT (PLR_FLAGS(ch),PLR_TRACK);
      HUNTING(ch) = vict;
    }
    sprintf(buf, "You sense a trail %s from here!\r\n", dirs[dir]);
    send_to_char(buf, ch);
    break;
  }
}

void find_track_plr (struct char_data* ch)
{
  struct char_data* tmp;

  int found,dir, num;

  if (!HUNTING(ch)) {
    REMOVE_BIT(PLR_FLAGS(ch),PLR_TRACK);
    return;
  }

  for (found = 0, tmp = character_list; tmp && !found; tmp = tmp->next)
    if (HUNTING(ch) == tmp)
      found = 1;

  if(!found)
  {
    send_to_char("You have lost your prey !\r\n",ch);
    REMOVE_BIT(PLR_FLAGS(ch),PLR_TRACK);
    HUNTING(ch) = 0;
    return;
  }

  dir = find_first_step(ch->in_room, HUNTING(ch)->in_room);

  switch (dir) {
  case BFS_ERROR:
    send_to_char("Hmm.. something seems to be wrong.\r\n", ch);
    if (PLR_FLAGGED(ch,PLR_TRACK))
      REMOVE_BIT(PLR_FLAGS(ch),PLR_TRACK);
    break;
  case BFS_ALREADY_THERE:
    send_to_char("You have reached your goal!!\r\n", ch);
    if (PLR_FLAGGED(ch,PLR_TRACK))
      REMOVE_BIT(PLR_FLAGS(ch),PLR_TRACK);
    break;
  case BFS_NO_PATH:
    sprintf(buf, "You can't sense a trail to %s from here.\r\n",
            HMHR(HUNTING(ch)));
    send_to_char(buf, ch);
    if (PLR_FLAGGED(ch,PLR_TRACK))
      REMOVE_BIT(PLR_FLAGS(ch),PLR_TRACK);
    break;
  default:
    num = number(0, 101);       /* 101% is a complete failure */
    if (GET_SKILL(ch, SKILL_TRACK) < num)
      do {
        dir = number(0, NUM_OF_DIRS - 1);
      } while (!CAN_GO(ch, dir));
    sprintf(buf, "You sense a trail %s from here!\r\n", dirs[dir]);
    send_to_char(buf, ch);
    break;
  }
}

4. In interpreter.c add PLR_TRACK to all the list that removes PLR_WRITING
etc.



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