This is a little piece of code that allows your players to return to a room that they
specify as a waypoint. In order for them to do this, the room has to be flagged as a
waypoint room by a builder. You can not get to another waypoint unless you are currently at
a waypoint. At this time a player can have up to 10 waypoints.
Changes for merc.h
******************
Below:
#define ROOM_SAFE (K)
Add a new room flag:
#define ROOM_WAYPOINT (XXX) <- use an open bit
Somewhere with your other max's put this:
#define MAX_WAYPOINT 10
in struct char_data below:
sh_int dam_type;
put:
sh_int wpoint[MAX_WAYPOINT];
In file save.c
**************
somewhere in fwrite_char put:
fprintf( fp, "Wpoint %d %d %d %d %d %d %d %d %d %d\n",
ch->wpoint[0], ch->wpoint[1], ch->wpoint[2], ch->wpoint[3], ch->wpoint[4],
ch->wpoint[5], ch->wpoint[6], ch->wpoint[7], ch->wpoint[8], ch->wpoint[9] );
In fread char below case 'V':
put:
case 'W':
if (!str_cmp(word,"Wpoint"))
{
int i;
for (i = 0; i <= 9; i++)
{
ch->wpoint[i] = fread_number(fp);
}
fMatch = TRUE;
break;
}
In file tables.c
Below:
{ "law", ROOM_LAW, TRUE },
Put:
{ "waypoint", ROOM_WAYPOINT, TRUE },
Add wpoint to interp.c and interp.h
Cut and paste this code below. You can put it in any file you want, but I put
it at the bottom of act_move.c
void do_wpoint( CHAR_DATA *ch, char *argument )
{
char buf[MSL];
char arg[MSL];
int a;
ROOM_INDEX_DATA *location;
if( ch->in_room == NULL )
{
return;
}
if ( IS_NPC( ch ) )
{
send_to_char( "Mobs don't need way points!\n\r", ch );
return;
}
argument = one_argument( argument, arg );
if (!IS_SET(ch->in_room->room_flags,ROOM_WAYPOINT) )
{
send_to_char("You are not at a waypoint!\n\r", ch );
return;
}
if( arg[0] == '\0' )
{
send_to_char( " {CLocation name{x\n\r" , ch );
send_to_char( " {G==========================={x\n\r" , ch );
for( a = 0; a < MAX_WAYPOINT; a++ )
{
location = get_room_index( ch->wpoint[a] );
sprintf( buf, " %2d: %s\n\r", a,
( location == NULL ? "(No way point set yet)" : location->name ) );
send_to_char( buf, ch );
location = NULL;
}
return;
}
if( !str_cmp( "set", arg ) )
{
argument = one_argument( argument, arg );
if( arg[0] == '\0' )
{
send_to_char("Syntx: wpoint set (number)\n\r", ch );
return;
}
a = atoi(arg);
if( a < 0 || a >= MAX_WAYPOINT )
{
printf_to_char( ch, "Please choose a number between 1 and %d.\n\r", MAX_WAYPOINT );
return;
}
else
{
ch->wpoint[a] = ch->in_room->vnum;
send_to_char("You memorize your current location.\n\r", ch );
return;
}
}
if( !str_cmp( "recall", arg ) )
{
argument = one_argument( argument, arg );
if( arg[0] == '\0' )
{
send_to_char("To visit another waypoint type wpoint recall (number).\n\r", ch );
return;
}
a = atoi( arg );
if( a < 0 || a >= MAX_WAYPOINT )
{
printf_to_char(ch, "Please choose a number between 1 and %d.\n\r", MAX_WAYPOINT );
return;
}
else
{
location = get_room_index( ch->wpoint[a] );
if ( ch->in_room == location )
{
send_to_char( "You are already there!\n\r", ch );
return;
}
if( IS_SET( ch->in_room->room_flags, ROOM_NO_RECALL ) )
{
send_to_char("The room glows for a moment, then fades.\n\r", ch);
return;
}
if( location == NULL )
{
send_to_char("You remember no such location.\n\r", ch );
ch->wpoint[a] = 0;
return;
}
if (!IS_SET(ch->in_room->room_flags,ROOM_WAYPOINT) )
{
send_to_char("You are not at a waypoint!\n\r", ch );
return;
}
act("$n disappears in a blinding flash of light!",ch,NULL,NULL,TO_ROOM);
char_from_room( ch );
char_to_room( ch, location );
act("$n appears suddenly from a puff of smoke!",ch,NULL,NULL,TO_ROOM);
do_function( ch, &do_look, "auto" );
return;
if (ch->pet != NULL)
{
char_from_room( ch->pet );
char_to_room( ch->pet, ch->in_room );
do_function(ch->pet, &do_look, "auto" );
return;
}
if (ch->mount != NULL)
{
char_from_room( ch->mount );
char_to_room( ch->mount, ch->in_room );
do_function(ch->mount, &do_look, "auto" );
return;
}
}
}
return;
}