Discover AI command drop_item and decompile chrDropItem

This commit is contained in:
Ryan Dwyer 2020-05-27 20:47:36 +10:00
parent 913c3f93a5
commit 1e55efb2e8
7 changed files with 36 additions and 68 deletions

View File

@ -13985,64 +13985,29 @@ s32 chrConsiderGrenadeThrow(struct chrdata *chr, u32 entitytype, u32 entityid)
return done;
}
GLOBAL_ASM(
glabel func0f03b97c
/* f03b97c: 27bdffd8 */ addiu $sp,$sp,-40
/* f03b980: afb00018 */ sw $s0,0x18($sp)
/* f03b984: 00808025 */ or $s0,$a0,$zero
/* f03b988: afbf001c */ sw $ra,0x1c($sp)
/* f03b98c: afa60030 */ sw $a2,0x30($sp)
/* f03b990: 10800003 */ beqz $a0,.L0f03b9a0
/* f03b994: 00a03825 */ or $a3,$a1,$zero
/* f03b998: 10000002 */ beqz $zero,.L0f03b9a4
/* f03b99c: 908202fe */ lbu $v0,0x2fe($a0)
.L0f03b9a0:
/* f03b9a0: 00001025 */ or $v0,$zero,$zero
.L0f03b9a4:
/* f03b9a4: 24010002 */ addiu $at,$zero,0x2
/* f03b9a8: 10410003 */ beq $v0,$at,.L0f03b9b8
/* f03b9ac: 24010004 */ addiu $at,$zero,0x4
/* f03b9b0: 14410003 */ bne $v0,$at,.L0f03b9c0
/* f03b9b4: 00e02025 */ or $a0,$a3,$zero
.L0f03b9b8:
/* f03b9b8: 1000001d */ beqz $zero,.L0f03ba30
/* f03b9bc: 00001025 */ or $v0,$zero,$zero
.L0f03b9c0:
/* f03b9c0: 93a50033 */ lbu $a1,0x33($sp)
/* f03b9c4: 0fc22e20 */ jal func0f08b880
/* f03b9c8: 02003025 */ or $a2,$s0,$zero
/* f03b9cc: 50400018 */ beqzl $v0,.L0f03ba30
/* f03b9d0: 00001025 */ or $v0,$zero,$zero
/* f03b9d4: 8c4e0014 */ lw $t6,0x14($v0)
/* f03b9d8: 51c00015 */ beqzl $t6,.L0f03ba30
/* f03b9dc: 00001025 */ or $v0,$zero,$zero
/* f03b9e0: 8c440018 */ lw $a0,0x18($v0)
/* f03b9e4: 8c850014 */ lw $a1,0x14($a0)
/* f03b9e8: 0c006bd6 */ jal func0001af58
/* f03b9ec: afa20024 */ sw $v0,0x24($sp)
/* f03b9f0: 8fa30024 */ lw $v1,0x24($sp)
/* f03b9f4: 8e05001c */ lw $a1,0x1c($s0)
/* f03b9f8: 0fc181a6 */ jal propReparent
/* f03b9fc: 8c640014 */ lw $a0,0x14($v1)
/* f03ba00: 8fa30024 */ lw $v1,0x24($sp)
/* f03ba04: 240f02d0 */ addiu $t7,$zero,0x2d0
/* f03ba08: 24050001 */ addiu $a1,$zero,0x1
/* f03ba0c: a46f0062 */ sh $t7,0x62($v1)
/* f03ba10: 0fc20a59 */ jal propobjSetDropped
/* f03ba14: 8c640014 */ lw $a0,0x14($v1)
/* f03ba18: 8e180014 */ lw $t8,0x14($s0)
/* f03ba1c: 24020001 */ addiu $v0,$zero,0x1
/* f03ba20: 37190001 */ ori $t9,$t8,0x1
/* f03ba24: 10000002 */ beqz $zero,.L0f03ba30
/* f03ba28: ae190014 */ sw $t9,0x14($s0)
/* f03ba2c: 00001025 */ or $v0,$zero,$zero
.L0f03ba30:
/* f03ba30: 8fbf001c */ lw $ra,0x1c($sp)
/* f03ba34: 8fb00018 */ lw $s0,0x18($sp)
/* f03ba38: 27bd0028 */ addiu $sp,$sp,0x28
/* f03ba3c: 03e00008 */ jr $ra
/* f03ba40: 00000000 */ sll $zero,$zero,0x0
);
bool chrDropItem(struct chrdata *chr, u32 modelnum, u32 weaponnum)
{
struct weaponobj *weapon;
u8 race = CHRRACE(chr);
if (race == RACE_DRCAROLL || race == RACE_ROBOT) {
return false;
}
weapon = func0f08b880(modelnum, (u8)weaponnum, chr);
if (weapon && weapon->base.prop) {
func0001af58(weapon->base.animdata, weapon->base.animdata->unk14);
propReparent(weapon->base.prop, chr->prop);
weapon->unk62 = 720;
propobjSetDropped(weapon->base.prop, 1);
chr->hidden |= CHRHFLAG_00000001;
return true;
}
return false;
}
GLOBAL_ASM(
glabel func0f03ba44

View File

@ -46,7 +46,7 @@ bool (*g_CommandPointers[])(void) = {
/*0x0019*/ ai0019,
/*0x001a*/ ai001a,
/*0x001b*/ aiConsiderGrenadeThrow,
/*0x001c*/ ai001c,
/*0x001c*/ aiDropItem,
/*0x001d*/ aiJogToPad,
/*0x001e*/ aiGoToPadPreset,
/*0x001f*/ aiWalkToPad,

View File

@ -880,12 +880,12 @@ bool aiConsiderGrenadeThrow(void)
/**
* @cmd 001c
*/
bool ai001c(void)
bool aiDropItem(void)
{
u8 *cmd = g_Vars.ailist + g_Vars.aioffset;
u32 value = cmd[3] | (cmd[2] << 8);
u32 modelnum = cmd[3] | (cmd[2] << 8);
if (func0f03b97c(g_Vars.chrdata, value & 0xffff, cmd[4] & 0xff)) {
if (chrDropItem(g_Vars.chrdata, modelnum & 0xffff, cmd[4] & 0xff)) {
g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[5]);
} else {
g_Vars.aioffset += 6;

View File

@ -292,10 +292,13 @@
mkshort(value_2), \
label,
#define cmd001c(u1, u2, label) \
/**
* Makes the chr spawn the given item and drop it immediately.
*/
#define drop_item(modelnum, weaponnum, label) \
mkshort(0x001c), \
mkshort(u1), \
u2, \
mkshort(modelnum), \
weaponnum, \
label,
/**

View File

@ -104,7 +104,7 @@ u32 func0f03abd0(void);
u32 func0f03aca0(struct chrdata *chr, u32 arg1, u32 arg2);
u32 func0f03afac(struct chrdata *chr);
u32 func0f03b1e0(struct chrdata *chr);
u32 func0f03b97c(struct chrdata *chr, u32 arg1, u32 arg2);
bool chrDropItem(struct chrdata *chr, u32 modelnum, u32 weaponnum);
void func0f03ba44(struct chrdata *chr, u32 arg1, u32 arg2, u32 arg3);
u32 chrTryPunchOrKick(struct chrdata *chr, u32 arg1);
u32 func0f03c044(void);

View File

@ -31,7 +31,7 @@
/*0x0019*/ bool ai0019(void);
/*0x001a*/ bool ai001a(void);
/*0x001b*/ bool aiConsiderGrenadeThrow(void);
/*0x001c*/ bool ai001c(void);
/*0x001c*/ bool aiDropItem(void);
/*0x001d*/ bool aiJogToPad(void);
/*0x001e*/ bool aiGoToPadPreset(void);
/*0x001f*/ bool aiWalkToPad(void);

View File

@ -25,7 +25,7 @@ void func0001ad34(struct animdata *animdata, struct coord *coord);
u32 func0001ad5c(void);
f32 func0001ae44(struct animdata *animdata);
void func0001ae90(struct animdata *animdata, f32 arg1);
u32 func0001af58(void);
void func0001af58(struct animdata *animdata, f32 arg1);
void func0001af64(struct animdata *animdata, f32 arg1);
f32 func0001af80(struct animdata *animdata);
u32 func0001af98(void);