From d416678605e18cb186c2a8f397589a22b2e2e355 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 23 Feb 2021 21:33:25 +1000 Subject: [PATCH] Decompile func0f192dc0 --- src/game/game_190260.c | 95 +++++++++++----------------------- src/game/game_197600.c | 4 +- src/include/game/game_190260.h | 6 +-- src/include/game/game_197600.h | 2 +- 4 files changed, 37 insertions(+), 70 deletions(-) diff --git a/src/game/game_190260.c b/src/game/game_190260.c index 587cbd5da..8228571c7 100644 --- a/src/game/game_190260.c +++ b/src/game/game_190260.c @@ -1355,7 +1355,7 @@ glabel var7f1b8eb4 /* f1915b0: 27bd0050 */ addiu $sp,$sp,0x50 ); -u32 func0f1915b4(struct chrdata *chr) +s32 mpchrGetWeaponNum(struct chrdata *chr) { if (chr->aibot) { return chr->aibot->weaponnum; @@ -1364,16 +1364,16 @@ u32 func0f1915b4(struct chrdata *chr) return g_Vars.players[propGetPlayerNum(chr->prop)]->hands[HAND_RIGHT].base.weaponnum; } -u8 func0f191600(struct chrdata *chr) +u8 mpchrGetTargetsWeaponNum(struct chrdata *chr) { - struct prop *prop = chrGetTargetProp(chr); - u8 result = 0; + struct prop *target = chrGetTargetProp(chr); + u8 weaponnum = 0; - if (prop) { - result = func0f1915b4(prop->chr); + if (target) { + weaponnum = mpchrGetWeaponNum(target->chr); } - return result; + return weaponnum; } GLOBAL_ASM( @@ -2776,7 +2776,7 @@ glabel func0f192d64 /* f192d80: 91cf0047 */ lbu $t7,0x47($t6) /* f192d84: 55e1000a */ bnel $t7,$at,.L0f192db0 /* f192d88: 8fbf0014 */ lw $ra,0x14($sp) -/* f192d8c: 0fc6456d */ jal func0f1915b4 +/* f192d8c: 0fc6456d */ jal mpchrGetWeaponNum /* f192d90: afa30018 */ sw $v1,0x18($sp) /* f192d94: 10400004 */ beqz $v0,.L0f192da8 /* f192d98: 8fa30018 */ lw $v1,0x18($sp) @@ -2793,62 +2793,29 @@ glabel func0f192d64 /* f192dbc: 00000000 */ nop ); -GLOBAL_ASM( -glabel func0f192dc0 -/* f192dc0: 27bdffb0 */ addiu $sp,$sp,-80 -/* f192dc4: afbf002c */ sw $ra,0x2c($sp) -/* f192dc8: afa40050 */ sw $a0,0x50($sp) -/* f192dcc: 8c8302d4 */ lw $v1,0x2d4($a0) -/* f192dd0: 240f0001 */ addiu $t7,$zero,0x1 -/* f192dd4: afaf0048 */ sw $t7,0x48($sp) -/* f192dd8: 8c780004 */ lw $t8,0x4($v1) -/* f192ddc: 24010007 */ addiu $at,$zero,0x7 -/* f192de0: 00a02025 */ or $a0,$a1,$zero -/* f192de4: 93190047 */ lbu $t9,0x47($t8) -/* f192de8: 57210025 */ bnel $t9,$at,.L0f192e80 -/* f192dec: 8fbf002c */ lw $ra,0x2c($sp) -/* f192df0: 0fc6456d */ jal func0f1915b4 -/* f192df4: afa3004c */ sw $v1,0x4c($sp) -/* f192df8: 8fa3004c */ lw $v1,0x4c($sp) -/* f192dfc: afa20044 */ sw $v0,0x44($sp) -/* f192e00: 27a80040 */ addiu $t0,$sp,0x40 -/* f192e04: 8c650020 */ lw $a1,0x20($v1) -/* f192e08: 27a9003c */ addiu $t1,$sp,0x3c -/* f192e0c: afa90018 */ sw $t1,0x18($sp) -/* f192e10: afa00020 */ sw $zero,0x20($sp) -/* f192e14: afa0001c */ sw $zero,0x1c($sp) -/* f192e18: afa80014 */ sw $t0,0x14($sp) -/* f192e1c: afa00010 */ sw $zero,0x10($sp) -/* f192e20: 8fa40050 */ lw $a0,0x50($sp) -/* f192e24: 00003025 */ or $a2,$zero,$zero -/* f192e28: 0fc660ce */ jal func0f198338 -/* f192e2c: 24070001 */ addiu $a3,$zero,0x1 -/* f192e30: 27aa0038 */ addiu $t2,$sp,0x38 -/* f192e34: 27ab0034 */ addiu $t3,$sp,0x34 -/* f192e38: afab0018 */ sw $t3,0x18($sp) -/* f192e3c: afaa0014 */ sw $t2,0x14($sp) -/* f192e40: 8fa40050 */ lw $a0,0x50($sp) -/* f192e44: 8fa50044 */ lw $a1,0x44($sp) -/* f192e48: 00003025 */ or $a2,$zero,$zero -/* f192e4c: 24070001 */ addiu $a3,$zero,0x1 -/* f192e50: afa00010 */ sw $zero,0x10($sp) -/* f192e54: afa0001c */ sw $zero,0x1c($sp) -/* f192e58: 0fc660ce */ jal func0f198338 -/* f192e5c: afa00020 */ sw $zero,0x20($sp) -/* f192e60: 8fad0040 */ lw $t5,0x40($sp) -/* f192e64: 8fac0038 */ lw $t4,0x38($sp) -/* f192e68: 25aeffe2 */ addiu $t6,$t5,-30 -/* f192e6c: 018e082a */ slt $at,$t4,$t6 -/* f192e70: 54200003 */ bnezl $at,.L0f192e80 -/* f192e74: 8fbf002c */ lw $ra,0x2c($sp) -/* f192e78: afa00048 */ sw $zero,0x48($sp) -/* f192e7c: 8fbf002c */ lw $ra,0x2c($sp) -.L0f192e80: -/* f192e80: 8fa20048 */ lw $v0,0x48($sp) -/* f192e84: 27bd0050 */ addiu $sp,$sp,0x50 -/* f192e88: 03e00008 */ jr $ra -/* f192e8c: 00000000 */ nop -); +bool func0f192dc0(struct chrdata *botchr, struct chrdata *chr) +{ + struct aibot *aibot = botchr->aibot; + bool result = true; + s32 otherweaponnum; + s32 sp40; + s32 sp3c; + s32 sp38; + s32 sp34; + + if (aibot->simulant->base.simtype == SIMTYPE_COWARD) { + otherweaponnum = mpchrGetWeaponNum(chr); + + func0f198338(botchr, aibot->weaponnum, 0, 1, 0, &sp40, &sp3c, 0, 0); + func0f198338(botchr, otherweaponnum, 0, 1, 0, &sp38, &sp34, 0, 0); + + if (sp40 - 30 <= sp38) { + result = false; + } + } + + return result; +} GLOBAL_ASM( glabel func0f192e90 diff --git a/src/game/game_197600.c b/src/game/game_197600.c index dcfcaae6c..c56ae9445 100644 --- a/src/game/game_197600.c +++ b/src/game/game_197600.c @@ -1141,7 +1141,7 @@ glabel var7f1b908c /* f198524: 2401ffff */ addiu $at,$zero,-1 /* f198528: 51e1000f */ beql $t7,$at,.L0f198568 /* f19852c: 00004025 */ or $t0,$zero,$zero -/* f198530: 0fc64580 */ jal func0f191600 +/* f198530: 0fc64580 */ jal mpchrGetTargetsWeaponNum /* f198534: 01c02025 */ or $a0,$t6,$zero /* f198538: 28410002 */ slti $at,$v0,0x2 /* f19853c: 14200009 */ bnez $at,.L0f198564 @@ -1584,7 +1584,7 @@ glabel var7f1b908c /* f198bbc: 51a10007 */ beql $t5,$at,.L0f198bdc /* f198bc0: 8fac0070 */ lw $t4,0x70($sp) /* f198bc4: afa8004c */ sw $t0,0x4c($sp) -/* f198bc8: 0fc64580 */ jal func0f191600 +/* f198bc8: 0fc64580 */ jal mpchrGetTargetsWeaponNum /* f198bcc: afaa0048 */ sw $t2,0x48($sp) /* f198bd0: 8fa8004c */ lw $t0,0x4c($sp) /* f198bd4: 8faa0048 */ lw $t2,0x48($sp) diff --git a/src/include/game/game_190260.h b/src/include/game/game_190260.h index 50ee2fa33..8de01b98b 100644 --- a/src/include/game/game_190260.h +++ b/src/include/game/game_190260.h @@ -24,15 +24,15 @@ bool func0f19294c(struct chrdata *botchr, struct chrdata *otherchr); bool chrHasGround(struct chrdata *chr); u32 func0f192a74(void); u32 func0f192d64(void); -u32 func0f192dc0(void); +bool func0f192dc0(struct chrdata *botchr, struct chrdata *chr); u32 func0f192e90(void); u32 func0f19369c(void); s32 func0f1937a4(struct chrdata *chr, s32 arg1); u32 func0f194990(void); u32 func0f194b40(void); s32 mpObjIsSafe(struct defaultobj *obj); -u32 func0f1915b4(struct chrdata *chr); -u8 func0f191600(struct chrdata *chr); +s32 mpchrGetWeaponNum(struct chrdata *chr); +u8 mpchrGetTargetsWeaponNum(struct chrdata *chr); char *mpGetBotCommandName(s32 command); void mpAibotApplyAttack(struct chrdata *chr, struct prop *prop); void mpAibotApplyFollow(struct chrdata *chr, struct prop *prop); diff --git a/src/include/game/game_197600.h b/src/include/game/game_197600.h index 54646f193..dd8f524aa 100644 --- a/src/include/game/game_197600.h +++ b/src/include/game/game_197600.h @@ -18,7 +18,7 @@ bool aibotGiveProp(struct chrdata *chr, struct prop *prop); u32 func0f198068(void); bool mpHasShield(void); s32 mpGetWeaponIndexByWeaponNum(s32 weaponnum); -u32 func0f198338(void); +void func0f198338(struct chrdata *chr, s32 weaponnum, s32 arg2, s32 arg3, s32 arg4, s32 *arg5, s32 *arg6, s32 arg7, s32 arg8); u32 func0f198db4(void); u32 func0f198df8(void); s32 func0f198e38(s32 weaponnum, s32 funcnum);