diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 6fb668250..8fa8eda8e 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -2693,7 +2693,7 @@ glabel ai005b * @cmd 005c */ GLOBAL_ASM( -glabel ai005c +glabel aiIfTargetInRoom /* f051468: 27bdffd8 */ addiu $sp,$sp,-40 /* f05146c: afb00018 */ sw $s0,0x18($sp) /* f051470: 3c10800a */ lui $s0,0x800a @@ -2741,6 +2741,23 @@ glabel ai005c /* f05150c: 00001025 */ or $v0,$zero,$zero ); +// Mismatch due to different temporary registers +//bool aiIfTargetInRoom(void) +//{ +// u8 *cmd = g_Vars.ailist + g_Vars.aioffset; +// struct position *pos = chrGetTargetPosition(g_Vars.chrdata); +// s32 room_id = cmd[3] | (cmd[2] << 8); +// room_id = func0f0495d0(g_Vars.chrdata, room_id & 0xffff); +// +// if (room_id >= 0 && pos && room_id == pos->room) { +// g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); +// } else { +// g_Vars.aioffset += 5; +// } +// +// return false; +//} + /** * @cmd 005d */ diff --git a/src/include/commands.h b/src/include/commands.h index aa237b5d3..363864ba1 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -388,6 +388,11 @@ mkshort(room), \ label, +#define if_target_in_room(room, label) \ + mkshort(0x005c), \ + mkshort(room), \ + label + #define if_chr_has_object(chr, object, label) \ mkshort(0x005d), \ chr, \ diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 2e58ea470..9112efbcc 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -95,7 +95,7 @@ /*0x0059*/ bool aiIfDistanceFromTargetToPadLessThan(void); /*0x005a*/ bool aiIfDistanceFromTargetToPadGreaterThan(void); /*0x005b*/ bool ai005b(void); -/*0x005c*/ bool ai005c(void); +/*0x005c*/ bool aiIfTargetInRoom(void); /*0x005d*/ bool aiIfChrHasObject(void); /*0x005e*/ bool aiIfWeaponThrown(void); /*0x005f*/ bool ai005f(void); diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index b33054412..89b601a9a 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14045,7 +14045,7 @@ bool (*g_CommandPointers[])(void) = { /*0x0059*/ aiIfDistanceFromTargetToPadLessThan, /*0x005a*/ aiIfDistanceFromTargetToPadGreaterThan, /*0x005b*/ ai005b, - /*0x005c*/ ai005c, + /*0x005c*/ aiIfTargetInRoom, /*0x005d*/ aiIfChrHasObject, /*0x005e*/ aiIfWeaponThrown, /*0x005f*/ ai005f,