Files needed: mud.h
              space.c

New ship flag added: SHIP_PREPPED

Description: I wrote this for a little bit more RP in ships.
You prep the ship before launching it. It can EASILY be added and expanded on,
and any ideas can be sent to me or you can update this code as you wish,
as long as you give credit where credit is due. Suggestions for future updates
would be prepping a ship while outside using an arguement or additonal
commands that work in conjunction with this.

================================================[ MUD.H ]================================================
Search for:

typedef enum { SHIP_DOCKED, SHIP_READY, SHIP_BUSY, SHIP_BUSY_2, SHIP_BUSY_3, SHIP_REFUEL,
SHIP_LAUNCH, SHIP_LAUNCH_2, SHIP_LAND, SHIP_LAND_2, SHIP_HYPERSPACE, SHIP_DISABLED, SHIP_FLYING,
SHIP_DOCKED_2, SHIP_DOCKED_3, SHIP_DOCK, IS_DOCKED, SHIP_PREPPED } ship_states;

And put SHIP_PREPPED in there with the others.

================================================[ SPACE.C ]================================================

Search for do_launch:
Find:
    
   if( ship->shipstate != SHIP_DOCKED && ship->shipstate != SHIP_DISABLED  )
   {
      send_to_char( "The ship is not docked right now.\n\r", ch );
      return;
   }

Change it to look like this:


   if( ship->shipstate != SHIP_DOCKED && ship->shipstate != SHIP_DISABLED  && ship->shipstate != SHIP_PREPPED )
   {
      send_to_char( "The ship is not docked right now.\n\r", ch );
      return;
   }

Still in do_launch:
Search for:

   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( ship->statet3 == LASER_DAMAGED )
            price += 50;
         if( ship->statet4 == 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 );
      }

Comment it out.

Scroll down farther and comment out this block of code:

      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->statet3 = LASER_READY;
      ship->statet4 = LASER_READY;
      ship->shipstate = SHIP_DOCKED;


At the bottom of space.c:
Add do_prep:


------------------------------------------------------[ BEGIN CODE ]-------------------------------------------------------

/*I wrote this code for a little bit more RP in ships.
 *You prep the ship before launching it. It can EASILY be added and expanded on,
 *and any ideas can be sent to me or you can update this code as you wish,
 *as long as you give credit where credit is due. Suggestions for future updates
 *would be prepping a ship while outside using an arguement or additonal
 *commands that work in conjunction with this.
 * - Banner 2005
 */
void do_prep( CHAR_DATA *ch, char *argument )
{
    long price = 0;
    SHIP_DATA *ship;
    char buf[MAX_STRING_LENGTH];
    int  x;
    long xpgain;  
    int  chance;   


         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 == LAND_CAR )
                {  
                    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 ( !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;
                }

/* Modify your ship classes to work with the ship->class part. - Banner */
                 
      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 == TRANSPORT_SHIP )
            price = 150;
         if( ship->class == FRIGATE_SHIP )
            price = 500;
         if( ship->class == CAPITAL_SHIP )
            price = 1000;
   
         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( ship->statet3 == LASER_DAMAGED )
            price += 50;
         if( ship->statet4 == LASER_DAMAGED )
            price += 50;
     Get rid of these or modify them if you have more or less than 2-4 turrets. - Banner*/
      }
           
  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 );
      }

/* Uncomment or modify this for simulators. - Banner
 *            
      else if( !str_cmp( ship->owner, "Simulator" ) )
      {
         ch_printf( ch, "&GYou push the button and the simulation starts.&w\n\r" );
      } */
                     
      else if( str_cmp( ship->owner, "Public" ) )
      {
         if( ch->gold < price )
         {
            price = 500;
            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 );
            
      }
            
switch( ch->substate )
   {        
     default:
       
         
     chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_shipsystems]);
     if ( number_percent( ) < chance )
                {  
                   send_to_char( "&GPrepping ship for launch.\n\r", ch);
                   act( AT_PLAIN, "$n begins prepping the ship for launch.", ch, NULL, argument , TO_ROOM );
                   add_timer ( ch , TIMER_DO_FUN , 1 , do_prep , 1 );
                   return;
                }
                send_to_char("&RYou fail to prep the ship properly.\n\r",ch);
                return;
       
        case 1:
                break;
                     
        case SUB_TIMER_DO_ABORT:
                ch->substate = SUB_NONE;
                if ( (ship = ship_from_cockpit(ch->in_room->vnum)) == NULL )
                      return;
                send_to_char("&RYour concentration is broken. You fail to prep the ship.\n\r", ch);
                return;
    }
          
    ch->substate = SUB_NONE;
         
    chance = IS_NPC(ch) ? ch->top_level
    : (int) (ch->pcdata->learned[gsn_shipsystems]);
       
    x = number_percent( );

    if ( number_percent( ) > chance*2 )
     {
      send_to_char("&RYou fail to prep the ship properly.\n\r",ch);
      learn_from_failure( ch, gsn_shipsystems );
      return;
     }
                   
      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->statet3 = LASER_READY;
      ship->statet4 = LASER_READY; */
      ship->shipstate = SHIP_PREPPED;
   /* Comment ship->state2-4 out if you have only two turrets. Add if you have more. - Banner */
     
     send_to_char( "&c[&wShip Computer&c]&w Ship prepped for launch.\n\r", ch);
     act( AT_PLAIN, "$n preps the ship for launch.", ch,NULL, argument , TO_ROOM );
    
      xpgain = 3000;
      gain_exp(ch, xpgain, PILOTING_ABILITY);
      ch_printf( ch , " You gain %d experience points for being a Pilot.\n\r", xpgain );
      learn_from_success( ch, gsn_shipsystems) ;
      return;
}

------------------------------------------------------[ END OF CODE ]-------------------------------------------------------
Update tables.c and mud.h to include entries for do_prep.

make clean
make

In the mud:

saveall
copyover now
cedit prep create
cedit prep level 1
cedit save

----------------------------------------------------------------------------------------------------------------------------
If there are any problems with this installation, feel free to email your
question to Shoie13@yahoo.com or contact me via aim (SystmFrz).

This code has been installed and tested on SWR 1.0 FUSS, which is a bugfixed
and cleaned up version of the base SWR 1.0.

No guarantees are made that this code will be compatible with your codebase and any
modifications you may have made to it. No warranty of any kind is expressed or implied
by the use of this code, and I am not responsible for any damages which may result
from the application of this snippet to your codebase.

Banner
Star Wars: Galactic Insights
Frostmud.com:8060
------------------------------------------------------------------------------------------------------------