From 5cd7bd77b32187ee82d0bb60611980b16299f1cb Mon Sep 17 00:00:00 2001 From: hedara90 <90hedara@gmail.com> Date: Thu, 24 Apr 2025 17:06:47 +0200 Subject: [PATCH] Fix various Toxic Spikes interactions (#6690) Co-authored-by: Hedara Co-authored-by: PhallenTree <168426989+PhallenTree@users.noreply.github.com> --- src/battle_script_commands.c | 8 +------ test/battle/ability/comatose.c | 32 ++++++++++++++++++++++++++++ test/battle/ability/immunity.c | 17 +++++++++++++++ test/battle/ability/purifying_salt.c | 17 +++++++++++++++ 4 files changed, 67 insertions(+), 7 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ede0a7749d..72e05cfb68 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8240,13 +8240,7 @@ static bool32 DoSwitchInEffectsForBattler(u32 battler) else if (IsBattlerAffectedByHazards(battler, TRUE)) { i = GetBattlerAbility(battler); - if (!(gBattleMons[battler].status1 & STATUS1_ANY) - && !IS_BATTLER_OF_TYPE(battler, TYPE_STEEL) - && i != ABILITY_IMMUNITY - && i != ABILITY_PURIFYING_SALT - && !IsAbilityOnSide(battler, ABILITY_PASTEL_VEIL) - && !(gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_SAFEGUARD) - && !(gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN)) + if (CanBePoisoned(gBattlerAttacker, battler, i)) { if (gSideTimers[GetBattlerSide(battler)].toxicSpikesAmount >= 2) gBattleMons[battler].status1 |= STATUS1_TOXIC_POISON; diff --git a/test/battle/ability/comatose.c b/test/battle/ability/comatose.c index b23a6ca85f..d714ee5e3d 100644 --- a/test/battle/ability/comatose.c +++ b/test/battle/ability/comatose.c @@ -55,3 +55,35 @@ SINGLE_BATTLE_TEST("Comatose may be suppressed if pokemon transformed into a pok else if (move == MOVE_SLEEP_POWDER) { STATUS_ICON(opponent, sleep: TRUE); } } } + +SINGLE_BATTLE_TEST("Comatose pokemon doesn't get poisoned by Toxic Spikes on switch-in") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_KOMALA) { Ability(ABILITY_COMATOSE); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TOXIC_SPIKES); } + TURN { SWITCH(player, 1); } + } SCENE { + NOT STATUS_ICON(player, STATUS1_POISON); + ABILITY_POPUP(player, ABILITY_COMATOSE); + NOT HP_BAR(player); + } +} + +SINGLE_BATTLE_TEST("Comatose pokemon don't get poisoned by Toxic Spikes on switch-in if forced in by phazing with Mold Breaker") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_KOMALA) { Ability(ABILITY_COMATOSE); } + OPPONENT(SPECIES_PINSIR) { Ability(ABILITY_MOLD_BREAKER); } + } WHEN { + TURN { MOVE(opponent, MOVE_TOXIC_SPIKES); } + TURN { MOVE(opponent, MOVE_DRAGON_TAIL); } + } SCENE { + NOT STATUS_ICON(player, STATUS1_POISON); + ABILITY_POPUP(player, ABILITY_COMATOSE); + NOT HP_BAR(player); + } +} diff --git a/test/battle/ability/immunity.c b/test/battle/ability/immunity.c index 92e32d31f3..365b5d0d50 100644 --- a/test/battle/ability/immunity.c +++ b/test/battle/ability/immunity.c @@ -45,3 +45,20 @@ SINGLE_BATTLE_TEST("Immunity prevents Toxic Spikes poison") NOT STATUS_ICON(opponent, poison: TRUE); } } + +SINGLE_BATTLE_TEST("Immunity doesn't prevent pokemon from being poisoned by Toxic Spikes on switch-in if forced in by phazing with Mold Breaker, but it cures it immediately") +{ + GIVEN { + ASSUME(GetMoveEffect(MOVE_DRAGON_TAIL) == EFFECT_HIT_SWITCH_TARGET); + ASSUME(GetMoveEffect(MOVE_TOXIC_SPIKES) == EFFECT_TOXIC_SPIKES); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_SNORLAX) { Ability(ABILITY_IMMUNITY); } + OPPONENT(SPECIES_PINSIR) { Ability(ABILITY_MOLD_BREAKER); } + } WHEN { + TURN { MOVE(opponent, MOVE_TOXIC_SPIKES); } + TURN { MOVE(opponent, MOVE_DRAGON_TAIL); } + } SCENE { + STATUS_ICON(player, STATUS1_POISON); + NOT HP_BAR(player); + } +} diff --git a/test/battle/ability/purifying_salt.c b/test/battle/ability/purifying_salt.c index cb8fc6ca56..85d2e9c009 100644 --- a/test/battle/ability/purifying_salt.c +++ b/test/battle/ability/purifying_salt.c @@ -100,3 +100,20 @@ SINGLE_BATTLE_TEST("Purifying Salt user can't be poisoned by Toxic Spikes") EXPECT_EQ(player->status1, STATUS1_NONE); } } + +SINGLE_BATTLE_TEST("Purifying Salt doesn't prevent pokemon from being poisoned by Toxic Spikes on switch-in if forced in by phazing with Mold Breaker") +{ + GIVEN { + ASSUME(GetMoveEffect(MOVE_DRAGON_TAIL) == EFFECT_HIT_SWITCH_TARGET); + ASSUME(GetMoveEffect(MOVE_TOXIC_SPIKES) == EFFECT_TOXIC_SPIKES); + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_GARGANACL) { Ability(ABILITY_PURIFYING_SALT); } + OPPONENT(SPECIES_PINSIR) { Ability(ABILITY_MOLD_BREAKER); } + } WHEN { + TURN { MOVE(opponent, MOVE_TOXIC_SPIKES); } + TURN { MOVE(opponent, MOVE_DRAGON_TAIL); } + } SCENE { + STATUS_ICON(player, STATUS1_POISON); + HP_BAR(player); + } +}