re: Scan

From: Wheel of Fish! (piraeus@connectus.com)
Date: 02/27/95


well .. here is the base scan code I've got.. it's not pretty (yet) but it
functions quite well... right now it's set up to let theives and immortals
scan for *3* rooms in any direction.. I plan on implementing a 'peer'
skill for thieves forcing them to learn it before they can get the extra 2
rooms but thats just another thing to work on eh? :)  also I plan on
cleaning up the output some and trying to tighten the code down.. but for
now it's not a half bad.

#include <stdio.h>
#include <string.h>

#include "structs.h"
#include "utils.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"

/* get external functions */
extern struct room_data *world;
extern struct descriptor_data *descriptor_list; 
extern struct index_data *obj_index;
extern int rev_dir[];
extern char *dirs[]; 

/* the scan command */
ACMD(do_scan)
{
  int i, depth, j;
  struct char_data *p;
  sh_int room;
  char buffer[MAX_STRING_LENGTH];
  bool flag;
  
  depth = 1;
  if (GET_CLASS(ch) == CLASS_THIEF || GET_LEVEL(ch) >= LVL_IMMORT ) depth = 3;
  
  for (i = 0; i < 6; i++)
  {
    buffer[0] = '\0';
    room = ch->in_room;
    for (j = 1; j <= depth; j++)
    {
      if((!world[room].dir_option[i]) 
         || ((world[room].dir_option[i])->to_room == NOWHERE))
      {
        j = depth + 1;
        continue;
      }
      else if (IS_SET((world[room].dir_option[i])->exit_info, EX_CLOSED))
      {
        if (j == 1)
        {
          sprintf(buffer,"There is a closed %s to the %s.\n\r",
            fname(world[room].dir_option[i]->keyword), dirs[i]);
          send_to_char(buffer, ch);
        }
        j = depth + 1;
        continue;
      }
      else
      {
        room = world[room].dir_option[i]->to_room;       
        for (flag = TRUE, p = world[room].people; p; p = p->next_in_room)
        {
          if ((ch != p) && CAN_SEE(ch, p) && !IS_AFFECTED(p, AFF_HIDE))
          {
            if (flag)
            {
              sprintf(buffer,"%d moves to the %s\n\r", j, dirs[i]);
              send_to_char(buffer, ch);
              flag = FALSE;
            }
            if (IS_NPC(p))
              sprintf(buffer,"    %s\n\r", p->player.short_descr);
            else
              sprintf(buffer,"    %s\n\r", GET_NAME(p));
            send_to_char(buffer, ch);
          }
        }
      }
    }
  }
  return;
}



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