src/hcode/btech/btmacros.h

Go to the documentation of this file.
00001 
00002 /*
00003  * $Id: btmacros.h,v 1.8 2005/08/10 14:09:34 av1-op Exp $
00004  *
00005  * Author: Markus Stenberg <fingon@iki.fi>
00006  *
00007  *  Copyright (c) 1998 Markus Stenberg
00008  *  Copyright (c) 1998-2002 Thomas Wouters
00009  *  Copyright (c) 2000-2002 Cord Awtry
00010  *  Copyright (c) 1999-2005 Kevin Stevens
00011  *       All rights reserved
00012  *
00013  * Created: Sat Jun  6 15:08:11 1998 fingon
00014  * Last modified: Mon Jul 20 01:05:41 1998 fingon
00015  *
00016  */
00017 
00018 /* Descendant of the original macros.h that died of being too bloated :) */
00019 
00020 #include "config.h"
00021 
00022 #ifndef BTMACROS_H
00023 #define BTMACROS_H
00024 
00025 #include <math.h>
00026 #include "macros.h"
00027 #include "floatsim.h"
00028 #include "mech.h"
00029 #include "muxevent.h"
00030 #include "p.event.h"
00031 
00032 #define LOS_NB InLineOfSight_NB
00033 #define MWalkingSpeed(maxspeed) ((float) 2.0 * (maxspeed) / 3.0 + 0.1)
00034 #define WalkingSpeed(maxspeed) ((float) 2.0 * (maxspeed) / 3.0)
00035 #define IsRunning(speed,maxspeed) (speed > MWalkingSpeed(maxspeed))
00036 #define is_aero(mech) ((MechType(mech) == CLASS_AERO) || (IsDS(mech)))
00037 #define IsForest(t) (t == LIGHT_FOREST || t == HEAVY_FOREST)
00038 #define IsForestHex(map,x,y) (IsForest(GetRTerrain(map,x,y)))
00039 #define IsMountains(t) (t == MOUNTAINS)
00040 #define IsMountainsHex(map,x,y) (IsMountains(GetRTerrain(map,x,y)))
00041 #define IsRough(t) (t == ROUGH)
00042 #define IsRoughHex(map,x,y) (IsRough(GetRTerrain(map,x,y)))
00043 #define IsBuilding(t) (t == BUILDING)
00044 #define IsBuildingHex(map,x,y) (IsBuilding(GetRTerrain(map,x,y)))
00045 #define BaseElev(terr,elev) ((terr) == WATER ? -(elev) : (terr) == ICE ? -(elev) : (elev))
00046 #define Elevation(mech_map,x,y) \
00047   BaseElev(GetRTerrain(mech_map,x,y),GetElevation(mech_map,x,y))
00048 #define MechElevation(mech) \
00049   BaseElev(MechRTerrain(mech),abs(MechElev(mech)))
00050 #define MechEngineSizeC(mech) \
00051     ((int) rint((2 * MechMaxSpeed(mech) / KPH_PER_MP) / 3) * MechTons(mech))
00052 #define MechLowerElevation(mech) \
00053  (MechRTerrain(mech) != BRIDGE ? MechElevation(mech) : bridge_w_elevation(mech))
00054 #define MechUpperElevation(mech) (MechRTerrain(mech) == ICE ? 0 : MechElevation(mech))
00055 #define MechsElevation(mech) \
00056   (MechZ(mech) - ((MechUpperElevation(mech) <= MechZ(mech) ? MechUpperElevation(mech) : MechLowerElevation(mech))))
00057 
00058 /* GotPilot checks if mech's pilot is valid and inside his machine */
00059 #define GotPilot(mech) \
00060      (MechPilot(mech) > 0 && Location(MechPilot(mech)) == mech->mynum)
00061 
00062 #define RGotPilot(mech) \
00063        ((GotPilot(mech)) && (Connected(MechPilot(mech)) || !isPlayer(MechPilot(mech))))
00064 
00065 #define GotGPilot(mech) \
00066      ((pilot_override && GunPilot(mech) > 0) || \
00067       (!pilot_override && GotPilot(mech)))
00068 
00069 #define RGotGPilot(mech) \
00070      ((pilot_override && GunPilot(mech) > 0 && (Connected(GunPilot(mech)) || \
00071                                                 !isPlayer(GunPilot(mech)))) \
00072       || (!pilot_override && RGotPilot(mech)))
00073 
00074 #define AeroBay(a,b)            (a)->pd.bay[b]
00075 #define AeroFuel(a)             (a)->ud.fuel
00076 #define AeroFuelMax(a)          (a)->rd.maxfuel
00077 #define AeroFuelOrig(a)         (a)->ud.fuel_orig
00078 #define AeroSI(a)               (a)->ud.si
00079 #define AeroSIOrig(a)           (a)->ud.si_orig
00080 #define AeroTurret(a,b)         (a)->pd.turret[b]
00081 #define AeroUnusableArcs(a)     (a)->pd.unusable_arcs
00082 #define AeroFreeFuel(a) ((MechType(a) == CLASS_VTOL) && mudconf.btech_nofusionvtolfuel && (!(MechSpecials(a) & ICE_TECH)))
00083 #define DSLastMsg(a)            (a)->rd.last_ds_msg
00084 #define GunPilot(a)             (pilot_override>0?pilot_override:MechPilot(a))
00085 #define MechRadioType(a)        ((a)->ud.radioinfo)
00086 #define MechRadioInfo(a)        (MechRadioType(a) / FREQS)
00087 #define MechFreqs(a)            (MechRadioType(a) % FREQS)
00088 #define MFreqs(a)               MechFreqs(a)
00089 #define MechAim(a)              (a)->rd.aim
00090 #define MechAimType(a)          (a)->rd.aim_type
00091 #define MechAuto(a)             (a)->rd.autopilot_num
00092 #define MechBTH(a)              (a)->rd.basetohit
00093 #define MechBaseWalk(a) (a)->ud.walkspeed
00094 #define MechBaseRun(a)  (a)->ud.runspeed
00095 #define MechBoomStart(a)        (a)->rd.boom_start
00096 #define MechCarriedCargo(a)     (a)->rd.cargo_weight
00097 #define MechXPMod(a)            (a)->rd.xpmod
00098 #define SetCWCheck(a)           MechCritStatus(a) &= ~LOAD_OK
00099 #define SetWCheck(a)            MechCritStatus(a) &= ~OWEIGHT_OK
00100 #define SetCarriedCargo(a,b)    do { MechCarriedCargo(a) = (b) ; SetCWCheck(a); } while (0)
00101 #define MechCarrying(a)         (a)->rd.carrying
00102 #define SetCarrying(a,b)        do { MechCarrying(a) = (b) ; SetCWCheck(a) ; } while (0)
00103 #define MechChargeTarget(a)     (a)->rd.chgtarget
00104 #define MechChargeTimer(a)      (a)->rd.chargetimer
00105 #define MechChargeDistance(a)   (a)->rd.chargedist
00106 #define MechCocoon(a)           (a)->rd.cocoon
00107 #define MechComm(a)             (a)->rd.commconv
00108 #define MechCommLast(a)         (a)->rd.commconv_last
00109 #define MechComputer(a)         (a)->ud.computer
00110 #define MechCritStatus(a)       (a)->rd.critstatus
00111 #define MechCritStatus2(a)      (a)->rd.critstatus2
00112 #define MechDFATarget(a)        (a)->rd.dfatarget
00113 #define MechDesiredAngle(a)     (a)->rd.angle
00114 #define MechDesiredFacing(a)    (a)->rd.desiredfacing
00115 #define MechDesiredSpeed(a)     (a)->rd.desired_speed
00116 #define MechElev(a)             (a)->pd.elev
00117 #define MechEndFZ(a)            (a)->rd.endfz
00118 #define MechEngineHeat(a)       (a)->rd.engineheat
00119 #define MechFX(a)               (a)->pd.fx
00120 #define MechFY(a)               (a)->pd.fy
00121 #define MechFZ(a)               (a)->pd.fz
00122 #define MechFacing(a)           (FSIM2SHO((a)->pd.facing))
00123 #define MechRFacing(a)          (a)->pd.facing
00124 #define SetRFacing(a,b)         MechRFacing(a) = (b)
00125 #define SetFacing(a,b)          SetRFacing(a,SHO2FSIM(b))
00126 #define AddRFacing(a,b)         MechRFacing(a) += b
00127 #define AddFacing(a,b)          AddRFacing(a,SHO2FSIM(b))
00128 #define MechFireAdjustment(a)   (a)->rd.fire_adjustment
00129 #define MechGoingX(a)           (a)->rd.goingx
00130 #define MechGoingY(a)           (a)->rd.goingy
00131 #define MechHeat(a)             (a)->rd.heat
00132 #define MechHeatLast(a)         (a)->rd.heatboom_last
00133 #define MechHexes(a)            (a)->pd.hexes_walked
00134 #define MechID(a)               (a)->ID
00135 #define MechIsOmniMech(a)               MechSpecials2(a) & OMNIMECH_TECH
00136 #define MechInfantrySpecials(a)         (a)->rd.infantry_specials
00137 #define MechJumpHeading(a)      (a)->rd.jumpheading
00138 #define MechJumpLength(a)       (a)->rd.jumplength
00139 #define MechJumpSpeed(a)        (a)->rd.jumpspeed
00140 #define MechJumpTop(a)          (a)->rd.jumptop
00141 #define MechLRSRange(a)         (a)->ud.lrs_range
00142 #define MechLWRT(a)             (a)->rd.last_weapon_recycle
00143 #define MechLastRndU(a)         (a)->rd.lastrndu
00144 #define MechLastUse(a)          (a)->rd.lastused
00145 #define MechLastStartup(a)      (a)->rd.last_startup
00146 #define MechLastX(a)            (a)->pd.last_x
00147 #define MechLastY(a)            (a)->pd.last_y
00148 #define MechLateral(a)          (a)->rd.lateral
00149 #define MechMASCCounter(a)      (a)->rd.masc_value
00150 #define MechSChargeCounter(a)   (a)->rd.scharge_value
00151 #define MechEngineSizeV(a)      (a)->rd.erat
00152 #define MechEngineSize(a)       (MechEngineSizeV(a) > 0 ? MechEngineSizeV(a) : MechEngineSizeC(a))
00153 #define MechMaxSpeed(a)         (a)->ud.maxspeed
00154 #define TemplateMaxSpeed(a)     (a)->ud.template_maxspeed
00155 #define SetMaxSpeed(a,b)        do {MechMaxSpeed(a) = b;MechCritStatus(a) &= ~SPEED_OK;correct_speed(a);} while (0)
00156 #define LowerMaxSpeed(a,b)      SetMaxSpeed(a,MechMaxSpeed(a)-b)
00157 #define DivideMaxSpeed(a,b)     SetMaxSpeed(a,MechMaxSpeed(a)/b)
00158 #define MechRMaxSpeed(a)        (a)->rd.rspd
00159 #define MMaxSpeed(a)            ((float) MechCargoMaxSpeed((a),(float) MechMaxSpeed((a))))
00160 #define MechMaxSuits(a) (a)->rd.maxsuits
00161 #define MechMinusHeat(a)        (a)->rd.minus_heat
00162 #define MechMove(a)             (a)->ud.move
00163 #define MechIsQuad(a)                   (MechMove(a) == MOVE_QUAD)
00164 #define MechIsBiped(a)                  (MechMove(a) == MOVE_BIPED)
00165 #define MechNumOsinks(a)        (a)->rd.onumsinks
00166 #define MechNumSeen(a)          (a)->rd.num_seen
00167 #define MechPNumSeen(a)         (a)->rd.can_see
00168 #define MechRealNumsinks(a)     (a)->ud.numsinks
00169 #define MechActiveNumsinks(a)   (MechRealNumsinks(a) - MechDisabledHS(a))
00170 #define MechDisabledHS(a)       (a)->rd.disabled_hs
00171 #define MechPer(a)              (a)->rd.per
00172 #define MechPrefs(a)            (a)->rd.mech_prefs
00173 #define MechPKiller(a)          (MechPrefs(a) & MECHPREF_PKILL)
00174 #define SetMechPKiller(a)       (MechPrefs(a) |= MECHPREF_PKILL)
00175 #define UnSetMechPKiller(a)     (MechPrefs(a) &= ~MECHPREF_PKILL)
00176 #define MechSLWarn(a)           (MechPrefs(a) & MECHPREF_SLWARN)
00177 #define MechAutoFall(a)         (MechPrefs(a) & MECHPREF_AUTOFALL)
00178 #define MechArmorWarn(a)        (!(MechPrefs(a) & MECHPREF_NOARMORWARN))
00179 #define MechAmmoWarn(a)         (!(MechPrefs(a) & MECHPREF_NOAMMOWARN))
00180 #define MechFailStand(a)        (!(MechPrefs(a) & MECHPREF_NOFAILSTAND))
00181 #define MechAutoconSD(a)        (MechPrefs(a) & MECHPREF_AUTOCON_SD)
00182 #define MechNoFriendlyFire(a)   (MechPrefs(a) & MECHPREF_NOFRIENDLYFIRE)
00183 #define MechWalkXPFactor(a)     (a)->rd.wxf
00184 #define MechPilot(a)            (a)->pd.pilot
00185 #define MechPilotSkillBase(a)   (a)->rd.pilotskillbase
00186 #define MechPilotStatus(a)      (a)->pd.pilotstatus
00187 #define MechPlusHeat(a)         (a)->rd.plus_heat
00188 #define MechRadio(a)            (a)->ud.radio
00189 #define MechRadioRange(a)       (a)->ud.radio_range
00190 #define MechRnd(a)               (a)->rd.rnd
00191 #define MechScanRange(a)        (a)->ud.scan_range
00192 #define MechSections(a)         (a)->ud.sections
00193 #define MechSensor(a)           (a)->rd.sensor
00194 #define MechSpecials(a)         (a)->rd.specials
00195 #define MechSpecials2(a)        (a)->rd.specials2
00196 #define MechSpeed(a)            (a)->rd.speed
00197 #define MechSpotter(a)          (a)->rd.spotter
00198 #define MechStall(a)            (a)->pd.stall
00199 #define MechStartFX(a)          (a)->rd.startfx
00200 #define MechStartFY(a)          (a)->rd.startfy
00201 #define MechStartFZ(a)          (a)->rd.startfz
00202 #define MechStartSpin(a)        (a)->rd.sspin
00203 #define MechStatus(a)       (a)->rd.status
00204 /* Adding in Exile's status2 and removing 3030's specialsstatus */
00205 #define MechStatus2(a)      (a)->rd.status2
00206 /* #define MechSpecialsStatus(a)                (a)->rd.specialsstatus */
00207 #define MechSwarmTarget(a)      (a)->rd.swarming
00208 #define MechSwarmer(a)          (a)->rd.swarmedby
00209 #define MechTacRange(a)         (a)->ud.tac_range
00210 #define MechTankCritStatus(a)   (a)->rd.tankcritstatus
00211 #define MechTargX(a)            (a)->rd.targx
00212 #define MechTargY(a)            (a)->rd.targy
00213 #define MechTargZ(a)            (a)->rd.targz
00214 #define MechTarget(a)           (a)->rd.target
00215 #define MechTeam(a)             (a)->pd.team
00216 #define MechTerrain(a)          (a)->pd.terrain
00217 #define MechRTerrain(a)         ((MechTerrain(a) == FIRE || MechTerrain(a) == SMOKE) ? mech_underlying_terrain(a) : MechTerrain(a))
00218 #define MechTons(a)             (a)->ud.tons
00219 #define MechRTons(a)            get_weight(a)
00220 #define MechRTonsV(a)           (a)->rd.row
00221 #define MechRealTons(a)         ((a)->rd.row / 1024)
00222 #define MechRCTonsV(a)          (a)->rd.rcw
00223 #define MechTurnDamage(a)       (a)->rd.turndamage
00224 #define MechStaggeredLastTurn(a) (a)->rd.staggerstamp
00225 #define MechStaggerStamp(a)     ((a)->rd.staggerstamp - 1)
00226 #define SetMechStaggerStamp(a,b) ((a)->rd.staggerstamp = (b) + 1)
00227 #define MechTurretFacing(a)     (a)->rd.turretfacing
00228 #define MechType(a)             (a)->ud.type
00229 #define MechType_Name(a)        (a)->ud.mech_name
00230 #define MechType_Ref(a)         (a)->ud.mech_type
00231 #define MechVFacing(a)          AcceptableDegree(MechFacing(a) + MechLateral(a))
00232 #define MechVerticalSpeed(a)    (a)->rd.verticalspeed
00233 #define MechVisMod(a)           (a)->rd.vis_mod
00234 #define MechWeapHeat(a)         (a)->rd.weapheat
00235 #define MechX(a)                (a)->pd.x
00236 #define MechY(a)                (a)->pd.y
00237 #define MechZ(a)                (a)->pd.z
00238 #define MechLX(a)               (a)->rd.lx
00239 #define MechLY(a)               (a)->rd.ly
00240 
00241 #define MechTargComp(a)              (a)->ud.targcomp
00242 #ifdef BT_CALCULATE_BV
00243 #define MechBVLast(a)           (a)->ud.mechbv_last
00244 #endif
00245 #define MechBV(a)               (a)->ud.mechbv
00246 #define CargoSpace(a)           (a)->ud.cargospace
00247 #define CarMaxTon(a)            (a)->ud.carmaxton
00248 #define Heatcutoff(a)           (MechCritStatus(a) & HEATCUTOFF)
00249 
00250 #define MechHasDHS(a)           (MechSpecials(a) & (CLAN_TECH|DOUBLE_HEAT_TECH))
00251 #define ClanMech(a)             (MechSpecials(a) & CLAN_TECH)
00252 
00253 #define HS_Size(a)              (MechType(mech) == CLASS_MECH ? (ClanMech(a) ? 2 : ((MechSpecials(a) & DOUBLE_HEAT_TECH) ? 3 : 1)) : 1)
00254 #define HS_Efficiency(a)        (MechHasDHS(a) ? 2 : 1)
00255 #define MechHasHeat(a)          (MechType(a) == CLASS_MECH || MechType(a) == CLASS_AERO || MechType(a) == CLASS_DS || \
00256                                  MechType(a) == CLASS_SPHEROID_DS)
00257 
00258 #define DSSpam(mek,msg)         do { if (DropShip(MechType(mek)) && DSOkToNotify(mek)) MechLOSBroadcast(mek,msg); } while (0)
00259 #define DSSpam_O(mek,msg)       do { if (DropShip(MechType(mek))) MechLOSBroadcast(mek,msg); } while (0)
00260 
00261 #define MechHasTurret(a)        ((MechType(a) == CLASS_VEH_GROUND || \
00262                                   MechType(a) == CLASS_VEH_NAVAL || \
00263                                   MechType(a) == CLASS_VTOL) && \
00264                                  GetSectOInt(a, TURRET))
00265 
00266 #define MechSeemsFriend(a, b)   (MechTeam(a) == MechTeam(b) && \
00267                                  InLineOfSight_NB(a, b, 0, 0, 0))
00268 
00269 #define SetTurnMode(a,b) do { if (b) MechPrefs(a) |= MECHPREF_TURNMODE; else MechPrefs(a) &= ~MECHPREF_TURNMODE; } while (0)
00270 #define GetTurnMode(a)  (MechPrefs(a) & MECHPREF_TURNMODE)
00271 
00272 #define MECHEVENT(mech,type,func,time,data) \
00273   do { if (mech->mynum > 0) \
00274      muxevent_add(time, 0, type, func, (void *) (mech), (void *) (data)); } while (0)
00275 
00276 #define AUTOEVENT(auto,type,func,time,data) \
00277   muxevent_add(time, 0, type, func, (void *) (auto), (void *) (data))
00278 
00279 #define MAPEVENT(map,type,func,time,data) \
00280   muxevent_add(time, 0, type, func, (void *) (map), (void *) (data))
00281 #define StopDec(a)    muxevent_remove_type_data2(EVENT_DECORATION, (void *) a)
00282 
00283 #define OBJEVENT(obj,type,func,time,data) \
00284   muxevent_add(time, 0, type, func, (void *) obj, (void *) (data))
00285 
00286 #define GetPartType(a,b,c)   MechSections(a)[b].criticals[c].type
00287 #define SetPartType(a,b,c,d) GetPartType(a,b,c)=d
00288 
00289 #define GetPartFireMode(a,b,c)   MechSections(a)[b].criticals[c].firemode
00290 #define SetPartFireMode(a,b,c,d) GetPartFireMode(a,b,c)=d
00291 
00292 #define GetPartAmmoMode(a,b,c)   MechSections(a)[b].criticals[c].ammomode
00293 #define SetPartAmmoMode(a,b,c,d) GetPartAmmoMode(a,b,c)=d
00294 
00295 #define GetPartDamageFlags(a,b,c)   MechSections(a)[b].criticals[c].weapDamageFlags
00296 #define SetPartDamageFlags(a,b,c,d) GetPartDamageFlags(a,b,c)=d
00297 
00298 #define GetPartDesiredAmmoLoc(a,b,c)   MechSections(a)[b].criticals[c].desiredAmmoLoc
00299 #define SetPartDesiredAmmoLoc(a,b,c,d) GetPartDesiredAmmoLoc(a,b,c)=d
00300 
00301 #define GetPartData(a,b,c)   MechSections(a)[b].criticals[c].data
00302 #define SetPartData(a,b,c,d) GetPartData(a,b,c)=d
00303 
00304 #define GetPartRBrand(mech,a,b) MechSections(mech)[a].criticals[b].brand
00305 #define GetPartBrand(mech,a,b) (GetPartRBrand(mech,a,b)%16)
00306 
00307 #define SetPartBrand(mech,a,b,d) \
00308     GetPartRBrand(mech,a,b) = (d) + (PartTempNuke(mech,a,b)<<4)
00309 #define PartTempNuke(mech,a,b)  (GetPartRBrand(mech,a,b)>>4)
00310 #define SetPartTempNuke(mech,a,b,d) \
00311     GetPartRBrand(mech,a,b) = GetPartBrand(mech,a,b) + ((d) << 4)
00312 #define ClearTempNuke(mech,a,b) GetPartRBrand(mech,a,b) = GetPartBrand(mech,a,b)
00313 
00314 #define PartIsNonfunctional(a,b,c)  (PartIsDisabled(a,b,c) || PartIsBroken(a,b,c) || PartIsDestroyed(a,b,c))
00315 #define PartIsDamaged(a,b,c)   (GetPartFireMode(a,b,c) & DAMAGED_MODE)
00316 #define DamagePart(a,b,c)      (GetPartFireMode(a,b,c) |= DAMAGED_MODE)
00317 #define UnDamagePart(a,b,c)    do { (GetPartFireMode(a,b,c) &= ~DAMAGED_MODE); SetPartDamageFlags(a,b,c,0); SetPartTempNuke(a,b,c,0); } while (0)
00318 #define PartIsDisabled(a,b,c)  (GetPartFireMode(a,b,c) & DISABLED_MODE)
00319 #define DisablePart(a,b,c)     (GetPartFireMode(a,b,c) |= DISABLED_MODE)
00320 #define UnDisablePart(a,b,c)   (GetPartFireMode(a,b,c) &= ~DISABLED_MODE)
00321 #define PartIsBroken(a,b,c)    (GetPartFireMode(a,b,c) & (DESTROYED_MODE|BROKEN_MODE))
00322 #define BreakPart(a,b,c)       (GetPartFireMode(a,b,c) |= BROKEN_MODE)
00323 #define UnBreakPart(a,b,c)     (GetPartFireMode(a,b,c) &= ~BROKEN_MODE)
00324 #define PartIsDestroyed(a,b,c) (GetPartFireMode(a,b,c) & DESTROYED_MODE)
00325 #define DestroyPart(a,b,c)     do { (GetPartFireMode(a,b,c) |= DESTROYED_MODE); GetPartFireMode(a,b,c) &= ~(BROKEN_MODE|DISABLED_MODE|DAMAGED_MODE); SetPartDamageFlags(a,b,c,0); SetPartTempNuke(a,b,c,0); } while (0)
00326 #define UnDestroyPart(a,b,c)   do { (GetPartFireMode(a,b,c) &= ~(DESTROYED_MODE|HOTLOAD_MODE|DISABLED_MODE|BROKEN_MODE|DAMAGED_MODE)); SetPartDamageFlags(a,b,c,0); SetPartTempNuke(a,b,c,0); } while (0)
00327 
00328 #define WpnIsRecycling(a,b,c)  (GetPartData(a,b,c) > 0 && \
00329                                 IsWeapon(GetPartType(a,b,c)) && \
00330                                 !PartIsNonfunctional(a,b,c) && \
00331                                 !SectIsDestroyed(a,b))
00332 #define SectArmorRepair(a,b)  SomeoneFixingA(a,b)
00333 #define SectRArmorRepair(a,b) SomeoneFixingA(a,b+8)
00334 #define SectIntsRepair(a,b)   SomeoneFixingI(a,b)
00335 
00336 #define SectIsDestroyed(a,b)  (!GetSectArmor(a,b) && ((is_aero(a) || !GetSectInt(a,b)) && !IsDS(a)))
00337 #define SetSectDestroyed(a,b)
00338 #define UnSetSectDestroyed(a,b)
00339 #define SectIsBreached(a,b)  ((a)->ud.sections[b].config & SECTION_BREACHED)
00340 #define SetSectBreached(a,b) \
00341 do { MechSections(a)[b].config |= SECTION_BREACHED ; SetWCheck(a); } while (0)
00342 #define UnSetSectBreached(a,b) \
00343 do { MechSections(a)[b].config &= ~SECTION_BREACHED ; SetWCheck(a); } while (0)
00344 
00345 /*
00346  * Added 8/4/99 by Kipsta for new flooding code
00347  */
00348 
00349 #define SectIsFlooded(a,b)  ((a)->ud.sections[b].config & SECTION_FLOODED)
00350 #define SetSectFlooded(a,b) do { MechSections(a)[b].config |= SECTION_FLOODED ; SetWCheck(a); } while (0)
00351 #define UnSetSectFlooded(a,b) do { MechSections(a)[b].config &= ~SECTION_FLOODED ; SetWCheck(a); } while (0)
00352 
00353 #define GetSectArmor(a,b)    ((a)->ud.sections[b].armor)
00354 #define GetSectRArmor(a,b)   ((a)->ud.sections[b].rear)
00355 #define GetSectInt(a,b)      ((a)->ud.sections[b].internal)
00356 
00357 #define SetSectArmor(a,b,c)  do { (a)->ud.sections[b].armor=c;SetWCheck(a); } while (0)
00358 #define SetSectRArmor(a,b,c) do { (a)->ud.sections[b].rear=c;SetWCheck(a); } while (0)
00359 #define SetSectInt(a,b,c)    do { (a)->ud.sections[b].internal=c;SetWCheck(a); } while (0)
00360 
00361 #define GetSectOArmor(a,b)   (a)->ud.sections[b].armor_orig
00362 #define GetSectORArmor(a,b)  (a)->ud.sections[b].rear_orig
00363 #define GetSectOInt(a,b)     (a)->ud.sections[b].internal_orig
00364 
00365 #define SetSectOArmor(a,b,c) (a)->ud.sections[b].armor_orig=c
00366 #define SetSectORArmor(a,b,c) (a)->ud.sections[b].rear_orig=c
00367 #define SetSectOInt(a,b,c)   (a)->ud.sections[b].internal_orig=c
00368 
00369 #define CanJump(a) (!(Stabilizing(a)) && !(Jumping(a)))
00370 
00371 /* #define Jumping(a)           muxevent_count_type_data(EVENT_JUMP,(void *) a) */
00372 
00373 /* crew stunned related events and macros */
00374 #define CrewStunned(a)                   muxevent_count_type_data(EVENT_UNSTUN_CREW, (void *) a)
00375 #define StunCrew(a)                                      MECHEVENT(a, EVENT_UNSTUN_CREW, unstun_crew_event, 60, 0)
00376 
00377 /* Exile Stun code */
00378 #define CrewStunning(a)         muxevent_count_type_data(EVENT_CREWSTUN, (void *) a)
00379 #define StopCrewStunning(a)     muxevent_remove_type_data(EVENT_CREWSTUN, (void *) a)
00380 
00381 #define Burning(a)           muxevent_count_type_data(EVENT_VEHICLEBURN, (void *) a)
00382 #define BurningSide(a,side)  muxevent_count_type_data_data(EVENT_VEHICLEBURN, (void *) a, (void *) side)
00383 #define StopBurning(a)       muxevent_remove_type_data(EVENT_VEHICLEBURN, (void *) a)
00384 #define StopBurningSide(a,side) muxevent_remove_type_data_data(EVENT_VEHICLEBURN, (void *) a, (void *) side)
00385 #define Extinguishing(a)     muxevent_count_type_data(EVENT_VEHICLE_EXTINGUISH, (void *) a)
00386 #define Jellied(a)           (MechCritStatus(a) & JELLIED)
00387 #define Exploding(a)         muxevent_count_type_data(EVENT_EXPLODE, (void *) a)
00388 #define Dumping(a)           muxevent_count_type_data(EVENT_DUMP, (void *) a)
00389 #define Dumping_Type(a,type) (muxevent_count_type_data_data(EVENT_DUMP, (void *) a, (void *) type) || muxevent_count_type_data_data(EVENT_DUMP, (void *) a, (void *) 0))
00390 #define DumpingData(a,data2) muxevent_get_type_data(EVENT_DUMP, (void *) a, (void *) data2)
00391 #define ChangingLateral(a)   muxevent_count_type_data(EVENT_LATERAL,(void *) a)
00392 #define Seeing(a)            muxevent_count_type_data(EVENT_PLOS,(void *) a)
00393 #define Locking(a)           muxevent_count_type_data(EVENT_LOCK,(void *) a)
00394 #define Hiding(a)            muxevent_count_type_data(EVENT_HIDE,(void *) a)
00395 #define HasCamo(a)           (MechSpecials2(a) & CAMO_TECH)
00396 #define Digging(a)           (MechTankCritStatus(a) & DIGGING_IN)
00397 #define MechDugIn(a)         (MechTankCritStatus(mech) & DUG_IN)
00398 #define ChangingHulldown(a)  muxevent_count_type_data(EVENT_CHANGING_HULLDOWN,(void *) a)
00399 #define IsHulldown(a)        (MechStatus(a) & HULLDOWN)
00400 #define Falling(a)           muxevent_count_type_data(EVENT_FALL,(void *) a)
00401 #define Moving(a)            muxevent_count_type_data(EVENT_MOVE,(void *) a)
00402 #define RemovingPods(a)      muxevent_count_type_data(EVENT_REMOVE_PODS,(void *) a)
00403 #define SensorChange(a)      muxevent_count_type_data(EVENT_SCHANGE,(void *) a)
00404 #define Stabilizing(a)       muxevent_count_type_data(EVENT_JUMPSTABIL,(void *) a)
00405 #define Standrecovering(a)   muxevent_count_type_data(EVENT_STANDFAIL, (void *) a)
00406 #define Standing(a)          muxevent_count_type_data(EVENT_STAND,(void *) a)
00407 #define Starting(a)          muxevent_count_type_data(EVENT_STARTUP,(void *) a)
00408 #define Recovering(a)        muxevent_count_type_data(EVENT_RECOVERY,(void *) a)
00409 #define TakingOff(a)         muxevent_count_type_data(EVENT_TAKEOFF,(void *) a)
00410 #define FlyingT(a)           (is_aero(a) || MechMove(a) == MOVE_VTOL)
00411 #define RollingT(a)          ((MechType(a) == CLASS_AERO) || (MechType(a) == CLASS_DS))
00412 #define MaybeMove(a) \
00413 do { if (!Moving(a) && Started(a) && (!Fallen(mech) || MechType(a) == CLASS_MECH)) \
00414    MECHEVENT(a,EVENT_MOVE,is_aero(a) ? aero_move_event : mech_move_event,\
00415              MOVE_TICK,0); } while (0)
00416 #define SetRecyclePart(a,b,c,d) \
00417 do { UpdateRecycling(a) ; SetPartData(a,b,c,d); } while (0)
00418 #define SetRecycleLimb(a,b,c) \
00419 do { UpdateRecycling(a) ; (a)->ud.sections[b].recycle=c; } while (0)
00420 #define UpdateRecycling(a) \
00421 do { if (Started(a) && !Destroyed(a) && a->rd.last_weapon_recycle != muxevent_tick) \
00422     recycle_weaponry(a); } while (0)
00423 
00424 #define AllLimbsRecycling(mech) \
00425     (MechSections(mech)[RARM].recycle && \
00426     MechSections(mech)[LARM].recycle && \
00427     MechSections(mech)[RLEG].recycle && \
00428     MechSections(mech)[LLEG].recycle)
00429 
00430 #define AnyLimbsRecycling(mech) \
00431     (MechSections(mech)[RARM].recycle || \
00432     MechSections(mech)[LARM].recycle || \
00433     MechSections(mech)[RLEG].recycle || \
00434     MechSections(mech)[LLEG].recycle)
00435 
00436 #define StopExploding(a)    muxevent_remove_type_data(EVENT_EXPLODE, (void *) a)
00437 #define StopLateral(a)      muxevent_remove_type_data(EVENT_LATERAL,(void *) a)
00438 #define StopMasc(a)         muxevent_remove_type_data(EVENT_MASC_FAIL,(void *) a)
00439 #define StopMascR(a)        muxevent_remove_type_data(EVENT_MASC_REGEN,(void *) a)
00440 #define StopSCharge(a)      muxevent_remove_type_data(EVENT_SCHARGE_FAIL,(void *) a)
00441 #define StopSChargeR(a)     muxevent_remove_type_data(EVENT_SCHARGE_REGEN,(void *) a)
00442 #define StopDump(a)          muxevent_remove_type_data(EVENT_DUMP, (void *) a)
00443 #define StopJump(a)          muxevent_remove_type_data(EVENT_JUMP, (void *) a)
00444 #define StopOOD(a)          muxevent_remove_type_data(EVENT_OOD, (void *) a)
00445 #define StopMoving(a)        muxevent_remove_type_data(EVENT_MOVE, (void *) a)
00446 #define StopStand(a)         muxevent_remove_type_data(EVENT_STAND, (void *) a)
00447 #define StopStabilization(a) muxevent_remove_type_data(EVENT_JUMPSTABIL, (void *) a)
00448 #define StopSensorChange(a)  muxevent_remove_type_data(EVENT_SCHANGE,(void *) a)
00449 #define StopStartup(a)       muxevent_remove_type_data(EVENT_STARTUP, (void *) a)
00450 #define StopHiding(a)          muxevent_remove_type_data(EVENT_HIDE, (void *) a)
00451 #define StopDigging(a)          muxevent_remove_type_data(EVENT_DIG, (void *) a);MechTankCritStatus(a) &= ~DIGGING_IN
00452 #define StopHullDown(a)      muxevent_remove_type_data(EVENT_CHANGING_HULLDOWN, (void *) a)
00453 #define StopTakeOff(a)       muxevent_remove_type_data(EVENT_TAKEOFF, (void *) a)
00454 #define UnjammingTurret(a)   muxevent_count_type_data(EVENT_UNJAM_TURRET, (void *) a)
00455 #define UnJammingAmmo(a)                 muxevent_count_type_data(EVENT_UNJAM_AMMO, (void *) a)
00456 #define UnJammingAmmoData(a,type) muxevent_get_type_data(EVENT_UNJAM_AMMO, (void *) a, (void *) type)
00457 #define WeaponUnJammingAmmo(a,type) muxevent_count_type_data_data(EVENT_UNJAM_AMMO, (void *) a, (void *) type)
00458 #define EnteringHangar(a)                muxevent_count_type_data(EVENT_ENTER_HANGAR, (void *) a)
00459 #define OODing(a)            MechCocoon(a)
00460 #define C_OODing(a)          (MechCocoon(a) > 0)
00461 #define InSpecial(a)         (MechStatus(a) & UNDERSPECIAL)
00462 #define InGravity(a)         (MechStatus(a) & UNDERGRAVITY)
00463 #define InVacuum(a)          (MechStatus(a) & UNDERVACUUM)
00464 #define Jumping(a)           (MechStatus(a) & JUMPING)
00465 #define Started(a)           (MechStatus(a) & STARTED)
00466 #define Destroyed(a)         (MechStatus(a) & DESTROYED)
00467 #define Fallen(a)            (MechStatus(a) & FALLEN)
00468 #define Immobile(a)          ( !Started(a) || Uncon(a) || Blinded(a) || (MechMove(a) == MOVE_NONE) || ((MechStatus(a) & FALLEN) && ( (MechType(a) != CLASS_MECH) && (MechType(a) != CLASS_MW) )) )
00469 #define Landed(a)            (MechStatus(a) & LANDED)
00470 #define Towed(a)             (MechStatus(a) & TOWED)
00471 #define Towable(a)           (MechCritStatus(a) & TOWABLE)
00472 #define PerformingAction(a)  (MechStatus(a) & PERFORMING_ACTION)
00473 #define StopPerformingAction(a) (MechStatus(a) &= ~PERFORMING_ACTION)
00474 
00475 #define MakeMechFall(a)      MechStatus(a) |= FALLEN;FallCentersTorso(a);MarkForLOSUpdate(a);MechFloods(a);StopStand(a);StopHullDown(a);MechStatus(a) &= ~HULLDOWN;
00476 #define FallCentersTorso(a)  MechStatus(a) &= ~(TORSO_RIGHT|TORSO_LEFT|FLIPPED_ARMS)
00477 #define MakeMechStand(a)     MechStatus(a) &= ~FALLEN;MarkForLOSUpdate(a)
00478 #define StandMechTime(a)     (30 / BOUNDED(1,(MechMaxSpeed(a)/MP2),30))
00479 #define StopLock(a)          muxevent_remove_type_data(EVENT_LOCK, (void *) a);\
00480 MechStatus(a) &= ~LOCK_MODES
00481 #define SearchlightChanging(a)  muxevent_count_type_data(EVENT_SLITECHANGING, (void *) a)
00482 #define HeatcutoffChanging(a)   muxevent_count_type_data(EVENT_HEATCUTOFFCHANGING, (void *) a)
00483 
00484 #define SeeWhenShutdown(a)      (MechStatus(mech) & AUTOCON_WHEN_SHUTDOWN)
00485 
00486 #define LoseLock(a)         StopLock(a);MechTarget(a)=-1;MechTargX(a)=-1;MechTargY(a)=-1;if (MechAim(a) != NUM_SECTIONS) { mech_notify(a, MECHALL, "Location-specific targeting powers down."); MechAim(a) = NUM_SECTIONS; }
00487 #ifdef ADVANCED_LOS
00488 #define StartSeeing(a) \
00489     MECHEVENT(a,EVENT_PLOS,mech_plos_event,INITIAL_PLOS_TICK,0)
00490 #else
00491 #define StartSeeing(a)
00492 #endif
00493 
00494 #define Startup(a)           \
00495     do { MechStatus(a) |= STARTED;MechTurnDamage(a) = 0;UpdateRecycling(a); \
00496     MechNumSeen(a)=0; StartSeeing(a); } while (0)
00497 
00498 #define Shutdown(a)          \
00499         do { if (!Destroyed(a)) { UpdateRecycling(a); MechSpeed(a) = 0.0; \
00500                 MechCritStatus(a) &= ~(HEATCUTOFF); MechStatus(a) &= ~(STARTED|MASC_ENABLED); \
00501                 MechStatus2(a) &= ~(ECM_ENABLED|ECCM_ENABLED|PER_ECM_ENABLED|PER_ECCM_ENABLED|ANGEL_ECM_ENABLED|ANGEL_ECCM_ENABLED|NULLSIGSYS_ON|STH_ARMOR_ON);\
00502                 MechDesiredSpeed(a) = 0.0; }; \
00503                 MechPilot(a) = -1; MechTarget(a) = -1; StopStartup(a); \
00504                 StopMoveMode(a); MechStatus2(a) &= ~(MOVE_MODES); \
00505                 StopJump(a); StopMoving(a); MechMASCCounter(a) = 0; \
00506                 StopStand(a); StopStabilization(a); StopTakeOff(a); \
00507                 StopHiding(a); StopDigging(a); StopHullDown(a); stopTAG(a); \
00508                 DropClub(a); StopMasc(a); MechChargeTarget(a) = -1;\
00509                 StopSwarming(a,0); MechSChargeCounter(a) = 0; \
00510                 if (MechCarrying(a) > 0) {\
00511                         mech_dropoff(GOD, a, ""); \
00512                 }; \
00513         } while (0)
00514 
00515 #define Destroy(a) \
00516     do { \
00517         if (Uncon(a)) { \
00518             MechStatus(a) &= ~(BLINDED|UNCONSCIOUS); \
00519             mech_notify(a, MECHALL, "The mech was destroyed while pilot was unconscious!"); \
00520         } \
00521         Shutdown(a); \
00522         MechStatus(a) |= DESTROYED; \
00523         MechCritStatus(a) &= ~MECH_STUNNED; \
00524         StopBSuitSwarmers(FindObjectsData(a->mapindex),a,1); \
00525         muxevent_remove_data((void *) a); \
00526         if ((MechType(a) == CLASS_MECH && Jumping(a)) || \
00527                 (MechType(a) != CLASS_MECH && MechZ(a) > MechUpperElevation(a))) \
00528             MECHEVENT(a, EVENT_FALL, mech_fall_event, FALL_TICK, -1); \
00529     } while (0)
00530 
00531 #define DestroyAndDump(a)           \
00532     do { Destroy(a); MechVerticalSpeed(a) = 0.0; \
00533     if (MechRTerrain(a) == WATER || MechRTerrain(a) == ICE) \
00534       MechZ(a) = -MechElev(a); \
00535     else \
00536        if (MechRTerrain(a) == BRIDGE) { \
00537            if (MechZ(a) >= MechUpperElevation(a)) \
00538                MechZ(a) = MechUpperElevation(a); \
00539            else \
00540                MechZ(a) = MechLowerElevation(a); \
00541       } else \
00542           MechZ(a) = MechElev(a); \
00543       MechFZ(a) = ZSCALE * MechZ(a); } while (0)
00544 
00545 #define GetTerrain(mapn,x,y)     Coding_GetTerrain(mapn->map[y][x])
00546 #define GetRTerrain(map,x,y)      ((GetTerrain(map,x,y)==FIRE || GetTerrain(map,x,y)==SMOKE) ? map_underlying_terrain(map,x,y) : GetTerrain(map,x,y))
00547 #define GetElevation(mapn,x,y)   Coding_GetElevation(mapn->map[y][x])
00548 #define GetElev(mapn,x,y)        GetElevation(mapn,x,y)
00549 #define SetMap(mapn,x,y,t,e)     mapn->map[y][x] = Coding_GetIndex(t,e)
00550 #define SetMapB(mapn,x,y,t,e)    mapn[y][x] = Coding_GetIndex(t,e)
00551 #define SetTerrain(mapn,x,y,t)   do {SetMap(mapn,x,y,t,GetElevation(mapn,x,y));UpdateMechsTerrain(mapn,x,y,t); } while (0)
00552 #define SetTerrainBase(mapn,x,y,t) SetMap(mapn,x,y,t,GetElevation(mapn,x,y))
00553 #define SetElevation(mapn,x,y,e) SetMap(mapn,x,y,GetTerrain(mapn,x,y),e)
00554 
00555 /* For now I don't care about allocations */
00556 #define ScenError(msg...)        send_channel("ScenErrors",msg)
00557 #define ScenStatus(msg...)       send_channel("ScenStatus",msg)
00558 #define SendAI(msg...)           send_channel("MechAI",msg)
00559 #define SendAlloc(msg)
00560 #define SendLoc(msg)
00561 #define SendCustom(msg...)          send_channel("MechCustom",msg)
00562 #define SendDB(msg...)              send_channel("DBInfo",msg)
00563 #define SendDebug(msg...)           send_channel("MechDebugInfo",msg)
00564 #define SendEcon(msg...)            send_channel("MechEconInfo",msg)
00565 #define SendError(msg...)           send_channel("MechErrors",msg)
00566 #define SendEvent(msg...)           send_channel("EventInfo",msg)
00567 #define SendSensor(msg...)          send_channel("MechSensor",msg)
00568 #define SendTrigger(msg...)         send_channel("MineTriggers",msg)
00569 #define SendXP(msg...)              send_channel("MechXP",msg)
00570 #define SendDSInfo(msg...)          send_channel("DSInfo",msg)
00571 
00572 /*
00573  * Exile Added Channel Message Emits
00574  */
00575 #define SendAttackEmits(msg...)     send_channel("MechAttackEmits",msg)
00576 #define SendAttacks(msg...)         send_channel("MechAttacks",msg)
00577 #define SendAttackXP(msg...)        send_channel("MechAttackXP",msg)
00578 #define SendBTHDebug(msg...)        send_channel("MechBTHDebug",msg)
00579 #define SendFreqs(msg...)           send_channel("MechFreqs",msg)
00580 #define SendPilotXP(msg...)         send_channel("MechPilotXP",msg)
00581 #define SendTechXP(msg...)          send_channel("MechTechXP",msg)
00582 
00583 /*
00584  * This is the prototype for functions
00585  */
00586 
00587 #ifdef TEMPLATE_VERBOSE_ERRORS
00588 
00589 #define TEMPLATE_ERR(a,b...) \
00590 if (a) { \
00591 notify(player, tprintf(b)); \
00592 if (fp) fclose(fp); return -1; }
00593 
00594 #define TEMPLATE_GERR(a,b...) \
00595 if (a) { \
00596 char foobarbuf[512]; \
00597 sprintf(foobarbuf, b); \
00598 SendError(foobarbuf); \
00599 if (fp) fclose(fp); return -1; }
00600 #else
00601 
00602 #define TEMPLATE_ERR(a,b...) \
00603 if (a) { \
00604 if (fp) fclose(fp); return -1; }
00605 #define TEMPLATE_GERR TEMPLATE_ERR
00606 
00607 #endif
00608 
00609 #define HotLoading(weapindx,mode) \
00610 ((mode & HOTLOAD_MODE) && (MechWeapons[weapindx].special & IDF))
00611 
00612 #define MirrorPosition(from,to,heightMod) \
00613 do {     MechFX(to) = MechFX(from); \
00614           MechFY(to) = MechFY(from); \
00615           MechFZ(to) = MechFZ(from) + (heightMod * ZSCALE); \
00616           MechX(to) = MechX(from); \
00617           MechY(to) = MechY(from); \
00618           MechZ(to) = MechZ(from) + heightMod; \
00619           MechLastX(to) = MechLastX(from); \
00620           MechLastY(to) = MechLastY(from); \
00621           MechTerrain(to) = MechTerrain(from); \
00622           MechElev(to) = MechElev(from) + heightMod; MarkForLOSUpdate(to); MechFloods(to); } while (0)
00623 
00624 #define ValidCoordA(mech_map,newx,newy,msg) \
00625 DOCHECK(newx < 0 || newx >= mech_map->map_width || \
00626         newy < 0 || newy >= mech_map->map_height, \
00627         msg)
00628 #define ValidCoord(mech_map,newx,newy) \
00629         ValidCoordA(mech_map,newx, newy, "Illegal coordinates!")
00630 #define FlMechRange(map,m1,m2) \
00631         FaMechRange(m1,m2)
00632 
00633 #define Readnum(tovar,fromvar) \
00634         (!(tovar = atoi(fromvar)) && strcmp(fromvar, "0"))
00635 
00636 #define SetBit(val,bit)   (val |= bit)
00637 #define UnSetBit(val,bit) (val &= ~(bit))
00638 #define EvalBit(val,bit,state) \
00639         do {if (state) SetBit(val,bit); else UnSetBit(val,bit);} while (0)
00640 #define ToggleBit(val,bit) \
00641 do { if (!(val & bit)) SetBit(val,bit);else UnSetBit(val,bit); } while (0)
00642 #define Sees360(mech) ((MechMove(mech)==MOVE_NONE) || (MechType(mech) == CLASS_BSUIT))
00643 #define FindWeapons(m,i,wa,wda,cr) FindWeapons_Advanced(m,i,wa,wda,cr,1)
00644 
00645 #define ContinueFlying(mech) \
00646 if (FlyingT(mech)) { \
00647   MechStatus(mech) &= ~LANDED; \
00648   MechZ(mech) += 1; \
00649   MechFZ(mech) = ZSCALE * MechZ(mech); \
00650   StopMoving(mech); }
00651 
00652 #define Overwater(mech) \
00653 (MechMove(mech) == MOVE_HOVER || MechType(mech) == CLASS_MW || \
00654  MechMove(mech) == MOVE_FOIL || MechMove(mech) == MOVE_HULL)
00655 
00656 #define MoveMod(mech) \
00657 (MechType(mech) == CLASS_MW ? 3 : \
00658  (MechIsBiped(mech) || MechIsQuad(mech)) ? 2 : 1)
00659 
00660 #define IsWater(t)    ((t) == ICE  || (t) == WATER || (t) == BRIDGE)
00661 #define InWater(mech) (IsWater(MechRTerrain((mech))) && MechZ(mech)<0)
00662 #define OnWater(mech) (IsWater(MechRTerrain((mech))) && MechZ(mech)<=0)
00663 
00664 #define IsC3(mech) ((MechSpecials(mech) & (C3_MASTER_TECH|C3_SLAVE_TECH)) && !C3Destroyed(mech))
00665 #define IsC3i(mech) ((MechSpecials2(mech) & C3I_TECH) && !C3iDestroyed(mech))
00666 #define IsAMS(weapindx) (MechWeapons[weapindx].special & AMS)
00667 
00668 /* Macro for figuring out the truly ugly stuff - whether ammo
00669    crit is in fact 1 or 2 'half-tons' of ammo */
00670 #define AmmoMod(mech,loc,pos) \
00671   ((!IsAmmo(GetPartType(mech,loc,pos)) || \
00672     GetPartFireMode(mech,loc,pos) & HALFTON_MODE || \
00673                 GetPartAmmoMode(mech,loc,pos) & AC_AP_MODE || \
00674                 GetPartAmmoMode(mech,loc,pos) & AC_PRECISION_MODE) ? 1 : ( GetPartAmmoMode(mech,loc,pos) & AC_CASELESS_MODE ? .5 : 2 ) )
00675 
00676 #define JumpSpeed(mech,map) \
00677   ((InGravity(mech) && map) ? (MechJumpSpeed(mech) * 100 / ((MAX(50, MapGravity(map))))) : MechJumpSpeed(mech))
00678 #define JumpSpeedMP(mech,map) \
00679   ((int) (JumpSpeed(mech,map) * MP_PER_KPH))
00680 
00681 #define NotInWater(mech) (!(OnWater(mech)))
00682 #define WaterBeast(mech) (MechMove(mech)==MOVE_HULL || MechMove(mech)==MOVE_FOIL)
00683 
00684 #define IsCrap(val) \
00685   (((val) == Special(ENDO_STEEL)) || ((val) == Special(FERRO_FIBROUS)) || \
00686    ((val) == Special(TRIPLE_STRENGTH_MYOMER)) || ((val) == Special(STEALTH_ARMOR)) || \
00687          ((val) == Special(HVY_FERRO_FIBROUS)) || ((val) == Special(LT_FERRO_FIBROUS)))
00688 
00689 #define Spinning(mech)      (MechCritStatus(mech) & SPINNING)
00690 #define StopSpinning(mech)  (MechCritStatus(mech) &= ~SPINNING)
00691 #define StartSpinning(mech) (MechCritStatus(mech) |= SPINNING)
00692 
00693 #define MechLit(mech)           (MechCritStatus(mech) & SLITE_LIT)
00694 #define MechLites(mech)         (MechStatus2(mech) & SLITE_ON)
00695 #define IsLit(mech)             (MechLit(mech) || MechLites(mech))
00696 
00697 #define OkayCritSect(sect,num,ok) OkayCritSect2(mech,sect,num,ok)
00698 #define OkayCritSectS(sect,num,ok) OkayCritSect(sect,num,I2Special(ok))
00699 #define OkayCritSect2(mech,sect,num,ok) \
00700   (GetPartType(mech,sect,num)==(ok) && !PartIsNonfunctional(mech,sect,num))
00701 #define OkayCritSectS2(mech,sect,num,ok) OkayCritSect2(mech,sect,num,I2Special(ok))
00702 #define MAPMOVEMOD(map) ((map)->movemod > 0 ? (float) (map)->movemod / 100.0 : 1.0)
00703 
00704 #define RCache_Remove(n)
00705 #define RCache_Flush()
00706 
00707 /* Ancient remnant ; of pre-06061998 rangecache-code */
00708 #define FaMechRange(mech,target) \
00709     FindRange(MechFX(mech), MechFY(mech), MechFZ(mech), \
00710               MechFX(target), MechFY(target), MechFZ(target))
00711 
00712 #define DSBearMod(ds) \
00713   ((MechFacing(ds) +30) / 60) % 6
00714 
00715 /* ECM related macros */
00716 #define ECMActive(mech)                         (ECMEnabled(mech) && !ECMCountered(mech))
00717 #define ECCMActive(mech)                        ECCMEnabled(mech)
00718 
00719 #define ECMEnabled(mech)                        (MechStatus2(mech) & ECM_ENABLED)
00720 #define ECCMEnabled(mech)                       (MechStatus2(mech) & ECCM_ENABLED)
00721 
00722 #define EnableECM(mech)                         (MechStatus2(mech) |= ECM_ENABLED)
00723 #define EnableECCM(mech)                        (MechStatus2(mech) |= ECCM_ENABLED)
00724 
00725 #define DisableECM(mech)                        (MechStatus2(mech) &= ~ECM_ENABLED)
00726 #define DisableECCM(mech)                       (MechStatus2(mech) &= ~ECCM_ENABLED)
00727 
00728 #define PerECMActive(mech)              (PerECMEnabled(mech) && !ECMCountered(mech))
00729 #define PerECCMActive(mech)             PerECCMEnabled(mech)
00730 
00731 #define PerECMEnabled(mech)             (MechStatus2(mech) & PER_ECM_ENABLED)
00732 #define PerECCMEnabled(mech)    (MechStatus2(mech) & PER_ECCM_ENABLED)
00733 
00734 #define EnablePerECM(mech)              (MechStatus2(mech) |= PER_ECM_ENABLED)
00735 #define EnablePerECCM(mech)     (MechStatus2(mech) |= PER_ECCM_ENABLED)
00736 
00737 #define DisablePerECM(mech)     (MechStatus2(mech) &= ~PER_ECM_ENABLED)
00738 #define DisablePerECCM(mech)    (MechStatus2(mech) &= ~PER_ECCM_ENABLED)
00739 
00740 #define AnyECMDisturbed(mech)           (ECMDisturbed(mech) || AngelECMDisturbed(mech))
00741 #define AnyECMProtected(mech)           (ECMProtected(mech) || AngelECMProtected(mech))
00742 #define AnyECMActive(mech)              (ECMActive(mech) || AngelECMActive(mech))
00743 #define AnyECCMActive(mech)             (ECCMActive(mech) || AngelECCMActive(mech))
00744 
00745 #define ECMDisturbed(mech)              (MechStatus2(mech) & ECM_DISTURBANCE)
00746 #define ECMProtected(mech)              ((MechStatus2(mech) & ECM_PROTECTED) || ECMActive(mech) || PerECMActive(mech))
00747 
00748 #define ECMCountered(mech)              (MechStatus2(mech) & ECM_COUNTERED)
00749 #define SetECMCountered(mech)           (MechStatus2(mech) |= ECM_COUNTERED)
00750 #define UnSetECMCountered(mech) (MechStatus2(mech) &= ~ECM_COUNTERED)
00751 
00752 #define SetECMDisturbed(mech)           (MechStatus2(mech) |= ECM_DISTURBANCE)
00753 #define UnSetECMDisturbed(mech) (MechStatus2(mech) &= ~ECM_DISTURBANCE)
00754 
00755 #define SetECMProtected(mech)           (MechStatus2(mech) |= ECM_PROTECTED)
00756 #define UnSetECMProtected(mech) (MechStatus2(mech) &= ~ECM_PROTECTED)
00757 
00758 /* Macro to check for ALL ECM types */
00759 #define HasWorkingECMSuite(mech)    (((MechSpecials(mech) & ECM_TECH) && \
00760                                     !(MechStatus2(mech) & ECM_DESTROYED)) || \
00761                                     ((MechSpecials2(mech) & ANGEL_ECM_TECH) && \
00762                                     !(MechStatus2(mech) & ANGEL_ECM_DESTROYED)) || \
00763                                     (MechInfantrySpecials(mech) & FC_INFILTRATORII_STEALTH_TECH))
00764 
00765 /* Angel ECM macros */
00766 
00767 #define AngelECMActive(mech)            (AngelECMEnabled(mech) && !ECMCountered(mech))
00768 #define AngelECCMActive(mech)           AngelECCMEnabled(mech)
00769 
00770 #define AngelECMEnabled(mech)           (MechStatus2(mech) & ANGEL_ECM_ENABLED)
00771 #define AngelECCMEnabled(mech)  (MechStatus2(mech) & ANGEL_ECCM_ENABLED)
00772 
00773 #define EnableAngelECM(mech)            (MechStatus2(mech) |= ANGEL_ECM_ENABLED)
00774 #define EnableAngelECCM(mech)   (MechStatus2(mech) |= ANGEL_ECCM_ENABLED)
00775 
00776 #define DisableAngelECM(mech)   (MechStatus2(mech) &= ~ANGEL_ECM_ENABLED)
00777 #define DisableAngelECCM(mech)  (MechStatus2(mech) &= ~ANGEL_ECCM_ENABLED)
00778 
00779 #define AngelECMProtected(mech) ((MechStatus2(mech) & ANGEL_ECM_PROTECTED) || AngelECMActive(mech))
00780 #define AngelECMDisturbed(mech) (MechStatus2(mech) & ANGEL_ECM_DISTURBED)
00781 
00782 #define SetAngelECMDisturbed(mech)       (MechStatus2(mech) |= ANGEL_ECM_DISTURBED)
00783 #define UnSetAngelECMDisturbed(mech) (MechStatus2(mech) &= ~ANGEL_ECM_DISTURBED)
00784 
00785 #define SetAngelECMProtected(mech)       (MechStatus2(mech) |= ANGEL_ECM_PROTECTED)
00786 #define UnSetAngelECMProtected(mech) (MechStatus2(mech) &= ~ANGEL_ECM_PROTECTED)
00787 
00788 #define HasWorkingAngelECMSuite(mech)   ((MechSpecials2(mech) & ANGEL_ECM_TECH) && \
00789                                         !(MechStatus2(mech) & ANGEL_ECM_DESTROYED))
00790 
00791 /* Stealth system macros */
00792 #define StealthArmorActive(mech)                (MechStatus2(mech) & STH_ARMOR_ON)
00793 #define EnableStealthArmor(mech)                (MechStatus2(mech) |= STH_ARMOR_ON)
00794 #define DisableStealthArmor(mech)               (MechStatus2(mech) &= ~STH_ARMOR_ON)
00795 #define StealthArmorChanging(mech)      muxevent_count_type_data(EVENT_STEALTH_ARMOR, (void *) mech)
00796 
00797 #define DestroyNullSigSys(mech) (MechCritStatus(mech) |= NSS_DESTROYED)
00798 #define NullSigSysDest(mech)      (MechCritStatus(mech) & NSS_DESTROYED)
00799 #define NullSigSysActive(mech)  (MechStatus2(mech) & NULLSIGSYS_ON)
00800 #define EnableNullSigSys(mech)  (MechStatus2(mech) |= NULLSIGSYS_ON)
00801 #define DisableNullSigSys(mech) (MechStatus2(mech) &= ~NULLSIGSYS_ON)
00802 #define NullSigSysChanging(mech) muxevent_count_type_data(EVENT_NSS, (void *) mech)
00803 
00804 /* C3 macros */
00805 
00806 #define HasC3(mech)                                                     (HasC3m(mech) || HasC3s(mech))
00807 #define HasC3m(mech)                                            ((MechSpecials(mech) & C3_MASTER_TECH))
00808 #define HasC3s(mech)                                            ((MechSpecials(mech) & C3_SLAVE_TECH))
00809 #define C3Destroyed(mech)                               (MechCritStatus(mech) & C3_DESTROYED)
00810 #define MechC3Network(a)                                (a)->sd.C3Network
00811 #define MechC3NetworkElem(a,b)  (a)->sd.C3Network[b]
00812 #define MechC3NetworkSize(a)            (a)->sd.wC3NetworkSize
00813 #define MechTotalC3Masters(a)           (a)->sd.wTotalC3Masters
00814 #define MechWorkingC3Masters(a) (a)->sd.wWorkingC3Masters
00815 
00816 /* Improved C3 macros */
00817 
00818 #define HasC3i(mech)                                            ((MechSpecials2(mech) & C3I_TECH))
00819 #define C3iDestroyed(mech)                      (MechCritStatus(mech) & C3I_DESTROYED)
00820 #define MechC3iNetwork(a)                               (a)->sd.C3iNetwork
00821 #define MechC3iNetworkElem(a,b) (a)->sd.C3iNetwork[b]
00822 #define MechC3iNetworkSize(a)           (a)->sd.wC3iNetworkSize
00823 
00824 /* TAG macros */
00825 
00826 #define HasTAG(mech)                                            ( (MechSpecials2(mech) & TAG_TECH) || HasC3m(mech) )
00827 #define TAGTarget(mech)                                 (mech)->sd.tagTarget
00828 #define TaggedBy(mech)                      (mech)->sd.taggedBy
00829 #define TagRecycling(a)          muxevent_count_type_data(EVENT_TAG_RECYCLE,(void *) a)
00830 
00831 /* Club stuff */
00832 #define CarryingClub(mech)                      ( (MechSections(mech)[RARM].specials & CARRYING_CLUB) || (MechSections(mech)[LARM].specials & CARRYING_CLUB))
00833 #define DropClub(mech)                                  do { if(CarryingClub(mech)) { MechSections(mech)[RARM].specials &= ~CARRYING_CLUB; MechSections(mech)[LARM].specials &= ~CARRYING_CLUB; mech_notify(mech, MECHALL, "Your club falls to the ground and shatters."); MechLOSBroadcast(mech, "'s club falls to the ground and shatters."); } } while (0)
00834 
00835 /* New stagger stuff */
00836 #define Staggering(mech)        ( StaggerLevel(mech) > 0 )
00837 #define CheckingStaggerDamage(mech) muxevent_count_type_data(EVENT_CHECK_STAGGER,(void *) mech)
00838 #define StartStaggerCheck(mech)   do { MECHEVENT(mech, EVENT_CHECK_STAGGER, check_stagger_event, 5, 0); SendDebug(tprintf("Starting stagger check for %d.", mech->mynum)); } while (0)
00839 #define StopStaggerCheck(mech)    do { muxevent_remove_type_data(EVENT_CHECK_STAGGER, (void *) mech); (mech)->rd.staggerDamage=0; (mech)->rd.lastStaggerNotify=0; SendDebug(tprintf("Stopping stagger check for %d.", mech->mynum)); } while (0)
00840 #define StaggerDamage(mech)     ( (mech)->rd.staggerDamage )
00841 #define LastStaggerNotify(mech) ( (mech)->rd.lastStaggerNotify )
00842 #define StaggerLevel(mech)      ( (mech)->rd.staggerDamage / 20 )
00843 
00844 #define MechIsObservator(mech)          (MechCritStatus(mech) & OBSERVATORIC)
00845 
00846 /* Macros related to map.h stuff */
00847 #define MechLOSFlag_WoodCount(flag)     \
00848                         (((flag) / MECHLOSFLAG_WOOD) % MECHLOSMAX_WOOD)
00849 #define MechLOSFlag_WaterCount(flag)    \
00850                         (((flag) / MECHLOSFLAG_WATER) % MECHLOSMAX_WATER)
00851 
00852 #define MechToMech_LOSFlag(map, from, to)       \
00853                         ((map)->LOSinfo[from->mapnumber][to->mapnumber])
00854 
00855 #define MoveModeChange(a)       muxevent_count_type_data(EVENT_MOVEMODE,(void *) a)
00856 #define MoveModeLock(a)         (MechStatus2(a) & MOVE_MODES_LOCK || (MoveModeChange(a) && !(MechStatus2(a) & DODGING)))
00857 #define MoveModeData(a)         muxevent_count_type_data_firstev(EVENT_MOVEMODE, (void *) a)
00858 #define StopMoveMode(a)         muxevent_remove_type_data(EVENT_MOVEMODE, (void *) a)
00859 #define Sprinting(a)            (MechStatus2(a) & SPRINTING)
00860 #define Evading(a)              (MechStatus2(a) & EVADING)
00861 #define Dodging(a)              (MechStatus2(a) & DODGING)
00862 #define SideSlipping(a)         muxevent_count_type_data(EVENT_SIDESLIP, (void *) a)
00863 #define StopSideslip(a)         muxevent_remove_type_data(EVENT_SIDESLIP, (void *) a)
00864                                                                                            
00865 #endif                          /* BTMACROS_H */

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