for(door = 0; door < 6; ++door){
scan_room = ch->in_room;
for(depth = 1; depth < shallow; ++depth){
if((pExit = scan_room->exit[door]) != NULL){
scan_room = pExit->u1.to_room;
scan_list (pExit->u1.to_room, ch, depth, door);
}else
break;
}
}
void scan_char (CHAR_DATA * victim, CHAR_DATA * ch, sh_int depth, sh_int door)
{
extern char *const dir_name[];
extern char *const distance[];
char buf[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
buf[0] = '\0';
if (door < 1)
sprintf (buf, "Northwards: ");
else if (door < 2)
sprintf (buf, "Eastwards: ");
else if (door < 3)
sprintf (buf, "Southwards: ");
else if (door < 4)
sprintf (buf, "Westwards: ");
else if (door < 5)
sprintf (buf, "Upwards: ");
else
sprintf (buf, "Downwards: ");
if (IS_NPC(victim))
strcat (buf, victim->short_descr);
else
strcat (buf, victim->name);
strcat (buf, ", ");
strcat (buf, distance[depth]);
strcat (buf, "\n\r");
send_to_char (buf, ch);
return;
}
int firstn = 0, firste = 0, firsts = 0, firstw = 0, firstu = 0, firstd = 0;
if (door == 0 && depth == 1)
{
if (victim != NULL)
{
firstn = 1;
}
}
else if (door == 1 && depth == 1)
{
if (victim != NULL)
{
firste = 1;
}
}
else if (door == 2 && depth == 1)
{
if (victim != NULL)
{
firsts = 1;
}
}
else if (door == 3 && depth == 1)
{
if (victim != NULL)
{
firstw = 1;
}
}
else if (door == 4 && depth == 1)
{
if (victim != NULL)
{
firstu = 1;
}
}
else if (door == 5 && depth == 1)
{
if (victim != NULL)
{
firstd = 1;
}
}
//next
if (door == 0 && depth != 1)
{
if (firstn == 0 && victim != NULL)
{
firstn = 1;
}
}
else if (door == 1 && depth != 1)
{
if (firste == 0 && victim != NULL)
{
firste = 1;
}
}
else if (door == 2 && depth != 1)
{
if (firsts == 0 && victim != NULL)
{
firsts = 1;
}
}
else if (door == 3 && depth != 1)
{
if (firstw == 0 && victim != NULL)
{
firstw = 1;
}
}
else if (door == 4 && depth != 1)
{
if (firstu == 0 && victim != NULL)
{
firstu = 1;
}
}
else if (door == 5 && depth != 1)
{
if (firstd == 0 && victim != NULL)
{
firstd = 1;
}
}
3-2
| |
X-1-2-3
0-0-0-0-0-0-0-0-0
| | | | | | | | |
0-0-0-0-X-1-2-3-4
| | | | | | | | |
0-0-0-0-0-0-0-0-0
0-0-0-0-4-0-0-0-0
| | | | | | | | |
0-0-0-0-3-0-0-0-0
| | | | | | | | |
0-0-0-0-2-0-0-0-0
| | | | | | | | |
0-0-0-0-1-0-0-0-0
| | | | | | | | |
4-3-2-1-X-1-2-3-4
| | | | | | | | |
0-0-0-0-1-0-0-0-0
| | | | | | | | |
0-0-0-0-2-0-0-0-0
| | | | | | | | |
0-0-0-0-3-0-0-0-0
| | | | | | | | |
0-0-0-0-4-0-0-0-0
3-2
| |
X-1-2-3
function do_scan(ch, argument)
if ch is blind: return
if argument == "":
send to ch: "you need an argument"
return
direction = str_to_direction(argument) // see below
if direction == -1:
send to ch: argument + " is not a valid direction"
return
if ch is ranger or ch is thief:
max_distance = 1 + (ch->level / 13)
else:
max_distance = ch->level < 25 ? 1 : 2
cur_room = ch->room
next_room = get cur_room->exits[direction]
if next_room is null:
send to ch: "no exit to the " + argument
return
// start scanning, with:
// actor: ch
// room: next_room (== cur_room->exits[direction])
// direction: direction
// current depth: 1
// max_depth: max_depth
// have we seen somebody: FALSE
scan(ch, next_room, direction, 1, max_depth, FALSE)
end
function scan(ch, room, direction, cur_depth, max_depth, seen_already)
if cur_depth > max_depth:
return
// we are currently in 'room', and need to display targets to ch
for each 'person' in room->people:
if person == ch: continue
if not(ch can see person): continue
if seen_already:
prefix = 12 spaces
else:
prefix = direction_to_xwards(direction)
suffix = depth_to_distancestr(cur_depth)
send_to_ch: prefix + " " + target->name + " " + suffix
seen_already = TRUE
// we have finished the people in this room. Move on to the next one.
next_room = get room->exits[direction]
if next_room is null:
return
else:
scan(ch, next_room, direction, cur_depth + 1, max_depth, seen_already
end
bool str_to_direction(const char *arg1)
{
else if (!str_cmp (arg1, "n") || !str_cmp (arg1, "north"))
return 0;
else if (!str_cmp (arg1, "e") || !str_cmp (arg1, "east"))
return 1;
else if (!str_cmp (arg1, "s") || !str_cmp (arg1, "south"))
return 2;
else if (!str_cmp (arg1, "w") || !str_cmp (arg1, "west"))
return 3;
else if (!str_cmp (arg1, "u") || !str_cmp (arg1, "up"))
return 4;
else if (!str_cmp (arg1, "d") || !str_cmp (arg1, "down"))
return 5;
else
return -1;
}
bool str_to_direction args( ( const char *arg1) );
Here is the code I am trying to write:
The problem is..
In my room: the cityguard
1 east: the guardian vampire
2 east: a patrolman
3 east: an ogre gang member
4 east: a troll gang member
1 west: the kitten
(nothing else west)
so.. my "scout should show:
the guardian vampire, nearby to the east.
a patrolman, not far east.
an ogre gang member, off in the distance east.
a troll gang member, way WAY east
the kitten, nearby to the west.
But instead I get:
the guardian vampire, nearby to the east.
a patrolman, not far east.
an ogre gang member, off in the distance east.
a troll gang member, way WAY east
an ogre gang member, nearby to the west.
a patrolman, not far west.
the guardian vampire, off in the distance west.
the cityguard, way WAY west
It seems to be looking east and then moving me to that furtherest east room and once there looking back west…