Discover if_hoverbot_next_step, heli_arm_weapons, heli_unarm_weapons and if_heli_weapons_armed

This commit is contained in:
Ryan Dwyer 2020-01-14 17:45:00 +10:00
parent 558f3c8943
commit d7cd3c7426
11 changed files with 65 additions and 51 deletions

View File

@ -1092,7 +1092,7 @@ u8 func0406_general_combat[] = {
u8 func0408_hovercopter[] = {
set_target_chr(CHR_BOND)
cmd0143
heli_arm_weapons
move_object_to_pad(OBJ_HOVERCOPTER, 0x0199)
begin_hovercar_path(0x02)
restart_timer

View File

@ -3204,7 +3204,7 @@ u8 func042c_foyer_clone[] = {
set_vehicle_speed(512, 120) \
\
beginloop(0x04) \
if_hoverbot_path_finished(0x01, 0x03, /*goto*/ 0x02) \
if_hoverbot_next_step(OPERATOR_GREATER_THAN, 3, /*goto*/ 0x02) \
endloop(0x04) \
\
/* Path 2 */ \
@ -3214,7 +3214,7 @@ u8 func042c_foyer_clone[] = {
set_vehicle_speed(512, 120) \
\
beginloop(0x05) \
if_hoverbot_path_finished(0x01, 0x03, /*goto*/ 0x02) \
if_hoverbot_next_step(OPERATOR_GREATER_THAN, 3, /*goto*/ 0x02) \
endloop(0x05) \
\
/* Path 3 */ \
@ -3224,7 +3224,7 @@ u8 func042c_foyer_clone[] = {
set_vehicle_speed(512, 120) \
\
beginloop(0x06) \
if_hoverbot_path_finished(0x01, 0x03, /*goto*/ 0x02) \
if_hoverbot_next_step(OPERATOR_GREATER_THAN, 3, /*goto*/ 0x02) \
endloop(0x06) \
\
label(0x02) \

View File

@ -2061,7 +2061,7 @@ u8 func0411_yellowbot[] = {
set_vehicle_speed(512, 120)
beginloop(0x04)
if_hoverbot_path_finished(0x01, 0x0a, /*goto*/ 0x06)
if_hoverbot_next_step(OPERATOR_GREATER_THAN, 10, /*goto*/ 0x06)
endloop(0x04)
label(0x06)
@ -2069,7 +2069,7 @@ u8 func0411_yellowbot[] = {
set_vehicle_speed(512, 120)
beginloop(0x08)
if_hoverbot_path_finished(0x01, 0x08, /*goto*/ 0x06)
if_hoverbot_next_step(OPERATOR_GREATER_THAN, 8, /*goto*/ 0x06)
endloop(0x08)
label(0x06)
@ -2101,7 +2101,7 @@ u8 func0412_purplebot_programs[] = {
beginloop(0x09)
if_stage_flag_eq(STAGEFLAG_BOT_ACTIVE_NOPROGRAM, FALSE, /*goto*/ 0x0e)
if_hoverbot_path_finished(0x01, 0x01, /*goto*/ 0x06)
if_hoverbot_next_step(OPERATOR_GREATER_THAN, 1, /*goto*/ 0x06)
endloop(0x09)
label(0x06)
@ -2115,7 +2115,7 @@ u8 func0412_purplebot_programs[] = {
beginloop(0x0b)
if_stage_flag_eq(STAGEFLAG_BOT_ACTIVE_NOPROGRAM, FALSE, /*goto*/ 0x0e)
if_stage_flag_eq(STAGEFLAG_BOT_ACTIVE_CLEANING, TRUE, /*goto*/ 0x10)
if_hoverbot_path_finished(0x01, 0x01, /*goto*/ 0x06)
if_hoverbot_next_step(OPERATOR_GREATER_THAN, 1, /*goto*/ 0x06)
endloop(0x0b)
label(0x06)
@ -2127,7 +2127,7 @@ u8 func0412_purplebot_programs[] = {
set_vehicle_speed(768, 120)
beginloop(0x0d)
if_hoverbot_path_finished(0x01, 0x18, /*goto*/ 0x06)
if_hoverbot_next_step(OPERATOR_GREATER_THAN, 24, /*goto*/ 0x06)
endloop(0x0d)
label(0x14)
@ -2146,7 +2146,7 @@ u8 func0412_purplebot_programs[] = {
if_stage_flag_eq(STAGEFLAG_BOT_ACTIVE_NOPROGRAM, TRUE, /*goto*/ 0x11)
if_stage_flag_eq(STAGEFLAG_BOT_ACTIVE_MAINTENANCE, TRUE, /*goto*/ 0x12)
if_stage_flag_eq(STAGEFLAG_BOT_ACTIVE_CLEANING, TRUE, /*goto*/ 0x10)
if_hoverbot_path_finished(0x01, 0x01, /*goto*/ 0x06)
if_hoverbot_next_step(OPERATOR_GREATER_THAN, 1, /*goto*/ 0x06)
endloop(0x0f)
label(0x06)

View File

@ -1675,7 +1675,7 @@ u8 func040a_top_interceptor[] = {
label(0x06)
unset_object_flag_bank0(OBJ_INTERCEPTOR3, OBJECTFLAG0_INTERCEPTOR_DISABLED)
cmd0143
heli_arm_weapons
begin_hovercar_path(0x22)
set_chr_maxdamage(CHR_SELF, 5000)

View File

@ -10892,12 +10892,12 @@ bool ai013e(void)
/**
* @cmd 013f
*/
bool ai013f(void)
bool aiIfHeliWeaponsArmed(void)
{
u8 *cmd = g_Vars.ailist + g_Vars.aioffset;
if (g_Vars.hovdata) {
if (g_Vars.hovdata->unk90 != 0) {
if (g_Vars.hovdata->weaponsarmed) {
g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]);
} else {
g_Vars.aioffset += 3;
@ -10912,12 +10912,12 @@ bool ai013f(void)
/**
* @cmd 0140
*/
bool ai0140(void)
bool aiIfHoverbotNextStep(void)
{
u8 *cmd = g_Vars.ailist + g_Vars.aioffset;
if (g_Vars.hovdata) {
if ((cmd[3] < g_Vars.hovdata->unk8c && cmd[2] == 1) || (g_Vars.hovdata->unk8c < cmd[3] && cmd[2] == 0)) {
if ((g_Vars.hovdata->nextstep > cmd[3] && cmd[2] == 1) || (g_Vars.hovdata->nextstep < cmd[3] && cmd[2] == 0)) {
g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]);
} else {
g_Vars.aioffset += 5;
@ -11197,10 +11197,10 @@ bool aiSetPadPresetToInvestigationTerminal(void)
/**
* @cmd 0143
*/
bool ai0143(void)
bool aiHeliArmWeapons(void)
{
if (g_Vars.hovdata) {
heliSetField90(&g_Vars.hovdata->base, true);
heliSetArmed(&g_Vars.hovdata->base, true);
}
g_Vars.aioffset += 2;
@ -11211,10 +11211,10 @@ bool ai0143(void)
/**
* @cmd 0144
*/
bool ai0144(void)
bool aiHeliUnarmWeapons(void)
{
if (g_Vars.hovdata) {
heliSetField90(&g_Vars.hovdata->base, false);
heliSetArmed(&g_Vars.hovdata->base, false);
}
g_Vars.aioffset += 2;

View File

@ -24796,12 +24796,12 @@ glabel heliTryStop
/* f07b0b8: 00000000 */ sll $zero,$zero,0x0
);
bool heliSetField90(struct defaultobj *obj, bool value)
bool heliSetArmed(struct defaultobj *obj, bool armed)
{
struct heliobj *heli = heliFromObj(obj);
if (heli) {
heli->unk90 = value;
heli->weaponsarmed = armed;
return true;
}

View File

@ -2661,17 +2661,23 @@
#define run_from_grenade \
mkshort(0x013e),
#define cmd013f(label) \
/**
* Checks if the current heli's weapons are armed.
*/
#define if_heli_weapons_armed(label) \
mkshort(0x013f), \
label,
/**
* Checks if a hoverbot has finished its path.
* Checks if a hoverbot's next step is less than or greater than the given
* value.
*
* Operator is expected to be OPERATOR_LESS_THAN or OPERATOR_GREATER_THAN.
*/
#define if_hoverbot_path_finished(u1, u2, label) \
#define if_hoverbot_next_step(operator, step, label) \
mkshort(0x0140), \
u1, \
u2, \
operator, \
step, \
label,
/**
@ -2704,12 +2710,20 @@
object, \
0x00,
// Sets the heli's 0x90 field to true.
#define cmd0143 \
/**
* Sets the current heli's weapons to armed.
*
* The state of the weapons can be checked with if_heli_weapons_armed.
*/
#define heli_arm_weapons \
mkshort(0x0143),
// Sets the heli's 0x90 field to false.
#define cmd0144 \
/**
* Sets the current heli's weapons to unarmed.
*
* The state of the weapons can be checked with if_heli_weapons_armed.
*/
#define heli_unarm_weapons \
mkshort(0x0144), \
label,

View File

@ -317,12 +317,12 @@
/*0x013c*/ bool ai013c(void);
/*0x013d*/ bool ai013d(void);
/*0x013e*/ bool ai013e(void);
/*0x013f*/ bool ai013f(void);
/*0x0140*/ bool ai0140(void);
/*0x013f*/ bool aiIfHeliWeaponsArmed(void);
/*0x0140*/ bool aiIfHoverbotNextStep(void);
/*0x0141*/ bool aiShuffleInvestigationTerminals(void);
/*0x0142*/ bool aiSetPadPresetToInvestigationTerminal(void);
/*0x0143*/ bool ai0143(void);
/*0x0144*/ bool ai0144(void);
/*0x0143*/ bool aiHeliArmWeapons(void);
/*0x0144*/ bool aiHeliUnarmWeapons(void);
/*0x0145*/ bool aiRebuildTeams(void);
/*0x0146*/ bool aiRebuildSquadrons(void);
/*0x0147*/ bool ai0147(void);

View File

@ -167,7 +167,7 @@ u32 func0f07af34(struct heliobj *heli);
void heliSetTarget(struct heliobj *heli, s32 arg1);
u32 func0f07b038(struct heliobj *heli);
void heliTryStop(struct heliobj *heli);
bool heliSetField90(struct defaultobj *obj, u32 value);
bool heliSetArmed(struct defaultobj *obj, bool armed);
u32 heliRestartTimer(struct heliobj *heli);
f32 heliGetTimer(struct heliobj *heli);
void heliSetMaxDamage(struct heliobj *heli, s16 health);

View File

@ -804,19 +804,19 @@ struct heliobj {
/*0x5c*/ u8 *ailist;
/*0x60*/ u16 aioffset;
/*0x62*/ s16 aireturnlist;
/*0x64*/ u32 unk64;
/*0x68*/ u32 unk68;
/*0x6c*/ u32 unk6c;
/*0x70*/ u32 unk70;
/*0x74*/ u32 unk74;
/*0x78*/ u32 unk78;
/*0x7c*/ u32 unk7c;
/*0x80*/ u32 unk80;
/*0x84*/ u32 unk84;
/*0x64*/ u32 speed;
/*0x68*/ u32 speedaim;
/*0x6c*/ u32 speedtime60;
/*0x70*/ u32 turnyspeed60;
/*0x74*/ u32 turnxspeed60;
/*0x78*/ u32 turnrot60;
/*0x7c*/ u32 roty;
/*0x80*/ u32 rotx;
/*0x84*/ u32 rotz;
/*0x88*/ u32 unk88;
/*0x8c*/ s32 unk8c;
/*0x90*/ s16 unk90;
/*0x92*/ u16 unk92;
/*0x8c*/ s32 nextstep;
/*0x90*/ s16 weaponsarmed;
/*0x92*/ u16 ontarget;
/*0x94*/ s16 target;
};

View File

@ -14454,12 +14454,12 @@ bool (*g_CommandPointers[])(void) = {
/*0x013c*/ ai013c,
/*0x013d*/ ai013d,
/*0x013e*/ ai013e,
/*0x013f*/ ai013f,
/*0x0140*/ ai0140,
/*0x013f*/ aiIfHeliWeaponsArmed,
/*0x0140*/ aiIfHoverbotNextStep,
/*0x0141*/ aiShuffleInvestigationTerminals,
/*0x0142*/ aiSetPadPresetToInvestigationTerminal,
/*0x0143*/ ai0143,
/*0x0144*/ ai0144,
/*0x0143*/ aiHeliArmWeapons,
/*0x0144*/ aiHeliUnarmWeapons,
/*0x0145*/ aiRebuildTeams,
/*0x0146*/ aiRebuildSquadrons,
/*0x0147*/ ai0147,