00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #if defined(macintosh)
00029 #include <types.h>
00030 #else
00031 #include <sys/types.h>
00032 #endif
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #include <string.h>
00036 #include <time.h>
00037 #include "merc.h"
00038
00039 char *const distance[4] = {
00040 "right here.", "nearby to the %s.", "not far %s.",
00041 "off in the distance %s."
00042 };
00043
00044 void scan_list args ((ROOM_INDEX_DATA * scan_room, CHAR_DATA * ch,
00045 sh_int depth, sh_int door));
00046 void scan_char args ((CHAR_DATA * victim, CHAR_DATA * ch,
00047 sh_int depth, sh_int door));
00048 void do_scan (CHAR_DATA * ch, char *argument)
00049 {
00050 extern char *const dir_name[];
00051 char arg1[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
00052 ROOM_INDEX_DATA *scan_room;
00053 EXIT_DATA *pExit;
00054 sh_int door, depth;
00055
00056 argument = one_argument (argument, arg1);
00057
00058 if (arg1[0] == '\0')
00059 {
00060 act ("$n looks all around.", ch, NULL, NULL, TO_ROOM);
00061 send_to_char ("Looking around you see:\n\r", ch);
00062 scan_list (ch->in_room, ch, 0, -1);
00063
00064 for (door = 0; door < 10; door++)
00065 {
00066 if ((pExit = ch->in_room->exit[door]) != NULL)
00067 scan_list (pExit->u1.to_room, ch, 1, door);
00068 }
00069 return;
00070 }
00071 else if (!str_cmp (arg1, "n") || !str_cmp (arg1, "north"))
00072 door = 0;
00073 else if (!str_cmp (arg1, "e") || !str_cmp (arg1, "east"))
00074 door = 1;
00075 else if (!str_cmp (arg1, "s") || !str_cmp (arg1, "south"))
00076 door = 2;
00077 else if (!str_cmp (arg1, "w") || !str_cmp (arg1, "west"))
00078 door = 3;
00079 else if (!str_cmp (arg1, "u") || !str_cmp (arg1, "up"))
00080 door = 4;
00081 else if (!str_cmp (arg1, "d") || !str_cmp (arg1, "down"))
00082 door = 5;
00083 else if ( !str_cmp( arg1, "ne" ) || !str_cmp( arg1, "northeast" ) )
00084 door = 6;
00085 else if ( !str_cmp( arg1, "nw" ) || !str_cmp( arg1, "northwest" ) )
00086 door = 7;
00087 else if ( !str_cmp( arg1, "se" ) || !str_cmp( arg1, "southeast" ) )
00088 door = 8;
00089 else if ( !str_cmp( arg1, "sw" ) || !str_cmp( arg1, "southwest" ) )
00090 door = 9;
00091
00092 else
00093 {
00094 send_to_char ("Which way do you want to scan?\n\r", ch);
00095 return;
00096 }
00097
00098 act ("You peer intently $T.", ch, NULL, dir_name[door], TO_CHAR);
00099 act ("$n peers intently $T.", ch, NULL, dir_name[door], TO_ROOM);
00100 sprintf (buf, "Looking %s you see:\n\r", dir_name[door]);
00101
00102 scan_room = ch->in_room;
00103
00104 for (depth = 1; depth < 4; depth++)
00105 {
00106 if ((pExit = scan_room->exit[door]) != NULL)
00107 {
00108 scan_room = pExit->u1.to_room;
00109 scan_list (pExit->u1.to_room, ch, depth, door);
00110 }
00111 }
00112 return;
00113 }
00114
00115 void scan_list (ROOM_INDEX_DATA * scan_room, CHAR_DATA * ch, sh_int depth,
00116 sh_int door)
00117 {
00118 CHAR_DATA *rch;
00119
00120 if (scan_room == NULL)
00121 return;
00122 for (rch = scan_room->people; rch != NULL; rch = rch->next_in_room)
00123 {
00124 if (rch == ch)
00125 continue;
00126 if (!IS_NPC (rch) && rch->invis_level > get_trust (ch))
00127 continue;
00128 if (can_see (ch, rch))
00129 scan_char (rch, ch, depth, door);
00130 }
00131 return;
00132 }
00133
00134 void scan_char (CHAR_DATA * victim, CHAR_DATA * ch, sh_int depth, sh_int door)
00135 {
00136 extern char *const dir_name[];
00137 extern char *const distance[];
00138 char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
00139
00140 buf[0] = '\0';
00141
00142 strcat (buf, PERS (victim, ch));
00143 strcat (buf, ", ");
00144 sprintf (buf2, distance[depth], dir_name[door]);
00145 strcat (buf, buf2);
00146 strcat (buf, "\n\r");
00147
00148 send_to_char (buf, ch);
00149 return;
00150 }