diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 10e409afc..1937084d2 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -10097,49 +10097,23 @@ bool ai00f2(void) /** * @cmd 00f3 */ -GLOBAL_ASM( -glabel ai00f3 -/* f058144: 27bdffd0 */ addiu $sp,$sp,-48 -/* f058148: afb00018 */ sw $s0,0x18($sp) -/* f05814c: 3c10800a */ lui $s0,0x800a -/* f058150: 26109fc0 */ addiu $s0,$s0,-24640 -/* f058154: 8e0e0434 */ lw $t6,0x434($s0) -/* f058158: 8e0f0438 */ lw $t7,0x438($s0) -/* f05815c: afbf001c */ sw $ra,0x1c($sp) -/* f058160: 8e040424 */ lw $a0,0x424($s0) -/* f058164: 01cf1021 */ addu $v0,$t6,$t7 -/* f058168: 0fc126d1 */ jal chrFindById -/* f05816c: 90450002 */ lbu $a1,0x2($v0) -/* f058170: 50400014 */ beqzl $v0,.L0f0581c4 -/* f058174: 8e090438 */ lw $t1,0x438($s0) -/* f058178: 8c43001c */ lw $v1,0x1c($v0) -/* f05817c: 50600011 */ beqzl $v1,.L0f0581c4 -/* f058180: 8e090438 */ lw $t1,0x438($s0) -/* f058184: 90780000 */ lbu $t8,0x0($v1) -/* f058188: 24010006 */ addiu $at,$zero,0x6 -/* f05818c: 5701000d */ bnel $t8,$at,.L0f0581c4 -/* f058190: 8e090438 */ lw $t1,0x438($s0) -/* f058194: 8e19028c */ lw $t9,0x28c($s0) -/* f058198: afb90024 */ sw $t9,0x24($sp) -/* f05819c: 0fc4a25f */ jal posGetPlayerNum -/* f0581a0: 8c44001c */ lw $a0,0x1c($v0) -/* f0581a4: 0fc4a24b */ jal setCurrentPlayerNum -/* f0581a8: 00402025 */ or $a0,$v0,$zero -/* f0581ac: 24080001 */ addiu $t0,$zero,0x1 -/* f0581b0: 3c018007 */ lui $at,0x8007 -/* f0581b4: ac280760 */ sw $t0,0x760($at) -/* f0581b8: 0fc4a24b */ jal setCurrentPlayerNum -/* f0581bc: 8fa40024 */ lw $a0,0x24($sp) -/* f0581c0: 8e090438 */ lw $t1,0x438($s0) -.L0f0581c4: -/* f0581c4: 8fbf001c */ lw $ra,0x1c($sp) -/* f0581c8: 00001025 */ or $v0,$zero,$zero -/* f0581cc: 252a0003 */ addiu $t2,$t1,0x3 -/* f0581d0: ae0a0438 */ sw $t2,0x438($s0) -/* f0581d4: 8fb00018 */ lw $s0,0x18($sp) -/* f0581d8: 03e00008 */ jr $ra -/* f0581dc: 27bd0030 */ addiu $sp,$sp,0x30 -); +bool aiChrSetInvincible(void) +{ + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]); + + if (chr && chr->pos && chr->pos->unk00 == 6) { + u32 prevplayernum = g_Vars.currentplayernum; + u32 playernum = posGetPlayerNum(chr->pos); + setCurrentPlayerNum(playernum); + g_PlayerInvincible = true; + setCurrentPlayerNum(prevplayernum); + } + + g_Vars.aioffset += 3; + + return false; +} /** * @cmd 00f4 diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 0bbeaf57b..c7d7b8d34 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -243,7 +243,7 @@ /*0x00f0*/ bool ai00f0(void); /*0x00f1*/ bool ai00f1(void); /*0x00f2*/ bool ai00f2(void); -/*0x00f3*/ bool ai00f3(void); +/*0x00f3*/ bool aiChrSetInvincible(void); /*0x00f4*/ bool ai00f4(void); /*0x00f5*/ bool ai00f5(void); /*0x00f6*/ bool ai00f6(void); diff --git a/src/include/setup/setup_0160b0.h b/src/include/setup/setup_0160b0.h index 57bfc9ba1..930d190f6 100644 --- a/src/include/setup/setup_0160b0.h +++ b/src/include/setup/setup_0160b0.h @@ -6,5 +6,6 @@ extern struct menu_dialog menudialog_18d78; extern struct menu_dialog menudialog_18d90; extern u32 g_PlayersWithControl[]; +extern bool g_PlayerInvincible; #endif diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 01b385a80..1219d4e5b 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14196,7 +14196,7 @@ bool (*command_pointers[])(void) = { /*0x00f0*/ ai00f0, /*0x00f1*/ ai00f1, /*0x00f2*/ ai00f2, - /*0x00f3*/ ai00f3, + /*0x00f3*/ aiChrSetInvincible, /*0x00f4*/ ai00f4, /*0x00f5*/ ai00f5, /*0x00f6*/ ai00f6, diff --git a/src/setup/setup_0160b0.c b/src/setup/setup_0160b0.c index dedf52fba..7c2f378f8 100644 --- a/src/setup/setup_0160b0.c +++ b/src/setup/setup_0160b0.c @@ -445,7 +445,8 @@ bool g_PlayersWithControl[] = { true, true, true, true }; -u32 var00016780 = 0x00000000; +bool g_PlayerInvincible = false; + u32 var00016784 = 0x00000000; u32 var00016788 = 0x001a001c; u32 var0001678c = 0x00200021;