Fix Mimic trying to access MOVE_UNAVAILABLE in an incredibly small amount of possible scenarios (#8685)

This commit is contained in:
hedara90 2025-12-27 09:53:44 +01:00 committed by GitHub
parent 6e12b35287
commit 22fb105f70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View File

@ -11303,10 +11303,10 @@ static void Cmd_mimicattackcopy(void)
{
CMD_ARGS(const u8 *failInstr);
if ((IsMoveMimicBanned(gLastMoves[gBattlerTarget]))
|| (gBattleMons[gBattlerAttacker].volatiles.transformed)
if (gLastMoves[gBattlerTarget] == MOVE_UNAVAILABLE
|| gLastMoves[gBattlerTarget] == MOVE_NONE
|| gLastMoves[gBattlerTarget] == MOVE_UNAVAILABLE)
|| gBattleMons[gBattlerAttacker].volatiles.transformed
|| IsMoveMimicBanned(gLastMoves[gBattlerTarget]))
{
gBattlescriptCurrInstr = cmd->failInstr;
}

View File

@ -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")