space.c
DBZu/src/space.c · 57.0 KB
From the archive DBZu.zip
Download the archive « Back to the archive contents
/****************************************************************************
* |Dragon Ball Z Universe, Version FINAL | *
* -----------------------------------------------------------| *
* |DBZUCodebase V. FINAL, 2005, 2006, 2007, Jessie Reidl | *
* -----------------------------------------------------------| *
* ------------------------- *
* | Space Module | *
****************************************************************************/
#include <math.h>
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"
SHIP_DATA * first_ship;
SHIP_DATA * last_ship;
/* local routines */
void write_ship_list args( ( void ) );
bool load_ship_file args( ( char *shipfile ) );
void fread_ship args( ( SHIP_DATA *ship, FILE *fp ) );
void do_makeship( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
char arg[MAX_INPUT_LENGTH];
argument = one_argument( argument, arg );
if ( !argument || argument[0] == '\0' )
{
send_to_pager_color( "Usage: makeship <filename> <ship name>\n\r", ch );
return;
}
CREATE( ship, SHIP_DATA, 1 );
LINK( ship, first_ship, last_ship, next, prev );
ship->name = STRALLOC( argument );
ship->description = STRALLOC( "" );
ship->owner = STRALLOC( "" );
ship->owner2 = STRALLOC( "" );
ship->home = STRALLOC( "" );
ship->first_stop = NULL;
ship->second_stop = NULL;
ship->launch1 = 0;
ship->launch2 = 0;
ship->speed = 40;
ship->in_room=NULL;
ship->next_in_room=NULL;
ship->prev_in_room=NULL;
ship->time = 100;
ship->filename = str_dup( arg );
save_ship( ship );
write_ship_list( );
send_to_pager_color( "Done.\n\r", ch );
}
/* void do_test(CHAR_DATA *ch, char *argument )
{
transform_oozaru( );
} */
void save_ship( SHIP_DATA *ship )
{
FILE *fp;
char filename[256];
char buf[MAX_STRING_LENGTH];
sh_int i;
if ( !ship )
{
bug( "save_ship: null ship pointer!", 0 );
return;
}
if ( !ship->filename || ship->filename[0] == '\0' )
{
sprintf( buf, "save_ship: %s has no filename", ship->name );
bug( buf, 0 );
return;
}
sprintf( filename, "%s%s", SHIP_DIR, ship->filename );
fclose( fpReserve );
if ( ( fp = fopen( filename, "w" ) ) == NULL )
{
bug( "save_ship: fopen", 0 );
perror( filename );
}
else
{
fprintf( fp, "#SHIP\n" );
fprintf( fp, "Name %s~\n", ship->name );
fprintf( fp, "Filename %s~\n", ship->filename );
fprintf( fp, "Description %s~\n", ship->description );
fprintf( fp, "Owner %s~\n", ship->owner );
fprintf( fp, "Owner2 %s~\n", ship->owner2 );
fprintf( fp, "Shipyard %d\n", ship->shipyard );
fprintf( fp, "Entrance %d\n", ship->entrance );
fprintf( fp, "Firstroom %d\n", ship->firstroom );
fprintf( fp, "Lastroom %d\n", ship->lastroom );
fprintf( fp, "Lastdoc %d\n", ship->lastdoc );
fprintf( fp, "Home %s~\n", ship->home );
fprintf( fp, "Target %d\n", ship->target );
fprintf( fp, "Temptarget %d\n", ship->target );
fprintf( fp, "Time %d\n", ship->time );
fprintf( fp, "Timeleft %d\n", ship->timeleft );
fprintf( fp, "Type %d\n", ship->type );
fprintf( fp, "Keyvnum %d\n", ship->keyvnum );
fprintf( fp, "Lock %d\n", ship->lock );
fprintf( fp, "Speed %d\n", ship->speed );
fprintf( fp, "Launch1 %d\n", ship->launch1 );
fprintf( fp, "Launch2 %d\n", ship->launch2 );
fprintf( fp, "Firststop %s~\n", ship->first_stop );
fprintf( fp, "Secondstop %s~\n", ship->second_stop );
fprintf( fp, "Current_loc %d\n", ship->current_loc );
fprintf( fp, "Location %d\n", ship->location );
for (i=0; i < MAX_SHIP_ROOMS; i++)
{
if (ship->vnum[i] > 0)
fprintf( fp, "Vnum %d\n", ship->vnum[i]);
}
fprintf( fp, "End\n\n" );
fprintf( fp, "#END\n" );
}
fclose( fp );
fpReserve = fopen( NULL_FILE, "r" );
return;
}
void write_ship_list( )
{
SHIP_DATA *tship;
FILE *fpout;
char filename[256];
sprintf( filename, "%s%s", SHIP_DIR, SHIP_LIST );
fpout = fopen( filename, "w" );
if ( !fpout )
{
bug( "FATAL: cannot open ship.lst for writing!\n\r", 0 );
return;
}
for ( tship = first_ship; tship; tship = tship->next )
fprintf( fpout, "%s\n", tship->filename );
fprintf( fpout, "$\n" );
fclose( fpout );
}
/*
* Load in all the ship files.
*/
void load_ships( )
{
FILE *fpList;
char *filename;
char shiplist[256];
char buf[MAX_STRING_LENGTH];
first_ship = NULL;
last_ship = NULL;
log_string( "Loading ships..." );
sprintf( shiplist, "%s%s", SHIP_DIR, SHIP_LIST );
fclose( fpReserve );
if ( ( fpList = fopen( shiplist, "r" ) ) == NULL )
{
perror( shiplist );
exit( 1 );
}
for ( ; ; )
{
filename = feof( fpList ) ? "$" : fread_word( fpList );
if ( filename[0] == '$' )
break;
if ( !load_ship_file( filename ) )
{
sprintf( buf, "Cannot load ship file: %s", filename );
bug( buf, 0 );
}
}
fclose( fpList );
log_string(" Done ships " );
fpReserve = fopen( NULL_FILE, "r" );
return;
}
/*
* Read in actual ship data.
*/
#if defined(KEY)
#undef KEY
#endif
#define KEY( literal, field, value ) \
if ( !str_cmp( word, literal ) ) \
{ \
field = value; \
fMatch = TRUE; \
break; \
}
void fread_ship( SHIP_DATA *ship, FILE *fp )
{
char buf[MAX_STRING_LENGTH];
char *word;
bool fMatch;
int dummy_number;
for ( ; ; )
{
word = feof( fp ) ? "End" : fread_word( fp );
fMatch = FALSE;
switch ( UPPER(word[0]) )
{
case '*':
fMatch = TRUE;
fread_to_eol( fp );
break;
case 'C':
KEY( "Current_loc", ship->current_loc, fread_number( fp ) );
break;
case 'D':
KEY( "Description", ship->description, fread_string( fp ) );
break;
case 'E':
KEY( "Entrance", ship->entrance, fread_number( fp ) );
if ( !str_cmp( word, "End" ) )
{
if (!ship->home)
ship->home = STRALLOC( "" );
if (!ship->name)
ship->name = STRALLOC( "" );
if (!ship->owner)
ship->owner = STRALLOC( "" );
if (!ship->owner2)
ship->owner2 = STRALLOC( "" );
if (!ship->description)
ship->description = STRALLOC( "" );
if (ship->shipyard <= 0)
ship->shipyard = ROOM_LIMBO_SHIPYARD;
if (ship->lastdoc <= 0)
ship->lastdoc = ship->shipyard;
ship->in_room=NULL;
ship->next_in_room=NULL;
ship->prev_in_room=NULL;
return;
}
break;
case 'F':
KEY( "Filename", ship->filename, fread_string_nohash( fp ) );
KEY( "Firstroom", ship->firstroom, fread_number( fp ) );
KEY( "Firststop", ship->first_stop, fread_string( fp ) );
break;
case 'H':
KEY( "Home" , ship->home, fread_string( fp ) );
break;
case 'K':
KEY( "Keyvnum" , ship->keyvnum, fread_number( fp ) );
break;
case 'L':
KEY( "Lastdoc", ship->lastdoc, fread_number( fp ) );
KEY( "Lastroom", ship->lastroom, fread_number( fp ) );
KEY( "Launch1", ship->launch1, fread_number( fp ) );
KEY( "Launch2", ship->launch2, fread_number( fp ) );
KEY( "Location", ship->location, fread_number( fp ) );
KEY( "Lock", ship->lock, fread_number( fp ) );
break;
case 'N':
KEY( "Name", ship->name, fread_string( fp ) );
break;
case 'O':
KEY( "Owner2", ship->owner2, fread_string( fp ) );
KEY( "Owner", ship->owner, fread_string( fp ) );
/* KEY( "Owner2", ship->owner2, fread_string( fp ) ); */
break;
case 'S':
KEY( "Secondstop", ship->second_stop, fread_string( fp ) );
KEY( "Shipyard", ship->shipyard, fread_number( fp ) );
KEY( "Shipstate", ship->shipstate, fread_number( fp ) );
KEY( "Speed", ship->speed, fread_number( fp ) );
break;
case 'T':
KEY( "Target", ship->target, fread_number( fp ) );
KEY( "Temptarget", ship->temptarget, fread_number( fp ) );
KEY( "Time", ship->time, fread_number( fp ) );
KEY( "Timeleft", ship->timeleft, fread_number( fp ) );
KEY( "Type", ship->type, fread_number( fp ) );
break;
}
if ( !fMatch )
{
sprintf( buf, "Fread_ship: no match: %s", word );
bug( buf, 0 );
}
}
}
/*
* Load a ship file
*/
bool load_ship_file( char *shipfile )
{
char filename[256];
SHIP_DATA *ship;
DOCK_DATA *dock, *coordname;
FILE *fp;
bool found;
ROOM_INDEX_DATA *pRoomIndex;
int x, y, z, d, room;
CREATE( ship, SHIP_DATA, 1 );
found = FALSE;
sprintf( filename, "%s%s", SHIP_DIR, shipfile );
if ( ( fp = fopen( filename, "r" ) ) != NULL )
{
found = TRUE;
for ( ; ; )
{
char letter;
char *word;
letter = fread_letter( fp );
if ( letter == '*' )
{
fread_to_eol( fp );
continue;
}
if ( letter != '#' )
{
bug( "Load_ship_file: # not found.", 0 );
break;
}
word = fread_word( fp );
if ( !str_cmp( word, "SHIP" ) )
{
fread_ship( ship, fp );
break;
}
else
if ( !str_cmp( word, "END" ) )
break;
else
{
char buf[MAX_STRING_LENGTH];
sprintf( buf, "Load_ship_file: bad section: %s.", word );
bug( buf, 0 );
break;
}
}
fclose( fp );
}
if ( !(found) )
DISPOSE( ship );
else
{
LINK( ship, first_ship, last_ship, next, prev );
ship->shipyard = ship->shipyard;
extract_ship( ship );
ship_to_room( ship , ship->shipyard );
ship->location = ship->shipyard;
ship->current_loc = ship->shipyard;
ship->shipstate = SHIP_DOCKED;
ship->location = ship->location;
get_curr_home ( ship );
}
return found;
}
void do_status(CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
int x;
int y;
int xx;
int yy;
if ( (ship = ship_from_entrance(ch->in_room->vnum)) == NULL )
{
send_to_pager_color("&RYou must be in the control room of an spaceship to do that!\n\r",ch);
return;
}
x = ship->target - 3;
y = ship->target + 4;
xx = ship->location - 3;
yy = ship->location + 4;
pager_printf_color( ch, "&G-=[ %s BOARDCOMPUTER ]=-\n\r", capitalize(ship->name) );
if ( ship->shipstate == SHIP_FLYING )
pager_printf_color( ch, "&c- Current position:&C %s\n\r", ship->shipstate == SHIP_FLYING ? "In the air" : "Unknown" );
else
pager_printf_color( ch, "&c- Current position:&C %d . -%d . -%d\n\r", ship->location, xx, yy );
pager_printf_color( ch, "&c- Target position :&C -%d . %d . -%d\n\r", ship->target, x, y );
pager_printf_color( ch, "&c- Maximum speed :&C 30 parasecs/minute\n\r" );
pager_printf_color( ch, "&c- Flight time :&C %d seconds estimated.\n\r", ship->timeleft );
pager_printf_color( ch, "&c- Status :&C %s\n\r",
ship->shipstate == SHIP_DOCKED ? "Docked" :
(ship->shipstate == SHIP_FLYING ? "Flying" : "Unknown" ) );
pager_printf_color( ch, "&G-=[ End of Report ]=-\n\r" );
}
void do_leaveship( CHAR_DATA *ch, char *argument )
{
ROOM_INDEX_DATA *fromroom;
ROOM_INDEX_DATA *toroom;
SHIP_DATA *ship;
fromroom = ch->in_room;
if ( (ship = ship_from_entrance(fromroom->vnum)) == NULL )
{
send_to_pager_color( "I see no exit here.\n\r" , ch );
return;
}
if( ch->position < POS_STANDING && ch->position != POS_FIGHTING )
{
act( AT_PLAIN, "You can't do that in your current state.", ch, NULL, argument, TO_CHAR );
return;
}
if( ship->shipstate == SHIP_FLYING )
{
act( AT_PLAIN, "Are you serious? You're in space idiot.", ch, NULL, argument, TO_CHAR );
return;
}
if ( xIS_SET( ch->act, PLR_SPLIT_FORM ) )
{
act( AT_PLAIN, "You can't leave spaceships when you're split!", ch, NULL, argument, TO_CHAR );
return;
}
if ( ( toroom = get_room_index( ship->location ) ) != NULL )
{
act( AT_WHITE, "$n leaves the spaceship.", ch,
NULL, argument , TO_ROOM );
act( AT_WHITE, "You leave the spaceship.", ch,
NULL, argument , TO_CHAR );
char_from_room( ch );
char_to_room( ch , toroom );
act( AT_WHITE, "$n walks out of the spaceship and closes the hatch behind him.", ch,
NULL, argument , TO_ROOM );
do_look( ch , "auto" );
}
else
send_to_pager_color ( "The exit doesn't seem to be working properly.\n\r", ch );
}
/* void do_resetship( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
ship = get_ship( argument );
if (ship == NULL)
{
send_to_pager_color("&RNo such ship!",ch);
return;
}
resetship( ship );
} */
void do_unlockship( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
OBJ_DATA *obj;
bool found;
char arg[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
/* if ( arg[0] == '\0')
{
send_to_char("\n\rUnlock what ship?\n\r", ch);
return;
}
found = FALSE;
if ( (ship = ship_from_entrance(ch->in_room->vnum)) != NULL )
{
found = TRUE;
}
else if ( (ship = ship_from_location(ch->in_room->vnum)) != NULL )
{
found = TRUE;
}
if ( !found )
{
send_to_char( "You can't find it.\n\r", ch );
return;
} */
if ( ship->type != SHIP_SPACESHIP )
{
send_to_char("Shuttles cannot be unlocked\n\r",ch);
return;
}
if ( (obj = has_key( ch, ship->keyvnum) ) == NULL )
{
send_to_char("You need the key for that ship to do that!\n\r",ch);
return;
}
if ( ship->lock == SHIP_UNLOCKED )
{
send_to_char("Its already unlocked.\n\r",ch);
return;
}
ship->lock = SHIP_UNLOCKED;
ch_printf(ch, "You unlock your spaceship.\n\r");
act(AT_WHITE, "$n unlocks $s spaceship.", ch, NULL, NULL, TO_CANSEE);
return;
}
void do_lockship( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
OBJ_DATA *key;
bool found;
char arg[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
/* if ( arg[0] == '\0')
{
send_to_char("\n\rLock what ship?\n\r", ch);
return;
} */
/* ship = get_ship( arg ); */
/* found = FALSE;
if ( (ship = ship_from_entrance(ch->in_room->vnum)) != NULL )
{
found = TRUE;
}
if ( (ship = ship_from_location(ch->in_room->vnum)) != NULL )
{
found = TRUE;
}
if ( !found )
{
send_to_char( "You can't find it.\n\r", ch );
return;
} */
if ( ship->type != SHIP_SPACESHIP )
{
send_to_char("Shuttles cannot be locked\n\r",ch);
return;
}
if ( (key = has_key( ch, ship->keyvnum) ) == NULL )
{
send_to_char("You need the key for that ship to do that!\n\r",ch);
return;
}
if ( ship->lock == SHIP_LOCKED )
{
send_to_char("Its already locked.\n\r",ch);
return;
}
ship->lock = SHIP_LOCKED;
ch_printf(ch, "You lock your spaceship.\n\r");
act(AT_WHITE, "$n locks $s spaceship.", ch, NULL, NULL, TO_CANSEE);
return;
}
void do_board( CHAR_DATA *ch, char *argument )
{
ROOM_INDEX_DATA *fromroom;
ROOM_INDEX_DATA *toroom;
CHAR_DATA *inroom;
CHAR_DATA *nextinroom;
ROOM_INDEX_DATA *dock;
SHIP_DATA *ship;
sh_int chance;
chance = number_range( 0, 3 );
if ( !argument || argument[0] == '\0')
{
send_to_pager_color( "Board what?\n\r", ch );
return;
}
if ( ( ship = ship_in_room( ch->in_room , argument ) ) == NULL )
{
act( AT_PLAIN, "I see no $T here.", ch, NULL, argument, TO_CHAR );
return;
}
if ( carrying_dball(ch) )
{
act( AT_PLAIN, "You can't go in there while carrying dragonballs!", ch, NULL, argument, TO_CHAR );
return;
}
if ( xIS_SET( ch->act, ACT_MOUNTED ) )
{
act( AT_PLAIN, "You can't go in there riding THAT.", ch, NULL, argument, TO_CHAR );
return;
}
if ( xIS_SET( ch->act, PLR_SPLIT_FORM ) )
{
act( AT_PLAIN, "You can't enter spaceships when you're split!", ch, NULL, argument, TO_CHAR );
return;
}
if ( str_cmp( ship->owner, ch->name ) && ship->type == SHIP_SPACEPOD )
{
act( AT_PLAIN, "That's not your spacepod!", ch, NULL, argument, TO_CHAR );
return;
}
if( ch->position < POS_STANDING )
{
act( AT_PLAIN, "Standing up first might be a smart idea.", ch, NULL, argument, TO_CHAR );
return;
}
if ( ch->exp < 5000000 )
{
act( AT_PLAIN, "You aren't strong enough to enter spaceships yet.", ch, NULL, argument, TO_CHAR );
return;
}
if ( ch->in_room->vnum == 200 && get_timer(ch, TIMER_RECENTFIGHT) > 22 )
{
act( AT_PLAIN, "Mabye you should finish your fight first?", ch, NULL, argument, TO_CHAR );
return;
}
fromroom = ch->in_room;
if ( ( toroom = get_room_index( ship->entrance ) ) != NULL )
{
if ( (chance == 0 || chance == 1 || chance == 2) && get_timer(ch, TIMER_RECENTFIGHT) > 0)
{
send_to_char( "&RIn your haste, you are unable to type in the correct code.\n\r", ch);
WAIT_STATE(ch, 6);
return;
}
if ( ship->lock == SHIP_LOCKED )
{
send_to_char( "You can't enter that ship it's locked!\n\r", ch);
return;
}
act( AT_WHITE, "$n walks over to the $T and enters it.", ch,
NULL, ship->name , TO_ROOM );
act( AT_WHITE, "You walk over to the $T and enter it.", ch,
NULL, ship->name , TO_CHAR );
char_from_room( ch );
char_to_room( ch , toroom );
act( AT_WHITE, "$n enters the spaceship.", ch,
NULL, argument , TO_ROOM );
do_look( ch , "auto" );
for ( inroom = fromroom->first_person; inroom; inroom = nextinroom )
{
nextinroom = inroom->next_in_room;
if (inroom->position == POS_STANDING && inroom->leader == ch && !inroom->fighting && inroom->exp > 5000000 && ship->type != SHIP_SPACEPOD )
{
act( AT_WHITE, "$n walks over to the $T and enters it.", inroom,
NULL, ship->name , TO_ROOM );
act( AT_WHITE, "You walk over to the $T and enter it.", inroom,
NULL, ship->name , TO_CHAR );
char_from_room( inroom );
char_to_room( inroom , toroom );
act( AT_WHITE, "$n enters the spaceship.", inroom,
NULL, argument , TO_ROOM );
do_look( inroom , "auto" );
}
}
}
else
send_to_pager_color("That ship has no entrance!\n\r", ch);
}
SHIP_DATA *ship_from_location( int vnum )
{
SHIP_DATA *ship;
for ( ship = first_ship; ship; ship = ship->next )
if ( vnum == ship->location )
return ship;
return NULL;
}
SHIP_DATA *ship_from_entrance( int vnum )
{
SHIP_DATA *ship;
for ( ship = first_ship; ship; ship = ship->next )
if ( vnum == ship->entrance )
return ship;
return NULL;
}
bool extract_ship( SHIP_DATA *ship )
{
ROOM_INDEX_DATA *room;
if ( ( room = ship->in_room ) != NULL )
{
UNLINK( ship, room->first_ship, room->last_ship, next_in_room, prev_in_room );
ship->in_room = NULL;
}
return TRUE;
}
bool ship_to_room(SHIP_DATA *ship , int vnum )
{
ROOM_INDEX_DATA *shipto;
if ( (shipto=get_room_index(vnum)) == NULL )
return FALSE;
LINK( ship, shipto->first_ship, shipto->last_ship, next_in_room, prev_in_room );
ship->in_room = shipto;
return TRUE;
}
SHIP_DATA *ship_from_cockpit( int vnum )
{
SHIP_DATA *ship;
for ( ship = first_ship; ship; ship = ship->next )
if ( vnum == ship->entrance )
return ship;
return NULL;
}
void do_land( SHIP_DATA *ship )
{
ROOM_INDEX_DATA *room;
int parsec, dist1, dist2, dist3, dist4, speed, remain;
ROOM_INDEX_DATA *location;
int vnum, level;
char buf[MAX_INPUT_LENGTH];
if (ship->shipstate == 0)
return;
location = get_room_index(ship->entrance);
speed = ship->speed;
dist1 = ship->x1 - ship->x2;
dist2 = ship->y1 - ship->y2;
dist3 = ship->z1 - ship->z2;
dist4 = ship->d1 - ship->d2;
parsec = convert_pos(dist1) + convert_pos(dist2)+ convert_pos(dist3) + convert_pos(dist4) + 20;
parsec -= ship->speed;
if (parsec <= 10 && parsec >= 1)
echo_to_room(AT_YELLOW, location, "The spaceship rocks slightly as it speeds through space...");
else if (parsec > 10)
echo_to_room(AT_YELLOW, location, "The ship dodges past asteroids as it speeds to it's destination...");
if ( parsec <= 0 )
{
room = get_room_index( ship->destination );
location = get_room_index( ship->entrance );
ship->shipstate = 0;
ship->current_loc = ship->destination;
if ( ( room = get_room_index( ship->destination ) ) == NULL )
{
sprintf( buf, "Something went wrong with %s\n\r", ship->name);
bug( buf );
return;
}
sprintf(buf, "&wYou hear a high pitched sound as a spaceship enters the atmosphere...\n\r\n\rWith a lot of noise %s approaches the platform to land on...\n\r\n\rThings calm down again as the spaceship turn off its engines...", ship->name);
echo_to_room(AT_WHITE, room, buf );
echo_to_room(AT_YELLOW, location, "&YThe spaceship reduces speed as it prepares for orbit...\n\rYou have reached your destination!\n\r\n\r&wYou enter the atmosphere and prepare for final descent...\n\r\n\rYou feel the spaceship trembling as it touches the landing platform...\n\r\n\rThe spaceship engines shut down as you stand still at your destination.");
ship->x1 = ship->x2;
ship->y1 = ship->y2;
ship->z1 = ship->z2;
ship->d1 = ship->d2;
extract_ship( ship );
ship->shipstate = SHIP_DOCKED;
ship_to_room( ship, ship->current_loc );
ship->location = ship->current_loc;
}
else
{
speed /= 3;
/* x */
if (ship->x1 != ship->x2 && (speed > 0 ))
{
if (ship->x1 > ship->x2 )
{
remain = ship->x1 - ship->x2;
ship->x1 -= speed;
if ( ship->x1 < ship->x2 )
ship->x1 = ship->x2;
}
else
{
remain = ship->x2 - ship->x1;
ship->x1 += speed;
if ( ship->x1 > ship->x2 )
ship->x1 = ship->x2;
}
}
/* y */
if (ship->y1 != ship->y2 && (speed > 0))
{
if (ship->y1 > ship->y2 )
{
remain = ship->y1 - ship->y2;
ship->y1 -= speed;
if ( ship->y1 < ship->y2 )
ship->y1 = ship->y2;
}
else
{
remain = ship->y2 - ship->y1;
ship->y1 += speed;
if ( ship->y1 > ship->y2 )
ship->y1 = ship->y2;
}
}
/* z */
if (ship->z1 != ship->z2 && (speed > 0))
{
if (ship->z1 > ship->z2 )
{
remain = ship->z1 - ship->z2;
ship->z1 -= speed;
if ( ship->z1 < ship->z2 )
ship->z1 = ship->z2;
}
else
{
remain = ship->z2 - ship->z1;
ship->z1 += speed;
if ( ship->z1 > ship->z2 )
ship->z1 = ship->z2;
}
}
/* d */
if (ship->d1 != ship->d2 && (speed > 0))
{
if (ship->d1 > ship->d2 )
{
remain = ship->d1 - ship->d2;
ship->d1 -= speed;
if ( ship->d1 < ship->d2 )
ship->d1 = ship->d2;
}
else
{
remain = ship->d2 - ship->d1;
ship->d1 += speed;
if ( ship->d1 > ship->d2 )
ship->d1 = ship->d2;
}
}
}
return;
}
/* void land_ships( )
{
SHIP_DATA *ship;
char buf[MAX_STRING_LENGTH];
CHAR_DATA *ch;
ROOM_INDEX_DATA *room;
for ( ship = first_ship; ship; ship = ship->next )
{
if ( ship->shipstate == SHIP_FLYING && ship->type == SHIP_SPACESHIP )
{
extract_ship( ship );
ship->location = ship->target;
ship_to_room( ship , ship->target );
sprintf( buf , "&wYou hear a high pitched sound as a spaceship enters the atmosphere..\n\r\n\rWith a lot of noise %s approaches the platform to land on...\n\r\n\rThings calm down again as the spaceship turn off its engines...&D", ship->name );
echo_to_room( AT_YELLOW , get_room_index(ship->location) , buf );
echo_to_ship( AT_YELLOW , ship , "&YThe spaceship reduces speed as it prepares for orbit...\n\rYou have reached your destination!\n\r\n\r&wYou enter the atmosphere and prepare for final descent...\n\r\n\rYou feel the spaceship trembling as it touches the landing platform...\n\r\n\rThe spaceship engines shut down as you stand still at your destination.&D");
ship->shipstate = SHIP_DOCKED;
ship->timeleft = ship->time;
ship->target = 0;
return;
}
if ( ship->shipstate == SHIP_FLYING && ship->location == ship->target )
{
extract_ship( ship );
ship->location = ship->shipyard;
ship_to_room( ship , ship->shipyard );
sprintf( buf , "&wYou hear a high pitched sound as a spaceship enters the atmosphere..\n\r\n\rWith a lot of noise %s approaches the platform to land on...\n\r\n\rThings calm down again as the spaceship turn off its engines...\n\r&D", ship->name );
echo_to_room( AT_YELLOW , get_room_index(ship->location) , buf );
echo_to_ship( AT_YELLOW , ship , "&YThe spaceship reduces speed as it prepares for orbit...\n\rYou have reached your destination!\n\r\n\r&wYou enter the atmosphere and prepare for final descent...\n\r\n\rYou feel the spaceship trembling as it touches the landing platform...\n\r\n\rThe spaceship engines shut down as you stand still at your destination.&D");
ship->shipstate = SHIP_DOCKED;
ship->timeleft = ship->time;
return;
}
if ( ship->shipstate == SHIP_FLYING )
{
extract_ship( ship );
ship->location = ship->target;
ship_to_room( ship , ship->target );
sprintf( buf , "&wYou hear a high pitched sound as a spaceship enters the atmosphere..\n\r\n\rWith a lot of noise %s approaches the platform to land on...\n\r\n\rThings calm down again as the spaceship turn off its engines...&D", ship->name );
echo_to_room( AT_YELLOW , get_room_index(ship->location) , buf );
echo_to_ship( AT_YELLOW , ship , "&YThe spaceship reduces speed as it prepares for orbit...\n\rYou have reached your destination!\n\r\n\r&wYou enter the atmosphere and prepare for final descent...\n\r\n\rYou feel the spaceship trembling as it touches the landing platform...\n\r\n\rThe spaceship engines shut down as you stand still at your destination.&D");
ship->shipstate = SHIP_DOCKED;
ship->timeleft = ship->time;
return;
}
}
} */
void echo_to_ship( int color , SHIP_DATA *ship , char *argument )
{
int room;
for ( room = ship->firstroom ; room <= ship->lastroom ;room++ )
{
echo_to_room( color , get_room_index(room) , argument );
}
}
SHIP_DATA *get_ship( char *name )
{
SHIP_DATA *ship;
for ( ship = first_ship; ship; ship = ship->next )
if ( !str_cmp( name, ship->name ) )
return ship;
for ( ship = first_ship; ship; ship = ship->next )
if ( nifty_is_name_prefix( name, ship->name ) )
return ship;
return NULL;
}
SHIP_DATA * ship_in_room( ROOM_INDEX_DATA *room, char *name )
{
SHIP_DATA *ship;
if ( !room )
return NULL;
for ( ship = room->first_ship ; ship ; ship = ship->next_in_room )
if ( !str_cmp( name, ship->name ) )
return ship;
for ( ship = room->first_ship ; ship ; ship = ship->next_in_room )
if ( nifty_is_name_prefix( name, ship->name ) )
return ship;
return NULL;
}
void do_monitor( CHAR_DATA *ch, char *argument )
{
DOCK_DATA *dock;
if ( !first_dock )
{
send_to_char( "There are no ships.\n\r", ch );
return;
}
set_char_color( AT_NOTE, ch );
send_to_pager( "\n\r&W+----------------------------+------------------+----------------------+\n\r", ch );
send_to_pager( "&W| &CLocation&W |&G X Y Z ZZ&W |&C Coord Name&W |\n\r", ch );
send_to_pager( "&W+----------------------------+------------------+----------------------+\n\r", ch );
for ( dock = first_dock; dock; dock = dock->next )
{
if ( dock->onlyshuttle == TRUE )
continue;
ch_printf( ch, "&W|&c %-25s &W| &c%3d %3d %3d %3d &W| &c%-20s &W|\n\r", dock->name, dock->x, dock->y,dock->z, dock->d, dock->coordname );
}
send_to_pager( "&W+----------------------------+------------------+----------------------+\n\r", ch );
return;
}
void do_calculate( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
OBJ_DATA *obj;
DOCK_DATA *dock;
char arg[MAX_INPUT_LENGTH];
argument = one_argument( argument, arg);
int coord;
coord = 0;
// char coordname[MAX_INPUT_LENGTH];
char const* coordname;
coordname = "UNKNOWN";
if ( arg[0] == '\0')
{
send_to_char("\n\rSyntax: Calculate <Name>\n\r", ch);
return;
}
if ( (ship = ship_from_entrance(ch->in_room->vnum)) == NULL )
{
send_to_pager_color("&RYou must be in the control room of an spaceship to do that!\n\r",ch);
return;
}
if ( ship->type != SHIP_SPACESHIP && ship->type != SHIP_SPACEPOD )
{
send_to_char("You can't change the coordinates of a shuttle!\n\r", ch);
return;
}
if ( (obj = has_key( ch, ship->keyvnum)) == NULL && ship->type == SHIP_SPACESHIP)
{
send_to_char("&wYou need the controlkey for that ship to do that!\n\r",ch);
return;
}
/* if ( !str_cmp( arg, "planet_vegeta" ) )
{
coord = 10201;
coordname = "PLANET_VEGETA";
}
if ( !str_cmp( arg, "nexus" ) )
{
coord = 9001;
coordname = "NEXUS";
}
if ( !str_cmp( arg, "hbtc" ) )
{
coord = 1100;
coordname = "HBTC";
}
if ( !str_cmp( arg, "underworld" ) )
{
coord = 10601;
coordname = "UNDERWORLD";
}
if ( !str_cmp( arg, "asteroid" ) )
{
coord = 200;
coordname = "ASTEROID";
}
if ( !str_cmp( arg, "planet_namek" ) )
{
coord = 600;
coordname = "PLANET_NAMEK";
}
if ( !str_cmp( arg, "planet_mutant" ) )
{
coord = 400;
coordname = "PLANET_MUTANT";
}
if ( !str_cmp( arg, "planet_freezar" ) )
{
coord = 630;
coordname = "PLANET_FREEZAR";
}
if ( !str_cmp( arg, "planet_earth" ) )
{
coord = 1700;
coordname = "PLANET_EARTH";
}
if ( !str_cmp( arg, "planet_android" ) )
{
coord = 756;
coordname = "PLANET_ANDROID";
}
if ( !str_cmp( arg, "md_hq" ) )
{
coord = 3201;
coordname = "MD_HQ";
}
if ( !str_cmp( arg, "planet_ghetti" ) )
{
coord = 1212;
coordname = "PLANET_GHETTI";
}
if ( !str_cmp( arg, "good_chikara" ) )
{
coord = 1600;
coordname = "GOOD_CHIKARA";
}
if ( !str_cmp( arg, "evil_chikara" ) )
{
coord = 8800;
coordname = "EVIL_CHIKARA";
}
if ( !str_cmp( arg, "planet_gerok" ) )
{
coord = 500;
coordname = "PLANET_GEROK";
}
if ( !str_cmp( arg, "turks_hq" ) )
{
coord = 10100;
coordname = "TURKS_HQ";
}
if ( !str_cmp( arg, "personal_dock" ) )
{
coord = 383;
coordname = "PERSONAL_DOCK";
}
ch_printf(ch, "\n\r&z[&YBoard Computer&z] &WCoordinates set to -%d (%s)\n\r", coord, coordname );
ship->target = coord;
act(AT_GREY, "&w$n enters new target coordinates.", ch, NULL, NULL, TO_CANSEE);
return; */
for ( dock = first_dock; dock; dock = dock->next )
{
if ( !dock->coordname || dock->coordname[0] == '\0')
continue;
if ( dock->room <= 0 )
{
send_to_char( "You can't reach this coordinate.\n\r", ch);
return;
}
if ( !str_cmp( dock->coordname, arg ) && dock->onlyshuttle == FALSE )
{
ch_printf(ch, "\n\r&z[&YBoard Computer&z] &WCoordinates set to %s\n\r", dock->name );
ship->x2 = dock->x;
ship->y2 = dock->y;
ship->z2 = dock->z;
ship->d2 = dock->d;
ship->destination = dock->room;
act(AT_GREY, "&w$n enters new target coordinates.", ch, NULL, NULL, TO_CANSEE);
return;
}
continue;
}
send_to_char("\n\rInvalid Coordinate name.\n\r", ch);
return;
}
void do_start( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
OBJ_DATA *obj, *key;
if ( (ship = ship_from_entrance(ch->in_room->vnum)) == NULL )
{
send_to_pager_color("&RYou must be in the control room of an spaceship to do that!\n\r",ch);
return;
}
if ( (obj = has_key( ch, ship->keyvnum )) == NULL && ship->type == SHIP_SPACESHIP )
{
send_to_char("&wYou need the controlkey for that ship to do that!\n\r",ch);
return;
}
if ( ship->type != SHIP_SPACESHIP && ship->type != SHIP_SPACEPOD )
{
send_to_char("You can't start shuttles!\n\r",ch);
return;
}
if ( ship->shipstate == SHIP_STARTED || ship->shipstate == SHIP_FLYING )
{
send_to_char("Its already powered up!\n\r",ch);
return;
}
ship->shipstate = SHIP_STARTED;
ch_printf(ch, "\n\rYou use your controlcard to active the ship's powersupply...\n\r\n\r");
ch_printf(ch, "The monitors and controls switch glow up...the system is online.\n\r");
act(AT_GREY, "$n use $s controlcard to active the ship's powersupply...\n\r", ch, NULL, NULL, TO_CANSEE);
act(AT_GREY, "The monitors and controls switch glow up...the system is online.", ch, NULL, NULL, TO_CANSEE);
}
void do_launch( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
DOCK_DATA *dock;
char buf[MAX_INPUT_LENGTH];
int location;
if ( (ship = ship_from_entrance(ch->in_room->vnum)) == NULL )
{
send_to_pager_color("&RYou must be in the control room of an spaceship to do that!\n\r",ch);
return;
}
if (ship->shipstate == SHIP_DOCKED )
{
send_to_char("&RThe system is offline.\n\r",ch);
return;
}
if ( ship->x1 == ship->x2 && ship->y1 == ship->y2 && ship->z1 == ship->z2 && ship->d1 == ship->d2)
{
send_to_char("&RInput some coordinates!\n\r",ch);
return;
}
if (ship->type != SHIP_SPACESHIP && ship->type != SHIP_SPACEPOD )
{
send_to_char("You can't launch shuttles!\n\r",ch);
return;
}
location = ship->location;
ship->location = ship->location;
ch_printf(ch, "\n\rYou press the launch button to start your journey...\n\r\n\r");
ch_printf(ch, "You feel the spaceship trembling and shaking as the engines power up...\n\r\n\r");
ch_printf(ch, "You get firmly pressed into your chair as the spaceship blasts off into orbit!\n\r");
act(AT_WHITE, "&w$n presses the launch button to start your journey...\n\r", ch, NULL, NULL, TO_CANSEE);
act(AT_WHITE, "&wYou feel the spaceship trembling and shaking as the engines power up...\n\r", ch, NULL, NULL,TO_CANSEE);
act(AT_WHITE, "&wYou get firmly pressed into your chair as the spaceship blasts off into orbit!", ch, NULL,NULL, TO_CANSEE);
sprintf( buf , "&wYou hear space-engines hauling as they are being throttled up...\n\r\n\rSmoke and bright light surrounds %s as it rises\n\roff the ground slowly, turning around, preparing for lift-off...\n\r\n\rWith a loud explosion of power the spaceship blasts off into orbit!&D", ship->name );
echo_to_room( AT_YELLOW , get_room_index(ship->location) , buf );
extract_ship( ship );
ship->shipstate = SHIP_FLYING;
ship_to_room( ship , 8 );
}
void do_ship( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
ROOM_INDEX_DATA *room;
ROOM_INDEX_DATA *location;
OBJ_DATA *key;
char arg[MAX_INPUT_LENGTH];
sh_int i = 0;
ROOM_INDEX_DATA *addloc = NULL;
AREA_DATA *pArea = NULL;
EXIT_DATA *pexit, *rexit = NULL;
char buf[MAX_STRING_LENGTH];
location = ch->in_room;
room = ch->in_room;
if ( IS_NPC(ch))
return;
if (!argument || argument[0] == '\0')
{
send_to_char_color( "&C&CSyntax:\n\r", ch);
send_to_char_color( "&C&G ship <argument>\n\r", ch);
send_to_char_color( "&C&CArgument can be one of:\n\r", ch);
send_to_char_color( "&C&G getkey &YFree\n\r&Gdesc&Y Free", ch);
send_to_char_color( "&C&G\n\r", ch);
return;
}
argument=one_argument( argument, arg);
if ( !str_cmp( arg, "getkey"))
{
if ( (ship = ship_from_entrance(ch->in_room->vnum)) == NULL )
{
send_to_pager_color("&RYou must be in the control room of an spaceship to do that!\n\r",ch);
return;
}
if ( str_cmp( ship->owner, ch->name ) && str_cmp( ship->owner2, ch->name ) )
{
act( AT_PLAIN, "You cannot get a key from this ship!", ch, NULL, argument, TO_CHAR );
return;
}
key = create_object( get_obj_index( ship->keyvnum ), 0 );
obj_to_char( key, ch );
send_to_char( "You press a button on the console, a keycard is released, you grab it.\n\r", ch );
return;
}
if ( !str_cmp( arg, "desc"))
do_shipdesc( ch, "" );
/* if ( !str_cmp( arg, "addroom"))
{
if ( argument[0] == '\0' )
{
send_to_char_color( "&C&wship addroom <direction>\n\r", ch);
return;
}
if ( (ship = ship_from_entrance(ch->in_room->vnum)) == NULL )
{
send_to_pager_color("&RYou must be in the control room of an spaceship to do that!\n\r",ch);
return;
}
if ( str_cmp( ship->owner, ch->name ) && str_cmp( ship->owner2, ch->name ) )
{
act( AT_PLAIN, "This is not your ship!", ch, NULL, argument, TO_CHAR );
return;
}
if ( ch->gold < 5000000)
{
send_to_char_color( "&C&wYou don't have enough to buy an additional room.\n\r", ch);
return;
}
for ( i=0; i < MAX_SHIP_ROOMS; i++)
{
if ( ship->vnum[i] == 0)
break;
}
if (i == MAX_SHIP_ROOMS)
{
send_to_char_color( "&C&wYou already have the maximum amount of rooms for a ship.\n\r", ch);
return;
}
if ( (get_exit( location, get_dir(argument))) != NULL)
{
send_to_char_color( "&C&wThere's already a room in that direction.\n\r", ch);
return;
}
pArea = location->area;
if (!pArea)
return;
for ( i = pArea->low_r_vnum; i < pArea->hi_r_vnum; i++)
{
if ( (get_room_index( i )) == NULL )
{
if ( (addloc = make_room(i)) == NULL)
return;
break;
}
}
if ( !addloc)
return;
if ( ( pexit = make_exit( location, addloc, get_dir(argument))) == NULL
|| (rexit = make_exit( addloc, location, rev_dir[get_dir(argument)] )) == NULL)
return;
pexit->keyword = STRALLOC( "" );
pexit->description = STRALLOC( "" );
pexit->key = -1;
pexit->exit_info = 0;
rexit->keyword = STRALLOC( "" );
rexit->description = STRALLOC( "" );
rexit->key = -1;
rexit->exit_info = 0;
pexit->rexit = rexit;
rexit->rexit = pexit;
for ( i=0; i < MAX_SHIP_ROOMS; i++)
{
if ( ship->vnum[i] == 0)
{
ship->vnum[i] = addloc->vnum;
break;
}
}
save_ship( ship );
sprintf( buf, "%s\'s Additional Ship Room %d", capitalize(ship->name), i);
STRFREE( addloc->name );
addloc->name = STRALLOC( buf );
STRFREE( addloc->description );
addloc->description = STRALLOC( "This is your desc. You can edit this with SHIP DESC.\n\r");
addloc->sector_type = 0;
xSET_BIT( addloc->room_flags, ROOM_NO_SUMMON );
xSET_BIT( addloc->room_flags, ROOM_INDOORS );
xSET_BIT( addloc->room_flags, ROOM_SAFE );
xREMOVE_BIT( addloc->room_flags, ROOM_PROTOTYPE);
addloc->area = pArea;
fold_area( addloc->area, addloc->area->filename, FALSE );
ch->gold -= 5000000;
return;
} */
}
void do_shipdesc( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
ROOM_INDEX_DATA *room;
ROOM_INDEX_DATA *location;
location = ch->in_room;
room = ch->in_room;
switch( ch->substate )
{
default:
break;
case SUB_ROOM_DESC:
location = ch->dest_buf;
if ( !location )
{
bug( "redit: sub_room_desc: NULL ch->dest_buf", 0 );
location = ch->in_room;
}
STRFREE( location->description );
location->description = copy_buffer( ch );
stop_editing( ch );
ch->substate = ch->tempnum;
fold_area( room->area, room->area->filename, FALSE );
return;
}
if ( IS_NPC(ch))
return;
if ( (ship = ship_from_entrance(ch->in_room->vnum)) == NULL )
{
send_to_pager_color("&RYou must be in the control room of an spaceship to do that!\n\r",ch);
return;
}
if ( str_cmp( ship->owner, ch->name ) && str_cmp( ship->owner2, ch->name ) )
{
act( AT_PLAIN, "That's not your ship!", ch, NULL, argument, TO_CHAR );
return;
}
/* location = ch->in_room->vnum;
ch->tempnum = SUB_NONE;
ch->substate = SUB_ROOM_DESC;
ch->dest_buf = location;
start_editing( ch, location->description );
return; */
if ( ch->substate == SUB_REPEATCMD )
ch->tempnum = SUB_REPEATCMD;
else
ch->tempnum = SUB_NONE;
ch->substate = SUB_ROOM_DESC;
ch->dest_buf = location;
start_editing( ch, location->description );
smash_tilde( location->description );
fold_area( room->area, room->area->filename, FALSE );
return;
}
void do_setship( CHAR_DATA *ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char arg3[MAX_INPUT_LENGTH];
SHIP_DATA *ship;
DOCK_DATA *dock;
int tempnum;
ROOM_INDEX_DATA *roomindex;
if ( IS_NPC( ch ) )
{
send_to_pager_color( "Huh?\n\r", ch );
return;
}
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if ( arg1[0] == '\0' || arg2[0] == '\0' || arg1[0] == '\0' )
{
send_to_pager_color( "Usage: setship <ship> <field> <values>\n\r", ch );
send_to_pager_color( "\n\rField being one of:\n\r", ch );
send_to_pager_color( "filename name owner owner2 desc\n\r", ch );
send_to_pager_color( "firstroom lastroom shipyard type\n\r", ch );
send_to_pager_color( "launch1 launch2 speed first_stop second_stop\n\r", ch );
send_to_pager_color( "speed\n\r", ch );
return;
}
ship = get_ship( arg1 );
dock = get_dock( argument );
if ( !ship )
{
send_to_pager_color( "No such ship.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "owner" ) )
{
STRFREE( ship->owner );
ship->owner = STRALLOC( argument );
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "owner2" ) )
{
STRFREE( ship->owner2 );
ship->owner2 = STRALLOC( argument );
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "target" ) )
{
tempnum = atoi(argument);
roomindex = get_room_index(tempnum);
if (roomindex == NULL)
{
send_to_pager_color("That room doesn't exist.",ch);
return;
}
ship->target = tempnum;
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "home" ) )
{
STRFREE( ship->home );
ship->home = STRALLOC( argument );
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "first_stop" ) )
{
if ( ( dock = get_dock( argument ) ) == NULL )
{
send_to_char("That dock doesn't exist.\n\r", ch );
return;
}
ship->first_stop = STRALLOC( argument );
ch_printf(ch,"\n\rSetting the Ship's First Stop to: %s", dock->coordname);
send_to_char( "\n\rDone.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "second_stop" ) )
{
if ( ( dock = get_dock( argument ) ) == NULL )
{
send_to_char("That dock doesn't exist.\n\r", ch );
return;
}
ship->second_stop = STRALLOC( argument );
ch_printf(ch,"\n\rSetting the Ship's Second Stop to: %s", dock->coordname);
send_to_char( "\n\rDone.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "firstroom" ) )
{
tempnum = atoi(argument);
roomindex = get_room_index(tempnum);
if (roomindex == NULL)
{
send_to_pager_color("That room doesn't exist.\n\r",ch);
return;
}
ship->firstroom = tempnum;
ship->lastroom = tempnum;
ship->entrance = tempnum;
send_to_pager_color( "You will now need to set the other rooms in the ship.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "speed" ) )
{
tempnum = atoi(argument);
if ( tempnum < 0 || tempnum > 80 )
{
send_to_char( "Exceeding Speed Limits!\n\r", ch );
return;
}
ship->speed = tempnum;
ch_printf(ch, "Setting the Ship's Speed to: %d", tempnum);
send_to_char( "\n\rDone.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "launch1" ) )
{
tempnum = atoi(argument);
if ( tempnum < 0 || tempnum > 24 )
{
send_to_char( "Invalid number (1-24)!\n\r", ch );
return;
}
ship->launch1 = tempnum;
ch_printf(ch, "Setting the ships launch time to: %d", tempnum);
send_to_char( "\n\rDone.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "launch2" ) )
{
tempnum = atoi(argument);
if ( tempnum < 0 || tempnum > 24 )
{
send_to_char( "Invalid number (1-24)!\n\r", ch );
return;
}
ship->launch2 = tempnum;
ch_printf(ch, "Setting the ships launch2 time to: %d", tempnum);
send_to_char( "\n\rDone.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "keyvnum" ) )
{
tempnum = atoi(argument);
if ( tempnum < 0 || tempnum > 1000000000 )
{
send_to_char( "Invalid vnum number!\n\r", ch );
return;
}
ship->keyvnum = tempnum;
ch_printf(ch, "Setting the Ship's Key Vnum to: %d", tempnum);
send_to_char( "\n\rDone.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "entrance" ) )
{
tempnum = atoi(argument);
roomindex = get_room_index(tempnum);
if (roomindex == NULL)
{
send_to_pager_color("That room doesn't exist.\n\r",ch);
return;
}
if ( tempnum < ship->firstroom || tempnum > ship->lastroom )
{
send_to_pager_color("That room number is not in that ship .. \n\rIt must be between Firstroom and Lastroom.\n\r",ch);
return;
}
ship->entrance = tempnum;
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "shipyard" ) )
{
tempnum = atoi(argument);
roomindex = get_room_index(tempnum);
if (roomindex == NULL)
{
send_to_pager_color("That room doesn't exist.",ch);
return;
}
ship->shipyard = tempnum;
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "name" ) )
{
STRFREE( ship->name );
ship->name = STRALLOC( argument );
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "filename" ) )
{
if ( ship->filename )
DISPOSE( ship->filename );
ship->filename = str_dup( argument );
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
write_ship_list( );
return;
}
if ( !str_cmp( arg2, "type" ) )
{
if ( !str_cmp( argument, "spaceship" ) )
ship->type = SHIP_SPACESHIP;
else if ( !str_cmp( argument, "spacepod" ) )
{
ship->type = SHIP_SPACESHIP;
ship->type = SHIP_SPACEPOD;
}
else
{
send_to_pager_color( "Ship type must be either: spaceship.\n\r", ch );
ship->type = SHIP_SHUTTLE;
save_ship( ship );
return;
}
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
return;
}
if ( !str_cmp( arg2, "desc" ) )
{
STRFREE( ship->description );
ship->description = STRALLOC( argument );
send_to_pager_color( "Done.\n\r", ch );
save_ship( ship );
return;
}
do_setship( ch, "" );
return;
}
void do_showship( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
DOCK_DATA *dock;
if ( IS_NPC( ch ) )
{
send_to_pager_color( "Huh?\n\r", ch );
return;
}
if ( argument[0] == '\0' )
{
send_to_pager_color( "Usage: showship <ship>\n\r", ch );
return;
}
ship = get_ship( argument );
if ( !ship )
{
send_to_pager_color( "No such ship.\n\r", ch );
return;
}
set_char_color( AT_YELLOW, ch );
ch_printf( ch, "\n\r&RSpaceship Data&W:\n\r");
pager_printf_color( ch, "&YDescription:&z %s\n\r",
ship->description );
pager_printf_color( ch, "Firstroom: %d Lastroom: %d\n\rEntrance: %d\n\r",
ship->firstroom,
ship->lastroom, ship->entrance );
ch_printf( ch, "&YShipName: &W%s &YFilename: &R%s\n\r", ship->name, ship->filename);
ch_printf( ch, "&YKeyvnum: &W%d\n\r", ship->keyvnum);
ch_printf( ch, "&YSpeed: &W%d\n\r", ship->speed);
ch_printf( ch, "&YCurr_Loc: &W%d\n\r", ship->current_loc);
ch_printf( ch, "&YLocation: &W%d\n\r", ship->location);
ch_printf( ch, "&YShipyard: &G%d\n\r", ship->shipyard);
ch_printf( ch, "&YDestination: &C%d\n\r", ship->destination);
pager_printf_color( ch, "&YState:&O %s\n\r",
ship->shipstate == SHIP_DOCKED ? "SHUTDOWN" :
(ship->shipstate == SHIP_FLYING ? "IN ORBIT" : "STANDBY" ) );
pager_printf_color( ch, "&YShip Type:&z %s\n\r",
ship->type == SHIP_SPACESHIP ? "SPACESHIP" : "SHUTTLE" );
ch_printf( ch, "\n\r&RPersonal Ship Data&W:");
pager_printf_color( ch, "\n\r&YOwner:&W %s\n\r&YCoOwner:&W %s\n\r",
ship->owner,
ship->owner2 );
pager_printf_color( ch, "&YKeyVnum:&G %d\n\r",
ship->keyvnum );
ch_printf( ch, "\n\r&RShuttle Data&W:");
ch_printf( ch, "\n\r&YFirst_Stop : &W%s\n\r", ship->first_stop );
ch_printf( ch, "&YSecond_Stop: &W%s\n\r", ship->second_stop );
ch_printf( ch, "&YLaunch Times: &W%d&z/&W%d\n\r", ship->launch1, ship->launch2);
return;
}
void do_ships( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
if ( !first_ship )
{
send_to_char( "There are no ships.\n\r", ch );
return;
}
set_char_color( AT_NOTE, ch );
for ( ship = first_ship; ship; ship = ship->next )
{
ch_printf( ch, "Name: %8s Speed: %2d Entrance: %5d\n\r",
ship->name,
ship->speed,
ship->entrance );
}
return;
}
/* void do_ships( CHAR_DATA *ch, char *argument )
{
DOCK_DATA *dock;
if ( !first_dock )
{
send_to_char( "There are no ships.\n\r", ch );
return;
}
set_char_color( AT_NOTE, ch );
for ( dock = first_dock; dock; dock = dock->next )
{
if ( dock->onlyshuttle == TRUE )
continue;
ch_printf( ch, "Name: %8s\n\r",
dock->name );
}
return;
} */