00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "mech.h"
00011 #include "mech.events.h"
00012 #include "p.mech.utils.h"
00013 #include "p.mech.update.h"
00014 #include "p.mech.restrict.h"
00015 #include "p.mech.combat.h"
00016 #include "p.mech.damage.h"
00017 #include "p.template.h"
00018 #include "p.btechstats.h"
00019 #include "p.mech.combat.misc.h"
00020
00021 void mech_ood_damage(MECH * wounded, MECH * attacker, int damage)
00022 {
00023 mech_printf(attacker, MECHALL,
00024 "%%cgYou hit the cocoon for %d points of damage!%%cn",
00025 damage);
00026 mech_printf(wounded, MECHALL,
00027 "%%ch%%cyYour cocoon has been hit for %d points of damage!%%cn",
00028 damage);
00029 MechCocoon(wounded) = MAX(0, MechCocoon(wounded) - damage);
00030 if(MechCocoon(wounded))
00031 return;
00032
00033 if(MechZ(wounded) > MechElevation(wounded)) {
00034 if(MechJumpSpeed(wounded) >= MP1) {
00035 mech_notify(wounded, MECHALL,
00036 "You initiate your jumpjets to compensate for the breached cocoon!");
00037 MechCocoon(wounded) = -1;
00038 return;
00039 }
00040 mech_notify(wounded, MECHALL,
00041 "Your cocoon has been destroyed - have a nice fall!");
00042 MechLOSBroadcast(wounded,
00043 "starts plummeting down, as the final blast blows the cocoon apart!");
00044 StopOOD(wounded);
00045 MECHEVENT(wounded, EVENT_FALL, mech_fall_event, FALL_TICK, -1);
00046 }
00047 }
00048
00049 void mech_ood_event(MUXEVENT * e)
00050 {
00051 MECH *mech = (MECH *) e->data;
00052 int mof = 0, roll, roll_needed, para = 0;
00053
00054 if(!OODing(mech))
00055 return;
00056 MarkForLOSUpdate(mech);
00057 if((MechsElevation(mech) - DropGetElevation(mech)) > OOD_SPEED) {
00058 MechZ(mech) -= OOD_SPEED;
00059 MechFZ(mech) = MechZ(mech) * ZSCALE;
00060 MECHEVENT(mech, EVENT_OOD, mech_ood_event, OOD_TICK, 0);
00061 return;
00062 }
00063
00064 mech_notify(mech, MECHALL, "Your unit touches down!");
00065
00066 if(MechStatus(mech) & COMBAT_SAFE) {
00067
00068 MechCocoon(mech) = 0;
00069 MechLOSBroadcast(mech, "touches down safely!");
00070 DropSetElevation(mech, 1);
00071 MaybeMove(mech);
00072 return;
00073 }
00074
00075 if(Fallen(mech))
00076 mof = -10;
00077 if(Uncon(mech) || !Started(mech) || Blinded(mech))
00078 mof = -20;
00079 roll = Roll();
00080 roll_needed = MechType(mech) == CLASS_BSUIT
00081 || MechType(mech) ==
00082 CLASS_MW ? FindPilotPiloting(mech) - 1 : FindSPilotPiloting(mech) +
00083 MechPilotSkillBase(mech);
00084
00085 if(!Started(mech))
00086 roll_needed += 10;
00087 if(MechCocoon(mech) == 1) {
00088 para = 1;
00089 } else if(MechCocoon(mech) < 0) {
00090 roll_needed += 4;
00091 } else if(MechCocoon(mech) == 0) {
00092 roll_needed += 10;
00093 }
00094
00095 if(MechRTerrain(mech) != GRASSLAND && MechRTerrain(mech) != ROAD) {
00096 if(MechRTerrain(mech) == WATER || MechRTerrain(mech) == HIGHWATER)
00097 roll_needed += 2;
00098 else
00099 roll_needed += 3;
00100 }
00101
00102 MechCocoon(mech) = 0;
00103
00104 if(In_Character(mech->mynum) && Location(MechPilot(mech)) != mech->mynum)
00105 roll_needed += 99;
00106
00107 mech_notify(mech, MECHPILOT, "You make a piloting skill roll!");
00108
00109 mech_notify(mech, MECHPILOT,
00110
00111 tprintf("Modified Pilot Skill: BTH %d\tRoll: %d",
00112 roll_needed, roll));
00113
00114 mof += (roll - roll_needed);
00115
00116 if(roll >= roll_needed) {
00117
00118 if(roll_needed > 2)
00119
00120 AccumulatePilXP(MechPilot(mech), mech,
00121 BOUNDED(1, (abs(mof) + 1) * 2, 20), 1);
00122
00123 }
00124
00125 mof += (roll - roll_needed);
00126
00127
00128 if(mof < 0) {
00129
00130 if(MechType(mech) == CLASS_MECH) {
00131
00132 mech_notify(mech, MECHALL,
00133
00134 "You are unable to control your momentum and fall on your face!");
00135
00136 MechLOSBroadcast(mech,
00137
00138 "touches down on the ground, twists, and falls down!");
00139
00140 MechFalls(mech, (abs(mof) * (para ? 1 : 2)), 1);
00141
00142 } else if(MechType(mech) == CLASS_BSUIT) {
00143
00144 int i, ii, dam;
00145
00146 mech_notify(mech, MECHALL,
00147
00148 "You are unable to control your momentum and crash!");
00149
00150 MechLOSBroadcast(mech, "crashes to the ground!");
00151
00152 for(i = 0; i < NUM_SECTIONS; i++) {
00153
00154 dam = 0;
00155
00156 if(GetSectOInt(mech, i) > 0) {
00157
00158 for(ii = mof; ii < 0; ii++)
00159
00160 dam += Number(1, 4);
00161
00162 DamageMech(mech, mech, 0, -1, i, 0, 0, dam, -1, -1, 0, 0,
00163 0, 0);
00164
00165 MechFloods(mech);
00166
00167 }
00168
00169 }
00170
00171 MechFalls(mech, 0, 1);
00172
00173 } else {
00174
00175 mech_notify(mech, MECHALL,
00176
00177 "You are unable to control your momentum and crash!");
00178
00179 MechLOSBroadcast(mech, "crashes at the ground!");
00180
00181 MechFalls(mech, (abs(mof) * (para ? 1 : 3)), 1);
00182
00183 }
00184
00185 } else if(!para) {
00186
00187 MechLOSBroadcast(mech, "touches down!");
00188
00189 } else if(para) {
00190
00191 MechLOSBroadcast(mech, "touches down and rolls on the ground!");
00192
00193
00194
00195
00196 }
00197
00198 DropSetElevation(mech, 1);
00199
00200 if(!Fallen(mech))
00201
00202 domino_space(mech, 2);
00203
00204 if(WaterBeast(mech) && NotInWater(mech))
00205
00206 MechDesiredSpeed(mech) = 0.0;
00207
00208 MaybeMove(mech);
00209
00210
00211 if(InWater(mech) && (MechType(mech) == CLASS_VEH_GROUND ||
00212 MechType(mech) == CLASS_VTOL ||
00213 MechType(mech) == CLASS_BSUIT ||
00214 MechType(mech) == CLASS_AERO ||
00215 MechType(mech) == CLASS_DS) &&
00216 !(MechSpecials2(mech) & WATERPROOF_TECH)) {
00217
00218 mech_notify(mech, MECHALL,
00219 "Water floods your engine and your unit "
00220 "becomes unoperable.");
00221 if(MechType(mech) == CLASS_BSUIT)
00222 MechLOSBroadcast(mech,"emits some bubbles and flails their arms around as they sink to the bottom!");
00223 else
00224 MechLOSBroadcast(mech,"emits some bubbles as its engines are flooded.");
00225 DestroyMech(mech, mech, 0);
00226 }
00227
00228 }
00229
00230 void initiate_ood(dbref player, MECH * mech, char *buffer)
00231 {
00232 char *args[4];
00233 int x, y, z = ORBIT_Z, argc;
00234
00235 DOCHECK((argc =
00236 mech_parseattributes(buffer, args, 3)) < 2,
00237 "Invalid attributes!");
00238 DOCHECK(Readnum(x, args[0]), "Invalid number! (x)");
00239 DOCHECK(Readnum(y, args[1]), "Invalid number! (y)");
00240 if(argc == 3)
00241 DOCHECK(Readnum(z, args[2]), "Invalid number! (z)");
00242 DOCHECK(OODing(mech), "OOD already in progress!");
00243 mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", x, y));
00244 DOCHECK(MechX(mech) != x || MechY(mech) != y, "Invalid co-ordinates!");
00245 DOCHECK(Fallen(mech), "You'll have to get up first.");
00246 DOCHECK(Digging(mech), "You're too busy digging in.");
00247 MechZ(mech) = z;
00248 MechFZ(mech) = ZSCALE * MechZ(mech);
00249 MarkForLOSUpdate(mech);
00250 notify(player, "OOD initiated.");
00251 if(Evading(mech)) {
00252 MechStatus2(mech) &= ~EVADING;
00253 }
00254
00255 if(Sprinting(mech)) {
00256 MechStatus2(mech) &= ~SPRINTING;
00257 }
00258
00259 if(FlyingT(mech)) {
00260 MechStatus(mech) &= ~LANDED;
00261 MechDesiredSpeed(mech) = MechMaxSpeed(mech) / 2;
00262 if(is_aero(mech))
00263 MechDesiredAngle(mech) = 0;
00264 MaybeMove(mech);
00265 } else {
00266 MechCocoon(mech) = MechRTons(mech) / 5 / 1024 + 1;
00267 StopMoving(mech);
00268 MECHEVENT(mech, EVENT_OOD, mech_ood_event, OOD_TICK, 0);
00269 }
00270 }