diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 8fa8eda8e..660526efa 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -2805,7 +2805,7 @@ bool aiIfWeaponThrown(void) * @cmd 005f */ GLOBAL_ASM( -glabel ai005f +glabel aiIfWeaponThrownOnObject /* f05167c: 3c08800a */ lui $t0,0x800a /* f051680: 25089fc0 */ addiu $t0,$t0,-24640 /* f051684: 8d0e0434 */ lw $t6,0x434($t0) @@ -2865,6 +2865,34 @@ glabel ai005f /* f051748: 00000000 */ sll $zero,$zero,0x0 ); +// Mismatch due to different registers +//bool aiIfWeaponThrownOnObject(void) +//{ +// u8 *cmd = g_Vars.ailist + g_Vars.aioffset; +// struct defaultobj *obj = objFindByTagId(cmd[3]); +// bool pass = false; +// +// if (obj && obj->pos) { +// struct attachment *attachment = obj->pos->attachments; +// +// while (attachment) { +// if (attachment->type == ATTACHMENTTYPE_WEAPON && attachment->weapon->weapon_id == cmd[2]) { +// pass = true; +// } +// +// attachment = attachment->next; +// } +// } +// +// if (pass) { +// g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); +// } else { +// g_Vars.aioffset += 5; +// } +// +// return false; +//} + /** * @cmd 0060 */ diff --git a/src/include/constants.h b/src/include/constants.h index 9383c6c0e..cab1972ce 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -57,6 +57,8 @@ // 0x19 #define AMMOTYPE_ECM_MINE 0x20 +#define ATTACHMENTTYPE_WEAPON 0x04 + #define BANK_0 0 #define BANK_1 1 #define BANK_2 2 diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 9112efbcc..ca1da50cc 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -98,7 +98,7 @@ /*0x005c*/ bool aiIfTargetInRoom(void); /*0x005d*/ bool aiIfChrHasObject(void); /*0x005e*/ bool aiIfWeaponThrown(void); -/*0x005f*/ bool ai005f(void); +/*0x005f*/ bool aiIfWeaponThrownOnObject(void); /*0x0060*/ bool ai0060(void); /*0x0061*/ bool ai0061(void); /*0x0062*/ bool aiIfObjectHealthy(void); diff --git a/src/include/types.h b/src/include/types.h index 451f94d18..79e65268f 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -11,6 +11,20 @@ struct coord { float z; }; +struct weaponobj; + +struct attachment { + u8 type; + struct weaponobj *weapon; + u32 unk08; + u32 unk0c; + u32 unk10; + u32 unk14; + u32 unk18; + u32 unk1c; + struct attachment *next; +}; + // This might be a pad, but given that chrs have a gunground pointer to this // struct, I think it's more likely an ad hoc coordinate that can be created as // needed during gameplay. @@ -22,7 +36,7 @@ struct position { struct coord coord; u32 unk14; u32 unk18; // related to gun recovery - u32 unk1c; + struct attachment *attachments; u32 unk20; u32 unk24; s16 room; diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 89b601a9a..f530fc173 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14048,7 +14048,7 @@ bool (*g_CommandPointers[])(void) = { /*0x005c*/ aiIfTargetInRoom, /*0x005d*/ aiIfChrHasObject, /*0x005e*/ aiIfWeaponThrown, - /*0x005f*/ ai005f, + /*0x005f*/ aiIfWeaponThrownOnObject, /*0x0060*/ ai0060, /*0x0061*/ ai0061, /*0x0062*/ aiIfObjectHealthy,