-=====================(===Info===)=====================- This code when all setup will enable you to have ship simulators. They are good for flight practice. -=====================(===On mud.h===)=====================- Find: #define ROOM_AUCTION BV31 Below add: #define SHIP_SIMULATOR BV00 Find: DECLARE_DO_FUN( do_exits ); Below add: DECLARE_DO_FUN( do_endsimulator ); -=====================(===On tables.c===)=====================- Find: if ( !str_cmp( name, "do_east" )) return do_east; Below add:if ( !str_cmp( name, "do_endsimulator" )) return do_endsimulator; Find: if ( skill == do_east ) return "do_east"; Below Add: if ( skill == do_endsimulator ) return "do_endsimulator"; -=====================(===On space.c===)=====================- Find: #define STOP_SHIPYARD 32015 Below Add: char *ship_bit_name( int vector ) { static char buf[512]; buf[0] = '\0'; if ( vector & SHIP_SIMULATOR ) strcat( buf, " simulator" ); return ( buf[0] != '\0' ) ? buf+1 : "none"; } char * const ship_flags [] = { "simulator", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31" }; int get_shipflag( char *flag ) { int x; for ( x = 0; x < 32; x++ ) if ( !str_cmp( flag, ship_flags[x] ) ) return x; return -1; } Find: if ( !str_cmp( arg2, "chaff" ) ) { ship->chaff = URANGE( 0, atoi(argument) , 25 ); ship->maxchaff = URANGE( 0, atoi(argument) , 25 ); send_to_char( "Done.\n\r", ch ); save_ship( ship ); return; } Below add: if ( !str_cmp( arg2, "flags" ) ) { if ( !argument || argument[0] == '\0' ) { send_to_char( "Usage: setship <ship> flags <flag> [flag]...\n\r", ch ); send_to_char( "Valid flags are: simulator\n\r", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); tempnum = get_shipflag( arg3 ); if ( tempnum < 0 || tempnum > 31 ) { ch_printf( ch, "Unknown flag: %s\n\r", arg3 ); return; } TOGGLE_BIT( ship->flags, 1 << tempnum ); } save_ship( ship ); return; } Add this anywhere: void do_endsimulator( CHAR_DATA *ch, char *argument ) { SHIP_DATA *ship; char buf[MAX_INPUT_LENGTH]; if ( (ship = ship_from_cockpit(ch->in_room->vnum)) == NULL ) { send_to_char("You must be in the cockpit of a simulator.\n\r", ch); return; } if (!IS_SET(ship->flags, SHIP_SIMULATOR) ) { send_to_char("You must be in the cockpit of a simulator.\n\r", ch); return; } ship->shipyard = ship->sim_vnum; ship->shipstate = SHIP_READY; extract_ship( ship ); ship_to_room( ship , ship->shipyard ); ship->location = ship->shipyard; ship->lastdoc = ship->shipyard; ship->shipstate = SHIP_DOCKED; if (ship->starsystem) ship_from_starsystem( ship, ship->starsystem ); save_ship(ship); send_to_char("The lights dim and the hatch opens.\n\r", ch); sprintf(buf, "%s suddenly disapears from your viewcreen and off your radar.\n\r", ship->name); echo_to_system( AT_WHITE, ship , buf , NULL ); } Find the destroy_ship function, comment it out and add this in: void destroy_ship( SHIP_DATA *ship , CHAR_DATA *ch ) { char buf[MAX_STRING_LENGTH]; int roomnum; ROOM_INDEX_DATA *room; OBJ_DATA *robj; CHAR_DATA *rch; sprintf( buf , "%s explodes in a blinding flash of light!", ship->name ); echo_to_system( AT_WHITE + AT_BLINK , ship , buf , NULL ); if ( ship->class == FIGHTER_SHIP ) echo_to_ship( AT_WHITE + AT_BLINK , ship , "A blinding flahs of light burns your eyes..."); echo_to_ship( AT_WHITE , ship , "But before you have a chance to scream...\n\rYou are ripped apart as your spacecraft explodes..."); for ( roomnum = ship->firstroom ; roomnum <= ship->lastroom ; roomnum++ ) { room = get_room_index(roomnum); if (room != NULL) { rch = room->first_person; while ( rch ) { if( IS_SET( ship->flags, SHIP_SIMULATOR ) ) { resetship(ship); ship->shipyard = ship->sim_vnum; ship->shipstate = SHIP_READY; extract_ship( ship ); ship_to_room( ship , ship->shipyard ); ship->location = ship->shipyard; ship->lastdoc = ship->shipyard; ship->shipstate = SHIP_DOCKED; if (ship->starsystem) ship_from_starsystem( ship, ship->starsystem ); save_ship(ship); send_to_char("The lights dim and the hatch opens.\n\r", rch); return; } else if ( IS_IMMORTAL(rch) ) { char_from_room(rch); char_to_room( rch, get_room_index(wherehome(rch)) ); } else { if ( ch ) raw_kill( ch , rch ); else raw_kill( rch , rch ); } rch = room->first_person; } for ( robj = room->first_content ; robj ; robj = robj->next_content ) { separate_obj( robj ); extract_obj( robj ); } } } resetship(ship); } --Now Find the Do_launch and launch_ship functions. Comment them out and add this code-- void do_launch ( CHAR_DATA *ch, char *argument ) { int chance; long price = 0; SHIP_DATA *ship; char buf[MAX_STRING_LENGTH]; if ( (ship = ship_from_cockpit(ch->in_room->vnum)) == NULL ) { send_to_char("&RYou must be in the cockpit of a ship to do that!\n\r",ch); return; } if ( ship->class > SHIP_PLATFORM ) { send_to_char("&RThis isn't a spacecraft!\n\r",ch); return; } if ( (ship = ship_from_pilotseat(ch->in_room->vnum)) == NULL ) { send_to_char("&RYou don't seem to be in the pilot seat!\n\r",ch); return; } if ( autofly(ship) ) { send_to_char("&RThe ship is set on autopilot, you'll have to turn it off first.\n\r",ch); return; } if ( ship->class == SHIP_PLATFORM ) { send_to_char( "You can't do that here.\n\r" , ch ); return; } if ( !check_pilot( ch , ship ) ) { send_to_char("&RHey, thats not your ship! Try renting a public one.\n\r",ch); return; } if ( ship->lastdoc != ship->location ) { send_to_char("&rYou don't seem to be docked right now.\n\r",ch); return; } if ( ship->shipstate != SHIP_DOCKED && ship->shipstate != SHIP_DISABLED ) { send_to_char("The ship is not docked right now.\n\r",ch); return; } if ( ship->class == FIGHTER_SHIP ) chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_starfighters]) ; if ( ship->class == MIDSIZE_SHIP ) chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_midships]) ; if ( ship->class == CAPITAL_SHIP ) chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_capitalships]); if ( number_percent( ) < chance ) { if ( is_rental(ch,ship) ) if( !rent_ship(ch,ship) ) return; if ( !is_rental(ch,ship) ) { if ( ship->class == FIGHTER_SHIP ) price=20; if ( ship->class == MIDSIZE_SHIP ) price=50; if ( ship->class == CAPITAL_SHIP ) price=500; price += ( ship->maxhull-ship->hull ); if (ship->missiles ) price += ( 50 * (ship->maxmissiles-ship->missiles) ); else if (ship->torpedos ) price += ( 75 * (ship->maxtorpedos-ship->torpedos) ); else if (ship->rockets ) price += ( 150 * (ship->maxrockets-ship->rockets) ); if (ship->shipstate == SHIP_DISABLED ) price += 200; if ( ship->missilestate == MISSILE_DAMAGED ) price += 100; if ( ship->statet0 == LASER_DAMAGED ) price += 50; if ( ship->statet1 == LASER_DAMAGED ) price += 50; if ( ship->statet2 == LASER_DAMAGED ) price += 50; } if ( ch->pcdata && ch->pcdata->clan && !str_cmp(ch->pcdata->clan->name,ship->owner) ) { if ( ch->pcdata->clan->funds < price ) { ch_printf(ch, "&R%s doesn't have enough funds to prepare this ship for launch.\n\r", ch->pcdata->clan->name ); return; } ch->pcdata->clan->funds -= price; ch_printf(ch, "&GIt costs %s %ld credits to ready this ship for launch.\n\r", ch->pcdata->clan->name, price ); } else if ( str_cmp( ship->owner , "Public" ) ) { if ( ch->gold < price ) { ch_printf(ch, "&RYou don't have enough funds to prepare this ship for launch.\n\r"); return; } ch->gold -= price; ch_printf(ch, "&GYou pay %ld credits to ready the ship for launch.\n\r", price ); } ship->energy = ship->maxenergy; ship->chaff = ship->maxchaff; ship->missiles = ship->maxmissiles; ship->torpedos = ship->maxtorpedos; ship->rockets = ship->maxrockets; ship->shield = 0; ship->autorecharge = FALSE; ship->autotrack = FALSE; ship->autospeed = FALSE; ship->hull = ship->maxhull; ship->missilestate = MISSILE_READY; ship->statet0 = LASER_READY; ship->statet1 = LASER_READY; ship->statet2 = LASER_READY; ship->shipstate = SHIP_DOCKED; if (ship->hatchopen) { ship->hatchopen = FALSE; sprintf( buf , "The hatch on %s closes." , ship->name); echo_to_room( AT_YELLOW , get_room_index(ship->location) , buf ); echo_to_room( AT_YELLOW , get_room_index(ship->entrance) , "The hatch slides shut." ); sound_to_room( get_room_index(ship->entrance) , "!!SOUND(door)" ); sound_to_room( get_room_index(ship->location) , "!!SOUND(door)" ); } set_char_color( AT_GREEN, ch ); send_to_char( "Launch sequence initiated.\n\r", ch); act( AT_PLAIN, "$n starts up the ship and begins the launch sequence.", ch, NULL, argument , TO_ROOM ); echo_to_ship( AT_YELLOW , ship , "The ship hums as it lifts off the ground."); sprintf( buf, "%s begins to launch.", ship->name ); echo_to_room( AT_YELLOW , get_room_index(ship->location) , buf ); ship->shipstate = SHIP_LAUNCH; ship->currspeed = ship->realspeed; if ( ship->class == FIGHTER_SHIP ) learn_from_success( ch, gsn_starfighters ); if ( ship->class == MIDSIZE_SHIP ) learn_from_success( ch, gsn_midships ); if ( ship->class == CAPITAL_SHIP ) learn_from_success( ch, gsn_capitalships ); sound_to_ship(ship , "!!SOUND(xwing)" ); return; } set_char_color( AT_RED, ch ); send_to_char("You fail to work the controls properly!\n\r",ch); if ( ship->class == FIGHTER_SHIP ) learn_from_failure( ch, gsn_starfighters ); if ( ship->class == MIDSIZE_SHIP ) learn_from_failure( ch, gsn_midships ); if ( ship->class == CAPITAL_SHIP ) learn_from_failure( ch, gsn_capitalships ); return; } void launchship( SHIP_DATA *ship ) { char buf[MAX_STRING_LENGTH]; SHIP_DATA *target; int plusminus; SPACE_DATA *simul; for ( simul = first_starsystem; simul; simul = simul->next ) { if(!strcmp(simul->name,"Simulator\0")) break; } if(IS_SET(ship->flags, SHIP_SIMULATOR)) { ship_to_starsystem( ship, simul); } else { ship_to_starsystem( ship, starsystem_from_vnum( ship->location ) ); } if ( ship->starsystem == NULL && !IS_SET(ship->flags, SHIP_SIMULATOR ) ) { echo_to_room( AT_YELLOW , get_room_index(ship->pilotseat) , "Launch path blocked .. Launch aborted."); echo_to_ship( AT_YELLOW , ship , "The ship slowly sets back back down on the landing pad."); sprintf( buf , "%s slowly sets back down." ,ship->name ); echo_to_room( AT_YELLOW , get_room_index(ship->location) , buf ); ship->shipstate = SHIP_DOCKED; return; } if (ship->class == MIDSIZE_SHIP) { sound_to_room( get_room_index(ship->location) , "!!SOUND(falcon)" ); sound_to_ship(ship , "!!SOUND(falcon)" ); } else if (ship->owner == "The Empire" ) { sound_to_ship(ship , "!!SOUND(tie)" ); sound_to_room( get_room_index(ship->location) , "!!SOUND(tie)" ); } else { sound_to_ship(ship , "!!SOUND(xwing)" ); sound_to_room( get_room_index(ship->location) , "!!SOUND(xwing)" ); } extract_ship(ship); ship->location = 0; if (ship->shipstate != SHIP_DISABLED) ship->shipstate = SHIP_READY; plusminus = number_range ( -1 , 2 ); if (plusminus > 0 ) ship->hx = 1; else ship->hx = -1; plusminus = number_range ( -1 , 2 ); if (plusminus > 0 ) ship->hy = 1; else ship->hy = -1; plusminus = number_range ( -1 , 2 ); if (plusminus > 0 ) ship->hz = 1; else ship->hz = -1; if ( IS_SET( ship->flags, SHIP_SIMULATOR ) ) { ship->vx = 1500; ship->vx = 1500; ship->vz = 1500; } if (ship->lastdoc == ship->starsystem->doc1a || ship->lastdoc == ship->starsystem->doc1b || ship->lastdoc == ship->starsystem->doc1c ) { ship->vx = ship->starsystem->p1x; ship->vy = ship->starsystem->p1y; ship->vz = ship->starsystem->p1z; } else if (ship->lastdoc == ship->starsystem->doc2a || ship->lastdoc == ship->starsystem->doc2b || ship->lastdoc == ship->starsystem->doc2c ) { ship->vx = ship->starsystem->p2x; ship->vy = ship->starsystem->p2y; ship->vz = ship->starsystem->p2z; } else if (ship->lastdoc == ship->starsystem->doc3a || ship->lastdoc == ship->starsystem->doc3b || ship->lastdoc == ship->starsystem->doc3c ) { ship->vx = ship->starsystem->p3x; ship->vy = ship->starsystem->p3y; ship->vz = ship->starsystem->p3z; } else { for ( target = ship->starsystem->first_ship; target; target = target->next_in_starsystem ) { if (ship->lastdoc == target->hanger) { ship->vx = target->vx; ship->vy = target->vy; ship->vz = target->vz; } /* if (ship->lastdoc == target->hanger2) { ship->vx = target->vx; ship->vy = target->vy; ship->vz = target->vz; } if (ship->lastdoc == target->hanger3) { ship->vx = target->vx; ship->vy = target->vy; ship->vz = target->vz; } if (ship->lastdoc == target->hanger4) { ship->vx = target->vx; ship->vy = target->vy; ship->vz = target->vz; }*/ } } ship->energy -= (100+100*ship->class); ship->vx += (ship->hx*ship->currspeed*2); ship->vy += (ship->hy*ship->currspeed*2); ship->vz += (ship->hz*ship->currspeed*2); echo_to_room( AT_GREEN , get_room_index(ship->location) , "Launch complete.\n\r"); echo_to_ship( AT_YELLOW , ship , "The ship leaves the platform far behind as it flies into space." ); sprintf( buf ,"%s enters the starsystem at %.0f %.0f %.0f" , ship->name, ship->vx, ship->vy, ship->vz ); echo_to_system( AT_YELLOW, ship, buf , NULL ); sprintf( buf, "%s lifts off into space.", ship->name ); echo_to_room( AT_YELLOW , get_room_index(ship->lastdoc) , buf ); } ---Find The do_calculate function. Comment it out and put this in:--- void do_calculate(CHAR_DATA *ch, char *argument ) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; int chance , count; SHIP_DATA *ship; SPACE_DATA *starsystem; argument = one_argument( argument , arg1); argument = one_argument( argument , arg2); argument = one_argument( argument , arg3); if ( (ship = ship_from_cockpit(ch->in_room->vnum)) == NULL ) { send_to_char("&RYou must be in the cockpit of a ship to do that!\n\r",ch); return; } if ( ship->class > SHIP_PLATFORM ) { send_to_char("&RThis isn't a spacecraft!\n\r",ch); return; } if ( (ship = ship_from_navseat(ch->in_room->vnum)) == NULL ) { send_to_char("&RYou must be at a nav computer to calculate jumps.\n\r",ch); return; } if ( autofly(ship) ) { send_to_char("&RYou'll have to turn off the ships autopilot first....\n\r",ch); return; } if ( ship->class == SHIP_PLATFORM ) { send_to_char( "&RAnd what exactly are you going to calculate...?\n\r" , ch ); return; } if (ship->hyperspeed == 0) { send_to_char("&RThis ship is not equipped with a hyperdrive!\n\r",ch); return; } if (ship->shipstate == SHIP_DOCKED) { send_to_char("&RYou can't do that until after you've launched!\n\r",ch); return; } if (ship->starsystem == NULL) { send_to_char("&RYou can only do that in realspace.\n\r",ch); return; } if (argument[0] == '\0') { send_to_char("&WFormat: Calculate <starsystem> <entry x> <entry y> <entry z>\n\r&wPossible destinations:\n\r",ch); for ( starsystem = first_starsystem; starsystem; starsystem = starsystem->next ) { set_char_color( AT_NOTE, ch ); if ( IS_SET(ship->flags, SHIP_SIMULATOR) ) { if ( !str_cmp( starsystem->name, "Simulator" ) ) { ch_printf(ch,"%-30s %d\n\r",starsystem->name, (abs(starsystem->xpos - ship->starsystem->xpos)+ abs(starsystem->ypos - ship->starsystem->ypos))/2); count++; } } else { if ( str_cmp( starsystem->name, "Simulator" ) ) { ch_printf(ch,"%-30s %d\n\r",starsystem->name, (abs(starsystem->xpos - ship->starsystem->xpos)+ abs(starsystem->ypos - ship->starsystem->ypos))/2); count++; } } } if ( !count ) { send_to_char( "No Starsystems found.\n\r", ch ); } return; } chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_navigation]) ; if ( number_percent( ) > chance ) { send_to_char("&RYou cant seem to figure the charts out today.\n\r",ch); learn_from_failure( ch, gsn_navigation ); return; } ship->currjump = starsystem_from_name( arg1 ); ship->jx = atoi(arg2); ship->jy = atoi(arg3); ship->jz = atoi(argument); if ( ship->currjump == NULL ) { send_to_char( "&RYou can't seem to find that starsytsem on your charts.\n\r", ch); return; } if (IS_SET(ship->flags, SHIP_SIMULATOR) && ship->currjump != starsystem_from_name("Simulator") ) { send_to_char( "&RYou can't seem to find that starsytsem on your charts.\n\r", ch); return; } else if (!IS_SET(ship->flags, SHIP_SIMULATOR) && ship->currjump == starsystem_from_name("Simulator") ) { send_to_char( "&RYou can't seem to find that starsytsem on your charts.\n\r", ch); return; } else { SPACE_DATA * starsystem; starsystem = ship->currjump; if ( starsystem->star1 && strcmp(starsystem->star1,"") && abs(ship->jx - starsystem->s1x) < 300 && abs(ship->jy - starsystem->s1y) < 300 && abs(ship->jz - starsystem->s1z) < 300 ) { echo_to_cockpit( AT_RED, ship, "WARNING.. Jump coordinates too close to stellar object."); echo_to_cockpit( AT_RED, ship, "WARNING.. Hyperjump NOT set."); ship->currjump = NULL; return; } else if ( starsystem->star2 && strcmp(starsystem->star2,"") && abs(ship->jx - starsystem->s2x) < 300 && abs(ship->jy - starsystem->s2y) < 300 && abs(ship->jz - starsystem->s2z) < 300 ) { echo_to_cockpit( AT_RED, ship, "WARNING.. Jump coordinates too close to stellar object."); echo_to_cockpit( AT_RED, ship, "WARNING.. Hyperjump NOT set."); ship->currjump = NULL; return; } else if ( starsystem->planet1 && strcmp(starsystem->planet1,"") && abs(ship->jx - starsystem->p1x) < 300 && abs(ship->jy - starsystem->p1y) < 300 && abs(ship->jz - starsystem->p1z) < 300 ) { echo_to_cockpit( AT_RED, ship, "WARNING.. Jump coordinates too close to stellar object."); echo_to_cockpit( AT_RED, ship, "WARNING.. Hyperjump NOT set."); ship->currjump = NULL; return; } else if ( starsystem->planet2 && strcmp(starsystem->planet2,"") && abs(ship->jx - starsystem->p2x) < 300 && abs(ship->jy - starsystem->p2y) < 300 && abs(ship->jz - starsystem->p2z) < 300 ) { echo_to_cockpit( AT_RED, ship, "WARNING.. Jump coordinates too close to stellar object."); echo_to_cockpit( AT_RED, ship, "WARNING.. Hyperjump NOT set."); ship->currjump = NULL; return; } else if ( starsystem->planet3 && strcmp(starsystem->planet3,"") && abs(ship->jx - starsystem->p3x) < 300 && abs(ship->jy - starsystem->p3y) < 300 && abs(ship->jz - starsystem->p3z) < 300 ) { echo_to_cockpit( AT_RED, ship, "WARNING.. Jump coordinates too close to stellar object."); echo_to_cockpit( AT_RED, ship, "WARNING.. Hyperjump NOT set."); ship->currjump = NULL; return; } else if ( ship->jx > 5000 || ship->jy > 5000 || ship->jz > 5000 || ship->jx < -5000 || ship->jy < -5000 || ship->jz < -5000 ) { echo_to_cockpit( AT_RED, ship, "WARNING... Sorry guy, too far away from the starsystem!"); echo_to_cockpit( AT_RED, ship, "WARNING... Hyperjump NOT set."); ship->currjump = NULL; return; } else { ship->jx += number_range ( -250 , 250 ); ship->jy += number_range ( -250 , 250 ); ship->jz += number_range ( -250 , 250 ); } } ship->hyperdistance = abs(ship->starsystem->xpos - ship->currjump->xpos) ; ship->hyperdistance += abs(ship->starsystem->ypos - ship->currjump->ypos) ; ship->hyperdistance /= 20; ship->hyperdistance *= ship->hyperspeed; if (ship->hyperdistance<100) ship->hyperdistance = 100; ship->hyperdistance += number_range(0, 200); sound_to_room( ch->in_room , "!!SOUND(computer)" ); send_to_char( "&GHyperspace course set. Ready for the jump to lightspeed.\n\r", ch); act( AT_PLAIN, "$n does some calculations using the ships computer.", ch, NULL, argument , TO_ROOM ); learn_from_success( ch, gsn_navigation ); WAIT_STATE( ch , 2*PULSE_VIOLENCE ); } Find The following: if ( !str_cmp(target->owner, ship->owner) && str_cmp( target->owner , "" ) ) Replace With: if ( !str_cmp(target->owner, ship->owner) && str_cmp( target->owner , "" ) && !IS_SET(target->flags, SHIP_SIMULATOR) ) -=====================(===To Complete===)=====================- Run a make clean, and a make. Reboot your mud. Use makesystem to create a system and set it's name to "Simulator". Then do cedit endsimulator create do_endsimulator