void do_scan( CHAR_DATA *ch, char *argument )
{
ROOM_INDEX_DATA *was_in_room;
EXIT_DATA *pexit;
sh_int dir = -1;
sh_int dist;
sh_int max_dist = 8;
set_char_color( AT_ACTION, ch );
if ( IS_AFFECTED( ch, AFF_BLIND ) )
{
send_to_char( "Not very effective when you're blind...\n\r", ch );
return;
}
// if ( argument[0] == '\0' )
// {
// send_to_char( "Scan in a direction...\n\r", ch );
// return;
// }
// if ( ( dir = get_door( argument ) ) == -1 )
// {
// send_to_char( "Scan in WHAT direction?\n\r", ch );
// return;
// }
was_in_room = ch->in_room;
act( AT_GREY, "Scanning $t...", ch, dir_name[dir], NULL, TO_CHAR );
act( AT_GREY, "$n scans $t.", ch, dir_name[dir], NULL, TO_ROOM );
if ( IS_VAMPIRE( ch ) )
{
if ( time_info.hour < 21 && time_info.hour > 5 )
{
send_to_char( "You have trouble seeing clearly through all the "
"light.\n\r", ch );
max_dist = 1;
}
}
if ( ( pexit = get_exit( ch->in_room, dir ) ) == NULL )
{
act( AT_GREY, "You can't see $t.", ch, dir_name[dir], NULL, TO_CHAR );
return;
}
if ( ch->level < 50 ) --max_dist;
if ( ch->level < 40 ) --max_dist;
if ( ch->level < 30 ) --max_dist;
for ( dist = 1; dist <= max_dist; )
{
if ( IS_SET(pexit->exit_info, EX_CLOSED) )
{
if ( IS_SET(pexit->exit_info, EX_SECRET)
|| IS_SET(pexit->exit_info, EX_DIG) )
act( AT_GREY, "Your view $t is blocked by a wall.", ch,
dir_name[dir], NULL, TO_CHAR );
else
act( AT_GREY, "Your view $t is blocked by a door.", ch,
dir_name[dir], NULL, TO_CHAR );
break;
}
if ( room_is_private( pexit->to_room )
&& ch->level < LEVEL_BUILDER )
{
act( AT_GREY, "Your view $t is blocked by a private room.", ch,
dir_name[dir], NULL, TO_CHAR );
break;
}
char_from_room( ch );
char_to_room( ch, pexit->to_room );
set_char_color( AT_RMNAME, ch );
send_to_char( ch->in_room->name, ch );
send_to_char( "\n\r", ch );
show_list_to_char( ch->in_room->first_content, ch, FALSE, FALSE );
show_char_to_char( ch->in_room->first_person, ch );
switch( ch->in_room->sector_type )
{
default: dist++; break;
case SECT_AIR:
if ( number_percent() < 80 ) dist++; break;
case SECT_INSIDE:
case SECT_FIELD:
case SECT_UNDERGROUND:
dist++; break;
case SECT_FOREST:
case SECT_CITY:
case SECT_DESERT:
case SECT_HILLS:
dist += 2; break;
case SECT_WATER_SWIM:
case SECT_WATER_NOSWIM:
dist += 3; break;
case SECT_MOUNTAIN:
case SECT_UNDERWATER:
case SECT_OCEANFLOOR:
dist += 4; break;
}
if ( dist >= max_dist )
{
act( AT_GREY, "Your vision blurs with distance and you see no "
"farther $t.", ch, dir_name[dir], NULL, TO_CHAR );
break;
}
if ( ( pexit = get_exit( ch->in_room, dir ) ) == NULL )
{
act( AT_GREY, "Your view $t is blocked by a wall.", ch,
dir_name[dir], NULL, TO_CHAR );
break;
}
}
char_from_room( ch );
char_to_room( ch, was_in_room );
return;
}
Need help getting SCAN to work right
Posted by Toy on Fri 06 Feb 2004 10:54 PM — 7 posts, 24,756 views.
Much like Search, I'm attempting to make scan into a command, not a skill. I've got it changed around, removed the gsn_ parts, now I'm attepting to make scan need to arguement. I removed the first one, then it called to the second one. I removed the second, and it caused a segment core drop.
-Toy
-Toy
Well, I see the problem. First, if you can make sure that when you post code you check the forum codes box, it makes reading the post much easier.
As for the code part, you've made it not use an argument... How do you know what direction to scan in? This bit of code here:
is the part that assigns what direction your trying to scan. Since you've commented it out, the variable dir has no valid number, and that will cause your crash. You'll need to figure out how to get a direction with no argument, which I don't think you can do.
As for the code part, you've made it not use an argument... How do you know what direction to scan in? This bit of code here:
// if ( ( dir = get_door( argument ) ) == -1 )
// {
// send_to_char( "Scan in WHAT direction?\n\r", ch );
// return;
// }is the part that assigns what direction your trying to scan. Since you've commented it out, the variable dir has no valid number, and that will cause your crash. You'll need to figure out how to get a direction with no argument, which I don't think you can do.
Sorry about the code codes.. thought I was following it right. ;p
Ah, so it's not really possible to set scan to not have an arguement huh? Ah well. Not a major issue, just had seen it work without an arguement before on another game I'd played. No biggie, just being experimentive. :)
-Toy
Ah, so it's not really possible to set scan to not have an arguement huh? Ah well. Not a major issue, just had seen it work without an arguement before on another game I'd played. No biggie, just being experimentive. :)
-Toy
It is possible to set scan without any arguments, but he was saying that you have to learn how. In order to have scan work without arguments, you'd most likely have to redo the whole code, if not most of it.
Yeah, I meant that since your not entering a direction, it doesn't know where to look. You could make it look in the opposite direction from where you came from(aka, forward). You could make it look in a random direction, or... I dunno, my point wasn't that it can't be done, but that you have to decide how to do it.
You might try looking at the circle and dawn codeabses since they both have scan available without arguments. It's unlikely you can just drop their code directly into smaug but it might help you figure out where you've missed something.