00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018 #include <math.h>
00019 #include <sys/file.h>
00020
00021 #include "mech.h"
00022 #include "mech.events.h"
00023 #include "autopilot.h"
00024 #include "p.btechstats.h"
00025 #include "p.mech.utils.h"
00026 #include "p.econ_cmds.h"
00027 #include "p.mech.tech.h"
00028 #include "p.mech.build.h"
00029 #include "p.mech.update.h"
00030 #include "p.mech.pickup.h"
00031 #include "p.mech.tag.h"
00032 #include "p.bsuit.h"
00033 #include "p.bsuit.h"
00034 #include "p.mech.combat.misc.h"
00035
00036
00037
00038 #define BOOTCOUNT 6
00039
00040 char *bsuit_bootmsgs[BOOTCOUNT] = {
00041 "%%cg-> Initializing powerpack <-%%c",
00042 "%%cg-> Powerpack operational <-%%c",
00043 "%%cg-> Suit sealed <-%%c",
00044 "%%cg-> Computer system is now operational <-%%c",
00045 "%%cg-> Air pressure steady <-%%c",
00046 " %%cg- %%cr-=>%%ch%%cw All systems go!%%c %%cr<= %%cg-%%c"
00047 };
00048
00049 char *aero_bootmsgs[BOOTCOUNT] = {
00050 "%%cg-> Main reactor is now online <-%%c",
00051 "%%cg-> Thrusters online <-%%c",
00052 "%%cg-> Main computer system is now online <-%%c",
00053 "%%cg-> Scanners are now operational <-%%c",
00054 "%%cg-> Targeting system is now operational <-%%c",
00055 " %%cg- %%cr-=>%%ch%%cw All systems go!%%c %%cr<= %%cg-%%c"
00056 };
00057
00058 char *bootmsgs[BOOTCOUNT] = {
00059 "%%cg-> Main reactor is now online <-%%c",
00060 "%%cg-> Gyros are now stable <-%%c",
00061 "%%cg-> Main computer system is now online <-%%c",
00062 "%%cg-> Scanners are now operational <-%%c",
00063 "%%cg-> Targeting system is now operational <-%%c",
00064 " %%cg- %%cr-=>%%ch%%cw All systems operational!%%c %%cr<=- %%cg-%%c"
00065 };
00066
00067 char *hover_bootmsgs[BOOTCOUNT] = {
00068 "%%cg-> Powerplant initialized and online <-%%c",
00069 "%%cg-> Checking plenum chamber status <-%%c",
00070 "%%cg-> Verifying fan status <-%%c",
00071 "%%cg-> Scanners are now operational <-%%c",
00072 "%%cg-> Targeting system is now operational <-%%c",
00073 " %%cg- %%cr-=>%%ch%%cw All systems operational!%%c %%cr<=- %%cg-%%c"
00074 };
00075
00076 char *track_bootmsgs[BOOTCOUNT] = {
00077 "%%cg-> Powerplant initialized and online <-%%c",
00078 "%%cg-> Auto-aligning drive wheels <-%%c",
00079 "%%cg-> Adjusting track tension <-%%c",
00080 "%%cg-> Scanners are now operational <-%%c",
00081 "%%cg-> Targeting system is now operational <-%%c",
00082 " %%cg- %%cr-=>%%ch%%cw All systems operational!%%c %%cr<=- %%cg-%%c"
00083 };
00084
00085 char *wheel_bootmsgs[BOOTCOUNT] = {
00086 "%%cg-> Powerplant initialized and online <-%%c",
00087 "%%cg-> Performing steering system checks <-%%c",
00088 "%%cg-> Checking wheel status <-%%c",
00089 "%%cg-> Scanners are now operational <-%%c",
00090 "%%cg-> Targeting system is now operational <-%%c",
00091 " %%cg- %%cr-=>%%ch%%cw All systems operational!%%c %%cr<=- %%cg-%%c"
00092 };
00093
00094 char *vtol_bootmsgs[BOOTCOUNT] = {
00095 "%%cg-> Initializing main powerplant <-%%c",
00096 "%%cg-> Main turbine online and operational <-%%c",
00097 "%%cg-> Rotor transmission engaged <-%%c",
00098 "%%cg-> Scanners are now operational <-%%c",
00099 "%%cg-> Targeting system is now operational <-%%c",
00100 " %%cg- %%cr-=>%%ch%%cw All systems operational!%%c %%cr<=- %%cg-%%c"
00101 };
00102
00103 char *naval_bootmsgs[BOOTCOUNT] = {
00104 "%%cg-> Main reactor is now online <-%%c",
00105 "%%cg-> Main computer system is now online <-%%c",
00106 "%%cg-> Hull integrity monitoring online <-%%c",
00107 "%%cg-> Ballast and propulsion are nominal <-%%c",
00108 "%%cg-> Targeting system is now operational <-%%c",
00109 " %%cg- %%cr-=>%%ch%%cw All systems operational!%%c %%cr<=- %%cg-%%c"
00110 };
00111
00112 #define SSLEN MechType(mech) == CLASS_BSUIT ? 1 : (STARTUP_TIME / BOOTCOUNT)
00113
00114 static void mech_startup_event(MUXEVENT * e)
00115 {
00116 MECH *mech = (MECH *) e->data;
00117 int timer = (int) e->data2;
00118 MAP *mech_map;
00119 int i;
00120
00121 if(is_aero(mech)) {
00122 mech_printf(mech, MECHALL, aero_bootmsgs[timer]);
00123 } else if(MechType(mech) == CLASS_BSUIT) {
00124 mech_printf(mech, MECHALL, bsuit_bootmsgs[timer]);
00125 } else
00126 switch (MechMove(mech)) {
00127 case MOVE_HOVER:
00128 mech_printf(mech, MECHALL, hover_bootmsgs[timer]);
00129 break;
00130 case MOVE_TRACK:
00131 mech_printf(mech, MECHALL, track_bootmsgs[timer]);
00132 break;
00133 case MOVE_WHEEL:
00134 mech_printf(mech, MECHALL, wheel_bootmsgs[timer]);
00135 break;
00136 case MOVE_VTOL:
00137 mech_printf(mech, MECHALL, vtol_bootmsgs[timer]);
00138 break;
00139 case MOVE_BIPED:
00140 mech_printf(mech, MECHALL, bootmsgs[timer]);
00141 break;
00142 case MOVE_HULL:
00143 case MOVE_FOIL:
00144 case MOVE_SUB:
00145 mech_printf(mech, MECHALL, naval_bootmsgs[timer]);
00146 break;
00147 default:
00148 mech_printf(mech, MECHALL, bootmsgs[timer]);
00149 break;
00150 }
00151 timer++;
00152
00153
00154
00155 if(timer >= 2) {
00156
00157 if(InWater(mech) && (MechType(mech) == CLASS_VEH_GROUND ||
00158 MechType(mech) == CLASS_VTOL ||
00159 MechType(mech) == CLASS_BSUIT ||
00160 MechType(mech) == CLASS_AERO ||
00161 MechType(mech) == CLASS_DS) &&
00162 !(MechSpecials2(mech) & WATERPROOF_TECH)) {
00163
00164 mech_notify(mech, MECHALL,
00165 "Water floods your engine and your unit "
00166 "becomes inoperable.");
00167 if(MechType(mech) == CLASS_BSUIT)
00168 MechLOSBroadcast(mech,"emits some bubbles and flails their arms around as they sink to the bottom.");
00169 else
00170 MechLOSBroadcast(mech,"emits some bubbles as its engines are flooded.");
00171 DestroyMech(mech, mech, 0);
00172 return;
00173
00174 }
00175 }
00176
00177 if(timer < BOOTCOUNT) {
00178 MECHEVENT(mech, EVENT_STARTUP, mech_startup_event, SSLEN, timer);
00179 return;
00180 }
00181 if((mech_map = getMap(mech->mapindex)))
00182 for(i = 0; i < mech_map->first_free; i++)
00183 mech_map->LOSinfo[mech->mapnumber][i] = 0;
00184 initialize_pc(MechPilot(mech), mech);
00185 Startup(mech);
00186 MarkForLOSUpdate(mech);
00187 SetCargoWeight(mech);
00188 UnSetMechPKiller(mech);
00189 MechLOSBroadcast(mech, "powers up!");
00190 MechVerticalSpeed(mech) = 0;
00191 EvalBit(MechSpecials(mech), SS_ABILITY, ((MechPilot(mech) > 0 &&
00192 isPlayer(MechPilot(mech))) ?
00193 char_getvalue(MechPilot(mech),
00194 "Sixth_Sense") :
00195 0));
00196 if(FlyingT(mech)) {
00197 if(MechZ(mech) <= MechElevation(mech))
00198 MechStatus(mech) |= LANDED;
00199 }
00200 MechComm(mech) = DEFAULT_COMM;
00201 if(isPlayer(MechPilot(mech)) && !Quiet(mech->mynum)) {
00202 MechComm(mech) =
00203 char_getskilltarget(MechPilot(mech), "Comm-Conventional", 0);
00204 MechPer(mech) = char_getskilltarget(MechPilot(mech), "Perception", 0);
00205 } else {
00206 MechComm(mech) = 6;
00207 MechPer(mech) = 6;
00208 }
00209 MechCommLast(mech) = 0;
00210 MechLastStartup(mech) = mudstate.now;
00211 if(is_aero(mech) && !Landed(mech)) {
00212 MechDesiredAngle(mech) = -90;
00213 MechStartFX(mech) = 0.0;
00214 MechStartFY(mech) = 0.0;
00215 MechStartFZ(mech) = 0.0;
00216 MechDesiredSpeed(mech) = MechMaxSpeed(mech);
00217 MaybeMove(mech);
00218 }
00219 UnZombifyMech(mech);
00220 }
00221
00222 void mech_startup(dbref player, void *data, char *buffer)
00223 {
00224 MECH *mech = (MECH *) data;
00225 int n;
00226
00227 cch(MECH_CONSISTENT | MECH_MAP | MECH_PILOT_CON);
00228 skipws(buffer);
00229 DOCHECK(!(Good_obj(player) && (Alive(player) || isRobot(player) ||
00230 Hardcode(player))),
00231 "That is not a valid player!");
00232 DOCHECK(MechType(mech) == CLASS_MW
00233 && Started(mech), "You're up and about already!");
00234 DOCHECK(Towed(mech),
00235 "You're being towed! Wait for drop-off before starting again!");
00236 DOCHECK(mech->mapindex < 0, "You are not on any map!");
00237 DOCHECK(Destroyed(mech), "This 'Mech is destroyed!");
00238 DOCHECK(Started(mech), "This 'Mech is already started!");
00239 DOCHECK(Starting(mech), "This 'Mech is already starting!");
00240 DOCHECK(Extinguishing(mech), "You're way too busy putting out fires!");
00241 n = figure_latest_tech_event(mech);
00242 DOCHECK(n,
00243 "This 'Mech is still under repairs (see checkstatus for more info)");
00244 DOCHECK(MechHeat(mech) > 30., "This 'Mech is too hot to start back up!");
00245 DOCHECK(In_Character(mech->mynum) && !Wiz(player) &&
00246 (char_lookupplayer(GOD, GOD, 0, silly_atr_get(mech->mynum,
00247 A_PILOTNUM)) !=
00248 player), "This isn't your mech!");
00249 n = 0;
00250 if(*buffer && !strncasecmp(buffer, "override", strlen(buffer))) {
00251 DOCHECK(!WizP(player), "Insufficient access!");
00252 n = BOOTCOUNT - 1;
00253 }
00254 MechPilot(mech) = player;
00255
00256
00257
00258 fix_pilotdamage(mech, player);
00259 mech_notify(mech, MECHALL, "Startup Cycle commencing...");
00260 MechSections(mech)[RLEG].recycle = 0;
00261 MechSections(mech)[LLEG].recycle = 0;
00262 MechSections(mech)[RARM].recycle = 0;
00263 MechSections(mech)[LARM].recycle = 0;
00264 MechSections(mech)[RTORSO].recycle = 0;
00265 MechSections(mech)[LTORSO].recycle = 0;
00266 MECHEVENT(mech, EVENT_STARTUP, mech_startup_event, (n ||
00267 MechType(mech) ==
00268 CLASS_MW) ? 1 : SSLEN,
00269 MechType(mech) == CLASS_MW ? BOOTCOUNT - 1 : n);
00270 }
00271
00272 void mech_shutdown(dbref player, void *data, char *buffer)
00273 {
00274 MECH *mech = (MECH *) data;
00275
00276 if(!CheckData(player, mech))
00277 return;
00278 DOCHECK((!Started(mech) && !Starting(mech)),
00279 "The 'mech hasn't been started yet!");
00280 DOCHECK(MechType(mech) == CLASS_MW,
00281 "You snore for a while.. and then _start_ yourself back up.");
00282 DOCHECK(IsDS(mech) && !Landed(mech) && !Wiz(player),
00283 "No shutdowns in mid-air! Are you suicidal?");
00284 if(MechPilot(mech) == -1)
00285 return;
00286 if(Starting(mech)) {
00287 mech_notify(mech, MECHALL, "The startup sequence has been aborted.");
00288 StopStartup(mech);
00289 MechPilot(mech) = -1;
00290 return;
00291 }
00292 mech_printf(mech, MECHALL, "%s has been shutdown!",
00293 IsDS(mech) ? "Dropship" : is_aero(mech) ? "Fighter" :
00294 MechType(mech) == CLASS_BSUIT ? "Suit" : ((MechMove(mech) ==
00295 MOVE_HOVER)
00296 || (MechMove(mech)
00297 == MOVE_TRACK)
00298 || (MechMove(mech)
00299 ==
00300 MOVE_WHEEL)) ?
00301 "Vehicle" : MechMove(mech) == MOVE_VTOL ? "VTOL" : "Mech");
00302
00303
00304
00305
00306
00307 if(MechStatus2(mech) & SLITE_ON) {
00308 mech_notify(mech, MECHALL, "Your searchlight shuts off.");
00309 MechStatus2(mech) &= ~SLITE_ON;
00310 MechCritStatus(mech) &= ~SLITE_LIT;
00311 }
00312
00313 if(MechStatus(mech) & TORSO_RIGHT) {
00314 mech_notify(mech, MECHSTARTED,
00315 "Torso rotated back to center for shutdown");
00316 MechStatus(mech) &= ~TORSO_RIGHT;
00317 }
00318 if(MechStatus(mech) & TORSO_LEFT) {
00319 mech_notify(mech, MECHSTARTED,
00320 "Torso rotated back to center for shutdown");
00321 MechStatus(mech) &= ~TORSO_LEFT;
00322 }
00323 if(MechMove(mech) != MOVE_NONE && MechType(mech) != CLASS_VEH_NAVAL &&
00324 ((MechType(mech) == CLASS_MECH && Jumping(mech)) ||
00325 (MechType(mech) != CLASS_MECH &&
00326 MechZ(mech) > MechUpperElevation(mech) && MechZ(mech) < ORBIT_Z))) {
00327 mech_notify(mech, MECHALL, "You start free-fall.. Enjoy the ride!");
00328 MECHEVENT(mech, EVENT_FALL, mech_fall_event, FALL_TICK, -1);
00329 } else if(MechSpeed(mech) > MP1) {
00330 mech_notify(mech, MECHALL, "Your systems stop in mid-motion!");
00331 if(MechType(mech) == CLASS_MECH)
00332 MechLOSBroadcast(mech, "stops in mid-motion, and falls!");
00333 else {
00334 mech_notify(mech, MECHALL,
00335 "You tumble end over end and come to a crashing halt!");
00336 MechLOSBroadcast(mech,
00337 "tumbles end over end and comes to a crashing halt!");
00338 }
00339 MechFalls(mech, 1, 0);
00340 domino_space(mech, 2);
00341 }
00342 Shutdown(mech);
00343 }