From 18363207d91a62e8b3fa13477fcfe06f201c0adc Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Tue, 12 Aug 2025 09:40:10 -0400 Subject: [PATCH] Fix Mimicry Only Activating Once per Turn (#7537) Co-authored-by: ghoulslash --- asm/macros/battle_script.inc | 4 ++++ data/battle_scripts_1.s | 1 + src/battle_script_commands.c | 10 ++++++++++ test/battle/ability/mimicry.c | 25 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 02546d2f8a..721c844554 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1737,6 +1737,10 @@ callnative BS_ActivateTerrainChangeAbilities .byte \battler .endm + + .macro resetterrainabilityflags + callnative BS_ResetTerrainAbilityFlags + .endm @ Stores Healing Wish effect. .macro storehealingwish battler:req diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 23c1e10aa9..8688b2e97e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7889,6 +7889,7 @@ BattleScript_SnowWarningActivatesSnow:: BattleScript_ActivateTerrainEffects: saveattacker savetarget + resetterrainabilityflags setbyte gBattlerAttacker, 0 BattleScript_ActivateTerrainSeed: copyarraywithindex gBattlerTarget, gBattlerByTurnOrder, gBattlerAttacker, 1 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 870f21d7a8..e74bb4c60a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -18175,6 +18175,16 @@ void BS_ActivateTerrainChangeAbilities(void) AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, battler, 0, 0, 0); } +void BS_ResetTerrainAbilityFlags(void) +{ + NATIVE_ARGS(); + // reset terrain ability checks + for (u32 i = 0; i < gBattlersCount; i++) + gDisableStructs[i].terrainAbilityDone = 0; + + gBattlescriptCurrInstr = cmd->nextInstr; +} + void BS_StoreHealingWish(void) { NATIVE_ARGS(u8 battler); diff --git a/test/battle/ability/mimicry.c b/test/battle/ability/mimicry.c index fbdb5cf98a..b9c3bb5fc3 100644 --- a/test/battle/ability/mimicry.c +++ b/test/battle/ability/mimicry.c @@ -70,3 +70,28 @@ SINGLE_BATTLE_TEST("Mimicry restores the battler's types when terrain is removed EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].types[1], TYPE_STEEL); } } + +DOUBLE_BATTLE_TEST("Mimicry can trigger multiple times in a turn") +{ + GIVEN { + PLAYER(SPECIES_STUNFISK_GALAR) { Speed(50); Ability(ABILITY_MIMICRY); } + PLAYER(SPECIES_MORELULL) { Speed(40); } + OPPONENT(SPECIES_IGGLYBUFF) { Speed(60); } + OPPONENT(SPECIES_BAGON) { Speed(70); } + } WHEN { + TURN { MOVE(opponentRight, MOVE_ELECTRIC_TERRAIN); MOVE(opponentLeft, MOVE_MISTY_TERRAIN); } + } SCENE { + MESSAGE("The opposing Bagon used Electric Terrain!"); + ABILITY_POPUP(playerLeft, ABILITY_MIMICRY); + MESSAGE("Stunfisk's type changed to Electric!"); + // igglybuff + MESSAGE("The opposing Igglybuff used Misty Terrain!"); + ABILITY_POPUP(playerLeft, ABILITY_MIMICRY); + MESSAGE("Stunfisk's type changed to Fairy!"); + } THEN { + EXPECT_EQ(gBattleMons[0].types[0], TYPE_FAIRY); + EXPECT_EQ(gBattleMons[0].types[1], TYPE_FAIRY); + EXPECT_EQ(gBattleMons[0].types[2], TYPE_MYSTERY); + } +} +