From 9b5b69ae496f6005b194c3e15c43f76c97814e31 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Mon, 25 Aug 2025 05:40:52 -0400 Subject: [PATCH] switchinabilities also runs ON_WEATHER and ON_TERRAIN (#7612) Co-authored-by: ghoulslash --- src/battle_script_commands.c | 7 +++++++ test/battle/ability/mimicry.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bc97a288d8..0d90a3290d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10639,6 +10639,13 @@ static void Cmd_various(void) gBattlescriptCurrInstr = cmd->nextInstr; AbilityBattleEffects(ABILITYEFFECT_NEUTRALIZINGGAS, battler, 0, 0, 0); AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, battler, 0, 0, 0); + + if (gBattleWeather & B_WEATHER_ANY && HasWeatherEffect()) + AbilityBattleEffects(ABILITYEFFECT_ON_WEATHER, battler, 0, 0, 0); + + if (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY) + AbilityBattleEffects(ABILITYEFFECT_ON_TERRAIN, battler, 0, 0, 0); + AbilityBattleEffects(ABILITYEFFECT_OPPORTUNIST, battler, 0, 0, 0); return; } diff --git a/test/battle/ability/mimicry.c b/test/battle/ability/mimicry.c index b9c3bb5fc3..df69e89b71 100644 --- a/test/battle/ability/mimicry.c +++ b/test/battle/ability/mimicry.c @@ -95,3 +95,32 @@ DOUBLE_BATTLE_TEST("Mimicry can trigger multiple times in a turn") } } +DOUBLE_BATTLE_TEST("Mimicry triggers after Skill Swap") +{ + GIVEN { + PLAYER(SPECIES_STUNFISK_GALAR) { Speed(40); Ability(ABILITY_MIMICRY); } + PLAYER(SPECIES_SHIFTRY) { Speed(50); Ability(ABILITY_CHLOROPHYLL); } + OPPONENT(SPECIES_SHUCKLE) { Speed(30); } + OPPONENT(SPECIES_CHANSEY) { Speed(20); } + } WHEN { + TURN { MOVE(playerRight, MOVE_GRASSY_TERRAIN); } + TURN { MOVE(playerRight, MOVE_SKILL_SWAP, target: playerLeft); + MOVE(playerLeft, MOVE_SPLASH); + } + } SCENE { + // turn 1 + MESSAGE("Shiftry used Grassy Terrain!"); + ABILITY_POPUP(playerLeft, ABILITY_MIMICRY); + MESSAGE("Stunfisk's type changed to Grass!"); + // turn 2 + MESSAGE("Shiftry used Skill Swap!"); + ABILITY_POPUP(playerRight, ABILITY_MIMICRY); + MESSAGE("Shiftry's type changed to Grass!"); + MESSAGE("Stunfisk used Splash!"); // make sure popup occurs before the subsequent move + } THEN { + EXPECT_EQ(playerLeft->types[0], TYPE_GRASS); + EXPECT_EQ(playerLeft->types[1], TYPE_GRASS); + EXPECT_EQ(playerRight->types[0], TYPE_GRASS); + EXPECT_EQ(playerRight->types[1], TYPE_GRASS); + } +}