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"
2928#include "mech_combat_misc_api.h"
29+ #include "mech_condition_api.h"
3030#include "mech_damage_api.h"
3131#include "mech_enhanced_criticals_api.h"
32+ #include "mech_equipment_api.h"
3233#include "mech_events.h"
3334#include "mech_events_api.h"
35+ #include "mech_identity_api.h"
3436#include "mech_lifecycle.h"
35- #include "mech_macros.h"
3637#include "mech_move_api.h"
3738#include "mech_notify.h"
3839#include "mech_notify_api.h"
3940#include "mech_pickup_api.h"
4041#include "mech_sensor.h"
42+ #include "mech_specification_api.h"
4143#include "mech_tag_api.h"
4244#include "mech_tech_commands_api.h"
4345#include "mech_update_api.h"
5052#include "mux/support/formatting.h"
5153#include "random.h"
5254#include "registry_api.h"
55+ #include "section_types.h"
5356
54- void DestroyMainWeapon (Mech * mech ) {
57+ void mech_main_weapon_destroy (Mech * mech ) {
5558 unsigned char weaparray [MAX_WEAPS_SECTION ];
5659 unsigned char weapdata [MAX_WEAPS_SECTION ];
5760 int critical [MAX_WEAPS_SECTION ];
@@ -64,16 +67,17 @@ void DestroyMainWeapon(Mech *mech) {
6467 int critfound = 0 ;
6568 unsigned char maxtype = 0 ;
6669 int firstCrit = 0 ;
70+ BtechContext * context = mech_context (mech );
6771
6872 for (loop = 0 ; loop < NUM_SECTIONS ; loop ++ ) {
69- if (SectIsDestroyed (mech , loop ))
73+ if (mech_section_is_destroyed (mech , loop ))
7074 continue ;
71- count = FindWeapons (mech , loop , weaparray , weapdata , critical );
75+ count = FindWeapons_Advanced (mech , loop , weaparray , weapdata , critical , 1 );
7276 if (count > 0 ) {
7377 for (ii = 0 ; ii < count ; ii ++ ) {
74- if (!PartIsBroken (mech , loop , critical [ii ])) {
78+ if (!mech_critical_is_broken (mech , loop , critical [ii ])) {
7579 /* tempcrit = GetWeaponCrits(mech, weaparray[ii]); */
76- tempcrit = (int )btech_random_i31 ( & mech -> xcode . context -> random );
80+ tempcrit = (int )btech_context_random_i31 ( context );
7781 if (tempcrit > maxcrit ) {
7882 critfound = 1 ;
7983 maxcrit = tempcrit ;
@@ -93,13 +97,15 @@ void DestroyMainWeapon(Mech *mech) {
9397 }
9498}
9599
96- void HandleFasaVehicleCrit (Mech * wounded , Mech * attacker , int LOS , int hitloc ,
97- int num ) {
98- if (MechMove (wounded ) == MOVE_NONE )
100+ void mech_fasa_vehicle_critical_handle (Mech * wounded , Mech * attacker , int LOS ,
101+ int hitloc , int num ) {
102+ BtechContext * context = mech_context (wounded );
103+
104+ if (mech_movement_type (wounded ) == MOVE_NONE )
99105 return ;
100106
101107 mech_notify (wounded , MECHALL , "[fg=yellow bold]CRITICAL HIT![reset]" );
102- switch (btech_random_range (wounded -> xcode . context , 0 , 5 )) {
108+ switch (btech_random_range (context , 0 , 5 )) {
103109 case 0 :
104110 /* Crew stunned for one turn...treat like a head hit */
105111 headhitmwdamage (wounded , attacker , 1 );
@@ -136,37 +142,40 @@ void HandleFasaVehicleCrit(Mech *wounded, Mech *attacker, int LOS, int hitloc,
136142 if (wounded != attacker )
137143 mech_los_broadcast (wounded , "'s power plant suddenly explodes!" );
138144 DestroyMech (wounded , attacker , 1 , KILL_TYPE_POWERPLANT );
139- if (!( MechSections ( wounded )[ BSIDE ]. config & CASE_TECH ))
145+ if (!mech_section_has_special ( wounded , BSIDE , CASE_TECH ))
140146 explode_unit (wounded , attacker );
141147 else
142148 DestroySection (wounded , attacker , LOS , BSIDE );
143149 break ;
144150 }
145151}
146152
147- void HandleVehicleCrit (Mech * wounded , Mech * attacker , int LOS , int hitloc ,
148- int num ) {
149- if (MechMove (wounded ) == MOVE_NONE )
153+ void mech_vehicle_critical_handle (Mech * wounded , Mech * attacker , int LOS ,
154+ int hitloc , int num ) {
155+ BtechContext * context = mech_context (wounded );
156+ MechConditionSummary condition = mech_condition_summary (wounded );
157+
158+ if (mech_movement_type (wounded ) == MOVE_NONE )
150159 return ;
151160 if (hitloc == TURRET ) {
152- if (btech_random_range (wounded -> xcode . context , 1 , 3 ) == 2 ) {
153- if (!( MechTankCritStatus ( wounded ) & TURRET_LOCKED ) ) {
161+ if (btech_random_range (context , 1 , 3 ) == 2 ) {
162+ if (!condition . turret_locked ) {
154163 mech_notify (wounded , MECHALL , "[fg=yellow bold]CRITICAL HIT![reset]" );
155- MechTankCritStatus (wounded ) |= TURRET_LOCKED ;
164+ mech_turret_locked_set (wounded , true) ;
156165 mech_notify (wounded , MECHALL ,
157166 "Your turret takes a direct hit and locks up!" );
158167 }
159168 return ;
160169 }
161170 } else
162- switch (btech_random_range (wounded -> xcode . context , 1 , 10 )) {
171+ switch (btech_random_range (context , 1 , 10 )) {
163172 case 1 :
164173 case 2 :
165174 case 3 :
166175 case 4 :
167- if (!Fallen ( wounded ) ) {
176+ if (!condition . fallen ) {
168177 mech_notify (wounded , MECHALL , "[fg=yellow bold]CRITICAL HIT![reset]" );
169- switch (MechMove (wounded )) {
178+ switch (mech_movement_type (wounded )) {
170179 case MOVE_TRACK :
171180 mech_notify (wounded , MECHALL , "One of your tracks is damaged!" );
172181 break ;
@@ -187,9 +196,9 @@ void HandleVehicleCrit(Mech *wounded, Mech *attacker, int LOS, int hitloc,
187196 return ;
188197 break ;
189198 case 5 :
190- if (!Fallen ( wounded ) ) {
199+ if (!condition . fallen ) {
191200 mech_notify (wounded , MECHALL , "[fg=yellow bold]CRITICAL HIT![reset]" );
192- switch (MechMove (wounded )) {
201+ switch (mech_movement_type (wounded )) {
193202 case MOVE_TRACK :
194203 mech_notify (
195204 wounded , MECHALL ,
@@ -218,7 +227,7 @@ void HandleVehicleCrit(Mech *wounded, Mech *attacker, int LOS, int hitloc,
218227 break ;
219228 }
220229 mech_notify (wounded , MECHALL , "[fg=yellow bold]CRITICAL HIT![reset]" );
221- switch (btech_random_range (wounded -> xcode . context , 0 , 5 )) {
230+ switch (btech_random_range (context , 0 , 5 )) {
222231 case 0 :
223232 /* Crew stunned for one turn...treat like a head hit */
224233 headhitmwdamage (wounded , attacker , 1 );
0 commit comments