00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "mech.h"
00018 #include "mech.sensor.h"
00019 #include "p.map.obj.h"
00020 #include "p.mech.update.h"
00021 #include "p.mech.utils.h"
00022 #include "p.template.h"
00023
00024
00025 SEEFUNC(vislight_see, r > (c * ((!l && t &&
00026 IsLit(t)) ? 3 : 1)) ? 0 : (100 -
00027 (r / 3)) / ((t
00028 &&
00029 (MechType
00030 (t)
00031 ==
00032 CLASS_BSUIT
00033 ||
00034 MechType
00035 (t)
00036 ==
00037 CLASS_MW))
00038 ? 3 :
00039 1));
00040
00041
00042
00043 SEEFUNC(liteamp_see, ((!l && r > (2 * c)) ? 0 : (l &&
00044 r > c) ? 0 : (70 - r)) / ((t
00045 &&
00046 (MechType
00047 (t)
00048 ==
00049 CLASS_BSUIT
00050 ||
00051 MechType
00052 (t)
00053 ==
00054 CLASS_MW))
00055 ? 3
00056 :
00057 1));
00058
00059
00060 SEEFUNC(infrared_see, (80 - r));
00061 SEEFUNC(electrom_see, MAX(r < 24 ? 2 : 0, (60 - (r * 2))) / 2);
00062 SEEFUNC(seismic_see, 50 - (r * 4));
00063
00064 SEEFUNC(radar_see, BOUNDED(10, (180 - r), 90));
00065 SEEFUNC(bap_see, 101);
00066 SEEFUNC(blood_see, 101);
00067
00068
00069
00070
00071 extern float ActualElevation(MAP * map, int x, int y, MECH * mech);
00072
00073
00074 CSEEFUNC(vislight_csee, !(map->sensorflags & (1 << SENSOR_VIS)) &&
00075 !(f & (MECHLOSFLAG_BLOCK | MECHLOSFLAG_FIRE | MECHLOSFLAG_SMOKE)) &&
00076 MechLOSFlag_WoodCount(f) < 3 && (!t || MechZ(t) >= 0 ||
00077 ActualElevation(getMap(t->mapindex),
00078 MechX(t), MechY(t),
00079 t) >= 0.0
00080 || MechLOSFlag_WaterCount(f) < 6));
00081
00082
00083 CSEEFUNC(liteamp_csee, !(map->sensorflags & (1 << SENSOR_LA)) &&
00084 !(f & (MECHLOSFLAG_BLOCK | MECHLOSFLAG_FIRE | MECHLOSFLAG_SMOKE)) &&
00085 (!t || !IsLit(t)) && MechLOSFlag_WoodCount(f) < 2
00086 && !(MechLOSFlag_WaterCount(f)));
00087
00088
00089 CSEEFUNC(infrared_csee, !(map->sensorflags & (1 << SENSOR_IR)) &&
00090 !(f & (MECHLOSFLAG_BLOCK | MECHLOSFLAG_FIRE)) &&
00091 MechLOSFlag_WoodCount(f) < 6 && (!t || (MechType(t) != CLASS_BSUIT &&
00092 MechType(t) != CLASS_MW)));
00093
00094
00095
00096 CSEEFUNC(electrom_csee, !(map->sensorflags & (1 << SENSOR_EM)) &&
00097 !(f & (MECHLOSFLAG_BLOCK | MECHLOSFLAG_MNTN)) &&
00098 MechLOSFlag_WoodCount(f) < 8 && !AnyECMDisturbed(m) && (!t ||
00099 (MechType(t)
00100 !=
00101 CLASS_MW)));
00102
00103
00104
00105
00106 CSEEFUNC(seismic_csee,
00107 !(map->sensorflags & (1 << SENSOR_SE)) &&
00108 t && (!Jumping(m)) &&
00109 (mudconf.btech_seismic_see_stopped ? 1 : (abs(MechSpeed(t)) > MP1))
00110 &&
00111 (((MechMove(m) != MOVE_VTOL)
00112 || ((MechMove(m) == MOVE_VTOL) && Landed(m)))
00113 && ((MechMove(m) != MOVE_FLY)
00114 || ((MechMove(m) == MOVE_FLY) && Landed(m))) && Started(t)
00115 && !Jumping(t) && (MechType(t) != CLASS_BSUIT)
00116 && (MechType(t) != CLASS_MW) && (MechMove(t) != MOVE_HOVER)
00117 && ((MechMove(t) != MOVE_VTOL)
00118 || ((MechMove(t) == MOVE_VTOL) && Landed(t)))
00119 && ((MechMove(t) != MOVE_FLY)
00120 || ((MechMove(t) == MOVE_FLY) && Landed(t))))
00121 && (MechMove(t) != MOVE_NONE));
00122
00123
00124 CSEEFUNC(radar_csee,
00125 !(map->sensorflags & (1 << SENSOR_RA)) &&
00126 t &&
00127 MechZ(t) > 2 &&
00128 !(f & MECHLOSFLAG_BLOCK) &&
00129 (MechZ(t) >= 10 || (r < (MechZ(t) * MechZ(t)))) &&
00130 MechsElevation(t) > 1);
00131
00132
00133 CSEEFUNC(bap_csee,
00134 !(map->sensorflags & (1 << SENSOR_BAP)) &&
00135 !AnyECMDisturbed(m) &&
00136 t &&
00137 !AngelECMProtected(t) &&
00138 !StealthArmorActive(t) && !NullSigSysActive(t));
00139
00140
00141 CSEEFUNC(blood_csee,
00142 !(map->sensorflags & (1 << SENSOR_BHAP)) &&
00143 !AnyECMDisturbed(m) && t && !AngelECMProtected(t));
00144
00145
00146
00147 #ifdef BT_SCALED_INFRARED
00148 #define HEAT_MODIFIER(a) ((a) <= 0 ? 2 : (a) > 50 ? -2 : (a) > 35 ? -1 : (a) > 20 ? 0 : 1)
00149 #else
00150
00151
00152
00153
00154
00155 #define HEAT_MODIFIER(a) ((a) <= 7 ? 2 : (a) <= 10 ? 1 : (a) <= 15 ? 0 : (a) <= 22 ? -1 : -2)
00156 #endif
00157
00158 #define WEIGHT_MODIFIER(a) (a > 65 ? -1 : a > 35 ? 0 : 1)
00159
00160
00161 #define MOVE_MODIFIER(a) (abs(a) >= 10.75 ? 1 : 0)
00162
00163 #define nwood_count(mech,a) (MechLOSFlag_WoodCount(a) + \
00164 ((MechElevation(mech) + 2) < MechZ(mech) ? 0 : \
00165 MechRTerrain(mech) == LIGHT_FOREST ? 1 : \
00166 MechRTerrain(mech) == HEAVY_FOREST ? 2 : 0))
00167
00168
00169
00170 TOHITFUNC(vislight_tohit, ((!t ||
00171 !IsLit(t)) ? (2 - l) : 0) + nwood_count(t,
00172 f) +
00173 ((f & MECHLOSFLAG_PARTIAL) ? 3 + (IsHulldown(t) ? 2 : 0) : 0));
00174
00175
00176 TOHITFUNC(liteamp_tohit, ((2 - l) / 2) + ((nwood_count(t,
00177 f) * 3) / 2) +
00178 ((f & MECHLOSFLAG_PARTIAL) ? 3 + (IsHulldown(t) ? 2 : 0) : 0));
00179
00180
00181 #ifdef BT_SCALED_INFRARED
00182 TOHITFUNC(infrared_tohit, ((nwood_count(t, f) * 4) / 3) +
00183 ((f & MECHLOSFLAG_PARTIAL) ? 3 : 0) +
00184 HEAT_MODIFIER((2 * (MechPlusHeat(t) - MechMinusHeat(t))) +
00185 MIN(MechPlusHeat(t), MechMinusHeat(t))));
00186 #else
00187 TOHITFUNC(infrared_tohit, ((nwood_count(t,
00188 f) * 4) / 3) +
00189 ((f & MECHLOSFLAG_PARTIAL) ? 3 + (IsHulldown(t) ? 2 : 0) : 0) +
00190 HEAT_MODIFIER(MechHeat(t) + 7));
00191 #endif
00192
00193
00194 TOHITFUNC(electrom_tohit, ((nwood_count(t,
00195 f) * 2) / 3) +
00196 ((f & MECHLOSFLAG_PARTIAL) ? 3 + (IsHulldown(t) ? 2 : 0) : 0) +
00197 WEIGHT_MODIFIER(MechTons(t)) + MOVE_MODIFIER(MechSpeed(t)) +
00198 (MechStatus(t) & FIRED ? -1 : 0) + MNumber(m, 0, 1));
00199
00200
00201 TOHITFUNC(seismic_tohit,
00202 2 + ((f & MECHLOSFLAG_PARTIAL) ? 3 + (IsHulldown(t) ? 2 : 0) : 0) +
00203 WEIGHT_MODIFIER(MechRealTons(t)) - MOVE_MODIFIER(MechSpeed(t)) +
00204 MNumber(m, 0, 1));
00205
00206
00207 TOHITFUNC(bap_tohit, MNumber(m, 0, 2));
00208
00209
00210 TOHITFUNC(blood_tohit, MNumber(m, 0, 2));
00211
00212
00213 TOHITFUNC(radar_tohit, ((MechZ(t) >= 10 ||
00214 FlyingT(t)) ? -3 : 0) +
00215 ((f & MECHLOSFLAG_PARTIAL) ? 2 + (IsHulldown(t) ? 2 : 0) : 0) +
00216 nwood_count(t, f));