#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/file.h>
#include "mech.h"
#include "map.h"
#include "mech.events.h"
#include "p.mech.restrict.h"
#include "p.mech.consistency.h"
#include "p.mech.utils.h"
#include "p.mech.startup.h"
#include "p.ds.bay.h"
#include "p.btechstats.h"
#include "p.mechrep.h"
#include "p.crit.h"
#include "p.mech.combat.h"
#include "p.mech.damage.h"
#include "p.template.h"
#include "p.bsuit.h"
#include "p.mech.los.h"
#include "p.aero.bomb.h"
#include "autopilot.h"
Include dependency graph for mech.utils.c:
Go to the source code of this file.
Defines | |
#define | DEG2RAD(d) ((float)(d) * (3.14159265f / 180.f)) |
#define | RAD2DEG(d) ((float)(d) * (180.f / 3.14159265f)) |
#define | MECHSKILL_PILOTING 0 |
#define | MECHSKILL_GUNNERY 1 |
#define | MECHSKILL_SPOTTING 2 |
#define | MECHSKILL_ARTILLERY 3 |
#define | NUM_MECHSKILLS 4 |
#define | GENERIC_FIND_MECHSKILL(num, n) |
#define | ROOT3 558.58638544096289 |
#define | ALPHA 93.097730906827152 |
#define | ANGLE_ALPHA 0.28867513459481287 |
#define | FULL_Y (1 * SCALEMAP) |
#define | HALF_Y (0.5 * FULL_Y) |
#define | NAV_ROW_HEIGHT (FULL_Y / 9.0) |
#define | NAV_COLUMN_WIDTH (4 * ALPHA / 21.0) |
#define | NAV_Y_OFFSET 2 |
#define | NAV_X_OFFSET 4 |
#define | NAV_MAX_HEIGHT 2+9+2 |
#define | NAV_MAX_WIDTH 4+21+2 |
#define | UGLYTEST |
#define | CV(fun) fun(mech) = fun(&opp) |
#define | NUM_NEIGHBORS 6 |
Functions | |
const char * | mechtypename (MECH *foo) |
int | MNumber (MECH *mech, int low, int high) |
char * | MechIDS (MECH *mech, int islower) |
char * | MyToUpper (char *string) |
int | CritsInLoc (MECH *mech, int index) |
int | SectHasBusyWeap (MECH *mech, int sect) |
MAP * | ValidMap (dbref player, dbref map) |
dbref | FindMechOnMap (MAP *map, char *mechid) |
dbref | FindTargetDBREFFromMapNumber (MECH *mech, char *mapnum) |
void | FindComponents (float magnitude, int degrees, float *x, float *y) |
static int | Leave_Hangar (MAP *map, MECH *mech) |
void | CheckEdgeOfMap (MECH *mech) |
int | FindZBearing (float x0, float y0, float z0, float x1, float y1, float z1) |
int | FindBearing (float x0, float y0, float x1, float y1) |
int | InWeaponArc (MECH *mech, float x, float y) |
char * | FindGunnerySkillName (MECH *mech, int weapindx) |
char * | FindPilotingSkillName (MECH *mech) |
int | FindPilotPiloting (MECH *mech) |
int | FindSPilotPiloting (MECH *mech) |
int | FindPilotSpotting (MECH *mech) |
int | FindPilotArtyGun (MECH *mech) |
int | FindPilotGunnery (MECH *mech, int weapindx) |
char * | FindTechSkillName (MECH *mech) |
int | FindTechSkill (dbref player, MECH *mech) |
int | MadePilotSkillRoll (MECH *mech, int mods) |
int | MechPilotSkillRoll_BTH (MECH *mech, int mods) |
int | MadePilotSkillRoll_NoXP (MECH *mech, int mods, int succeedWhenFallen) |
int | MadePilotSkillRoll_Advanced (MECH *mech, int mods, int succeedWhenFallen) |
void | FindXY (float x0, float y0, int bearing, float range, float *x1, float *y1) |
float | FindRange (float x0, float y0, float z0, float x1, float y1, float z1) |
float | FindXYRange (float x0, float y0, float x1, float y1) |
float | FindHexRange (float x0, float y0, float x1, float y1) |
void | RealCoordToMapCoord (short *hex_x, short *hex_y, float cart_x, float cart_y) |
void | MapCoordToRealCoord (int hex_x, int hex_y, float *cart_x, float *cart_y) |
void | navigate_sketch_mechs (MECH *mech, MAP *map, int x, int y, char buff[NAVIGATE_LINES][MBUF_SIZE]) |
int | FindTargetXY (MECH *mech, float *x, float *y, float *z) |
int | FindWeapons_Advanced (MECH *mech, int index, unsigned char *weaparray, unsigned char *weapdataarray, int *critical, int whine) |
int | FindAmmunition (MECH *mech, unsigned char *weaparray, unsigned short *ammoarray, unsigned short *ammomaxarray, unsigned int *modearray, int returnall) |
int | FindLegHeatSinks (MECH *mech) |
int | FindWeaponNumberOnMech_Advanced (MECH *mech, int number, int *section, int *crit, int sight) |
int | FindWeaponNumberOnMech (MECH *mech, int number, int *section, int *crit) |
int | FindWeaponFromIndex (MECH *mech, int weapindx, int *section, int *crit) |
int | FindWeaponIndex (MECH *mech, int number) |
int | FullAmmo (MECH *mech, int loc, int pos) |
int | findAmmoInSection (MECH *mech, int section, int type, int nogof, int gof) |
int | FindAmmoForWeapon_sub (MECH *mech, int weapSection, int weapCritical, int weapindx, int start, int *section, int *critical, int nogof, int gof) |
int | FindAmmoForWeapon (MECH *mech, int weapindx, int start, int *section, int *critical) |
int | CountAmmoForWeapon (MECH *mech, int weapindx) |
int | FindArtemisForWeapon (MECH *mech, int section, int critical) |
int | FindDestructiveAmmo (MECH *mech, int *section, int *critical) |
int | FindInfernoAmmo (MECH *mech, int *section, int *critical) |
int | FindRoundsForWeapon (MECH *mech, int weapindx) |
char ** | ProperSectionStringFromType (int type, int mtype) |
void | ArmorStringFromIndex (int index, char *buffer, char type, char mtype) |
int | IsInWeaponArc (MECH *mech, float x, float y, int section, int critical) |
int | GetWeaponCrits (MECH *mech, int weapindx) |
int | listmatch (char **foo, char *mat) |
void | do_sub_magic (MECH *mech, int loud) |
void | do_magic (MECH *mech) |
void | mech_RepairPart (MECH *mech, int loc, int pos) |
int | no_locations_destroyed (MECH *mech) |
void | mech_ReAttach (MECH *mech, int loc) |
void | mech_ReplaceSuit (MECH *mech, int loc) |
void | mech_ReSeal (MECH *mech, int loc) |
void | mech_Detach (MECH *mech, int loc) |
void | mech_FillPartAmmo (MECH *mech, int loc, int pos) |
int | AcceptableDegree (int d) |
void | MarkForLOSUpdate (MECH *mech) |
void | multi_weap_sel (MECH *mech, dbref player, char *buffer, int bitbybit, int(*foo)(MECH *, dbref, int, int)) |
int | Roll () |
int | MyHexDist (int x1, int y1, int x2, int y2, int tc) |
int | CountDestroyedLegs (MECH *objMech) |
int | IsLegDestroyed (MECH *objMech, int wLoc) |
int | IsMechLegLess (MECH *objMech) |
int | FindFirstWeaponCrit (MECH *objMech, int wLoc, int wSlot, int wStartSlot, int wCritType, int wMaxCrits) |
int | checkAllSections (MECH *mech, int specialToFind) |
int | checkSectionForSpecial (MECH *mech, int specialToFind, int wSec) |
int | getRemainingInternalPercent (MECH *mech) |
int | getRemainingArmorPercent (MECH *mech) |
int | FindObj (MECH *mech, int loc, int type) |
int | FindObjWithDest (MECH *mech, int loc, int type) |
MECH * | find_mech_in_hex (MECH *mech, MAP *mech_map, int x, int y, int needlos) |
int | FindAndCheckAmmo (MECH *mech, int weapindx, int section, int critical, int *ammoLoc, int *ammoCrit, int *ammoLoc1, int *ammoCrit1, int *wGattlingShots) |
void | ChannelEmitKill (MECH *mech, MECH *attacker) |
void | visit_neighbor_hexes (MAP *map, int tx, int ty, void(*callback)(MAP *, int, int)) |
int | GetPartWeight (int part) |
int | MechFullNoRecycle (MECH *mech, int num) |
int | HeatFactor (MECH *mech) |
int | WeaponIsNonfunctional (MECH *mech, int section, int crit, int numcrits) |
Variables | |
dbref | pilot_override |
char * | mechtypenames [CLASS_LAST+1] |
int | global_silence = 0 |
char * | quad_locs [NUM_SECTIONS+1] |
char * | mech_locs [NUM_SECTIONS+1] |
char * | bsuit_locs [NUM_BSUIT_MEMBERS+1] |
char * | veh_locs [NUM_VEH_SECTIONS+1] |
char * | aero_locs [NUM_AERO_SECTIONS+1] |
char * | ds_locs [NUM_DS_SECTIONS+1] |
char * | ds_spher_locs [NUM_DS_SECTIONS+1] |
int | dirs [6][2] |
#define ALPHA 93.097730906827152 |
Definition at line 764 of file mech.utils.c.
Referenced by MapCoordToRealCoord(), navigate_sketch_mechs(), and RealCoordToMapCoord().
#define ANGLE_ALPHA 0.28867513459481287 |
#define DEG2RAD | ( | d | ) | ((float)(d) * (3.14159265f / 180.f)) |
#define FULL_Y (1 * SCALEMAP) |
Definition at line 766 of file mech.utils.c.
Referenced by MapCoordToRealCoord(), and RealCoordToMapCoord().
#define GENERIC_FIND_MECHSKILL | ( | num, | |||
n | ) |
Value:
if (Quiet(mech->mynum)) \ { str = silly_atr_get(mech->mynum, A_MECHSKILLS); \ if (*str) if (sscanf (str, "%d %d %d %d", &i[0], &i[1], &i[2], &i[3]) > num) \ return i[num] - n; }
Definition at line 523 of file mech.utils.c.
Referenced by FindPilotArtyGun(), FindPilotGunnery(), FindPilotPiloting(), and FindPilotSpotting().
#define HALF_Y (0.5 * FULL_Y) |
Definition at line 767 of file mech.utils.c.
Referenced by MapCoordToRealCoord(), navigate_sketch_mechs(), and RealCoordToMapCoord().
#define MECHSKILL_ARTILLERY 3 |
#define MECHSKILL_GUNNERY 1 |
#define MECHSKILL_PILOTING 0 |
#define MECHSKILL_SPOTTING 2 |
#define NAV_COLUMN_WIDTH (4 * ALPHA / 21.0) |
#define NAV_MAX_HEIGHT 2+9+2 |
#define NAV_MAX_WIDTH 4+21+2 |
#define NAV_ROW_HEIGHT (FULL_Y / 9.0) |
#define NAV_X_OFFSET 4 |
#define NAV_Y_OFFSET 2 |
#define NUM_MECHSKILLS 4 |
Definition at line 520 of file mech.utils.c.
Referenced by FindPilotArtyGun(), FindPilotGunnery(), FindPilotPiloting(), and FindPilotSpotting().
#define NUM_NEIGHBORS 6 |
Definition at line 2517 of file mech.utils.c.
#define RAD2DEG | ( | d | ) | ((float)(d) * (180.f / 3.14159265f)) |
#define ROOT3 558.58638544096289 |
#define UGLYTEST |
Value:
if (num_crits) \ { \ if (num_crits != (i = GetWeaponCrits (mech, lastweap))) \ { \ if (whine && !global_silence) \ SendError (tprintf ("Error in the numcriticals for weapon on #%d! (Should be: %d, is: %d)", mech->mynum, i, num_crits)); \ return -1; \ } \ num_crits = 0; \ }
Definition at line 958 of file mech.utils.c.
Referenced by FindWeapons_Advanced().
int AcceptableDegree | ( | int | d | ) |
Definition at line 2026 of file mech.utils.c.
Referenced by aero_UpdateSpeed(), ai_path_score(), blast_arcf(), CheckDamage(), FindAreaHitGroup(), FindBearing(), InWeaponArc(), mech_bootlegger(), mech_heading(), mech_turret(), MechFalls(), PrintShortInfo(), ShowTurretFacing(), and updateAutoturnTurret().
02027 { 02028 /* 02029 * Silly billies, integer modulo (division) is still faster than loops. 02030 * And probably slightly faster than branches, too, but let's not worry 02031 * about that. 02032 */ 02033 if (d < 0) { 02034 return (d % 360) + 360; 02035 } else if (d >= 360) { 02036 return (d % 360); 02037 } else { 02038 return d; 02039 } 02040 }
void ArmorStringFromIndex | ( | int | index, | |
char * | buffer, | |||
char | type, | |||
char | mtype | |||
) |
Definition at line 1552 of file mech.utils.c.
References CLASS_AERO, CLASS_BSUIT, CLASS_DS, CLASS_MECH, CLASS_MW, CLASS_SPHEROID_DS, CLASS_VEH_GROUND, CLASS_VEH_NAVAL, CLASS_VTOL, NUM_AERO_SECTIONS, NUM_BSUIT_MEMBERS, NUM_DS_SECTIONS, NUM_SECTIONS, NUM_VEH_SECTIONS, and ProperSectionStringFromType().
Referenced by bomb_list(), BreachLoc(), bsuit_attackleg(), cause_internaldamage(), ChargeMech(), checkGrabClubLocation(), CriticalStatus(), DamageMech(), DeathFromAbove(), DestroySection(), DisplayTarget(), DoVehicleStablizerCrit(), FireWeapon(), FireWeaponNumber(), HandleMechCrit(), handleWeaponCrit(), mech_bootlegger(), mech_dump(), mech_dump_event(), mech_grabclub(), mech_target(), mech_thrash(), mech_unjamammo_func(), mech_usebin(), mech_weaponstatus(), MechFloodsLoc(), mechrep_Rshowtech(), MissileHitTarget(), muxevent_tickmech_reattach(), muxevent_tickmech_reload(), muxevent_tickmech_removegun(), muxevent_tickmech_removepart(), muxevent_tickmech_removesection(), muxevent_tickmech_repairarmor(), muxevent_tickmech_repairenhcrit(), muxevent_tickmech_repairgun(), muxevent_tickmech_repairinternal(), muxevent_tickmech_repairpart(), muxevent_tickmech_replacegun(), muxevent_tickmech_replacesuit(), muxevent_tickmech_reseal(), PhysicalAttack(), PrintEnemyWeaponStatus(), PrintWeaponStatus(), recycle_weaponry(), remove_inarc_pods_mech(), show_narc_pods(), showWeaponDamageAndInfo(), vehicle_burn_event(), and vehicle_start_burn().
01553 { 01554 char **locs = ProperSectionStringFromType(type, mtype); 01555 int high = 0; 01556 01557 switch (type) { 01558 case CLASS_MECH: 01559 case CLASS_MW: 01560 high = NUM_SECTIONS; 01561 break; 01562 case CLASS_VEH_GROUND: 01563 case CLASS_VEH_NAVAL: 01564 high = (NUM_VEH_SECTIONS - 1); 01565 break; 01566 case CLASS_VTOL: 01567 high = NUM_VEH_SECTIONS; 01568 break; 01569 case CLASS_AERO: 01570 high = NUM_AERO_SECTIONS; 01571 break; 01572 case CLASS_SPHEROID_DS: 01573 high = NUM_DS_SECTIONS; 01574 case CLASS_DS: 01575 high = NUM_DS_SECTIONS; 01576 break; 01577 case CLASS_BSUIT: 01578 high = NUM_BSUIT_MEMBERS; 01579 break; 01580 default: 01581 strcpy(buffer, "Invalid!!"); 01582 return; 01583 } 01584 if(high > 0 && index < high && locs) { 01585 strcpy(buffer, locs[index]); 01586 return; 01587 } 01588 strcpy(buffer, "Invalid!!"); 01589 }
Definition at line 2502 of file mech.utils.c.
References A_AMECHDEST, did_it(), IsDS, MECH::mynum, SendDebug, SendDSInfo, and tprintf().
Referenced by DestroyMech(), drop_thru_ice(), HandleMechCrit(), handlemwconc(), heat_effect(), NewHexEntered(), and swim_except().
02503 { 02504 if(!attacker) 02505 attacker = mech; 02506 02507 SendDebug(tprintf("#%d has been killed by #%d", mech->mynum, 02508 attacker->mynum)); 02509 if(IsDS(mech)) 02510 SendDSInfo(tprintf("#%d has been killed by #%d", mech->mynum, 02511 attacker->mynum)); 02512 if(mech->mynum > 0 && attacker->mynum > 0) 02513 did_it(attacker->mynum, mech->mynum, 0, NULL, 0, NULL, A_AMECHDEST, 02514 (char **) NULL, 0); 02515 }
int checkAllSections | ( | MECH * | mech, | |
int | specialToFind | |||
) |
Definition at line 2247 of file mech.utils.c.
References checkSectionForSpecial(), and NUM_SECTIONS.
Referenced by checkECM(), FindNormalBTH(), getStatusChar(), getStatusString(), Mech_ShowFlags(), MissileHitIndex(), remove_inarc_pods_tank(), and show_narc_pods().
02248 { 02249 int i; 02250 02251 for(i = 0; i < NUM_SECTIONS; i++) { 02252 if(checkSectionForSpecial(mech, specialToFind, i)) 02253 return 1; 02254 } 02255 02256 return 0; 02257 }
void CheckEdgeOfMap | ( | MECH * | mech | ) |
Definition at line 246 of file mech.utils.c.
References MAP::flags, getMap(), is_aero, IsMech, Jumping, Landed, LandMech(), Leave_DS(), Leave_Hangar(), MAP::map_height, map_linked(), MAP::map_width, MapCoordToRealCoord(), MAPFLAG_MAPO, MECH::mapindex, MAP::mapobj, MaybeMove, mech_notify(), mech_shutdown(), MECHALL, MechCocoon, MechDesiredSpeed, MechFX, MechFY, MECHPILOT, MechPilot, MechSpeed, MechStartFX, MechStartFY, MechStartFZ, MechX, MechY, MAP::onmap, SendError, tprintf(), and TYPE_LEAVE.
Referenced by move_mech().
00247 { 00248 int pinned = 0; 00249 int linked; 00250 MAP *map; 00251 00252 map = getMap(mech->mapindex); 00253 00254 if(!map) { 00255 mech_notify(mech, MECHPILOT, 00256 "You are on an invalid map! Map index reset!"); 00257 mech_shutdown(MechPilot(mech), (void *) mech, ""); 00258 SendError(tprintf("CheckEdgeofMap:invalid map:Mech: %d Index: %d", 00259 mech->mynum, mech->mapindex)); 00260 mech->mapindex = -1; 00261 return; 00262 } 00263 linked = map_linked(mech->mapindex); 00264 /* Prevents you from going off the map */ 00265 /* Eventually this could wrap and all that.. */ 00266 if(MechX(mech) < 0) { 00267 if(linked) { 00268 MechX(mech) += map->map_width; 00269 pinned = -1; 00270 } else { 00271 MechX(mech) = 0; 00272 pinned = 4; 00273 } 00274 } else if(MechX(mech) >= map->map_width) { 00275 if(linked) { 00276 MechX(mech) -= map->map_width; 00277 pinned = -1; 00278 } else { 00279 MechX(mech) = map->map_width - 1; 00280 pinned = 2; 00281 } 00282 } 00283 if(MechY(mech) < 0) { 00284 if(linked) { 00285 pinned = -1; 00286 MechY(mech) += map->map_height; 00287 } else { 00288 MechY(mech) = 0; 00289 pinned = 1; 00290 } 00291 } else if(MechY(mech) >= map->map_height) { 00292 if(linked) { 00293 pinned = -1; 00294 MechY(mech) -= map->map_height; 00295 } else { 00296 MechY(mech) = map->map_height - 1; 00297 pinned = 3; 00298 } 00299 } 00300 if(pinned > 0) { 00301 /* This is a DS bay. First, we need to check if the bay's doors are 00302 blocked, one way or another. 00303 */ 00304 if(map->onmap && IsMech(map->onmap)) { 00305 if(Leave_DS(map, mech)) 00306 return; 00307 } else if(map->flags & MAPFLAG_MAPO && map->mapobj[TYPE_LEAVE]) 00308 if(Leave_Hangar(map, mech)) 00309 return; 00310 } 00311 if(pinned) { 00312 MapCoordToRealCoord(MechX(mech), MechY(mech), &MechFX(mech), 00313 &MechFY(mech)); 00314 if(pinned > 0) { 00315 mech_notify(mech, MECHALL, "You cannot move off this map!"); 00316 if(Jumping(mech) && !is_aero(mech)) 00317 LandMech(mech); 00318 MechCocoon(mech) = 0; 00319 MechSpeed(mech) = 0.0; 00320 MechDesiredSpeed(mech) = 0.0; 00321 if(is_aero(mech)) { 00322 MechStartFX(mech) = 0.0; 00323 MechStartFY(mech) = 0.0; 00324 MechStartFZ(mech) = 0.0; 00325 if(!Landed(mech)) 00326 MaybeMove(mech); 00327 } 00328 } 00329 } 00330 }
int checkSectionForSpecial | ( | MECH * | mech, | |
int | specialToFind, | |||
int | wSec | |||
) |
Definition at line 2259 of file mech.utils.c.
References MechSections, SectIsDestroyed, and specials.
Referenced by checkAllSections(), remove_inarc_pods_mech(), and show_narc_pods().
02260 { 02261 if(SectIsDestroyed(mech, wSec)) 02262 return 0; 02263 02264 if(MechSections(mech)[wSec].specials & specialToFind) 02265 return 1; 02266 02267 return 0; 02268 }
int CountAmmoForWeapon | ( | MECH * | mech, | |
int | weapindx | |||
) |
Definition at line 1330 of file mech.utils.c.
References GetPartData, GetPartType, I2Ammo, NUM_CRITICALS, NUM_SECTIONS, and PartIsNonfunctional.
Referenced by decrement_ammunition(), and FindAndCheckAmmo().
01331 { 01332 int wSecIter; 01333 int wSlotIter; 01334 int wcAmmo = 0; 01335 int wAmmoIdx; 01336 01337 wAmmoIdx = I2Ammo(weapindx); 01338 01339 for(wSecIter = 0; wSecIter < NUM_SECTIONS; wSecIter++) { 01340 for(wSlotIter = 0; wSlotIter < NUM_CRITICALS; wSlotIter++) { 01341 if((GetPartType(mech, wSecIter, wSlotIter) == wAmmoIdx) && 01342 !PartIsNonfunctional(mech, wSecIter, wSlotIter) && 01343 (GetPartData(mech, wSecIter, wSlotIter) > 0)) 01344 wcAmmo += GetPartData(mech, wSecIter, wSlotIter); 01345 } 01346 } 01347 01348 return wcAmmo; 01349 }
int CountDestroyedLegs | ( | MECH * | objMech | ) |
Definition at line 2153 of file mech.utils.c.
References CLASS_MECH, IsLegDestroyed(), LARM, LLEG, MechIsQuad, MechType, RARM, and RLEG.
Referenced by AttackMovementMods(), auto_astar_follow_event(), auto_astar_goto_event(), auto_astar_roam_event(), auto_dumbfollow_event(), auto_dumbgoto_event(), auto_enter_event(), auto_leave_event(), FireWeaponNumber(), IsMechLegLess(), LandMech(), mech_bootlegger(), mech_charge(), mech_kickortrip(), mech_lateral(), mech_stand(), and NormalizeAllActuatorCrits().
02154 { 02155 int wcDeadLegs = 0; 02156 02157 if(MechType(objMech) != CLASS_MECH) 02158 return 0; 02159 02160 if(MechIsQuad(objMech)) { 02161 if(IsLegDestroyed(objMech, LARM)) 02162 wcDeadLegs++; 02163 02164 if(IsLegDestroyed(objMech, RARM)) 02165 wcDeadLegs++; 02166 } 02167 02168 if(IsLegDestroyed(objMech, LLEG)) 02169 wcDeadLegs++; 02170 02171 if(IsLegDestroyed(objMech, RLEG)) 02172 wcDeadLegs++; 02173 02174 return wcDeadLegs; 02175 }
int CritsInLoc | ( | MECH * | mech, | |
int | index | |||
) |
Definition at line 102 of file mech.utils.c.
References CLASS_MECH, CLASS_MW, HEAD, LARM, LLEG, MechIsQuad, MechType, NUM_CRITICALS, RARM, and RLEG.
Referenced by ammo_expedinture_check(), ammo_weight(), BlowDumpingAmmo(), countTotalC3MastersOnMech(), countWorkingC3MastersOnMech(), CriticalStatus(), critslot_func(), critstatus_func(), DestroyParts(), do_magic(), do_sub_magic(), DoAmmunitionCrit(), dump_locations(), isPartOfWorkingC3Master(), load_template(), mech_dump(), mech_dump_event(), mech_ReSeal(), mech_scharge_event(), mech_weight_sub_veh(), mechDamagefunc(), mechrep_Raddspecial(), mechrep_Rreload(), tech_parsegun(), tech_parsepart_advanced(), and update_specials().
00103 { 00104 if(MechType(mech) == CLASS_MECH) 00105 switch (index) { 00106 case HEAD: 00107 case RLEG: 00108 case LLEG: 00109 return 6; 00110 case RARM: 00111 case LARM: 00112 if(MechIsQuad(mech)) 00113 return 6; 00114 } else if(MechType(mech) == CLASS_MW) 00115 return 2; 00116 return NUM_CRITICALS; 00117 }
void do_magic | ( | MECH * | mech | ) |
Definition at line 1805 of file mech.utils.c.
References CL_ANTI_MISSILE_TECH, CLASS_MECH, CLAT, CREW_STUNNED, CritsInLoc(), CV, Destroyed, DESTROYED, DestroySection(), do_sub_magic(), EvalBit, FALLEN, Fallen, GetPartBrand, GetPartData, GetPartFireMode, GetPartType, GOD, HandleMechCrit(), INARC_ECM_ATTACHED, INARC_HAYWIRE_ATTACHED, INARC_HOMING_ATTACHED, INARC_NEMESIS_ATTACHED, IS_ANTI_MISSILE_TECH, IS_JETTISONED_MODE, IsAmmo, IsAMS, IsWeapon, mech_loadnew(), MechBTH, MechCritStatus, MechEngineHeat, MechEngineSizeC, MechEngineSizeV, MechJumpSpeed, MechLRSRange, MechMaxSpeed, MechNumOsinks, MechPilotSkillBase, MechRealNumsinks, MechScanRange, MechSections, MechSpecials, MechStall, MechStatus, MechTacRange, MechTankCritStatus, MechType, MechType_Ref, MechWeapons, MECH::mynum, NUM_SECTIONS, OS_USED, PartIsDestroyed, ROCKET_FIRED, SectIsDestroyed, SetPartAmmoMode, SetPartBrand, SetPartData, SetPartFireMode, SetPartType, STABILIZERS_DESTROYED, StopBurning, StopPerformingAction, TAIL_ROTOR_DESTROYED, TURRET_JAMMED, TURRET_LOCKED, UnSetSectBreached, update_specials(), and Weapon2I.
Referenced by apply_mechDamage(), mech_RepairPart(), muxevent_tickmech_reattach(), muxevent_tickmech_removepart(), muxevent_tickmech_repairarmor(), muxevent_tickmech_repairinternal(), muxevent_tickmech_replacesuit(), and TECHCOMMANDH().
01806 { 01807 MECH opp; 01808 int i, j, t; 01809 int mask = 0; 01810 int tankCritMask = 0; 01811 01812 if(MechType(mech) != CLASS_MECH) 01813 tankCritMask = 01814 (TURRET_LOCKED | TURRET_JAMMED | TAIL_ROTOR_DESTROYED | 01815 CREW_STUNNED); 01816 01817 /* stop the burning */ 01818 StopBurning(mech); 01819 StopPerformingAction(mech); 01820 01821 memcpy(&opp, mech, sizeof(MECH)); 01822 mech_loadnew(GOD, &opp, MechType_Ref(mech)); 01823 MechEngineSizeV(mech) = MechEngineSizeC(&opp); /* From intact template */ 01824 opp.mynum = -1; 01825 /* Ok.. It's at perfect condition. Start inflicting some serious crits.. */ 01826 for(i = 0; i < NUM_SECTIONS; i++) 01827 for(j = 0; j < CritsInLoc(mech, i); j++) { 01828 SetPartType(&opp, i, j, GetPartType(mech, i, j)); 01829 SetPartBrand(&opp, i, j, GetPartBrand(mech, i, j)); 01830 SetPartData(&opp, i, j, 0); 01831 SetPartFireMode(&opp, i, j, 0); 01832 SetPartAmmoMode(&opp, i, j, 0); 01833 } 01834 if(MechType(mech) == CLASS_MECH) 01835 do_sub_magic(&opp, 0); 01836 MechNumOsinks(mech) = MechNumOsinks(&opp); 01837 for(i = 0; i < NUM_SECTIONS; i++) { 01838 if(MechType(mech) == CLASS_MECH) { 01839 for(j = 0; j < CritsInLoc(mech, i); j++) { 01840 if(PartIsDestroyed(mech, i, j)) { 01841 if(!PartIsDestroyed(&opp, i, j)) { 01842 if(!IsAmmo((t = GetPartType(mech, i, j)))) { 01843 if(!IsWeapon(t)) 01844 HandleMechCrit(&opp, NULL, 0, i, j, t, 01845 GetPartData(mech, i, j)); 01846 } 01847 } 01848 } else { 01849 t = GetPartType(mech, i, j); 01850 if(IsAMS(Weapon2I(t))) { 01851 if(MechWeapons[Weapon2I(t)].special & CLAT) 01852 MechSpecials(mech) |= CL_ANTI_MISSILE_TECH; 01853 else 01854 MechSpecials(mech) |= IS_ANTI_MISSILE_TECH; 01855 } 01856 GetPartFireMode(mech, i, j) &= 01857 ~(OS_USED | ROCKET_FIRED | IS_JETTISONED_MODE); 01858 } 01859 } 01860 } 01861 01862 MechSections(mech)[i].config &= ~STABILIZERS_DESTROYED; 01863 01864 if(SectIsDestroyed(mech, i)) 01865 DestroySection(&opp, NULL, 0, i); 01866 if(MechStall(mech) > 0) 01867 UnSetSectBreached(mech, i); /* Just in case ; this leads to 'unbreachable' legs once you've 'done your time' once */ 01868 } 01869 CV(MechJumpSpeed); 01870 CV(MechMaxSpeed); 01871 CV(MechRealNumsinks); 01872 CV(MechEngineHeat); 01873 CV(MechPilotSkillBase); 01874 CV(MechLRSRange); 01875 CV(MechTacRange); 01876 CV(MechScanRange); 01877 CV(MechBTH); 01878 MechCritStatus(mech) &= mask; 01879 MechCritStatus(mech) |= MechCritStatus(&opp) & (~mask); 01880 01881 MechTankCritStatus(mech) &= tankCritMask; 01882 MechTankCritStatus(mech) |= MechTankCritStatus(&opp) & (~tankCritMask); 01883 01884 for(i = 0; i < NUM_SECTIONS; i++) { 01885 MechSections(mech)[i].basetohit = MechSections(&opp)[i].basetohit; 01886 MechSections(mech)[i].specials = MechSections(&opp)[i].specials; 01887 MechSections(mech)[i].specials &= 01888 ~(INARC_HOMING_ATTACHED | INARC_HAYWIRE_ATTACHED | 01889 INARC_ECM_ATTACHED | INARC_NEMESIS_ATTACHED); 01890 } 01891 01892 /* Case of undestroying */ 01893 if(!Destroyed(&opp) && Destroyed(mech)) 01894 MechStatus(mech) &= ~DESTROYED; 01895 else if(Destroyed(&opp) && !Destroyed(mech)) 01896 MechStatus(mech) |= DESTROYED; 01897 if(!Destroyed(mech) && MechType(mech) != CLASS_MECH) 01898 EvalBit(MechStatus(mech), FALLEN, Fallen(&opp)); 01899 update_specials(mech); 01900 }
void do_sub_magic | ( | MECH * | mech, | |
int | loud | |||
) |
Definition at line 1730 of file mech.utils.c.
References CritsInLoc(), GetPartType, HEAT_SINK, HS_Efficiency, HS_Size, ICE_TECH, JUMP_JET, MechEngineSize, MechJumpSpeed, MechMaxSpeed, MechNumOsinks, MechRealNumsinks, MechSpecials, MechType_Ref, MIN, MP1, MP_PER_KPH, NUM_SECTIONS, PartIsNonfunctional, SendError, Special2I, and tprintf().
Referenced by do_magic(), and load_template().
01731 { 01732 int jjs = 0; 01733 int hses = 0; 01734 int wanths, wanths_f; 01735 int shs_size = HS_Size(mech); 01736 int hs_eff = HS_Efficiency(mech); 01737 int i, j; 01738 int inthses = MechEngineSize(mech) / 25; 01739 int dest_hses = 0; 01740 int maxjjs = (int) ((float) MechMaxSpeed(mech) * MP_PER_KPH * 2 / 3); 01741 01742 if(MechSpecials(mech) & ICE_TECH) 01743 inthses = 0; 01744 for(i = 0; i < NUM_SECTIONS; i++) 01745 for(j = 0; j < CritsInLoc(mech, i); j++) 01746 switch (Special2I(GetPartType(mech, i, j))) { 01747 case HEAT_SINK: 01748 hses++; 01749 if(PartIsNonfunctional(mech, i, j)) 01750 dest_hses++; 01751 break; 01752 case JUMP_JET: 01753 jjs++; 01754 break; 01755 } 01756 hses += 01757 MIN(MechRealNumsinks(mech) * shs_size / hs_eff, inthses * shs_size); 01758 if(jjs > maxjjs) { 01759 if(loud) 01760 SendError(tprintf 01761 ("Error in #%d (%s): %d JJs, yet %d maximum available (due to walk MPs)?", 01762 mech->mynum, MechType_Ref(mech), jjs, maxjjs)); 01763 01764 jjs = maxjjs; 01765 } 01766 MechJumpSpeed(mech) = MP1 * jjs; 01767 wanths_f = (hses / shs_size) * hs_eff; 01768 wanths = wanths_f - (dest_hses * hs_eff / shs_size); 01769 if(loud) 01770 MechNumOsinks(mech) = 01771 wanths - MIN(MechRealNumsinks(mech), inthses * hs_eff); 01772 if(wanths != MechRealNumsinks(mech) && loud) { 01773 SendError(tprintf 01774 ("Error in #%d (%s): Set HS: %d. Existing HS: %d. Difference: %d. Please %s.", 01775 mech->mynum, MechType_Ref(mech), MechRealNumsinks(mech), 01776 wanths, MechRealNumsinks(mech) - wanths, 01777 wanths < 01778 MechRealNumsinks(mech) ? "add the extra HS critical(s)" : 01779 "fix the template")); 01780 } else 01781 MechRealNumsinks(mech) = wanths; 01782 MechNumOsinks(mech) = wanths_f; 01783 }
Definition at line 2337 of file mech.utils.c.
References FindObjectsData(), MAP::first_free, FlMechRange, InLineOfSight(), MechSeesHex(), MAP::mechsOnMap, MechTeam, MechX, MechY, and MECH::mynum.
Referenced by artillery_FriendlyAdjustment(), FireSpot(), FireWeaponNumber(), mech_report(), and mech_scan().
02338 { 02339 int loop; 02340 MECH *target; 02341 02342 for(loop = 0; loop < mech_map->first_free; loop++) 02343 if(mech_map->mechsOnMap[loop] != mech->mynum && 02344 mech_map->mechsOnMap[loop] != -1) { 02345 target = (MECH *) FindObjectsData(mech_map->mechsOnMap[loop]); 02346 if(!target) 02347 continue; 02348 if(!(MechX(target) == x && MechY(target) == y) && !(needlos & 2)) 02349 continue; 02350 if(needlos) { 02351 if(needlos & 1) 02352 if(!InLineOfSight(mech, target, x, y, 02353 FlMechRange(mech_map, mech, target))) 02354 continue; 02355 if(needlos & 2) { 02356 if(MechTeam(mech) != MechTeam(target)) 02357 continue; 02358 if(!(MechSeesHex(target, mech_map, x, y))) 02359 continue; 02360 if(mech == target) 02361 continue; 02362 } 02363 } 02364 return target; 02365 } 02366 return NULL; 02367 }
int FindAmmoForWeapon | ( | MECH * | mech, | |
int | weapindx, | |||
int | start, | |||
int * | section, | |||
int * | critical | |||
) |
Definition at line 1323 of file mech.utils.c.
References AMMO_MODES, and FindAmmoForWeapon_sub().
Referenced by handleWeaponCrit(), LocateAMSDefenses(), and mech_dump().
01325 { 01326 return FindAmmoForWeapon_sub(mech, -1, -1, weapindx, start, section, 01327 critical, AMMO_MODES, 0); 01328 }
int FindAmmoForWeapon_sub | ( | MECH * | mech, | |
int | weapSection, | |||
int | weapCritical, | |||
int | weapindx, | |||
int | start, | |||
int * | section, | |||
int * | critical, | |||
int | nogof, | |||
int | gof | |||
) |
Definition at line 1258 of file mech.utils.c.
References findAmmoInSection(), FindFirstWeaponCrit(), GetPartDesiredAmmoLoc, GetPartType, GetWeaponCrits(), I2Ammo, NUM_SECTIONS, and Weapon2I.
Referenced by decrement_ammunition(), FindAmmoForWeapon(), FindAndCheckAmmo(), handleWeaponCrit(), and mech_dump().
01261 { 01262 int loop; 01263 int foundSlot; 01264 int desired; 01265 int wCritType = 0; 01266 int wWeapSize = 0; 01267 int wFirstCrit = 0; 01268 int wDesiredLoc = -1; 01269 01270 desired = I2Ammo(weapindx); 01271 01272 /* The data on the desired location */ 01273 if((weapSection > -1) && (weapCritical > -1)) { 01274 wCritType = GetPartType(mech, weapSection, weapCritical); 01275 wWeapSize = GetWeaponCrits(mech, Weapon2I(wCritType)); 01276 wFirstCrit = 01277 FindFirstWeaponCrit(mech, weapSection, weapCritical, 0, 01278 wCritType, wWeapSize); 01279 01280 wDesiredLoc = GetPartDesiredAmmoLoc(mech, weapSection, wFirstCrit); 01281 01282 if(wDesiredLoc >= 0) { 01283 foundSlot = 01284 findAmmoInSection(mech, wDesiredLoc, desired, nogof, gof); 01285 01286 if(foundSlot >= 0) { 01287 *section = wDesiredLoc; 01288 *critical = foundSlot; 01289 01290 return 1; 01291 } 01292 } 01293 } 01294 01295 /* Now lets search the current section */ 01296 foundSlot = findAmmoInSection(mech, start, desired, nogof, gof); 01297 01298 if(foundSlot >= 0) { 01299 *section = start; 01300 *critical = foundSlot; 01301 01302 return 1; 01303 } 01304 01305 /* If all else fails, start hunting for ammo */ 01306 for(loop = 0; loop < NUM_SECTIONS; loop++) { 01307 if((loop == start) || (loop == wDesiredLoc)) 01308 continue; 01309 01310 foundSlot = findAmmoInSection(mech, loop, desired, nogof, gof); 01311 01312 if(foundSlot >= 0) { 01313 *section = loop; 01314 *critical = foundSlot; 01315 01316 return 1; 01317 } 01318 } 01319 01320 return 0; 01321 }
int findAmmoInSection | ( | MECH * | mech, | |
int | section, | |||
int | type, | |||
int | nogof, | |||
int | gof | |||
) |
Definition at line 1236 of file mech.utils.c.
References GetPartAmmoMode, GetPartData, GetPartType, NUM_CRITICALS, and PartIsNonfunctional.
Referenced by FindAmmoForWeapon_sub().
01237 { 01238 int wIter; 01239 01240 /* Can't use LBX ammo as normal, but can use Narc and Artemis as normal */ 01241 for(wIter = 0; wIter < NUM_CRITICALS; wIter++) { 01242 if(GetPartType(mech, section, wIter) == type && 01243 !PartIsNonfunctional(mech, section, wIter) && (!nogof || 01244 !(GetPartAmmoMode 01245 (mech, section, 01246 wIter) & nogof)) 01247 && (!gof || (GetPartAmmoMode(mech, section, wIter) & gof))) { 01248 01249 if(!PartIsNonfunctional(mech, section, wIter) && 01250 GetPartData(mech, section, wIter) > 0) 01251 return wIter; 01252 } 01253 } 01254 01255 return -1; 01256 }
int FindAmmunition | ( | MECH * | mech, | |
unsigned char * | weaparray, | |||
unsigned short * | ammoarray, | |||
unsigned short * | ammomaxarray, | |||
unsigned int * | modearray, | |||
int | returnall | |||
) |
Definition at line 1015 of file mech.utils.c.
References Ammo2Weapon, AMMO_MODES, FullAmmo(), GetPartAmmoMode, GetPartData, GetPartType, IsAmmo, MAX_WEAPS_SECTION, NUM_SECTIONS, and PartIsNonfunctional.
Referenced by PrintWeaponStatus().
01018 { 01019 int loop; 01020 int weapcount = 0; 01021 int temp, data, mode; 01022 int index, i, j, duplicate; 01023 01024 for(index = 0; index < NUM_SECTIONS; index++) 01025 for(loop = 0; loop < MAX_WEAPS_SECTION; loop++) { 01026 temp = GetPartType(mech, index, loop); 01027 if(IsAmmo(temp)) { 01028 data = GetPartData(mech, index, loop); 01029 mode = (GetPartAmmoMode(mech, index, loop) & AMMO_MODES); 01030 temp = Ammo2Weapon(temp); 01031 duplicate = 0; 01032 01033 for(i = 0; i < weapcount; i++) { 01034 if(temp == weaparray[i] && mode == modearray[i]) { 01035 if(!(PartIsNonfunctional(mech, index, loop))) 01036 ammoarray[i] += data; 01037 ammomaxarray[i] += FullAmmo(mech, index, loop); 01038 duplicate = 1; 01039 } 01040 } 01041 01042 if(!duplicate) { 01043 weaparray[weapcount] = temp; 01044 01045 if(!(PartIsNonfunctional(mech, index, loop))) 01046 ammoarray[weapcount] = data; 01047 else 01048 ammoarray[weapcount] = 0; 01049 01050 ammomaxarray[weapcount] = FullAmmo(mech, index, loop); 01051 modearray[weapcount] = mode; 01052 01053 weapcount++; 01054 } 01055 } 01056 } 01057 /* Then, prune entries with 0 ammo left */ 01058 if (!returnall) { 01059 for(i = 0; i < weapcount; i++) 01060 if(!ammoarray[i]) { 01061 for(j = i + 1; j < weapcount; j++) { 01062 weaparray[j - 1] = weaparray[j]; 01063 ammoarray[j - 1] = ammoarray[j]; 01064 ammomaxarray[j - 1] = ammomaxarray[j]; 01065 modearray[j - 1] = modearray[j]; 01066 } 01067 i--; 01068 weapcount--; 01069 } 01070 } 01071 return (weapcount); 01072 }
int FindAndCheckAmmo | ( | MECH * | mech, | |
int | weapindx, | |||
int | section, | |||
int | critical, | |||
int * | ammoLoc, | |||
int * | ammoCrit, | |||
int * | ammoLoc1, | |||
int * | ammoCrit1, | |||
int * | wGattlingShots | |||
) |
Definition at line 2369 of file mech.utils.c.
References AMMO_MODES, ARTILLERY_MODES, CountAmmoForWeapon(), DOCHECK0, FindAmmoForWeapon_sub(), GATTLING_MODE, GetPartAmmoMode, GetPartData, GetPartFireMode, GunPilot, IsArtillery, MAX, MechWeapons, OS_MODE, OS_USED, RAC, RAC_FOURSHOT_MODE, RAC_SIXSHOT_MODE, RAC_TWOSHOT_MODE, RFAC_MODE, ROCKET, ROCKET_FIRED, TBEAM, THAND, and ULTRA_MODE.
Referenced by FireWeapon(), and mech_unjam_ammo_event().
02376 { 02377 int mod, nmod = 0; 02378 int wMaxShots = 0; 02379 int wRoundsToCheck = 1; 02380 int wWeapMode = GetPartFireMode(mech, section, critical); 02381 int tResetMode = 0; 02382 dbref player = GunPilot(mech); 02383 02384 /* Return if it's an energy or PC weapon */ 02385 if(MechWeapons[weapindx].type == TBEAM || 02386 MechWeapons[weapindx].type == THAND) 02387 return 1; 02388 02389 /* Check for rocket launchers */ 02390 if(MechWeapons[weapindx].special == ROCKET) { 02391 DOCHECK0(wWeapMode & ROCKET_FIRED, 02392 "That weapon has already been used!"); 02393 return 1; 02394 } 02395 02396 /* Check for One-Shots */ 02397 if(wWeapMode & OS_MODE) { 02398 DOCHECK0(GetPartFireMode(mech, section, critical) & OS_USED, 02399 "That weapon has already been used!"); 02400 return 1; 02401 } 02402 /* Check RACs - No special ammo type possible */ 02403 if(MechWeapons[weapindx].special & RAC) { 02404 wMaxShots = CountAmmoForWeapon(mech, weapindx); 02405 02406 if((wWeapMode & RAC_TWOSHOT_MODE) && (wMaxShots < 2)) { 02407 GetPartFireMode(mech, section, critical) &= ~RAC_TWOSHOT_MODE; 02408 02409 return 1; 02410 } 02411 02412 if((wWeapMode & RAC_FOURSHOT_MODE) && (wMaxShots < 4)) { 02413 GetPartFireMode(mech, section, critical) &= ~RAC_FOURSHOT_MODE; 02414 02415 return 1; 02416 } 02417 02418 if((wWeapMode & RAC_SIXSHOT_MODE) && (wMaxShots < 6)) { 02419 GetPartFireMode(mech, section, critical) &= ~RAC_SIXSHOT_MODE; 02420 02421 return 1; 02422 } 02423 } 02424 /* Check GMGs */ 02425 if(wWeapMode & GATTLING_MODE) { 02426 wMaxShots = CountAmmoForWeapon(mech, weapindx); 02427 02428 /* 02429 * Gattling MGs suck up damage * 3 in ammo 02430 */ 02431 02432 if((wMaxShots / 3) < *wGattlingShots) 02433 *wGattlingShots = MAX((wMaxShots / 3), 1); 02434 } 02435 /* If we're an ULTRA or RFAC, we need to check for multiple rounds */ 02436 if((wWeapMode & ULTRA_MODE) || (wWeapMode & RFAC_MODE)) 02437 wRoundsToCheck = 2; 02438 02439 mod = GetPartAmmoMode(mech, section, critical) & AMMO_MODES; 02440 02441 if(!mod) { 02442 DOCHECK0(!FindAmmoForWeapon_sub(mech, section, critical, weapindx, 02443 section, ammoLoc, ammoCrit, 02444 AMMO_MODES, 0), 02445 "You don't have any ammo for that weapon stored on this mech!"); 02446 02447 DOCHECK0(!GetPartData(mech, *ammoLoc, *ammoCrit), 02448 "You are out of ammo for that weapon!"); 02449 02450 if(wRoundsToCheck > 1) { 02451 GetPartData(mech, *ammoLoc, *ammoCrit)--; 02452 02453 if(FindAmmoForWeapon_sub(mech, section, critical, weapindx, 02454 section, ammoLoc1, ammoCrit1, AMMO_MODES, 02455 0)) { 02456 if(!GetPartData(mech, *ammoLoc1, *ammoCrit1)) 02457 tResetMode = 1; 02458 } else 02459 tResetMode = 1; 02460 02461 if(tResetMode) 02462 GetPartFireMode(mech, section, critical) &= ~wWeapMode; 02463 02464 GetPartData(mech, *ammoLoc, *ammoCrit)++; 02465 } 02466 } else { 02467 if(IsArtillery(weapindx)) 02468 nmod = (~mod) & ARTILLERY_MODES; 02469 else 02470 nmod = (~mod) & AMMO_MODES; 02471 mod = (mod & AMMO_MODES); 02472 02473 DOCHECK0(!FindAmmoForWeapon_sub(mech, section, critical, weapindx, 02474 section, ammoLoc, ammoCrit, nmod, 02475 mod), 02476 "You don't have any ammo for that weapon stored on this mech!"); 02477 02478 DOCHECK0(!GetPartData(mech, *ammoLoc, *ammoCrit), 02479 "You are out of the special ammo type for that weapon!"); 02480 02481 if(wRoundsToCheck > 1) { 02482 GetPartData(mech, *ammoLoc, *ammoCrit)--; 02483 02484 if(FindAmmoForWeapon_sub(mech, section, critical, weapindx, 02485 section, ammoLoc1, ammoCrit1, nmod, 02486 mod)) { 02487 if(!GetPartData(mech, *ammoLoc1, *ammoCrit1)) 02488 tResetMode = 1; 02489 } else 02490 tResetMode = 1; 02491 02492 if(tResetMode) 02493 GetPartFireMode(mech, section, critical) &= ~wWeapMode; 02494 02495 GetPartData(mech, *ammoLoc, *ammoCrit)++; 02496 } 02497 } 02498 02499 return 1; 02500 }
int FindArtemisForWeapon | ( | MECH * | mech, | |
int | section, | |||
int | critical | |||
) |
Definition at line 1351 of file mech.utils.c.
References ARTEMIS_IV, GetPartData, GetPartType, I2Special, NUM_CRITICALS, and PartIsNonfunctional.
Referenced by mech_toggle_mode_sub_func().
01352 { 01353 int critloop; 01354 int desired; 01355 01356 desired = I2Special(ARTEMIS_IV); 01357 for(critloop = 0; critloop < NUM_CRITICALS; critloop++) 01358 if(GetPartType(mech, section, critloop) == desired && 01359 !PartIsNonfunctional(mech, section, critloop)) { 01360 if(GetPartData(mech, section, critloop) == critical) 01361 return 1; 01362 } 01363 return 0; 01364 }
int FindBearing | ( | float | x0, | |
float | y0, | |||
float | x1, | |||
float | y1 | |||
) |
Definition at line 346 of file mech.utils.c.
References AcceptableDegree(), and RAD2DEG.
Referenced by ai_path_score(), artillery_direction(), blast_arcf(), DisplayTarget(), figure_out_range_and_bearing(), FindAreaHitGroup(), InWeaponArc(), mech_bearing(), mech_contacts(), mech_findcenter(), mech_jump(), mech_vector(), mechCentBearingfunc(), PrintReport(), ScrambleMessage(), sendchannelstuff(), showNetworkData(), showNetworkTargets(), and updateAutoturnTurret().
00347 { 00348 const float dx = x1 - x0; 00349 const float dy = y1 - y0; 00350 00351 float rads; 00352 int degrees; 00353 00354 /* 00355 * atan2() doesn't need this check because we never actually divide by 00356 * dx, but we handle it specially for consistency with existing code. 00357 */ 00358 if (dx == 0.f) { 00359 return (dy < 0.f) ? 0 : 180; 00360 } 00361 00362 /* TODO: Use atan2f(), if we've got it. */ 00363 rads = (float)atan2(-dx, dy); 00364 00365 /* Round off degrees. */ 00366 degrees = ((int)RAD2DEG(10.f * rads) + 5) / 10; 00367 00368 return AcceptableDegree(degrees + 180); 00369 }
void FindComponents | ( | float | magnitude, | |
int | degrees, | |||
float * | x, | |||
float * | y | |||
) |
Definition at line 175 of file mech.utils.c.
References fcos, fsin, and TWOPIOVER360.
Referenced by aero_UpdateSpeed(), ai_crash(), and move_mech().
00176 { 00177 *x = magnitude * fcos((float) (TWOPIOVER360 * (degrees + 90))); 00178 *y = magnitude * fsin((float) (TWOPIOVER360 * (degrees + 90))); 00179 *x = -(*x); /* because 90 is to the right */ 00180 *y = -(*y); /* because y increases downwards */ 00181 }
int FindDestructiveAmmo | ( | MECH * | mech, | |
int * | section, | |||
int * | critical | |||
) |
Definition at line 1366 of file mech.utils.c.
References Ammo2WeaponI, weapon_struct::damage, GAUSS, GetPartData, GetPartType, IsAmmo, IsArtillery, IsMissile, missile_hit_table_struct::key, MechWeapons, MissileHitTable, NUM_CRITICALS, NUM_SECTIONS, and PartIsDestroyed.
Referenced by HandleOverheat(), mech_explode(), and mech_explode_event().
01367 { 01368 int loop; 01369 int critloop; 01370 int maxdamage = 0; 01371 int damage; 01372 int weapindx; 01373 int i; 01374 int type, data; 01375 01376 for(loop = 0; loop < NUM_SECTIONS; loop++) 01377 for(critloop = 0; critloop < NUM_CRITICALS; critloop++) 01378 if(IsAmmo(GetPartType(mech, loop, critloop)) && 01379 !PartIsDestroyed(mech, loop, critloop)) { 01380 data = GetPartData(mech, loop, critloop); 01381 type = GetPartType(mech, loop, critloop); 01382 weapindx = Ammo2WeaponI(type); 01383 damage = data * MechWeapons[weapindx].damage; 01384 if(MechWeapons[weapindx].special & GAUSS) 01385 continue; 01386 if(IsMissile(weapindx) || IsArtillery(weapindx)) { 01387 for(i = 0; MissileHitTable[i].key != -1; i++) 01388 if(MissileHitTable[i].key == weapindx) 01389 damage *= MissileHitTable[i].num_missiles[10]; 01390 } 01391 if(damage > maxdamage) { 01392 *section = loop; 01393 *critical = critloop; 01394 maxdamage = damage; 01395 } 01396 } 01397 return (maxdamage); 01398 }
int FindFirstWeaponCrit | ( | MECH * | objMech, | |
int | wLoc, | |||
int | wSlot, | |||
int | wStartSlot, | |||
int | wCritType, | |||
int | wMaxCrits | |||
) |
Definition at line 2201 of file mech.utils.c.
References FindFirstWeaponCrit(), GetPartType, and NUM_CRITICALS.
Referenced by decrement_ammunition(), DestroyMainWeapon(), DoWeaponDestroyedCrit(), FindAmmoForWeapon_sub(), FindFirstWeaponCrit(), getWeapData(), handleWeaponCrit(), LoseWeapon(), and muxevent_tickmech_repairenhcrit().
02203 { 02204 int wCritsInLoc = 0; 02205 int wCritIter, wFirstCrit; 02206 02207 /* 02208 * First let's count the number of crits in this loc, incase 02209 * we have two of the same weapon 02210 */ 02211 02212 wFirstCrit = -1; 02213 02214 for(wCritIter = wStartSlot; wCritIter < NUM_CRITICALS; wCritIter++) { 02215 if(GetPartType(objMech, wLoc, wCritIter) == wCritType) { 02216 wCritsInLoc++; 02217 02218 if(wFirstCrit == -1) 02219 wFirstCrit = wCritIter; 02220 } 02221 } 02222 02223 if((wFirstCrit > -1) && (wSlot == -1)) 02224 return wFirstCrit; 02225 02226 /* 02227 * Now, if there are more crits than our max crit, then we have 02228 * two of the same weapon in this location. We need to figure 02229 * out which weapon this crit actually belongs to. 02230 */ 02231 if(wCritsInLoc > wMaxCrits) { 02232 /* 02233 * Well, we have thje first crit of the first instance, so 02234 * let's see if our crit falls out of that range.. if so, then 02235 * we need to figure out what range it actually falls into. 02236 */ 02237 if((wFirstCrit + wMaxCrits) <= wSlot) 02238 wFirstCrit = 02239 FindFirstWeaponCrit(objMech, wLoc, wSlot, 02240 (wFirstCrit + wMaxCrits), wCritType, 02241 wMaxCrits); 02242 } 02243 02244 return wFirstCrit; 02245 }
char* FindGunnerySkillName | ( | MECH * | mech, | |
int | weapindx | |||
) |
Definition at line 408 of file mech.utils.c.
References CLASS_AERO, CLASS_BSUIT, CLASS_DS, CLASS_MECH, CLASS_MW, CLASS_SPHEROID_DS, CLASS_VEH_GROUND, CLASS_VEH_NAVAL, CLASS_VTOL, IsArtillery, IsBallistic, IsEnergy, IsFlamer, IsMissile, MechType, MechWeapons, and name.
Referenced by AccumulateGunXP(), AccumulateGunXPold(), and FindPilotGunnery().
00409 { 00410 #ifndef BT_EXILE_MW3STATS 00411 switch (MechType(mech)) { 00412 case CLASS_BSUIT: 00413 return "Gunnery-BSuit"; 00414 case CLASS_MECH: 00415 return "Gunnery-Battlemech"; 00416 case CLASS_VEH_GROUND: 00417 case CLASS_VEH_NAVAL: 00418 return "Gunnery-Conventional"; 00419 case CLASS_VTOL: 00420 case CLASS_AERO: 00421 return "Gunnery-Aerospace"; 00422 case CLASS_SPHEROID_DS: 00423 case CLASS_DS: 00424 return "Gunnery-Spacecraft"; 00425 case CLASS_MW: 00426 if(weapindx >= 0) { 00427 if(!strcmp(MechWeapons[weapindx].name, "PC.Sword")) 00428 return "Blade"; 00429 if(!strcmp(MechWeapons[weapindx].name, "PC.Vibroblade")) 00430 return "Blade"; 00431 } 00432 return "Small_Arms"; 00433 } 00434 #else 00435 if(weapindx < 0) 00436 return NULL; 00437 if(MechType(mech) == CLASS_MW) { 00438 if(weapindx >= 0) { 00439 if(!strcmp(MechWeapons[weapindx].name, "PC.Blade")) 00440 return "Blade"; 00441 if(!strcmp(MechWeapons[weapindx].name, "PC.Vibroblade")) 00442 return "Blade"; 00443 if(!strcmp(MechWeapons[weapindx].name, "PC.Blazer")) 00444 return "Support_Weapons"; 00445 if(!strcmp(MechWeapons[weapindx].name, "PC.HeavyGyrojetGun")) 00446 return "Support_Weapons"; 00447 return "Small_Arms"; 00448 } 00449 } else if(IsArtillery(weapindx)) 00450 return "Gunnery-Artillery"; 00451 else if(IsMissile(weapindx)) 00452 return "Gunnery-Missile"; 00453 else if(IsBallistic(weapindx)) 00454 return "Gunnery-Ballistic"; 00455 else if(IsEnergy(weapindx)) 00456 return "Gunnery-Laser"; 00457 else if(IsFlamer(weapindx)) 00458 return "Gunnery-Flamer"; 00459 #endif 00460 return NULL; 00461 }
float FindHexRange | ( | float | x0, | |
float | y0, | |||
float | x1, | |||
float | y1 | |||
) |
Definition at line 716 of file mech.utils.c.
References FindXYRange().
Referenced by add_mine_on_map(), aero_checklz(), artillery_round_flight_time(), auto_astar_generate_path(), auto_calc_target_score(), auto_gun_event(), determineDamageFromHit(), figure_out_range_and_bearing(), fun_bthexinblz(), fun_bthexlos(), is_blocked_lz(), mech_findcenter(), mech_range(), mech_vector(), mechCentDistfunc(), and possible_mine_explosion().
00717 { 00718 return FindXYRange(x0, y0, x1, y1); 00719 }
int FindInfernoAmmo | ( | MECH * | mech, | |
int * | section, | |||
int * | critical | |||
) |
Definition at line 1400 of file mech.utils.c.
References Ammo2WeaponI, weapon_struct::damage, GAUSS, GetPartAmmoMode, GetPartData, GetPartType, INFERNO_MODE, IsAmmo, IsArtillery, IsMissile, missile_hit_table_struct::key, MechWeapons, MissileHitTable, NUM_CRITICALS, NUM_SECTIONS, and PartIsDestroyed.
Referenced by HandleOverheat().
01401 { 01402 int loop; 01403 int critloop; 01404 int maxdamage = 0; 01405 int damage; 01406 int weapindx; 01407 int i; 01408 int type, data; 01409 int mode; 01410 01411 for(loop = 0; loop < NUM_SECTIONS; loop++) 01412 for(critloop = 0; critloop < NUM_CRITICALS; critloop++) 01413 if(IsAmmo(GetPartType(mech, loop, critloop)) && 01414 !PartIsDestroyed(mech, loop, critloop)) { 01415 data = GetPartData(mech, loop, critloop); 01416 type = GetPartType(mech, loop, critloop); 01417 mode = GetPartAmmoMode(mech, loop, critloop); 01418 if(!(mode & INFERNO_MODE)) 01419 continue; 01420 weapindx = Ammo2WeaponI(type); 01421 damage = data * MechWeapons[weapindx].damage; 01422 if(MechWeapons[weapindx].special & GAUSS) 01423 continue; 01424 if(IsMissile(weapindx) || IsArtillery(weapindx)) { 01425 for(i = 0; MissileHitTable[i].key != -1; i++) 01426 if(MissileHitTable[i].key == weapindx) 01427 damage *= MissileHitTable[i].num_missiles[10]; 01428 } 01429 if(damage > maxdamage) { 01430 *section = loop; 01431 *critical = critloop; 01432 maxdamage = damage; 01433 } 01434 } 01435 return (maxdamage); 01436 }
int FindLegHeatSinks | ( | MECH * | mech | ) |
Definition at line 1074 of file mech.utils.c.
References GetPartType, HEAT_SINK, I2Special, LARM, LLEG, MechIsQuad, NUM_CRITICALS, PartIsNonfunctional, RARM, and RLEG.
Referenced by setWeatherHeatEffects(), and UpdateHeat().
01075 { 01076 int loop; 01077 int heatsinks = 0; 01078 01079 for(loop = 0; loop < NUM_CRITICALS; loop++) { 01080 if(GetPartType(mech, LLEG, loop) == I2Special((HEAT_SINK)) && 01081 !PartIsNonfunctional(mech, LLEG, loop)) 01082 heatsinks++; 01083 if(GetPartType(mech, RLEG, loop) == I2Special((HEAT_SINK)) && 01084 !PartIsNonfunctional(mech, RLEG, loop)) 01085 heatsinks++; 01086 /* 01087 * Added by Kipsta on 8/5/99 01088 * Quads can get 'arm' HS in the water too 01089 */ 01090 01091 if(MechIsQuad(mech)) { 01092 if(GetPartType(mech, LARM, loop) == I2Special((HEAT_SINK)) && 01093 !PartIsNonfunctional(mech, LARM, loop)) 01094 heatsinks++; 01095 if(GetPartType(mech, RARM, loop) == I2Special((HEAT_SINK)) && 01096 !PartIsNonfunctional(mech, RARM, loop)) 01097 heatsinks++; 01098 } 01099 } 01100 return (heatsinks); 01101 }
Definition at line 145 of file mech.utils.c.
References MAP::first_free, getMech(), MechID, MAP::mechsOnMap, and MECH::mynum.
Referenced by FindTargetDBREFFromMapNumber(), fun_btid2db(), and parse_tacargs().
00146 { 00147 int loop; 00148 MECH *tempMech; 00149 00150 for(loop = 0; loop < map->first_free; loop++) 00151 if(map->mechsOnMap[loop] != -1) { 00152 tempMech = getMech(map->mechsOnMap[loop]); 00153 if(tempMech && !strncasecmp(MechID(tempMech), mechid, 2)) 00154 return tempMech->mynum; 00155 } 00156 return -1; 00157 }
int FindObj | ( | MECH * | mech, | |
int | loc, | |||
int | type | |||
) |
Definition at line 2308 of file mech.utils.c.
References GetPartType, NUM_CRITICALS, and PartIsNonfunctional.
Referenced by DestroyHeatSink(), have_axe(), have_mace(), have_saw(), and have_sword().
02309 { 02310 int count = 0, i; 02311 02312 for(i = 0; i < NUM_CRITICALS; i++) 02313 if(GetPartType(mech, loc, i) == type) 02314 if(!PartIsNonfunctional(mech, loc, i)) 02315 count++; 02316 return count; 02317 }
int FindObjWithDest | ( | MECH * | mech, | |
int | loc, | |||
int | type | |||
) |
Definition at line 2319 of file mech.utils.c.
References GetPartType, and NUM_CRITICALS.
Referenced by hasPhysical().
02320 { 02321 int count = 0, i; 02322 02323 for(i = 0; i < NUM_CRITICALS; i++) 02324 if(GetPartType(mech, loc, i) == type) 02325 count++; 02326 return count; 02327 }
int FindPilotArtyGun | ( | MECH * | mech | ) |
Definition at line 557 of file mech.utils.c.
References char_getskilltarget(), DEFAULT_ARTILLERY, GENERIC_FIND_MECHSKILL, GunPilot, MECHSKILL_ARTILLERY, NUM_MECHSKILLS, and RGotGPilot.
Referenced by FindArtilleryBTH().
00558 { 00559 char *str; 00560 int i[NUM_MECHSKILLS]; 00561 00562 GENERIC_FIND_MECHSKILL(MECHSKILL_ARTILLERY, 0); 00563 if(RGotGPilot(mech)) 00564 return (char_getskilltarget(GunPilot(mech), "Gunnery-Artillery", 0)); 00565 return DEFAULT_ARTILLERY; 00566 }
int FindPilotGunnery | ( | MECH * | mech, | |
int | weapindx | |||
) |
Definition at line 568 of file mech.utils.c.
References char_getskilltarget(), DEFAULT_GUNNERY, FindGunnerySkillName(), GENERIC_FIND_MECHSKILL, GunPilot, MECHSKILL_GUNNERY, NUM_MECHSKILLS, and RGotGPilot.
Referenced by FindNormalBTH(), getPilotBVMod(), and mech_unjam_ammo_event().
00569 { 00570 char *str; 00571 int i[NUM_MECHSKILLS]; 00572 00573 GENERIC_FIND_MECHSKILL(MECHSKILL_GUNNERY, 0); 00574 if(RGotGPilot(mech)) 00575 if((str = FindGunnerySkillName(mech, weapindx))) 00576 return char_getskilltarget(GunPilot(mech), str, 0); 00577 return DEFAULT_GUNNERY; 00578 }
char* FindPilotingSkillName | ( | MECH * | mech | ) |
Definition at line 463 of file mech.utils.c.
References CLASS_AERO, CLASS_BSUIT, CLASS_DS, CLASS_MECH, CLASS_MW, CLASS_SPHEROID_DS, CLASS_VEH_GROUND, CLASS_VEH_NAVAL, CLASS_VTOL, MechMove, MechRTerrain, MechType, MOVE_BIPED, MOVE_HOVER, MOVE_QUAD, MOVE_TRACK, MOVE_WHEEL, and WATER.
Referenced by AccumulatePilXP(), and FindPilotPiloting().
00464 { 00465 #ifndef BT_EXILE_MW3STATS 00466 switch (MechType(mech)) { 00467 case CLASS_MW: 00468 return "Running"; 00469 case CLASS_BSUIT: 00470 return "Piloting-BSuit"; 00471 case CLASS_MECH: 00472 return "Piloting-Battlemech"; 00473 case CLASS_VEH_GROUND: 00474 case CLASS_VEH_NAVAL: 00475 return "Drive"; 00476 case CLASS_VTOL: 00477 case CLASS_AERO: 00478 return "Piloting-Aerospace"; 00479 case CLASS_SPHEROID_DS: 00480 case CLASS_DS: 00481 return "Piloting-Spacecraft"; 00482 } 00483 #else 00484 if(MechType(mech) == CLASS_MW && MechRTerrain(mech) == WATER) 00485 return "Swimming"; 00486 switch (MechType(mech)) { 00487 case CLASS_MW: 00488 return "Running"; 00489 case CLASS_BSUIT: 00490 return "Piloting-Bsuit"; 00491 case CLASS_VEH_NAVAL: 00492 return "Piloting-Naval"; 00493 case CLASS_DS: 00494 case CLASS_SPHEROID_DS: 00495 return "Piloting-Spacecraft"; 00496 case CLASS_VTOL: 00497 case CLASS_AERO: 00498 return "Piloting-Aerospace"; 00499 } 00500 switch (MechMove(mech)) { 00501 case MOVE_BIPED: 00502 return "Piloting-Biped"; 00503 case MOVE_QUAD: 00504 return "Piloting-Quad"; 00505 case MOVE_TRACK: 00506 return "Piloting-Tracked"; 00507 case MOVE_HOVER: 00508 return "Piloting-Hover"; 00509 case MOVE_WHEEL: 00510 return "Piloting-Wheeled"; 00511 } 00512 #endif 00513 return NULL; 00514 }
int FindPilotPiloting | ( | MECH * | mech | ) |
Definition at line 529 of file mech.utils.c.
References char_getskilltarget(), DEFAULT_PILOTING, FindPilotingSkillName(), GENERIC_FIND_MECHSKILL, MechPilot, MECHSKILL_PILOTING, NUM_MECHSKILLS, and RGotPilot.
Referenced by ChargeMech(), DeathFromAbove(), FindSPilotPiloting(), getPilotBVMod(), mech_axe(), mech_club(), mech_kickortrip(), mech_mace(), mech_ood_event(), mech_punch(), mech_saw(), mech_sword(), and remove_inarc_pods_mech().
00530 { 00531 char *str; 00532 int i[NUM_MECHSKILLS]; 00533 00534 GENERIC_FIND_MECHSKILL(MECHSKILL_PILOTING, 0); 00535 if(RGotPilot(mech)) 00536 if((str = FindPilotingSkillName(mech))) 00537 return char_getskilltarget(MechPilot(mech), str, 0); 00538 return DEFAULT_PILOTING; 00539 }
int FindPilotSpotting | ( | MECH * | mech | ) |
Definition at line 546 of file mech.utils.c.
References char_getskilltarget(), DEFAULT_SPOTTING, GENERIC_FIND_MECHSKILL, MechPilot, MECHSKILL_SPOTTING, NUM_MECHSKILLS, and RGotPilot.
Referenced by FindArtilleryBTH(), and FindNormalBTH().
00547 { 00548 char *str; 00549 int i[NUM_MECHSKILLS]; 00550 00551 GENERIC_FIND_MECHSKILL(MECHSKILL_SPOTTING, 0); 00552 if(RGotPilot(mech)) 00553 return (char_getskilltarget(MechPilot(mech), "Gunnery-Spotting", 0)); 00554 return DEFAULT_SPOTTING; 00555 }
float FindRange | ( | float | x0, | |
float | y0, | |||
float | z0, | |||
float | x1, | |||
float | y1, | |||
float | z1 | |||
) |
Definition at line 695 of file mech.utils.c.
References SCALEMAP.
Referenced by findC3RangeWithNetwork(), FireSpot(), FireWeaponNumber(), fun_btgetrange(), fun_btmapunits(), MapLimitedBroadcast3d(), mech_eta(), mech_range(), mech_report(), mech_scan(), mech_vector(), MechFireBroadcast(), MechSeesHexF(), MechSeesRange(), MechSLitesRange(), and show_building_in_hex().
00696 { 00697 const float dx = x0 - x1; 00698 const float dy = y0 - y1; 00699 const float dz = z0 - z1; 00700 00701 /* TODO: Use sqrtf(), if we've got it. */ 00702 return (float)(1./SCALEMAP) * (float)sqrt(dx * dx + dy * dy + dz * dz); 00703 }
int FindRoundsForWeapon | ( | MECH * | mech, | |
int | weapindx | |||
) |
Definition at line 1438 of file mech.utils.c.
References GetPartData, GetPartType, I2Ammo, NUM_CRITICALS, NUM_SECTIONS, and PartIsNonfunctional.
01439 { 01440 int loop; 01441 int critloop; 01442 int desired; 01443 int found = 0; 01444 01445 desired = I2Ammo(weapindx); 01446 for(loop = 0; loop < NUM_SECTIONS; loop++) 01447 for(critloop = 0; critloop < NUM_CRITICALS; critloop++) 01448 if(GetPartType(mech, loop, critloop) == desired && 01449 !PartIsNonfunctional(mech, loop, critloop)) 01450 found += GetPartData(mech, loop, critloop); 01451 return found; 01452 }
int FindSPilotPiloting | ( | MECH * | mech | ) |
Definition at line 541 of file mech.utils.c.
References FindPilotPiloting(), MechMove, and MOVE_QUAD.
Referenced by ChargeMech(), MadePilotSkillRoll_Advanced(), MadePilotSkillRoll_NoXP(), mech_ood_event(), and MechPilotSkillRoll_BTH().
00542 { 00543 return FindPilotPiloting(mech) + (MechMove(mech) == MOVE_QUAD ? -2 : 0); 00544 }
Definition at line 159 of file mech.utils.c.
References FindMechOnMap(), getMap(), MECH::mapindex, MECH::mynum, SendError, and tprintf().
Referenced by auto_radio_command_dfollow(), auto_radio_command_embark(), auto_radio_command_follow(), auto_radio_command_jumpjet(), auto_radio_command_pickup(), auto_radio_command_target(), FindBSuitTarget(), FireWeaponNumber(), fun_btid2db(), mech_attachcables(), mech_c3_join_leave(), mech_c3i_join_leave(), mech_charge(), mech_detachcables(), mech_embark(), mech_enterbay(), mech_jump(), mech_pickup(), mech_radio(), mech_report(), mech_scan(), mech_settarget(), mech_snipe(), mech_spot(), mech_tag(), mech_view(), and PhysicalAttack().
00160 { 00161 MAP *map; 00162 00163 if(mech->mapindex == -1) 00164 return -1; 00165 map = getMap(mech->mapindex); 00166 if(!map) { 00167 SendError(tprintf("FTDBREFFMN:invalid map:Mech: %d Index: %d", 00168 mech->mynum, mech->mapindex)); 00169 mech->mapindex = -1; 00170 return -1; 00171 } 00172 return FindMechOnMap(map, mapnum); 00173 }
int FindTargetXY | ( | MECH * | mech, | |
float * | x, | |||
float * | y, | |||
float * | z | |||
) |
Definition at line 935 of file mech.utils.c.
References getMech(), MapCoordToRealCoord(), MechFX, MechFY, MechFZ, MechTarget, MechTargX, MechTargY, MechTargZ, and ZSCALE.
Referenced by FindNormalBTH(), FireWeaponNumber(), mech_bearing(), mech_range(), mech_report(), mech_scan(), and mech_vector().
00936 { 00937 MECH *tempMech; 00938 00939 if(MechTarget(mech) != -1) { 00940 tempMech = getMech(MechTarget(mech)); 00941 if(tempMech) { 00942 *x = MechFX(tempMech); 00943 *y = MechFY(tempMech); 00944 *z = MechFZ(tempMech); 00945 return 1; 00946 } 00947 } else if(MechTargX(mech) != -1 && MechTargY(mech) != -1) { 00948 MapCoordToRealCoord(MechTargX(mech), MechTargY(mech), x, y); 00949 *z = (float) ZSCALE *(MechTargZ(mech)); 00950 00951 return 1; 00952 } 00953 return 0; 00954 }
Definition at line 601 of file mech.utils.c.
References char_getskilltarget(), and FindTechSkillName().
Referenced by tech_roll().
00602 { 00603 char *skname; 00604 00605 if((skname = FindTechSkillName(mech))) 00606 return (char_getskilltarget(player, skname, 0)); 00607 return 18; 00608 }
char* FindTechSkillName | ( | MECH * | mech | ) |
Definition at line 580 of file mech.utils.c.
References char_getskilltarget(), CLASS_AERO, CLASS_BSUIT, CLASS_DS, CLASS_MECH, CLASS_SPHEROID_DS, CLASS_VEH_GROUND, CLASS_VEH_NAVAL, CLASS_VTOL, and MechType.
Referenced by AccumulateTechXP(), and FindTechSkill().
00581 { 00582 switch (MechType(mech)) { 00583 case CLASS_MECH: 00584 case CLASS_BSUIT: 00585 return "Technician-Battlemech"; 00586 case CLASS_VEH_GROUND: 00587 case CLASS_VEH_NAVAL: 00588 return "Technician-Mechanic"; 00589 case CLASS_AERO: 00590 case CLASS_VTOL: 00591 case CLASS_SPHEROID_DS: 00592 case CLASS_DS: 00593 return "Technician-Aerospace"; 00594 #if 0 /* Used to be DS tech */ 00595 return (char_getskilltarget(player, "Technician-Spacecraft", 0)); 00596 #endif 00597 } 00598 return NULL; 00599 }
int FindWeaponFromIndex | ( | MECH * | mech, | |
int | weapindx, | |||
int * | section, | |||
int * | crit | |||
) |
Definition at line 1166 of file mech.utils.c.
References FindWeapons, MAX_WEAPS_SECTION, NUM_SECTIONS, PartIsNonfunctional, and WpnIsRecycling.
01167 { 01168 int loop; 01169 unsigned char weaparray[MAX_WEAPS_SECTION]; 01170 unsigned char weapdata[MAX_WEAPS_SECTION]; 01171 int critical[MAX_WEAPS_SECTION]; 01172 int num_weaps; 01173 int index; 01174 01175 for(loop = 0; loop < NUM_SECTIONS; loop++) { 01176 num_weaps = FindWeapons(mech, loop, weaparray, weapdata, critical); 01177 for(index = 0; index < num_weaps; index++) 01178 if(weaparray[index] == weapindx) { 01179 *section = loop; 01180 *crit = critical[index]; 01181 if(!PartIsNonfunctional(mech, loop, index) && 01182 !WpnIsRecycling(mech, loop, index)) 01183 return 1; 01184 /* Return if not Recycling/Destroyed */ 01185 /* Otherwise keep looking */ 01186 } 01187 } 01188 return 0; 01189 }
int FindWeaponIndex | ( | MECH * | mech, | |
int | number | |||
) |
Definition at line 1191 of file mech.utils.c.
References FindWeapons, MAX_WEAPS_SECTION, and NUM_SECTIONS.
Referenced by mech_dump(), and mech_unjam_ammo_event().
01192 { 01193 int loop; 01194 unsigned char weaparray[MAX_WEAPS_SECTION]; 01195 unsigned char weapdata[MAX_WEAPS_SECTION]; 01196 int critical[MAX_WEAPS_SECTION]; 01197 int running_sum = 0; 01198 int num_weaps; 01199 int index; 01200 01201 if(number < 0) 01202 return -1; /* Anti-crash */ 01203 for(loop = 0; loop < NUM_SECTIONS; loop++) { 01204 num_weaps = FindWeapons(mech, loop, weaparray, weapdata, critical); 01205 if(num_weaps <= 0) 01206 continue; 01207 if(number < running_sum + num_weaps) { 01208 /* we found it... */ 01209 index = number - running_sum; 01210 return weaparray[index]; 01211 } 01212 running_sum += num_weaps; 01213 } 01214 return -1; 01215 }
int FindWeaponNumberOnMech | ( | MECH * | mech, | |
int | number, | |||
int * | section, | |||
int * | crit | |||
) |
Definition at line 1161 of file mech.utils.c.
References FindWeaponNumberOnMech_Advanced().
Referenced by CountWeaponsInLoc(), FindWeaponTypeNumInLoc(), fun_btticweaps(), IsArtyMech(), listtic_fun(), mech_dump(), mech_inarc_ammo_toggle(), mech_rac(), mech_unjam_ammo_event(), mech_unjamammo_func(), mech_usebin(), multi_weap_sel(), and tech_parsegun().
01162 { 01163 return FindWeaponNumberOnMech_Advanced(mech, number, section, crit, 0); 01164 }
int FindWeaponNumberOnMech_Advanced | ( | MECH * | mech, | |
int | number, | |||
int * | section, | |||
int * | crit, | |||
int | sight | |||
) |
Definition at line 1108 of file mech.utils.c.
References CLASS_MECH, CLASS_VEH_GROUND, CLASS_VTOL, FindWeapons, MAX_WEAPS_SECTION, MechSections, MechType, MechWeapons, NUM_SECTIONS, PartIsNonfunctional, TBEAM, TIC_NUM_DESTROYED, TIC_NUM_PHYSICAL, TIC_NUM_RECYCLING, and TIC_NUM_RELOADING.
Referenced by FindWeaponNumberOnMech(), FireWeaponNumber(), mech_disableweap_func(), mech_toggle_mode_sub_func(), and mechrep_Rfiremode().
01110 { 01111 int loop; 01112 unsigned char weaparray[MAX_WEAPS_SECTION]; 01113 unsigned char weapdata[MAX_WEAPS_SECTION]; 01114 int critical[MAX_WEAPS_SECTION]; 01115 int running_sum = 0; 01116 int num_weaps; 01117 int index; 01118 01119 for(loop = 0; loop < NUM_SECTIONS; loop++) { 01120 num_weaps = FindWeapons(mech, loop, weaparray, weapdata, critical); 01121 01122 if(num_weaps <= 0) 01123 continue; 01124 01125 if(number < running_sum + num_weaps) { 01126 /* we found it... */ 01127 index = number - running_sum; 01128 if(PartIsNonfunctional(mech, loop, critical[index])) { 01129 *section = loop; 01130 *crit = critical[index]; 01131 return TIC_NUM_DESTROYED; 01132 } else if(weapdata[index] > 0 && !sight) { 01133 *section = loop; 01134 *crit = critical[index]; 01135 return (MechWeapons[weaparray[index]].type == 01136 TBEAM) ? TIC_NUM_RECYCLING : TIC_NUM_RELOADING; 01137 } else { 01138 01139 if(MechSections(mech)[loop].recycle && 01140 (MechType(mech) == CLASS_MECH || 01141 MechType(mech) == CLASS_VEH_GROUND || 01142 MechType(mech) == CLASS_VTOL) && !sight) { 01143 01144 *section = loop; 01145 *crit = critical[index]; 01146 /* just did a physical attack */ 01147 return TIC_NUM_PHYSICAL; 01148 } 01149 01150 /* The recylce data for the weapon is clear- it is ready to fire! */ 01151 *section = loop; 01152 *crit = critical[index]; 01153 return weaparray[index]; 01154 } 01155 } else 01156 running_sum += num_weaps; 01157 } 01158 return -1; 01159 }
int FindWeapons_Advanced | ( | MECH * | mech, | |
int | index, | |||
unsigned char * | weaparray, | |||
unsigned char * | weapdataarray, | |||
int * | critical, | |||
int | whine | |||
) |
Definition at line 974 of file mech.utils.c.
References GetPartData, GetPartType, GetWeaponCrits(), IsWeapon, MAX_WEAPS_SECTION, UGLYTEST, and Weapon2I.
Referenced by ValidGunPos().
00977 { 00978 int loop; 00979 int weapcount = 0; 00980 int temp, data, lastweap = -1; 00981 int num_crits = 0, i; 00982 00983 for(loop = 0; loop < MAX_WEAPS_SECTION; loop++) { 00984 temp = GetPartType(mech, index, loop); 00985 data = GetPartData(mech, index, loop); 00986 if(IsWeapon(temp)) { 00987 temp = Weapon2I(temp); 00988 if(weapcount == 0) { 00989 lastweap = temp; 00990 weapdataarray[weapcount] = data; 00991 weaparray[weapcount] = temp; 00992 critical[weapcount] = loop; 00993 weapcount++; 00994 num_crits = 1; 00995 continue; 00996 } 00997 if(!num_crits || temp != lastweap || 00998 (num_crits == GetWeaponCrits(mech, temp))) { 00999 UGLYTEST; 01000 weaparray[weapcount] = temp; 01001 weapdataarray[weapcount] = data; 01002 critical[weapcount] = loop; 01003 lastweap = temp; 01004 num_crits = 1; 01005 weapcount++; 01006 } else 01007 num_crits++; 01008 } else 01009 UGLYTEST; 01010 } 01011 UGLYTEST; 01012 return (weapcount); 01013 }
void FindXY | ( | float | x0, | |
float | y0, | |||
int | bearing, | |||
float | range, | |||
float * | x1, | |||
float * | y1 | |||
) |
Definition at line 678 of file mech.utils.c.
References DEG2RAD, SCALEMAP, and XSCALE.
Referenced by auto_astar_follow_event(), auto_astar_generate_path(), auto_roam_generate_target_hex(), mech_jump(), and parse_tacargs().
00679 { 00680 float xscale, correction; 00681 00682 /* XXX: Something to do with ranges with actual number of hexes? */ 00683 correction = (float) (bearing % 60) / 60.0; 00684 if(correction > 0.5) 00685 correction = 1.0 - correction; 00686 correction = -correction * 2.0; /* 0 - 1 correction */ 00687 xscale = (1.0 + XSCALE * correction) * SCALEMAP; 00688 00689 /* TODO: Use sinf()/cosf(), if we've got them. */ 00690 *x1 = x0 + range * (float)sin(DEG2RAD(bearing)) * xscale; 00691 *y1 = y0 - range * (float)cos(DEG2RAD(bearing)) * SCALEMAP; 00692 }
float FindXYRange | ( | float | x0, | |
float | y0, | |||
float | x1, | |||
float | y1 | |||
) |
Definition at line 706 of file mech.utils.c.
References SCALEMAP.
Referenced by ai_path_score(), blast_hit_hexesf(), FindHexRange(), FindZBearing(), fun_btmapunits(), and MapLimitedBroadcast2d().
00707 { 00708 const float dx = x0 - x1; 00709 const float dy = y0 - y1; 00710 00711 /* TODO: Use sqrtf(), if we've got it. */ 00712 return (float)(1./SCALEMAP) * (float)sqrt(dx * dx + dy * dy); 00713 }
int FindZBearing | ( | float | x0, | |
float | y0, | |||
float | z0, | |||
float | x1, | |||
float | y1, | |||
float | z1 | |||
) |
Definition at line 331 of file mech.utils.c.
References FindXYRange(), RAD2DEG, and SCALEMAP.
Referenced by mech_vector().
00332 { 00333 float adj, opp, deg; 00334 00335 adj = FindXYRange(x0, y0, x1, y1); 00336 /* 00337 * XXX: Why can't opp be negative? If z1 < z0, shouldn't Z-bearing 00338 * also be negative? Also, why no range clamping on the value of deg? 00339 */ 00340 opp = (float)(1./SCALEMAP) * fabsf(z1 - z0); 00341 /* TODO: Use atan2f(), if we've got it. */ 00342 deg = RAD2DEG(atan2(opp, adj)); 00343 return ceilf(deg); 00344 }
int FullAmmo | ( | MECH * | mech, | |
int | loc, | |||
int | pos | |||
) |
Definition at line 1218 of file mech.utils.c.
References AC_AP_MODE, AC_CASELESS_MODE, AC_PRECISION_MODE, Ammo2I, weapon_struct::ammoperton, GetPartAmmoMode, GetPartFireMode, GetPartType, HALFTON_MODE, and MechWeapons.
Referenced by apply_mechDamage(), check_for_damage(), critslot_func(), damages_func(), dump_item(), FindAmmunition(), load_template(), mech_FillPartAmmo(), mechDamagefunc(), mechrep_Rreload(), show_mechs_damage(), and TECHCOMMANDH().
01219 { 01220 int baseammo; 01221 01222 baseammo = MechWeapons[Ammo2I(GetPartType(mech,loc,pos))].ammoperton; 01223 if((GetPartAmmoMode(mech, loc, pos) & AC_AP_MODE) 01224 || (GetPartAmmoMode(mech, loc, pos) & AC_PRECISION_MODE) 01225 || (GetPartFireMode(mech, loc, pos) & HALFTON_MODE)) { 01226 return baseammo >> 1; 01227 } 01228 01229 if((GetPartAmmoMode(mech, loc, pos) & AC_CASELESS_MODE)) { 01230 return baseammo << 1; 01231 } 01232 01233 return baseammo; 01234 }
int GetPartWeight | ( | int | part | ) |
Definition at line 2544 of file mech.utils.c.
References Bomb2I, BombWeight(), Cargo2I, CLAW, I2Special, IsAmmo, IsBomb, IsCargo, IsSpecial, IsWeapon, MechWeapons, Special2I, Weapon2I, and weapon_struct::weight.
Referenced by fun_btgetweight(), list_matching(), and SetCargoWeight().
02545 { 02546 if(IsWeapon(part)) 02547 return 10.24 * MechWeapons[Weapon2I(part)].weight; 02548 else if(IsAmmo(part)) 02549 return 1024; 02550 else if(IsBomb(part)) 02551 return 102 * BombWeight(Bomb2I(part)); 02552 #ifndef BT_PART_WEIGHTS 02553 else if(IsSpecial(part) && part <= I2Special(CLAW)) 02554 return 1024; 02555 #else 02556 else if(IsSpecial(part)) /* && i <= I2Special(LAMEQUIP) */ 02557 return internalsweight[Special2I(part)]; 02558 else if(IsCargo(part)) 02559 return cargoweight[Cargo2I(part)]; 02560 #endif /* BT_PART_WEIGHTS */ 02561 else 02562 /* hmm.. tricky, suppose we'll make things light */ 02563 return 102; 02564 }
int getRemainingArmorPercent | ( | MECH * | mech | ) |
Definition at line 2288 of file mech.utils.c.
References GetSectArmor, GetSectOArmor, GetSectORArmor, GetSectRArmor, and NUM_SECTIONS.
Referenced by showNetworkData().
02289 { 02290 int i; 02291 float wMax = 0; 02292 float wRemaining = 0; 02293 02294 for(i = 0; i < NUM_SECTIONS; i++) { 02295 wMax += GetSectOArmor(mech, i); 02296 wMax += GetSectORArmor(mech, i); 02297 02298 wRemaining += GetSectArmor(mech, i); 02299 wRemaining += GetSectRArmor(mech, i); 02300 } 02301 02302 if(wMax == 0) 02303 return 0; 02304 02305 return ((wRemaining / wMax) * 100); 02306 }
int getRemainingInternalPercent | ( | MECH * | mech | ) |
Definition at line 2270 of file mech.utils.c.
References GetSectInt, GetSectOInt, and NUM_SECTIONS.
Referenced by showNetworkData().
02271 { 02272 int i; 02273 float wMax = 0; 02274 float wRemaining = 0; 02275 02276 for(i = 0; i < NUM_SECTIONS; i++) { 02277 wMax += GetSectOInt(mech, i); 02278 02279 wRemaining += GetSectInt(mech, i); 02280 } 02281 02282 if(wMax == 0) 02283 return 0; 02284 02285 return ((wRemaining / wMax) * 100); 02286 }
int GetWeaponCrits | ( | MECH * | mech, | |
int | weapindx | |||
) |
Definition at line 1707 of file mech.utils.c.
References CLASS_MECH, weapon_struct::criticals, MechType, and MechWeapons.
Referenced by check_for_damage(), check_for_scrappage(), crit_weight(), decrement_ammunition(), DestroyMainWeapon(), dump_item(), FindAmmoForWeapon_sub(), FindWeapons_Advanced(), getWeapData(), handleWeaponCrit(), LoseWeapon(), mech_weight_sub_mech(), mech_weight_sub_veh(), mechrep_Raddweap(), muxevent_tickmech_removegun(), muxevent_tickmech_repairenhcrit(), muxevent_tickmech_repairgun(), muxevent_tickmech_replacegun(), TECHCOMMANDH(), TFUNC_LOCPOS(), WeaponIsNonfunctional(), and weaponstatus_func().
01708 { 01709 return (MechType(mech) == 01710 CLASS_MECH) ? (MechWeapons[weapindx].criticals) : 1; 01711 }
int HeatFactor | ( | MECH * | mech | ) |
Definition at line 3687 of file mech.utils.c.
References CLASS_MECH, HasWorkingECMSuite, LBUF_SIZE, MechMinusHeat, MechPlusHeat, MechSpecials, MechType, MECH::mynum, NullSigSysActive, SendDebug, and StealthArmorActive.
Referenced by auto_sensor_event().
03687 { 03688 03689 int factor = 0; 03690 char buf[LBUF_SIZE]; 03691 03692 if(MechType(mech) != CLASS_MECH) { 03693 factor = (((MechSpecials(mech) & ICE_TECH)) ? -1 : 21); 03694 return factor; 03695 } else { 03696 factor = 03697 (MechPlusHeat(mech) + 03698 (2 * (MechPlusHeat(mech) - MechMinusHeat(mech)))); 03699 return ((NullSigSysActive(mech) || HasWorkingECMSuite(mech) 03700 || StealthArmorActive(mech)) ? -1 : factor); 03701 } 03702 snprintf(buf, LBUF_SIZE, 03703 "HeatFactor : Invalid heat factor calculation on #%d.", 03704 mech->mynum); 03705 SendDebug(buf); 03706 }
int InWeaponArc | ( | MECH * | mech, | |
float | x, | |||
float | y | |||
) |
Definition at line 371 of file mech.utils.c.
References AcceptableDegree(), CLASS_BSUIT, CLASS_MECH, CLASS_MW, FindBearing(), FORWARDARC, LSIDEARC, MechFacing, MechFX, MechFY, MechHasTurret, MechStatus, MechTurretFacing, MechType, MECH::mynum, NOARC, REARARC, RSIDEARC, SendError, TORSO_LEFT, TORSO_RIGHT, tprintf(), and TURRETARC.
Referenced by ChargeMech(), DisplayTarget(), FindNormalBTH(), InLineOfSight(), IsInWeaponArc(), mech_contacts(), mech_lites_target(), MechSeesRange(), MechSLitesRange(), PhysicalAttack(), PrintReport(), SearchLightInRange(), Sensor_DoWeSeeNow(), and showNetworkTargets().
00372 { 00373 int relat; 00374 int bearingToTarget; 00375 int res = NOARC; 00376 00377 bearingToTarget = FindBearing(MechFX(mech), MechFY(mech), x, y); 00378 relat = MechFacing(mech) - bearingToTarget; 00379 if(MechType(mech) == CLASS_MECH || MechType(mech) == CLASS_MW || 00380 MechType(mech) == CLASS_BSUIT) { 00381 if(MechStatus(mech) & TORSO_RIGHT) 00382 relat += 59; 00383 else if(MechStatus(mech) & TORSO_LEFT) 00384 relat -= 59; 00385 } 00386 relat = AcceptableDegree(relat); 00387 if(relat >= 300 || relat <= 60) 00388 res |= FORWARDARC; 00389 if(relat > 120 && relat < 240) 00390 res |= REARARC; 00391 if(relat >= 240 && relat < 300) 00392 res |= RSIDEARC; 00393 if(relat > 60 && relat <= 120) 00394 res |= LSIDEARC; 00395 00396 if(MechHasTurret(mech)) { 00397 relat = AcceptableDegree((MechFacing(mech) + MechTurretFacing(mech)) 00398 - bearingToTarget); 00399 if(relat >= 330 || relat <= 30) 00400 res |= TURRETARC; 00401 } 00402 if(res == NOARC) 00403 SendError(tprintf("NoArc: #%d: BearingToTarget:%d Facing:%d", 00404 mech->mynum, bearingToTarget, MechFacing(mech))); 00405 return res; 00406 }
int IsInWeaponArc | ( | MECH * | mech, | |
float | x, | |||
float | y, | |||
int | section, | |||
int | critical | |||
) |
Definition at line 1591 of file mech.utils.c.
References AERO_AFT, AERO_LWING, AERO_NOSE, AERO_RWING, BSIDE, CLASS_AERO, CLASS_BSUIT, CLASS_DS, CLASS_MECH, CLASS_MW, CLASS_SPHEROID_DS, CLASS_VEH_GROUND, CLASS_VEH_NAVAL, CLASS_VTOL, DS_AFT, DS_LRWING, DS_LWING, DS_NOSE, DS_RRWING, DS_RWING, FLIPPED_ARMS, FORWARDARC, FSIDE, GetPartFireMode, InWeaponArc(), LARM, LLEG, LSIDE, LSIDEARC, MechIsQuad, MechStatus, MechType, NOARC, RARM, REAR_MOUNT, REARARC, RLEG, RSIDE, RSIDEARC, TORSO_LEFT, TORSO_RIGHT, TURRET, and TURRETARC.
01592 { 01593 int weaponarc, isrear; 01594 int wantarc = NOARC; 01595 01596 if(MechType(mech) == CLASS_MECH && (section == LLEG || section == RLEG 01597 || (MechIsQuad(mech) 01598 && (section == LARM 01599 || section == RARM)))) { 01600 int ts = MechStatus(mech) & (TORSO_LEFT | TORSO_RIGHT); 01601 MechStatus(mech) &= ~(ts); 01602 weaponarc = InWeaponArc(mech, x, y); 01603 MechStatus(mech) |= ts; 01604 } else 01605 weaponarc = InWeaponArc(mech, x, y); 01606 01607 switch (MechType(mech)) { 01608 case CLASS_MECH: 01609 case CLASS_BSUIT: 01610 case CLASS_MW: 01611 if(GetPartFireMode(mech, section, critical) & REAR_MOUNT) 01612 wantarc = REARARC; 01613 else if(section == LARM && (MechStatus(mech) & FLIPPED_ARMS)) 01614 wantarc = REARARC | LSIDEARC; 01615 else if(section == LARM) 01616 wantarc = FORWARDARC | LSIDEARC; 01617 else if(section == RARM && (MechStatus(mech) & FLIPPED_ARMS)) 01618 wantarc = REARARC | RSIDEARC; 01619 else if(section == RARM) 01620 wantarc = FORWARDARC | RSIDEARC; 01621 else 01622 wantarc = FORWARDARC; 01623 break; 01624 case CLASS_VEH_GROUND: 01625 case CLASS_VEH_NAVAL: 01626 case CLASS_VTOL: 01627 switch (section) { 01628 case TURRET: 01629 wantarc = TURRETARC; 01630 break; 01631 case FSIDE: 01632 wantarc = FORWARDARC; 01633 break; 01634 case LSIDE: 01635 wantarc = LSIDEARC; 01636 break; 01637 case RSIDE: 01638 wantarc = RSIDEARC; 01639 break; 01640 case BSIDE: 01641 wantarc = REARARC; 01642 break; 01643 } 01644 break; 01645 case CLASS_DS: 01646 switch (section) { 01647 case DS_NOSE: 01648 wantarc = FORWARDARC; 01649 break; 01650 case DS_LWING: 01651 case DS_LRWING: 01652 wantarc = LSIDEARC; 01653 break; 01654 case DS_RWING: 01655 case DS_RRWING: 01656 wantarc = RSIDEARC; 01657 break; 01658 case DS_AFT: 01659 wantarc = REARARC; 01660 break; 01661 } 01662 break; 01663 case CLASS_SPHEROID_DS: 01664 switch (section) { 01665 case DS_NOSE: 01666 wantarc = FORWARDARC; 01667 break; 01668 case DS_LWING: 01669 wantarc = FORWARDARC | LSIDEARC; 01670 break; 01671 case DS_LRWING: 01672 wantarc = REARARC | LSIDEARC; 01673 break; 01674 case DS_RWING: 01675 wantarc = FORWARDARC | RSIDEARC; 01676 break; 01677 case DS_RRWING: 01678 wantarc = REARARC | RSIDEARC; 01679 break; 01680 case DS_AFT: 01681 wantarc = REARARC; 01682 break; 01683 } 01684 break; 01685 01686 case CLASS_AERO: 01687 isrear = (GetPartFireMode(mech, section, critical) & REAR_MOUNT); 01688 switch (section) { 01689 case AERO_NOSE: 01690 wantarc = FORWARDARC | LSIDEARC | RSIDEARC; 01691 break; 01692 case AERO_LWING: 01693 wantarc = LSIDEARC | (isrear ? REARARC : FORWARDARC); 01694 break; 01695 case AERO_RWING: 01696 wantarc = RSIDEARC | (isrear ? REARARC : FORWARDARC); 01697 break; 01698 case AERO_AFT: 01699 wantarc = REARARC; 01700 break; 01701 } 01702 break; 01703 } 01704 return wantarc ? (wantarc & weaponarc) : 0; 01705 }
int IsLegDestroyed | ( | MECH * | objMech, | |
int | wLoc | |||
) |
Definition at line 2177 of file mech.utils.c.
References SectIsBreached, SectIsDestroyed, and SectIsFlooded.
Referenced by CountDestroyedLegs(), and NormalizeAllActuatorCrits().
02178 { 02179 return (SectIsDestroyed(objMech, wLoc) || SectIsBreached(objMech, wLoc) 02180 || SectIsFlooded(objMech, wLoc)); 02181 }
int IsMechLegLess | ( | MECH * | objMech | ) |
Definition at line 2183 of file mech.utils.c.
References CLASS_MECH, CountDestroyedLegs(), MechIsQuad, and MechType.
Referenced by bsuit_attackleg(), mech_enterbay(), and mech_move_event().
02184 { 02185 int wcMaxLegs = 0; 02186 02187 if(MechType(objMech) != CLASS_MECH) 02188 return 0; 02189 02190 if(MechIsQuad(objMech)) 02191 wcMaxLegs = 4; 02192 else 02193 wcMaxLegs = 2; 02194 02195 if(CountDestroyedLegs(objMech) >= wcMaxLegs) 02196 return 1; 02197 02198 return 0; 02199 }
Definition at line 183 of file mech.utils.c.
References auto_cal_mapindex(), MAP::cf, ContinueFlying, DOCHECKMA0, find_entrance_by_target(), FindObjectsData(), getMap(), getMech(), GetMechID(), GOD, In_Character, Location, loud_teleport, MECH::mapindex, mech_notify(), mech_printf(), mech_Rsetmapindex(), mech_Rsetxy(), mech_shutdown(), MECHALL, MechCarrying, MechLOSBroadcast(), MechPilot, MechSpeed, MechX, MechY, MirrorPosition, MMaxSpeed, SendError, StopBSuitSwarmers(), structure_name(), tprintf(), TYPE_LEAVE, mapobj_struct::x, and mapobj_struct::y.
Referenced by CheckEdgeOfMap().
00184 { 00185 MECH *car = NULL; 00186 int mapob; 00187 mapobj *mapo; 00188 00189 /* For now, leaving leads to finding yourself on the new map 00190 at a predetermined position */ 00191 mapob = mech->mapindex; 00192 if(MechCarrying(mech) > 0) 00193 car = getMech(MechCarrying(mech)); 00194 DOCHECKMA0(!map->cf, "The entrance is still filled with rubble!"); 00195 MechLOSBroadcast(mech, "has left the hangar."); 00196 mech_Rsetmapindex(GOD, (void *) mech, tprintf("%d", 00197 (int) map-> 00198 mapobj[TYPE_LEAVE]->obj)); 00199 if(car) 00200 mech_Rsetmapindex(GOD, (void *) car, tprintf("%d", 00201 (int) map-> 00202 mapobj[TYPE_LEAVE]-> 00203 obj)); 00204 map = getMap(mech->mapindex); 00205 if(mech->mapindex == mapob) { 00206 SendError(tprintf("#%d %s attempted to leave, but no target map?", 00207 mech->mynum, GetMechID(mech))); 00208 mech_notify(mech, MECHALL, 00209 "Exit of this map is.. fubared. Please contact a wizard"); 00210 return 0; 00211 } 00212 if(!(mapo = find_entrance_by_target(map, mapob))) { 00213 SendError(tprintf 00214 ("#%d %s attempted to leave, but no target place was found? setting the mech at 0,0 at %d.", 00215 mech->mynum, GetMechID(mech), mech->mapindex)); 00216 mech_notify(mech, MECHALL, 00217 "Weird bug happened during leave. Please contact a wizard. "); 00218 return 1; 00219 } 00220 00221 StopBSuitSwarmers(FindObjectsData(mech->mapindex), mech, 1); 00222 mech_printf(mech, MECHALL, "You have left %s.", structure_name(mapo)); 00223 mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", mapo->x, mapo->y)); 00224 ContinueFlying(mech); 00225 if(car) 00226 MirrorPosition(mech, car, 0); 00227 MechLOSBroadcast(mech, tprintf("has left %s at %d,%d.", 00228 structure_name(mapo), MechX(mech), 00229 MechY(mech))); 00230 loud_teleport(mech->mynum, mech->mapindex); 00231 if(car) 00232 loud_teleport(car->mynum, mech->mapindex); 00233 if(In_Character(mech->mynum) && Location(MechPilot(mech)) != mech->mynum) { 00234 mech_notify(mech, MECHALL, 00235 "%ch%cr%cf%ciINTRUDER ALERT! INTRUDER ALERT!%c"); 00236 mech_notify(mech, MECHALL, 00237 "%ch%cr%cfAutomatic self-destruct sequence initiated...%c"); 00238 mech_shutdown(GOD, (void *) mech, ""); 00239 } 00240 auto_cal_mapindex(mech); 00241 if(MechSpeed(mech) > MMaxSpeed(mech)) 00242 MechSpeed(mech) = MMaxSpeed(mech); 00243 return 1; 00244 }
int listmatch | ( | char ** | foo, | |
char * | mat | |||
) |
Definition at line 1713 of file mech.utils.c.
Referenced by do_show(), fun_btcharlist(), map_delobj(), and map_listmechs().
01714 { 01715 int i; 01716 01717 for(i = 0; foo[i]; i++) 01718 if(!strcasecmp(foo[i], mat)) 01719 return i; 01720 return -1; 01721 }
int MadePilotSkillRoll | ( | MECH * | mech, | |
int | mods | |||
) |
Definition at line 610 of file mech.utils.c.
References MadePilotSkillRoll_Advanced().
Referenced by aero_update(), bomb_drop(), bsuit_attackleg(), bsuit_swarm(), ChargeMech(), check_stagger_event(), CheckDamage(), DeathFromAbove(), DestroyParts(), DoVehicleEngineHit(), fun_btmakepilotroll(), HandleMechCrit(), HandleOverheat(), HandleVTOLCrit(), LandMech(), mech_bootlegger(), mech_drop(), mech_jump(), mech_land(), mech_stand(), mech_unjam_ammo_event(), MechFalls(), NewHexEntered(), PhysicalAttack(), PhysicalDamage(), PhysicalTrip(), StopSwarming(), and UpdatePilotSkillRolls().
00611 { 00612 return MadePilotSkillRoll_Advanced(mech, mods, 1); 00613 }
int MadePilotSkillRoll_Advanced | ( | MECH * | mech, | |
int | mods, | |||
int | succeedWhenFallen | |||
) |
Definition at line 648 of file mech.utils.c.
References AccumulatePilXP(), Blinded, BOUNDED(), Fallen, FindSPilotPiloting(), MAX, mech_notify(), mech_printf(), MECHPILOT, MechPilot, MechPilotSkillBase, MechPilotSkillRoll_BTH(), Roll(), SendDebug, Started, tprintf(), and Uncon.
Referenced by MadePilotSkillRoll().
00649 { 00650 int roll, roll_needed; 00651 00652 if(Fallen(mech) && succeedWhenFallen) 00653 return 1; 00654 if(Uncon(mech) || !Started(mech) || Blinded(mech)) 00655 return 0; 00656 roll = Roll(); 00657 roll_needed = MechPilotSkillRoll_BTH(mech, mods); 00658 00659 SendDebug(tprintf("Attempting to make pilot (noxp) skill roll. " 00660 "SPilot: %d, mods: %d, MechPilot: %d, BTH: %d", 00661 FindSPilotPiloting(mech), mods, 00662 MechPilotSkillBase(mech), roll_needed)); 00663 00664 mech_notify(mech, MECHPILOT, "You make a piloting skill roll!"); 00665 mech_printf(mech, MECHPILOT, 00666 "Modified Pilot Skill: BTH %d\tRoll: %d", roll_needed, roll); 00667 if(roll >= roll_needed) { 00668 if(roll_needed > 2) 00669 AccumulatePilXP(MechPilot(mech), mech, BOUNDED(1, 00670 roll_needed - 7, 00671 MAX(2, 1 + mods)), 00672 1); 00673 return 1; 00674 } 00675 return 0; 00676 }
int MadePilotSkillRoll_NoXP | ( | MECH * | mech, | |
int | mods, | |||
int | succeedWhenFallen | |||
) |
Definition at line 623 of file mech.utils.c.
References Blinded, Fallen, FindSPilotPiloting(), mech_notify(), mech_printf(), MECHPILOT, MechPilotSkillBase, MechPilotSkillRoll_BTH(), Roll(), SendDebug, Started, tprintf(), and Uncon.
Referenced by NewHexEntered().
00624 { 00625 int roll, roll_needed; 00626 00627 if(Fallen(mech) && succeedWhenFallen) 00628 return 1; 00629 if(Uncon(mech) || !Started(mech) || Blinded(mech)) 00630 return 0; 00631 roll = Roll(); 00632 roll_needed = MechPilotSkillRoll_BTH(mech, mods); 00633 00634 SendDebug(tprintf("Attempting to make pilot skill roll. " 00635 "SPilot: %d, mods: %d, MechPilot: %d, BTH: %d", 00636 FindSPilotPiloting(mech), mods, 00637 MechPilotSkillBase(mech), roll_needed)); 00638 00639 mech_notify(mech, MECHPILOT, "You make a piloting skill roll!"); 00640 mech_printf(mech, MECHPILOT, 00641 "Modified Pilot Skill: BTH %d\tRoll: %d", roll_needed, roll); 00642 if(roll >= roll_needed) { 00643 return 1; 00644 } 00645 return 0; 00646 }
void MapCoordToRealCoord | ( | int | hex_x, | |
int | hex_y, | |||
float * | cart_x, | |||
float * | cart_y | |||
) |
Definition at line 854 of file mech.utils.c.
References ALPHA, FULL_Y, and HALF_Y.
Referenced by add_mine_on_map(), aero_checklz(), artillery_direction(), artillery_shoot(), auto_astar_generate_path(), auto_goto_event(), auto_roam_generate_target_hex(), blast_hit_hex(), blast_hit_hexes(), blast_hit_hexesf(), CheckEdgeOfMap(), determineDamageFromHit(), figure_out_range_and_bearing(), findC3RangeWithNetwork(), FindTargetXY(), FireSpot(), FireWeaponNumber(), fun_btgetrange(), fun_bthexinblz(), fun_bthexlos(), fun_btmapemit(), fun_btmapunits(), HexLOSBroadcast(), InLineOfSight(), is_blocked_lz(), mech_bearing(), mech_eta(), mech_findcenter(), mech_jump(), mech_range(), mech_report(), mech_Rsetmapindex(), mech_Rsetxy(), mech_scan(), mech_vector(), mechCentBearingfunc(), mechCentDistfunc(), MechSeesHex(), MechSeesRange(), MechSLitesRange(), move_mech(), navigate_sketch_mechs(), possible_mine_explosion(), Sensor_DoWeSeeNow(), simulate_flight(), and updateAutoturnTurret().
00855 { 00856 /* TODO: Can use some integer math if we're careful about overflow. */ 00857 *cart_x = (2.f + 3.f * (float)hex_x) * ALPHA; 00858 *cart_y = ((hex_x & 0x1) ? 0 : HALF_Y) + ((float)hex_y * FULL_Y); 00859 }
void MarkForLOSUpdate | ( | MECH * | mech | ) |
Definition at line 2042 of file mech.utils.c.
References getMap(), MECH::mapindex, MECH::mapnumber, MAP::mechflags, and MAP::moves.
Referenced by auto_sensor_event(), break_thru_ice(), changeNullSigSysEvent(), changeStealthArmorEvent(), checkECM(), CheckNavalHeight(), HandleMechCrit(), initiate_ood(), mech_angeleccm(), mech_angelecm(), mech_eccm(), mech_ecm(), mech_embark(), mech_enter_event(), mech_enterbay_event(), mech_fall_event(), mech_ood_event(), mech_pereccm(), mech_perecm(), mech_rotatetorso(), mech_Rsetxy(), mech_sensorchange_event(), mech_startup_event(), mech_turret(), mech_udisembark(), MechFalls(), MechSliteChangeEvent(), move_mech(), updateAutoturnTurret(), UpdateHeading(), and UpdateMechsTerrain().
02043 { 02044 MAP *mech_map; 02045 02046 if(!(mech_map = getMap(mech->mapindex))) 02047 return; 02048 mech_map->moves++; 02049 mech_map->mechflags[mech->mapnumber] = 1; 02050 }
void mech_Detach | ( | MECH * | mech, | |
int | loc | |||
) |
Definition at line 2004 of file mech.utils.c.
References DestroySection(), and SectIsDestroyed.
Referenced by muxevent_tickmech_removesection().
02005 { 02006 if(SectIsDestroyed(mech, loc)) 02007 return; 02008 DestroySection(mech, NULL, 0, loc); 02009 }
void mech_FillPartAmmo | ( | MECH * | mech, | |
int | loc, | |||
int | pos | |||
) |
Definition at line 2013 of file mech.utils.c.
References Ammo2Weapon, FullAmmo(), GetPartType, IsAmmo, MechWeapons, and SetPartData.
Referenced by muxevent_tickmech_reload().
02014 { 02015 int t, to; 02016 02017 t = GetPartType(mech, loc, pos); 02018 02019 if(!IsAmmo(t)) 02020 return; 02021 if(!(to = MechWeapons[Ammo2Weapon(t)].ammoperton)) 02022 return; 02023 SetPartData(mech, loc, pos, FullAmmo(mech, loc, pos)); 02024 }
void mech_ReAttach | ( | MECH * | mech, | |
int | loc | |||
) |
Definition at line 1953 of file mech.utils.c.
References CLASS_MECH, DESTROYED, GetSectOInt, is_aero, IsDS, MechStatus, MechType, no_locations_destroyed(), SectIsDestroyed, SetSectInt, UnSetSectDestroyed, and UnSetSectFlooded.
Referenced by muxevent_tickmech_reattach().
01954 { 01955 if(!SectIsDestroyed(mech, loc)) 01956 return; 01957 UnSetSectDestroyed(mech, loc); 01958 UnSetSectFlooded(mech, loc); 01959 SetSectInt(mech, loc, GetSectOInt(mech, loc)); 01960 if(is_aero(mech)) 01961 SetSectInt(mech, loc, 1); 01962 if(MechType(mech) != CLASS_MECH) { 01963 if(no_locations_destroyed(mech) && IsDS(mech)) 01964 MechStatus(mech) &= ~DESTROYED; 01965 return; 01966 } 01967 }
void mech_RepairPart | ( | MECH * | mech, | |
int | loc, | |||
int | pos | |||
) |
Definition at line 1902 of file mech.utils.c.
References ANGELECM, ARTEMIS_IV, BEAGLE_PROBE, BLOODHOUND_PROBE, C3_MASTER, C3_SLAVE, C3I, CLASS_MECH, COCKPIT, do_magic(), ECM, ENGINE, GetPartFireMode, GetPartType, GYRO, HAND_OR_FOOT_ACTUATOR, HEAT_SINK, IS_JETTISONED_MODE, IsAmmo, IsSpecial, IsWeapon, JUMP_JET, LIFE_SUPPORT, LOWER_ACTUATOR, MechType, NULL_SIGNATURE_SYSTEM, OS_USED, ROCKET_FIRED, SENSORS, SetPartData, SHOULDER_OR_HIP, Special2I, TAG, TARGETING_COMPUTER, UnDestroyPart, and UPPER_ACTUATOR.
Referenced by apply_mechDamage(), mech_ReSeal(), muxevent_tickmech_repairgun(), muxevent_tickmech_repairpart(), and muxevent_tickmech_replacegun().
01903 { 01904 int t = GetPartType(mech, loc, pos); 01905 01906 UnDestroyPart(mech, loc, pos); 01907 if(IsWeapon(t) || IsAmmo(t)) { 01908 SetPartData(mech, loc, pos, 0); 01909 GetPartFireMode(mech, loc, pos) &= 01910 ~(OS_USED | IS_JETTISONED_MODE | ROCKET_FIRED); 01911 } else if(IsSpecial(t)) { 01912 switch (Special2I(t)) { 01913 case TARGETING_COMPUTER: 01914 case HEAT_SINK: 01915 case LIFE_SUPPORT: 01916 case COCKPIT: 01917 case SENSORS: 01918 case JUMP_JET: 01919 case ENGINE: 01920 case GYRO: 01921 case SHOULDER_OR_HIP: 01922 case LOWER_ACTUATOR: 01923 case UPPER_ACTUATOR: 01924 case HAND_OR_FOOT_ACTUATOR: 01925 case C3_MASTER: 01926 case C3_SLAVE: 01927 case C3I: 01928 case ECM: 01929 case ANGELECM: 01930 case NULL_SIGNATURE_SYSTEM: 01931 case BEAGLE_PROBE: 01932 case ARTEMIS_IV: 01933 case TAG: 01934 case BLOODHOUND_PROBE: 01935 /* Magic stuff here :P */ 01936 if(MechType(mech) == CLASS_MECH) 01937 do_magic(mech); 01938 break; 01939 } 01940 } 01941 }
void mech_ReplaceSuit | ( | MECH * | mech, | |
int | loc | |||
) |
Definition at line 1969 of file mech.utils.c.
References GetSectOInt, SectIsDestroyed, SetSectInt, and UnSetSectDestroyed.
Referenced by muxevent_tickmech_replacesuit().
01970 { 01971 if(!SectIsDestroyed(mech, loc)) 01972 return; 01973 01974 UnSetSectDestroyed(mech, loc); 01975 SetSectInt(mech, loc, GetSectOInt(mech, loc)); 01976 }
void mech_ReSeal | ( | MECH * | mech, | |
int | loc | |||
) |
Definition at line 1983 of file mech.utils.c.
References CritsInLoc(), mech_RepairPart(), PartIsBroken, PartIsDamaged, PartIsDisabled, SectIsDestroyed, SectIsFlooded, UnDisablePart, and UnSetSectFlooded.
Referenced by muxevent_tickmech_reseal().
01984 { 01985 int i; 01986 01987 if(SectIsDestroyed(mech, loc)) 01988 return; 01989 if(!SectIsFlooded(mech, loc)) 01990 return; 01991 01992 UnSetSectFlooded(mech, loc); 01993 01994 for(i = 0; i < CritsInLoc(mech, loc); i++) { 01995 if(PartIsDisabled(mech, loc, i)) { 01996 if(!PartIsBroken(mech, loc, i) && !PartIsDamaged(mech, loc, i)) 01997 mech_RepairPart(mech, loc, i); 01998 else 01999 UnDisablePart(mech, loc, i); 02000 } 02001 } 02002 }
int MechFullNoRecycle | ( | MECH * | mech, | |
int | num | |||
) |
Definition at line 3504 of file mech.utils.c.
References CHECK_PHYS, CHECK_WEAPS, MechSections, and SectHasBusyWeap().
Referenced by mech_embark().
03504 { 03505 int i; 03506 03507 for(i = 0; i < NUM_SECTIONS; i++) { 03508 if(num & CHECK_WEAPS && SectHasBusyWeap(mech, i)) 03509 return 1; 03510 if(num & CHECK_PHYS && MechSections(mech)[i].recycle > 0) 03511 return 2; 03512 } 03513 return 0; 03514 }
char* MechIDS | ( | MECH * | mech, | |
int | islower | |||
) |
Definition at line 75 of file mech.utils.c.
References MechID.
Referenced by auto_com_event(), auto_command_embark(), auto_command_pickup(), auto_set_comtitle(), GetMechID(), GetMechToMechID(), GetMechToMechID_base(), map_listmechs(), mech_contacts(), mech_spot(), PrintGenericStatus(), PrintReport(), sendC3TrackEmit(), sendchannelstuff(), showNetworkData(), showNetworkTargets(), and sketch_tac_mechs().
00076 { 00077 static char buf[3]; 00078 00079 if(mech) { 00080 buf[0] = MechID(mech)[0]; 00081 buf[1] = MechID(mech)[1]; 00082 } else { 00083 buf[0] = '*'; 00084 buf[1] = '*'; 00085 } 00086 buf[2] = 0; 00087 00088 if(islower) { 00089 buf[0] = tolower(buf[0]); 00090 buf[1] = tolower(buf[1]); 00091 } 00092 return buf; 00093 }
int MechPilotSkillRoll_BTH | ( | MECH * | mech, | |
int | mods | |||
) |
Definition at line 615 of file mech.utils.c.
References FindSPilotPiloting(), In_Character, Location, MechPilot, MechPilotSkillBase, and MECH::mynum.
Referenced by MadePilotSkillRoll_Advanced(), MadePilotSkillRoll_NoXP(), and mech_stand().
00616 { 00617 mods += FindSPilotPiloting(mech) + MechPilotSkillBase(mech); 00618 if(In_Character(mech->mynum) && Location(MechPilot(mech)) != mech->mynum) 00619 mods += 5; 00620 return mods; 00621 }
const char* mechtypename | ( | MECH * | foo | ) |
Definition at line 61 of file mech.utils.c.
References MechType, and mechtypenames.
00062 { 00063 return mechtypenames[(int) MechType(foo)]; 00064 }
int MNumber | ( | MECH * | mech, | |
int | low, | |||
int | high | |||
) |
Definition at line 66 of file mech.utils.c.
References MechLastRndU, MechRnd, muxevent_tick, random, and RANDOM_TICK.
00067 { 00068 if((muxevent_tick / RANDOM_TICK) != MechLastRndU(mech)) { 00069 MechRnd(mech) = random(); 00070 MechLastRndU(mech) = muxevent_tick / RANDOM_TICK; 00071 } 00072 return (low + MechRnd(mech) % (high - low + 1)); 00073 }
void multi_weap_sel | ( | MECH * | mech, | |
dbref | player, | |||
char * | buffer, | |||
int | bitbybit, | |||
int(*)(MECH *, dbref, int, int) | foo | |||
) |
Definition at line 2052 of file mech.utils.c.
References c, DOCHECK, FindWeaponNumberOnMech(), MAX_WEAPONS_PER_MECH, multi_weap_sel(), NUM_TICS, Readnum, skipws, and tprintf().
Referenced by addtic_sub(), cleartic_sub(), deltic_sub(), firetic_sub(), mech_disableweap(), mech_snipe(), mech_toggle_mode_sub(), mech_unjamammo(), and multi_weap_sel().
02054 { 02055 /* Insight: buffer contains stuff in form: 02056 <num> 02057 <num>-<num> 02058 <num>,.. 02059 <num>-<num>,.. 02060 */ 02061 /* Ugly recursive piece of code :> */ 02062 char *c; 02063 int i1, i2, i3; 02064 int section, critical; 02065 02066 skipws(buffer); 02067 if((c = strstr(buffer, ","))) { 02068 *c = 0; 02069 c++; 02070 } 02071 if(sscanf(buffer, "%d-%d", &i1, &i2) == 2) { 02072 DOCHECK(i1 < 0 || 02073 i1 >= MAX_WEAPONS_PER_MECH, 02074 tprintf("Invalid first number in range (%d)", i1)); 02075 DOCHECK(i2 < 0 || 02076 i2 >= MAX_WEAPONS_PER_MECH, 02077 tprintf("Invalid second number in range (%d)", i2)); 02078 if(i1 > i2) { 02079 i3 = i1; 02080 i1 = i2; 02081 i2 = i3; 02082 } 02083 } else { 02084 DOCHECK(Readnum(i1, buffer), tprintf("Invalid value: %s", buffer)); 02085 DOCHECK(i1 < 0 || 02086 i1 >= MAX_WEAPONS_PER_MECH, 02087 tprintf("Invalid weapon number: %d", i1)); 02088 i2 = i1; 02089 } 02090 if(bitbybit / 2) { 02091 DOCHECK(i2 >= NUM_TICS, tprintf("There are only %d tics!", i2)); 02092 } else { 02093 DOCHECK(!(FindWeaponNumberOnMech(mech, i2, §ion, 02094 &critical) != -1), 02095 tprintf("Error: the mech doesn't HAVE %d weapons!", i2 + 1)); 02096 } 02097 if(bitbybit % 2) { 02098 for(i3 = i1; i3 <= i2; i3++) 02099 if(foo(mech, player, i3, i3)) 02100 return; 02101 } else if(foo(mech, player, i1, i2)) 02102 return; 02103 if(c) 02104 multi_weap_sel(mech, player, c, bitbybit, foo); 02105 }
int MyHexDist | ( | int | x1, | |
int | y1, | |||
int | x2, | |||
int | y2, | |||
int | tc | |||
) |
Definition at line 2116 of file mech.utils.c.
Referenced by ai_path_score(), blast_hit_hexesf(), and DS_BlastNearbyMechsAndTrees().
02117 { 02118 int xd = abs(x2 - x1); 02119 int yd = abs(y2 - y1); 02120 int hm; 02121 02122 /* _the_ base case */ 02123 if(x1 == x2) 02124 return yd; 02125 /* 02126 + 02127 + 02128 + 02129 + 02130 */ 02131 if((hm = (xd / 2)) <= yd) 02132 return (yd - hm) + tc + xd; 02133 02134 /* 02135 + + 02136 + + 02137 + + 02138 + 02139 */ 02140 if(!yd) 02141 return (xd + tc); 02142 /* 02143 + 02144 + 02145 + + 02146 + + 02147 + 02148 */ 02149 /* For now, same as above */ 02150 return (xd + tc); 02151 }
char* MyToUpper | ( | char * | string | ) |
Definition at line 95 of file mech.utils.c.
Referenced by damage_cf(), show_building_in_hex(), and steppable_base_check().
void navigate_sketch_mechs | ( | MECH * | mech, | |
MAP * | map, | |||
int | x, | |||
int | y, | |||
char | buff[NAVIGATE_LINES][MBUF_SIZE] | |||
) |
Definition at line 884 of file mech.utils.c.
References ALPHA, FindObjectsData(), MAP::first_free, HALF_Y, InLineOfSight(), MapCoordToRealCoord(), MechFX, MechFY, MechSeemsFriend, MAP::mechsOnMap, MechX, MechY, NAV_COLUMN_WIDTH, NAV_MAX_HEIGHT, NAV_MAX_WIDTH, NAV_ROW_HEIGHT, NAV_X_OFFSET, and NAV_Y_OFFSET.
Referenced by mech_navigate().
00886 { 00887 float corner_fx, corner_fy, fx, fy; 00888 int i, row, column; 00889 MECH *other; 00890 00891 MapCoordToRealCoord(x, y, &corner_fx, &corner_fy); 00892 corner_fx -= 2 * ALPHA; 00893 corner_fy -= HALF_Y; 00894 00895 for(i = 0; i < map->first_free; i++) { 00896 if(map->mechsOnMap[i] < 0) 00897 continue; 00898 if(!(other = FindObjectsData(map->mechsOnMap[i]))) 00899 continue; 00900 if(other == mech) 00901 continue; 00902 if(MechX(other) != x || MechY(other) != y) 00903 continue; 00904 if(!InLineOfSight(mech, other, x, y, 0.5)) 00905 continue; 00906 00907 fx = MechFX(other) - corner_fx; 00908 column = fx / NAV_COLUMN_WIDTH + NAV_X_OFFSET; 00909 00910 fy = MechFY(other) - corner_fy; 00911 row = fy / NAV_ROW_HEIGHT + NAV_Y_OFFSET; 00912 00913 if(column < 0 || column > NAV_MAX_WIDTH || 00914 row < 0 || row > NAV_MAX_HEIGHT) 00915 continue; 00916 00917 buff[row][column] = MechSeemsFriend(mech, other) ? 'x' : 'X'; 00918 } 00919 00920 /* Draw 'mech last so we always see it. */ 00921 00922 fx = MechFX(mech) - corner_fx; 00923 column = fx / NAV_COLUMN_WIDTH + NAV_X_OFFSET; 00924 00925 fy = MechFY(mech) - corner_fy; 00926 row = fy / NAV_ROW_HEIGHT + NAV_Y_OFFSET; 00927 00928 if(column < 0 || column > NAV_MAX_WIDTH || 00929 row < 0 || row > NAV_MAX_HEIGHT) 00930 return; 00931 00932 buff[row][column] = '*'; 00933 }
int no_locations_destroyed | ( | MECH * | mech | ) |
Definition at line 1943 of file mech.utils.c.
References GetSectOInt, NUM_SECTIONS, and SectIsDestroyed.
Referenced by mech_ReAttach().
01944 { 01945 int i; 01946 01947 for(i = 0; i < NUM_SECTIONS; i++) 01948 if(GetSectOInt(mech, i) && SectIsDestroyed(mech, i)) 01949 return 0; 01950 return 1; 01951 }
char** ProperSectionStringFromType | ( | int | type, | |
int | mtype | |||
) |
Definition at line 1528 of file mech.utils.c.
References aero_locs, bsuit_locs, CLASS_AERO, CLASS_BSUIT, CLASS_DS, CLASS_MECH, CLASS_MW, CLASS_SPHEROID_DS, CLASS_VEH_GROUND, CLASS_VEH_NAVAL, CLASS_VTOL, ds_locs, ds_spher_locs, mech_locs, MOVE_QUAD, quad_locs, and veh_locs.
Referenced by ArmorSectionFromString(), armorstatus_func(), ArmorStringFromIndex(), find_section(), save_template(), and ShortArmorSectionString().
01529 { 01530 switch (type) { 01531 case CLASS_BSUIT: 01532 return bsuit_locs; 01533 case CLASS_MECH: 01534 case CLASS_MW: 01535 if(mtype == MOVE_QUAD) 01536 return quad_locs; 01537 return mech_locs; 01538 case CLASS_VEH_GROUND: 01539 case CLASS_VEH_NAVAL: 01540 case CLASS_VTOL: 01541 return veh_locs; 01542 case CLASS_AERO: 01543 return aero_locs; 01544 case CLASS_SPHEROID_DS: 01545 return ds_spher_locs; 01546 case CLASS_DS: 01547 return ds_locs; 01548 } 01549 return NULL; 01550 }
void RealCoordToMapCoord | ( | short * | hex_x, | |
short * | hex_y, | |||
float | cart_x, | |||
float | cart_y | |||
) |
Definition at line 769 of file mech.utils.c.
References ALPHA, ANGLE_ALPHA, FULL_Y, HALF_Y, ROOT3, SCALEMAP, x, and y.
Referenced by ai_crash(), auto_astar_follow_event(), auto_astar_generate_path(), auto_roam_generate_target_hex(), blast_hit_hexesf(), blast_hit_hexf(), calc_dest(), mech_jump(), move_mech(), parse_tacargs(), and simulate_flight().
00771 { 00772 float x, y; 00773 int x_count, y_count; 00774 00775 if(cart_x < ALPHA) { 00776 /* Special case: we are in section IV of x-column 0 or off the map */ 00777 *hex_x = cart_x < 0 ? -1 : 0; 00778 *hex_y = floor(cart_y / SCALEMAP); 00779 return; 00780 } 00781 00782 /* 'shift' the map to the left so the repeatable box starts at 0 */ 00783 cart_x -= ALPHA; 00784 00785 /* Figure out the x-coordinate of the 'repeatable box' we're in. */ 00786 x_count = cart_x / ROOT3; 00787 /* And the offset inside the box, from the left edge. */ 00788 x = cart_x - x_count * ROOT3; 00789 00790 /* The repbox holds two x-columns, we want the real X coordinate. */ 00791 x_count *= 2; 00792 00793 /* Do the same for the y-coordinate; this is easy */ 00794 y_count = floor(cart_y / FULL_Y); 00795 y = cart_y - y_count * FULL_Y; 00796 00797 if(x < 2 * ALPHA) { 00798 00799 /* Clean in area I. Nothing to do */ 00800 00801 } else if(x >= 3 * ALPHA && x < 5 * ALPHA) { 00802 /* Clean in either area II or III. Up x one, and y if in the lower 00803 half of the box. */ 00804 x_count++; 00805 if(y >= HALF_Y) 00806 /* Area II */ 00807 y_count++; 00808 00809 } else if(x >= 2 * ALPHA && x < 3 * ALPHA) { 00810 /* Any of areas I, II and III. */ 00811 if(y >= HALF_Y) { 00812 /* Area I or II */ 00813 if(2 * ANGLE_ALPHA * (FULL_Y - y) <= x - 2 * ALPHA) { 00814 /* Area II, up both */ 00815 x_count++; 00816 y_count++; 00817 } 00818 } else { 00819 /* Area I or III */ 00820 if(2 * ANGLE_ALPHA * y <= x - 2 * ALPHA) 00821 /* Area III, up only x */ 00822 x_count++; 00823 } 00824 } else if(y >= HALF_Y) { 00825 /* Area II or IV. Up x at least one, maybe two, and y maybe one. */ 00826 x_count++; 00827 if(2 * ANGLE_ALPHA * (y - HALF_Y) > (x - 5.0 * ALPHA)) 00828 /* Area II */ 00829 y_count++; 00830 else 00831 /* Area IV */ 00832 x_count++; 00833 } else { 00834 /* Area III or IV, up x at least one, maybe two */ 00835 x_count++; 00836 if(2 * ANGLE_ALPHA * y > ROOT3 - x) 00837 /* Area IV */ 00838 x_count++; 00839 } 00840 00841 *hex_x = x_count; 00842 *hex_y = y_count; 00843 }
int Roll | ( | void | ) |
Definition at line 2107 of file mech.utils.c.
References Number, stat_type::rolls, rollstat, and stat_type::totrolls.
Referenced by AMSMissiles(), bsuit_attackleg(), cause_armordamage(), cause_internaldamage(), ChargeMech(), CheckDamage(), checkVehicleInFire(), DamageMech(), DeathFromAbove(), DestroyParts(), do_scramble(), DoMotiveSystemHit(), FindAdvFasaVehicleHitLocation(), FindFasaHitLocation(), FindHitLocation(), FindHitLocation_CritProof(), FindSwarmHitLocation(), FireWeapon(), HandleAdvFasaVehicleCrit(), HandleOverheat(), heat_effect(), hit_building(), HitTarget(), MadePerceptionRoll(), MadePilotSkillRoll_Advanced(), MadePilotSkillRoll_NoXP(), mech_masc_event(), mech_ood_event(), mech_scharge_event(), mech_unjam_ammo_event(), MissileHitIndex(), PhysicalAttack(), possibly_clear(), possibly_ignite(), possibly_ignite_or_clear(), possibly_remove_mines(), PossiblyBreach(), remove_inarc_pods_mech(), scoreEnhancedWeaponCriticalHit(), sixth_sense_check(), SwarmHitTarget(), tech_roll(), and tech_weapon_roll().
02108 { 02109 int i = Number(1, 6) + Number(1, 6); 02110 02111 rollstat.rolls[i - 2]++; 02112 rollstat.totrolls++; 02113 return i; 02114 }
int SectHasBusyWeap | ( | MECH * | mech, | |
int | sect | |||
) |
Definition at line 119 of file mech.utils.c.
References FindWeapons, MAX_WEAPS_SECTION, and WpnIsRecycling.
Referenced by ChargeMech(), checkGrabClubLocation(), DeathFromAbove(), doBSuitCommonChecks(), FireWeaponNumber(), mech_bootlegger(), mech_club(), mech_explode(), mech_thrash(), mech_unjamammo_func(), MechFullNoRecycle(), PhysicalAttack(), and remove_inarc_pods_mech().
00120 { 00121 int i = 0, count, critical[MAX_WEAPS_SECTION]; 00122 unsigned char weaptype[MAX_WEAPS_SECTION]; 00123 unsigned char weapdata[MAX_WEAPS_SECTION]; 00124 00125 count = FindWeapons(mech, sect, weaptype, weapdata, critical); 00126 for(i = 0; i < count; i++) 00127 if(WpnIsRecycling(mech, sect, critical[i])) 00128 return 1; 00129 return 0; 00130 }
Definition at line 132 of file mech.utils.c.
References A_XTYPE, DOCHECKN, getMap(), Good_obj, and silly_atr_get().
Referenced by mech_Rsetmapindex(), mech_Rsetteam(), and move_mech().
00133 { 00134 char *str; 00135 MAP *maps; 00136 00137 DOCHECKN(!Good_obj(map), "Index out of range!"); 00138 str = silly_atr_get(map, A_XTYPE); 00139 DOCHECKN(!str || !*str, "That is not a valid map! (no XTYPE!)"); 00140 DOCHECKN(strcmp("MAP", str), "That is not a valid map!"); 00141 DOCHECKN(!(maps = getMap(map)), "The map has not been allocated!!"); 00142 return maps; 00143 }
Definition at line 2527 of file mech.utils.c.
References MAP::map_height, MAP::map_width, and NUM_NEIGHBORS.
Referenced by artillery_hit_neighbors(), growable(), ImproperLZ(), litemark_map(), and meltable().
02529 { 02530 int x1, y1; 02531 int i; 02532 02533 for(i = 0; i < NUM_NEIGHBORS; i++) { 02534 x1 = tx + dirs[i][0]; 02535 y1 = ty + dirs[i][1]; 02536 if(tx % 2 && !(x1 % 2)) 02537 y1--; 02538 if(x1 < 0 || x1 >= map->map_width || y1 < 0 || y1 >= map->map_height) 02539 continue; 02540 callback(map, x1, y1); 02541 } 02542 }
int WeaponIsNonfunctional | ( | MECH * | mech, | |
int | section, | |||
int | crit, | |||
int | numcrits | |||
) |
Definition at line 3714 of file mech.utils.c.
References GetPartType, GetWeaponCrits(), PartIsDestroyed, PartIsDisabled, and Weapon2I.
03715 { 03716 int sum = 0, disabled = 0, dested = 0; 03717 03718 if(numcrits <= 0) 03719 numcrits = 03720 GetWeaponCrits(mech, 03721 Weapon2I(GetPartType 03722 (mech, section, crit))); 03723 03724 while (sum < numcrits) { 03725 if(PartIsDestroyed(mech, section, crit + sum)) 03726 dested++; 03727 else if(PartIsDisabled(mech, section, crit + sum)) 03728 disabled++; 03729 sum++; 03730 } 03731 03732 if(disabled > 0) 03733 return 1; 03734 03735 if((numcrits == 1 && (dested || disabled)) || 03736 (numcrits > 1 && (dested + disabled) >= numcrits / 2)) 03737 return 2; 03738 03739 if(dested) 03740 return 0 - (dested + disabled); 03741 03742 return 0; 03743 }
char* aero_locs[NUM_AERO_SECTIONS+1] |
Initial value:
{ "Nose", "Left Wing", "Right Wing", "Aft Side", NULL }
Definition at line 1500 of file mech.utils.c.
Referenced by ProperSectionStringFromType().
char* bsuit_locs[NUM_BSUIT_MEMBERS+1] |
Initial value:
{ "Suit 1", "Suit 2", "Suit 3", "Suit 4", "Suit 5", "Suit 6", "Suit 7", "Suit 8", NULL }
Definition at line 1478 of file mech.utils.c.
Referenced by ProperSectionStringFromType().
int dirs[6][2] |
Initial value:
{ {0, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0} }
Definition at line 2518 of file mech.utils.c.
char* ds_locs[NUM_DS_SECTIONS+1] |
Initial value:
{ "Right Wing", "Left Wing", "Left Rear Wing", "Right Rear Wing", "Aft", "Nose", NULL }
Definition at line 1508 of file mech.utils.c.
Referenced by ProperSectionStringFromType().
char* ds_spher_locs[NUM_DS_SECTIONS+1] |
Initial value:
{ "Front Right Side", "Front Left Side", "Rear Left Side", "Rear Right Side", "Aft", "Nose", NULL }
Definition at line 1518 of file mech.utils.c.
Referenced by ProperSectionStringFromType().
int global_silence = 0 |
Definition at line 956 of file mech.utils.c.
char* mech_locs[NUM_SECTIONS+1] |
Initial value:
{ "Left Arm", "Right Arm", "Left Torso", "Right Torso", "Center Torso", "Left Leg", "Right Leg", "Head", NULL }
Definition at line 1466 of file mech.utils.c.
Referenced by ProperSectionStringFromType().
char* mechtypenames[CLASS_LAST+1] |
Initial value:
{ "mech", "tank", "VTOL", "vessel", "aerofighter", "DropShip" }
Definition at line 57 of file mech.utils.c.
Referenced by mechtypename().
Definition at line 22 of file ds.turret.c.
char* quad_locs[NUM_SECTIONS+1] |
Initial value:
{ "Front Left Leg", "Front Right Leg", "Left Torso", "Right Torso", "Center Torso", "Rear Left Leg", "Rear Right Leg", "Head", NULL }
Definition at line 1454 of file mech.utils.c.
Referenced by ProperSectionStringFromType().
char* veh_locs[NUM_VEH_SECTIONS+1] |
Initial value:
{ "Left Side", "Right Side", "Front Side", "Aft Side", "Turret", "Rotor", NULL }
Definition at line 1490 of file mech.utils.c.
Referenced by ProperSectionStringFromType().