From 3d5083b6a9482c5a170c4b852303bd634ca4bfdd Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 5 Jan 2020 13:57:55 +1000 Subject: [PATCH] Decompile func0f197544 --- src/game/game_187770.c | 78 +++++++++++----------------------- src/include/constants.h | 7 +-- src/include/game/game_187770.h | 2 +- src/include/types.h | 24 +++++++++-- 4 files changed, 50 insertions(+), 61 deletions(-) diff --git a/src/game/game_187770.c b/src/game/game_187770.c index 373748762..a4a23cde6 100644 --- a/src/game/game_187770.c +++ b/src/game/game_187770.c @@ -18471,57 +18471,27 @@ glabel func0f194b40 /* f197540: 27bd02f8 */ addiu $sp,$sp,0x2f8 ); -GLOBAL_ASM( -glabel func0f197544 -/* f197544: 27bdffe8 */ addiu $sp,$sp,-24 -/* f197548: afbf0014 */ sw $ra,0x14($sp) -/* f19754c: 908e02a0 */ lbu $t6,0x2a0($a0) -/* f197550: 2401002a */ addiu $at,$zero,0x2a -/* f197554: 00001025 */ or $v0,$zero,$zero -/* f197558: 15c1001d */ bne $t6,$at,.L0f1975d0 -/* f19755c: 8c8502d4 */ lw $a1,0x2d4($a0) -/* f197560: 908f0064 */ lbu $t7,0x64($a0) -/* f197564: 240d0001 */ addiu $t5,$zero,0x1 -/* f197568: 000fc080 */ sll $t8,$t7,0x2 -/* f19756c: 0098c821 */ addu $t9,$a0,$t8 -/* f197570: 8f28004c */ lw $t0,0x4c($t9) -/* f197574: 55000015 */ bnezl $t0,.L0f1975cc -/* f197578: acad00d8 */ sw $t5,0xd8($a1) -/* f19757c: 8ca30010 */ lw $v1,0x10($a1) -/* f197580: 50600012 */ beqzl $v1,.L0f1975cc -/* f197584: acad00d8 */ sw $t5,0xd8($a1) -/* f197588: 8c690018 */ lw $t1,0x18($v1) -/* f19758c: 5520000f */ bnezl $t1,.L0f1975cc -/* f197590: acad00d8 */ sw $t5,0xd8($a1) -/* f197594: 846a0002 */ lh $t2,0x2($v1) -/* f197598: 5540000c */ bnezl $t2,.L0f1975cc -/* f19759c: acad00d8 */ sw $t5,0xd8($a1) -/* f1975a0: 90620000 */ lbu $v0,0x0($v1) -/* f1975a4: 24010004 */ addiu $at,$zero,0x4 -/* f1975a8: 10410003 */ beq $v0,$at,.L0f1975b8 -/* f1975ac: 24010001 */ addiu $at,$zero,0x1 -/* f1975b0: 54410006 */ bnel $v0,$at,.L0f1975cc -/* f1975b4: acad00d8 */ sw $t5,0xd8($a1) -.L0f1975b8: -/* f1975b8: 8c620004 */ lw $v0,0x4($v1) -/* f1975bc: 8c4b0010 */ lw $t3,0x10($v0) -/* f1975c0: 356c4000 */ ori $t4,$t3,0x4000 -/* f1975c4: ac4c0010 */ sw $t4,0x10($v0) -/* f1975c8: acad00d8 */ sw $t5,0xd8($a1) -.L0f1975cc: -/* f1975cc: 24020001 */ addiu $v0,$zero,0x1 -.L0f1975d0: -/* f1975d0: 14400004 */ bnez $v0,.L0f1975e4 -/* f1975d4: 2485002c */ addiu $a1,$a0,0x2c -/* f1975d8: 24860038 */ addiu $a2,$a0,0x38 -/* f1975dc: 0fc0e10f */ jal func0f03843c -/* f1975e0: 90870065 */ lbu $a3,0x65($a0) -.L0f1975e4: -/* f1975e4: 8fbf0014 */ lw $ra,0x14($sp) -/* f1975e8: 27bd0018 */ addiu $sp,$sp,0x18 -/* f1975ec: 03e00008 */ jr $ra -/* f1975f0: 00000000 */ sll $zero,$zero,0x0 -/* f1975f4: 00000000 */ sll $zero,$zero,0x0 -/* f1975f8: 00000000 */ sll $zero,$zero,0x0 -/* f1975fc: 00000000 */ sll $zero,$zero,0x0 -); +void func0f197544(struct chrdata *chr) +{ + bool pass = false; + struct chr2d4 *chr2d4 = chr->unk2d4; + + if (chr->myaction == MA_AIBOTGETITEM) { + if (chr->act_aibotgetitem.unk4c[chr->unk064] == 0) { + struct prop *prop = chr2d4->prop; + + if (prop && !prop->parent && prop->timetoregen == 0) { + if (prop->type == PROPTYPE_WEAPON || prop->type == PROPTYPE_OBJ) { + prop->obj->flags3 |= OBJECTFLAG2_00004000; + } + } + } + + chr2d4->unkd8 = 1; + pass = true; + } + + if (!pass) { + func0f03843c(chr, &chr->act_aibotgetitem.pos, &chr->act_aibotgetitem.rooms[0], chr->speed); + } +} diff --git a/src/include/constants.h b/src/include/constants.h index bda3849ab..4b684e75f 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -533,7 +533,7 @@ #define MPSCENARIO_KINGOFTHEHILL 4 #define MPSCENARIO_CAPTURETHECASE 5 -// Object flags - bank 0 (object struct offset 0x08) +// obj->flags #define OBJECTFLAG0_00000001 0x00000001 // Not used in scripts #define OBJECTFLAG0_00000002 0x00000002 // Not used in scripts #define OBJECTFLAG0_00000004 0x00000004 // Not used in scripts @@ -567,7 +567,7 @@ #define OBJECTFLAG0_40000000 0x40000000 // Used quite a lot #define OBJECTFLAG0_INTERCEPTOR_DISABLED 0x80000000 -// Object flags - bank 1 (object struct offset 0x0c) +// obj->flags2 #define OBJECTFLAG1_00000001 0x00000001 // Used only in CI Training #define OBJECTFLAG1_00000002 0x00000002 // Ruins spikes #define OBJECTFLAG1_00000004 0x00000004 // Defense hostage doors - openable by AI? @@ -601,7 +601,7 @@ #define OBJECTFLAG1_40000000 0x40000000 // Not used in scripts #define OBJECTFLAG1_80000000 0x80000000 // Attack Ship glass -// Object flags - bank 2 (object struct offset 0x10) +// obj->flags3 #define OBJECTFLAG2_PUSHABLE 0x00000001 #define OBJECTFLAG2_GRABBABLE 0x00000002 #define OBJECTFLAG2_00000004 0x00000004 // Not used in scripts @@ -635,6 +635,7 @@ #define OBJECTFLAG2_40000000 0x40000000 // Not used in scripts #define OBJECTFLAG2_80000000 0x80000000 // Not used in scripts +// obj->hidden #define OBJHIDDENFLAG_00000080 0x00000080 #define OBJHIDDENFLAG_ACTIVATED_BY_BOND 0x00004000 #define OBJHIDDENFLAG_ACTIVATED_BY_COOP 0x00040000 diff --git a/src/include/game/game_187770.h b/src/include/game/game_187770.h index 53b3bc647..0bb732175 100644 --- a/src/include/game/game_187770.h +++ b/src/include/game/game_187770.h @@ -167,6 +167,6 @@ u32 func0f19489c(void); u32 func0f194904(void); u32 func0f194990(void); u32 func0f194b40(void); -u32 func0f197544(void); +void func0f197544(struct chrdata *chr); #endif diff --git a/src/include/types.h b/src/include/types.h index 136f7cf53..744220cb9 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -26,7 +26,7 @@ struct prop; struct prop { /*0x00*/ u8 type; /*0x01*/ u8 flags; - /*0x02*/ u16 timetoregen; + /*0x02*/ s16 timetoregen; /*0x04*/ union { @@ -138,7 +138,7 @@ struct chr2d4 { /*0x04*/ u32 unk04; /*0x08*/ u32 unk08; /*0x0c*/ u32 unk0c; - /*0x10*/ u32 unk10; + /*0x10*/ struct prop *prop; /*0x14*/ u32 unk14; /*0x18*/ u32 unk18; /*0x1c*/ u32 unk1c; @@ -193,6 +193,16 @@ struct chr2d4 { /*0xa8*/ u32 unka8; /*0xac*/ u32 unkac; /*0xb0*/ f32 unkb0; + /*0xb4*/ u32 unkb4; + /*0xb8*/ u32 unkb8; + /*0xbc*/ u32 unkbc; + /*0xc0*/ u32 unkc0; + /*0xc4*/ u32 unkc4; + /*0xc8*/ u32 unkc8; + /*0xcc*/ u32 unkcc; + /*0xd0*/ u32 unkd0; + /*0xd4*/ u32 unkd4; + /*0xd8*/ u32 unkd8; }; struct act_stand { @@ -277,6 +287,13 @@ struct act_attackamount { /*0x34*/ s8 unk034; }; +struct act_aibotgetitem { + /*0x2c*/ struct coord pos; + /*0x38*/ s16 rooms[8]; + /*0x48*/ u32 unk48; + /*0x4c*/ s32 unk4c[1]; +}; + struct chrdata { /*0x000*/ s16 chrnum; /*0x002*/ s8 accuracyrating; @@ -314,6 +331,7 @@ struct chrdata { struct act_surprised act_surprised; struct act_throwgrenade act_throwgrenade; struct act_attackamount act_attackamount; + struct act_aibotgetitem act_aibotgetitem; }; /*0x054*/ u32 unk054; @@ -321,7 +339,7 @@ struct chrdata { /*0x05c*/ u32 unk05c; /*0x060*/ u32 unk060; /*0x064*/ u8 unk064; - /*0x066*/ u8 unk065; + /*0x065*/ u8 speed; /*0x066*/ s16 unk066; /*0x068*/ u32 unk068; /*0x06c*/ u16 unk06c;