2222#include "failures.h"
2323#include "map.h"
2424#include "map_terrain.h"
25- #include "mech.h"
2625#include "mech_ammodump_api.h"
2726#include "mech_c3_api.h"
2827#include "mech_c3i_api.h"
28+ #include "mech_classification_api.h"
2929#include "mech_combat_misc_api.h"
30+ #include "mech_condition_api.h"
3031#include "mech_damage_api.h"
3132#include "mech_enhanced_criticals_api.h"
33+ #include "mech_equipment_api.h"
3234#include "mech_events.h"
3335#include "mech_events_api.h"
36+ #include "mech_identity_api.h"
3437#include "mech_lifecycle.h"
35- #include "mech_macros.h"
3638#include "mech_move_api.h"
3739#include "mech_notify.h"
3840#include "mech_notify_api.h"
3941#include "mech_pickup_api.h"
4042#include "mech_sensor.h"
43+ #include "mech_specification_api.h"
44+ #include "mech_status_types.h"
4145#include "mech_tag_api.h"
4246#include "mech_tech_commands_api.h"
4347#include "mech_update_api.h"
5054#include "mux/support/formatting.h"
5155#include "random.h"
5256#include "registry_api.h"
57+ #include "section_types.h"
5358
54- void HandleCritical (Mech * wounded , Mech * attacker , int LOS , int hitloc ,
55- int num ) {
59+ void mech_critical_handle (Mech * wounded , Mech * attacker , int LOS , int hitloc ,
60+ int num ) {
5661 int i ;
5762 int critHit ;
5863 int critType , critData ;
5964 int count , index ;
6065 int critList [NUM_CRITICALS ];
66+ BtechContext * context = mech_context (wounded );
67+ MechConditionSummary condition = mech_condition_summary (wounded );
6168
62- if (MechStatus ( wounded ) & COMBAT_SAFE )
69+ if (condition . combat_safe )
6370 return ;
64- if (MechSpecials (wounded ) & CRITPROOF_TECH )
71+ if (mech_technology_flags (wounded ) & CRITPROOF_TECH )
6572 return ;
66- if (MechType (wounded ) == CLASS_MW &&
67- btech_random_range (wounded -> xcode .context , 1 , 2 ) == 1 )
73+ if (mech_class (wounded ) == CLASS_MW && btech_random_range (context , 1 , 2 ) == 1 )
6874 return ;
69- if (MechType (wounded ) != CLASS_MECH &&
70- !wounded -> xcode . context -> configuration -> btech_vcrit )
75+ if (mech_class (wounded ) != CLASS_MECH &&
76+ !btech_context_vehicle_critical_mode ( context ) )
7177 return ;
72- if (MechType (wounded ) == CLASS_VEH_GROUND ||
73- MechType (wounded ) == CLASS_VEH_NAVAL ) {
74- if (wounded -> xcode . context -> configuration -> btech_fasaadvvhlcrit ) {
78+ if (mech_class (wounded ) == CLASS_VEH_GROUND ||
79+ mech_class (wounded ) == CLASS_VEH_NAVAL ) {
80+ if (btech_context_uses_advanced_vehicle_criticals ( context ) ) {
7581 for (i = 0 ; i < num ; i ++ )
7682 HandleAdvFasaVehicleCrit (wounded , attacker , LOS , hitloc , num );
7783
7884 return ;
79- } else if (!wounded -> xcode . context -> configuration -> btech_fasacrit ) {
85+ } else if (!btech_context_uses_fasa_criticals ( context ) ) {
8086 for (i = 0 ; i < num ; i ++ )
8187 HandleVehicleCrit (wounded , attacker , LOS , hitloc , num );
8288 return ;
83- } else if (wounded -> xcode . context -> configuration -> btech_fasacrit ) {
89+ } else if (btech_context_uses_fasa_criticals ( context ) ) {
8490 for (i = 0 ; i < num ; i ++ )
8591 HandleFasaVehicleCrit (wounded , attacker , LOS , hitloc , num );
8692 return ;
8793 }
8894 }
89- if (IsDS (wounded ))
95+ if (mech_is_dropship (wounded ))
9096 return ;
91- if (MechType (wounded ) == CLASS_VTOL ) {
92- if (wounded -> xcode . context -> configuration -> btech_fasaadvvtolcrit ) {
97+ if (mech_class (wounded ) == CLASS_VTOL ) {
98+ if (btech_context_uses_advanced_vtol_criticals ( context ) ) {
9399 for (i = 0 ; i < num ; i ++ )
94100 HandleAdvFasaVehicleCrit (wounded , attacker , LOS , hitloc , num );
95101
@@ -105,10 +111,11 @@ void HandleCritical(Mech *wounded, Mech *attacker, int LOS, int hitloc,
105111 count = 0 ;
106112 while (count == 0 ) {
107113 for (i = 0 ; i < NUM_CRITICALS ; i ++ ) {
108- critType = GetPartType (wounded , hitloc , i );
109- if (!PartIsDestroyed (wounded , hitloc , i ) &&
110- !PartIsDamaged (wounded , hitloc , i ) && critType != EMPTY &&
111- critType != Special (CASE ) && critType != Special (FERRO_FIBROUS ) &&
114+ critType = mech_critical_part_type (wounded , hitloc , i );
115+ if (!mech_critical_is_destroyed (wounded , hitloc , i ) &&
116+ !mech_critical_is_damaged (wounded , hitloc , i ) &&
117+ critType != EMPTY && critType != Special (CASE ) &&
118+ critType != Special (FERRO_FIBROUS ) &&
112119 critType != Special (STEALTH_ARMOR ) &&
113120 critType != Special (HVY_FERRO_FIBROUS ) &&
114121 critType != Special (LT_FERRO_FIBROUS ) &&
@@ -124,11 +131,11 @@ void HandleCritical(Mech *wounded, Mech *attacker, int LOS, int hitloc,
124131 return ;
125132 }
126133
127- index = btech_random_range (wounded -> xcode . context , 0 , count - 1 );
134+ index = btech_random_range (context , 0 , count - 1 );
128135 critHit = critList [index ]; /* This one should be linear */
129136
130- critType = GetPartType (wounded , hitloc , critHit );
131- critData = GetPartData (wounded , hitloc , critHit );
137+ critType = mech_critical_part_type (wounded , hitloc , critHit );
138+ critData = mech_critical_data (wounded , hitloc , critHit );
132139
133140 if (HandleMechCrit (wounded , attacker , LOS , hitloc , critHit , critType ,
134141 critData ))
0 commit comments