src/hcode/btech/mech.fire.c

Go to the documentation of this file.
00001 /*
00002  * Author: Cord Awtry <kipsta@mediaone.net>
00003  *
00004  *  Copyright (c) 2001-2002 Cord Awtry
00005  *       All rights reserved
00006  */
00007 
00008 #include "mech.h"
00009 #include "mech.events.h"
00010 #include "p.mech.fire.h"
00011 #include "p.mech.combat.h"
00012 #include "p.mech.damage.h"
00013 #include "p.mech.hitloc.h"
00014 #include "p.mech.utils.h"
00015 #include "p.mech.build.h"
00016 
00017 #define VEHICLEBURN_TICK 60
00018 #define VEHICLE_EXTINGUISH_TICK 120
00019 
00020 static void inferno_end_event(MUXEVENT * e)
00021 {
00022         MECH *mech = (MECH *) e->data;
00023 
00024         MechCritStatus(mech) &= ~JELLIED;
00025         mech_notify(mech, MECHALL,
00026                                 "You feel suddenly far cooler as the fires finally die.");
00027 }
00028 
00029 void inferno_burn(MECH * mech, int time)
00030 {
00031         int l;
00032 
00033         if(!(MechCritStatus(mech) & JELLIED)) {
00034                 MechCritStatus(mech) |= JELLIED;
00035                 MECHEVENT(mech, EVENT_BURN, inferno_end_event, time, 0);
00036                 return;
00037         }
00038 
00039         l = muxevent_last_type_data(EVENT_BURN, (void *) mech) + time;
00040         muxevent_remove_type_data(EVENT_BURN, (void *) mech);
00041         MECHEVENT(mech, EVENT_BURN, inferno_end_event, l, 0);
00042 }
00043 
00044 static void vehicle_burn_event(MUXEVENT * objEvent)
00045 {
00046         MECH *objMech = (MECH *) objEvent->data;        /* get the mech */
00047         int wLoc = (int) objEvent->data2;       /* and now the loc to damage */
00048         int wDamRoll = Number(1, 6);    /* do 1d6 damage */
00049         char strLocName[30];
00050 
00051         if(!objMech)
00052                 return;
00053 
00054         ArmorStringFromIndex(wLoc, strLocName, MechType(objMech),
00055                                                  MechMove(objMech));
00056 
00057         if(!GetSectInt(objMech, wLoc))  /* if our loc is gone, no damage to do */
00058                 return;
00059 
00060         mech_printf(objMech, MECHALL,
00061                                 "%%cr%%chYour %s takes damage from the fire!%%cn",
00062                                 strLocName);
00063         DamageMech(objMech, objMech, 0, -1, wLoc, 0, 0, wDamRoll, 0, 0, 0, -1,
00064                            0, 1);
00065 
00066         /*
00067          * Only continue the event if the damage was greater than one
00068          */
00069         if((wDamRoll > 1) && (GetSectInt(objMech, wLoc)))
00070                 MECHEVENT(objMech, EVENT_VEHICLEBURN, vehicle_burn_event,
00071                                   VEHICLEBURN_TICK, wLoc);
00072         else {
00073                 if(GetSectInt(objMech, wLoc))
00074                         mech_printf(objMech, MECHALL,
00075                                                 "The fire burning on your %s finally goes out.",
00076                                                 strLocName);
00077                 if(!Burning(objMech))
00078                         MechLOSBroadcast(objMech, "is no longer engulfed in flames.");
00079         }
00080 }
00081 
00082 void vehicle_start_burn(MECH * objMech, MECH * objAttacker)
00083 {
00084         int wIter;
00085         int wDamage = 0;
00086         char strLocName[30];
00087 
00088         if(!objAttacker)
00089                 objAttacker = objMech;
00090 
00091         mech_notify(objMech, MECHALL, "You catch on fire!");
00092         MechLOSBroadcast(objMech, "catches on fire!");
00093 
00094         for(wIter = 0; wIter < NUM_SECTIONS; wIter++) {
00095                 if(GetSectInt(objMech, wIter) && !BurningSide(objMech, wIter)) {
00096                         wDamage = Number(1, 6);
00097                         ArmorStringFromIndex(wIter, strLocName, MechType(objMech),
00098                                                                  MechMove(objMech));
00099                         mech_printf(objMech, MECHALL,
00100                                                 "Your %s catches on fire!", strLocName);
00101 
00102                         DamageMech(objMech, objAttacker, 0, -1, wIter, 0, 0, wDamage,
00103                                            0, 0, 0, -1, 0, 1);
00104                         MECHEVENT(objMech, EVENT_VEHICLEBURN, vehicle_burn_event,
00105                                           VEHICLEBURN_TICK, wIter);
00106                 }
00107         }
00108 }
00109 
00110 void vehicle_extinquish_fire_event(MUXEVENT * e)
00111 {
00112         MECH *objMech = (MECH *) e->data;
00113 
00114         if(!objMech)
00115                 return;
00116 
00117         if(!Burning(objMech))
00118                 return;
00119 
00120         StopBurning(objMech);
00121 
00122         mech_notify(objMech, MECHALL, "You manage to dowse the fire.");
00123         MechLOSBroadcast(objMech, "is no longer engulfed in flames.");
00124 }
00125 
00126 void vehicle_extinquish_fire(dbref player, MECH * mech, char *buffer)
00127 {
00128         cch(MECH_USUALS);
00129 
00130         DOCHECK(Started(mech),
00131                         "Your tank is started! You can not extinguish the flames while your tank is started!");
00132         DOCHECK(!Burning(mech), "This unit is not on fire!");
00133         DOCHECK(Extinguishing(mech),
00134                         "You're already trying to put out the fire!");
00135 
00136         mech_notify(mech, MECHALL, "You begin to exitinguish the fires!");
00137 
00138         MECHEVENT(mech, EVENT_VEHICLE_EXTINGUISH,
00139                           vehicle_extinquish_fire_event, VEHICLE_EXTINGUISH_TICK, 0);
00140 }
00141 
00142 /* 
00143  *  Mechs entering level 2 water, or proning in level 1 water should
00144  *  extinguish any inferno currently burning.
00145  */
00146 void water_extinguish_inferno(MECH * mech)
00147 {
00148         int elev = MechElevation(mech);
00149         MAP *map = getMap(mech->mapindex);
00150 
00151         if(!InWater(mech) || MechType(mech) != CLASS_MECH ||
00152            !Jellied(mech) || (elev == -1 && !Fallen(mech)))
00153                 return;
00154 
00155         muxevent_remove_type_data(EVENT_BURN, (void *) mech);
00156         MechCritStatus(mech) &= ~JELLIED;
00157 
00158         mech_notify(mech, MECHALL, "The flames extinguish in a roar of steam!");
00159         MechLOSBroadcast(mech,
00160                                          "is surrounded by a plume of steam as the flames extinguish.");
00161 
00162         /* According to FASA, the inferno jelly should keep on burning on the
00163          * water hex. We'll just add some steam (smoke) instead. */
00164         add_decoration(map, MechX(mech), MechY(mech), TYPE_SMOKE, SMOKE, 120);
00165 }
00166 
00167 void checkVehicleInFire(MECH * objMech, int fromHexFire)
00168 {
00169         int wRoll = Roll();
00170         int wIter;
00171         int wDamage = 0;
00172 
00173         switch (MechMove(objMech)) {
00174         case MOVE_WHEEL:
00175         case MOVE_VTOL:
00176                 wRoll += 2;
00177                 break;
00178         case MOVE_HOVER:
00179                 wRoll += 4;
00180                 break;
00181         }
00182 
00183         if(wRoll < 8)                           /* don't do jack if it's < 8 */
00184                 return;
00185 
00186         if(fromHexFire)
00187                 mech_notify(objMech, MECHALL,
00188                                         "%cr%chYou drive through a wall of searing flames!%cn");
00189         else
00190                 mech_notify(objMech, MECHALL,
00191                                         "%cr%chThe fires surround your vehicle!%cn");
00192 
00193         switch (wRoll) {
00194         case 8:                                 /* roll once on the motive system chart */
00195         case 9:
00196                 if(MechType(objMech) == CLASS_VTOL) {
00197                         /*
00198                          * VTOLs _should_ make a pskill or go up one level... not right now tho
00199                          */
00200                 } else {
00201                         mech_notify(objMech, MECHALL,
00202                                                 "%cr%chThe fire damages your motive system!%cn");
00203                         DoMotiveSystemHit(objMech, 0);
00204                 }
00205                 break;
00206 
00207         case 10:
00208         case 11:
00209                 /*
00210                  * Do 1d6 damage to each loc
00211                  */
00212                 mech_notify(objMech, MECHALL,
00213                                         "%cr%chThe fire sweeps across your unit damaging it!%cn");
00214 
00215                 for(wIter = 0; wIter < NUM_SECTIONS; wIter++) {
00216                         wDamage = Number(1, 6);
00217 
00218                         if(GetSectInt(objMech, wIter))
00219                                 DamageMech(objMech, objMech, 0, -1, wIter, 0, 0, wDamage,
00220                                                    0, 0, 0, -1, 0, 1);
00221                 }
00222                 break;
00223 
00224         default:
00225                 vehicle_start_burn(objMech, objMech);
00226                 break;
00227         }
00228 }

Generated on Mon May 28 04:25:22 2007 for BattletechMUX by  doxygen 1.4.7