Err automoving kind of

Posted by Gtr on Thu 22 Jul 2004 06:36 PM — 5 posts, 19,977 views.

#0
Hey guys..well I got past for the most part my last project totaling...to over 2k lines of code..that may not be alot..but it's alot for me heh. Now I'm working on somthing else...hoping some of you might have some ideas on it. I want there to be a type of automated moving..like the player type dash n and they continue to run north till they hit a wall or somthing. I'm not sure how exactly to start this, and to have it so maby they move faster depending on dex? Any ideas would be much appreciated.
USA #1
To find things like going in all one direction, check the scan command.. it should have what you need, just need to adjust it a bit.

I was bored.. so I did most of it.. you need to create a skill called dash, with code do_dash.


void do_dash( 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 = 100;

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 ( ( dir = get_door( argument ) ) == -1 )
{
send_to_char( "dash in WHAT direction?\n\r", ch );
return;
}

was_in_room = ch->in_room;
act( AT_GREY, "Dashing $t...", ch, dir_name[dir], NULL, TO_CHAR );
act( AT_GREY, "$n dashs $t.", ch, dir_name[dir], NULL, TO_ROOM );

if ( !can_use_skill(ch, number_percent(), gsn_dash ) )
{
act( AT_GREY, "You stop dashing $t as your legs fall from under you.", ch,
dir_name[dir], NULL, TO_CHAR );
learn_from_failure( ch, gsn_dash );
return;
}

if ( IS_VAMPIRE( ch ) )
{
if ( time_info.hour < 21 && time_info.hour > 5 )
{
send_to_char( "You trip in fall, blinded by all the "
"light.\n\r", ch );
max_dist = 20;
}
}

if ( ( pexit = get_exit( ch->in_room, dir ) ) == NULL )
{
act( AT_GREY, "You can't dash $t.", ch, dir_name[dir], NULL, TO_CHAR );
return;
}

if ( ch->perm_dex < 20 ) --max_dist;
if ( ch->perm_dex < 15 ) --max_dist;
if ( ch->perm_dex < 10 ) --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 dash $t is blocked by a wall. **SMACK**", ch,
dir_name[dir], NULL, TO_CHAR );
else
act( AT_GREY, "Your dash $t is blocked by a door. **WHACK**", ch,
dir_name[dir], NULL, TO_CHAR );
break;
}
if ( room_is_private( pexit->to_room )
&& ch->level < LEVEL_GREATER )
{
act( AT_GREY, "Your dash $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 );
do_look(ch, "")
send_to_char( "\n\r", 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 legs grow weak as you can no longer run any "
"farther $t.", ch, dir_name[dir], NULL, TO_CHAR );
break;
}
if ( ( pexit = get_exit( ch->in_room, dir ) ) == NULL )
{
act( AT_GREY, "Your dash $t is blocked by a wall **WHAM**.", ch,
dir_name[dir], NULL, TO_CHAR );
break;
}
}

char_from_room( ch );
learn_from_success( ch, gsn_dash );

return;
}
#2
Thanks! I was stuck on the actual moving part, I had in my mind kind of a forcing the player to actually move north, I didnt think about it like you put it.

Once more, thanks again.
USA #3
I didn't test it so lemme know if it works :)
USA #4
Samson has also made a "run" snippet that works fine.

www.afkmud.com

Should be the site.