From 8e5bb6ad6571cbb9ddf5f60c4d0987aff4044d01 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 26 Dec 2019 11:50:00 +1000 Subject: [PATCH] Attempt to decompile chrIsStopped --- src/game/chr/chr.c | 50 +++++++++++++++++++++++++++-- src/game/chr/chraicommands.c | 4 +-- src/game/game_066310.c | 2 +- src/include/game/chr/chr.h | 2 +- src/include/game/game_066310.h | 2 +- src/include/library/library_1a500.h | 2 +- src/include/types.h | 25 +++++++++++++-- 7 files changed, 76 insertions(+), 11 deletions(-) diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index edf09a618..bbdf8b6eb 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -20191,7 +20191,7 @@ glabel func0f02f530 /* f02f5d8: 10000007 */ beqz $zero,.L0f02f5f8 /* f02f5dc: ae090014 */ sw $t1,0x14($s0) .L0f02f5e0: -/* f02f5e0: 0fc0e576 */ jal func0f0395d8 +/* f02f5e0: 0fc0e576 */ jal chrIsStopped /* f02f5e4: 02002025 */ or $a0,$s0,$zero /* f02f5e8: 54400004 */ bnezl $v0,.L0f02f5fc /* f02f5ec: 8fbf001c */ lw $ra,0x1c($sp) @@ -31296,7 +31296,7 @@ void chrRecordLastHearTargetTime(struct chrdata *chr) } GLOBAL_ASM( -glabel func0f0395d8 +glabel chrIsStopped /* f0395d8: 27bdffd8 */ addiu $sp,$sp,-40 /* f0395dc: afb00018 */ sw $s0,0x18($sp) /* f0395e0: 00808025 */ or $s0,$a0,$zero @@ -31418,6 +31418,52 @@ glabel func0f0395d8 /* f039788: 00000000 */ sll $zero,$zero,0x0 ); +//bool chrIsStopped(struct chrdata *chr) +//{ +// u32 anim = func0001d13c(chr->unk020); +// +// if (anim == 0x269 || anim == 0x26b) { +// return false; +// } +// +// if (anim == 0x26a && chr->act_attack.unk034 <= chr->act_attack.unk033) { +// chrStopFiring(chr); +// return true; +// } +// +// if (chr->actiontype == ACT_ROBOTATTACK && chr->unk06e) { +// return true; +// } +// +// if (chr->actiontype == ACT_ATTACKAMOUNT && chr->act_attackamount.unk034 <= chr->act_attackamount.unk033) { +// return true; +// } +// +// if (chr->actiontype == ACT_STAND && chr->act_stand.unk02c == 0 && chr->act_stand.unk038 == 0 && chr->act_stand.unk03c != 1) { +// return true; +// } +// +// if (chr->actiontype == ACT_ANIM) { +// if (chr->act_anim.unk034) { +// return true; +// } +// +// if (func0001d260(chr->unk020) >= 0 && func0001d17c(chr->unk020) >= func0001d1a0(chr->unk020)) { +// return true; +// } +// +// if (func0001d260(chr->unk020) >= 0 || func0001d17c(chr->unk020) > 0) { +// return false; +// } +// } +// +// if (chr->actiontype == ACT_PATROL) { +// return true; +// } +// +// return false; +//} + GLOBAL_ASM( glabel func0f03978c /* f03978c: 27bdffb0 */ addiu $sp,$sp,-80 diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 053f1316a..3b9bf1447 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -384,7 +384,7 @@ bool aiStop(void) if (g_Vars.chrdata) { chrTryStop(g_Vars.chrdata); } else if (g_Vars.hovdata) { - func0f07b078(g_Vars.hovdata); + heliTryStop(g_Vars.hovdata); } g_Vars.aioffset += 2; @@ -672,7 +672,7 @@ bool aiBeSurprised000e(void) */ bool aiIfStopped(void) { - if (func0f0395d8(g_Vars.chrdata)) { + if (chrIsStopped(g_Vars.chrdata)) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]); } else { diff --git a/src/game/game_066310.c b/src/game/game_066310.c index 64225be23..1561b5eb7 100644 --- a/src/game/game_066310.c +++ b/src/game/game_066310.c @@ -24779,7 +24779,7 @@ glabel func0f07b038 ); GLOBAL_ASM( -glabel func0f07b078 +glabel heliTryStop /* f07b078: 27bdffe8 */ addiu $sp,$sp,-24 /* f07b07c: afbf0014 */ sw $ra,0x14($sp) /* f07b080: 0fc1eb7d */ jal objGetHeli diff --git a/src/include/game/chr/chr.h b/src/include/game/chr/chr.h index 73383d0a7..86a9947a8 100644 --- a/src/include/game/chr/chr.h +++ b/src/include/game/chr/chr.h @@ -232,7 +232,7 @@ u32 func0f039474(void); u32 func0f039558(void); void chrRecordLastSeeTargetTime(struct chrdata *chr); void chrRecordLastHearTargetTime(struct chrdata *chr); -u32 func0f0395d8(struct chrdata *chr); +bool chrIsStopped(struct chrdata *chr); u32 func0f03978c(struct chrdata *chr); u32 func0f039a18(struct chrdata *chr); bool chrIsDead(struct chrdata *chr); diff --git a/src/include/game/game_066310.h b/src/include/game/game_066310.h index c48e7be08..1238bec06 100644 --- a/src/include/game/game_066310.h +++ b/src/include/game/game_066310.h @@ -166,7 +166,7 @@ u32 func0f07ae18(struct heliobj *heli, u32 arg1); u32 func0f07af34(struct heliobj *heli); void heliSetTarget(struct heliobj *heli, s32 arg1); u32 func0f07b038(struct heliobj *heli); -void func0f07b078(struct heliobj *heli); +void heliTryStop(struct heliobj *heli); bool heliSetField90(struct defaultobj *obj, u32 value); u32 heliRestartTimer(struct heliobj *heli); f32 heliGetTimer(struct heliobj *heli); diff --git a/src/include/library/library_1a500.h b/src/include/library/library_1a500.h index ba2221d19..d1883f2e6 100644 --- a/src/include/library/library_1a500.h +++ b/src/include/library/library_1a500.h @@ -55,7 +55,7 @@ u32 func0001d15c(void); f32 func0001d17c(struct chr020 *chr020); f32 func0001d1a0(struct chr020 *chr020); u32 func0001d218(void); -u32 func0001d260(void); +f32 func0001d260(struct chr020 *chr020); u32 func0001d288(void); u32 func0001d320(void); u32 func0001d4fc(void); diff --git a/src/include/types.h b/src/include/types.h index ec34cbb27..e29e9afeb 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -209,6 +209,12 @@ struct act_stand { /*0x4c*/ s8 unk04c; }; +struct act_anim { + /*0x2c*/ u32 unk02c; + /*0x30*/ u32 unk030; + /*0x34*/ u32 unk034; +}; + struct act_die { /*0x2c*/ u32 unk02c; /*0x30*/ f32 unk030; @@ -226,8 +232,10 @@ struct act_dead { struct act_attack { /*0x2c*/ u32 unk02c; - /*0x30*/ u32 unk030; - /*0x34*/ u32 unk034; + /*0x30*/ u16 unk030; + /*0x32*/ u8 unk032; + /*0x33*/ s8 unk033; + /*0x34*/ s8 unk034; /*0x38*/ u32 unk038; /*0x3c*/ u32 unk03c; /*0x40*/ u32 unk040; @@ -263,6 +271,14 @@ struct act_throwgrenade { /*0x38*/ u32 unk038; }; +struct act_attackamount { + /*0x2c*/ u32 unk02c; + /*0x30*/ u16 unk030; + /*0x32*/ u8 unk032; + /*0x33*/ s8 unk033; + /*0x34*/ s8 unk034; +}; + struct chrdata { /*0x000*/ s16 chrnum; /*0x002*/ s8 accuracyrating; @@ -290,6 +306,7 @@ struct chrdata { union { struct act_stand act_stand; + struct act_anim act_anim; struct act_die act_die; struct act_dead act_dead; struct act_attack act_attack; @@ -298,6 +315,7 @@ struct chrdata { struct act_runpos act_runpos; struct act_surprised act_surprised; struct act_throwgrenade act_throwgrenade; + struct act_attackamount act_attackamount; }; /*0x054*/ u32 unk054; @@ -308,7 +326,8 @@ struct chrdata { /*0x066*/ u8 unk065; /*0x066*/ s16 unk066; /*0x068*/ u32 unk068; - /*0x06c*/ u32 unk06c; + /*0x06c*/ u16 unk06c; + /*0x06e*/ u8 unk06e; /*0x070*/ u32 unk070; /*0x074*/ u32 unk074; /*0x078*/ u32 unk078;