From 22fb105f70d3c328d05d9de0cd61e0a1f721c95d Mon Sep 17 00:00:00 2001 From: hedara90 <90hedara@gmail.com> Date: Sat, 27 Dec 2025 09:53:44 +0100 Subject: [PATCH] Fix Mimic trying to access MOVE_UNAVAILABLE in an incredibly small amount of possible scenarios (#8685) --- src/battle_script_commands.c | 8 ++++---- test/battle/move_effect/mimic.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 86f1b117e4..411421a29a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11303,10 +11303,10 @@ static void Cmd_mimicattackcopy(void) { CMD_ARGS(const u8 *failInstr); - if ((IsMoveMimicBanned(gLastMoves[gBattlerTarget])) - || (gBattleMons[gBattlerAttacker].volatiles.transformed) - || gLastMoves[gBattlerTarget] == MOVE_NONE - || gLastMoves[gBattlerTarget] == MOVE_UNAVAILABLE) + if (gLastMoves[gBattlerTarget] == MOVE_UNAVAILABLE + || gLastMoves[gBattlerTarget] == MOVE_NONE + || gBattleMons[gBattlerAttacker].volatiles.transformed + || IsMoveMimicBanned(gLastMoves[gBattlerTarget])) { gBattlescriptCurrInstr = cmd->failInstr; } diff --git a/test/battle/move_effect/mimic.c b/test/battle/move_effect/mimic.c index 4a51a4b79e..6ea6e3f1f8 100644 --- a/test/battle/move_effect/mimic.c +++ b/test/battle/move_effect/mimic.c @@ -1,4 +1,20 @@ #include "global.h" #include "test/battle.h" +SINGLE_BATTLE_TEST("Mimic doesn't error when the last move used by the target resolves to MOVE_UNAVAILABLE") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN {MOVE(opponent, MOVE_TRANSFORM); MOVE(player, MOVE_MIMIC); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRANSFORM, opponent); + NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_MIMIC, player); + } THEN { + EXPECT_EQ(gLastMoves[1], MOVE_UNAVAILABLE); // This test depends on the current implementation of Transform, if this changes, the test should be changed + } +} + TO_DO_BATTLE_TEST("TODO: Write Mimic (Move Effect) test titles")