From 742f7a4875f2e83ab86c605825aedaae4a5dd1cf Mon Sep 17 00:00:00 2001 From: PhallenTree <168426989+PhallenTree@users.noreply.github.com> Date: Fri, 20 Dec 2024 21:24:23 +0000 Subject: [PATCH] Fixes Cotton Down and Gulp Missile not interacting correctly with stat reduction prevention effects (#5841) --- data/battle_scripts_1.s | 16 ++++----- test/battle/ability/cotton_down.c | 34 ++++++++++++++++++ test/battle/ability/gulp_missile.c | 57 ++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 9 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d8eb279661..3e1888b031 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1218,7 +1218,6 @@ BattleScript_StrengthSapLower: playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 printfromtable gStatDownStringIds waitmessage B_WAIT_TIME_LONG - goto BattleScript_StrengthSapHp @ Drain HP without lowering a stat BattleScript_StrengthSapHp: jumpifability BS_TARGET, ABILITY_LIQUID_OOZE, BattleScript_StrengthSapManipulateDmg @@ -6396,18 +6395,14 @@ BattleScript_GulpMissileGulping:: datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER jumpiffainted BS_ATTACKER, TRUE, BattleScript_GulpMissileNoSecondEffectGulping - jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_CLEAR_AMULET, BattleScript_GulpMissileNoSecondEffectGulping - jumpifability BS_ATTACKER, ABILITY_CLEAR_BODY, BattleScript_GulpMissileNoSecondEffectGulping - jumpifability BS_ATTACKER, ABILITY_FULL_METAL_BODY, BattleScript_GulpMissileNoSecondEffectGulping - jumpifability BS_ATTACKER, ABILITY_WHITE_SMOKE, BattleScript_GulpMissileNoSecondEffectGulping - jumpifflowerveilattacker BattleScript_GulpMissileNoSecondEffectGulping BattleScript_GulpMissileNoDmgGulping: handleformchange BS_TARGET, 0 playanimation BS_TARGET, B_ANIM_FORM_CHANGE waitanimation swapattackerwithtarget @ to make gStatDownStringIds down below print the right battler setstatchanger STAT_DEF, 1, TRUE - statbuffchange STAT_CHANGE_NOT_PROTECT_AFFECTED, BattleScript_GulpMissileGorgingTargetDefenseCantGoLower + statbuffchange STAT_CHANGE_NOT_PROTECT_AFFECTED | STAT_CHANGE_ALLOW_PTR, BattleScript_GulpMissileGulpingEnd + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_GulpMissileGulpingTargetDefenseCantGoLower setgraphicalstatchangevalues playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 printfromtable gStatDownStringIds @@ -6419,9 +6414,11 @@ BattleScript_GulpMissileNoSecondEffectGulping: playanimation BS_TARGET, B_ANIM_FORM_CHANGE waitanimation return -BattleScript_GulpMissileGorgingTargetDefenseCantGoLower: +BattleScript_GulpMissileGulpingTargetDefenseCantGoLower: printstring STRINGID_STATSWONTDECREASE waitmessage B_WAIT_TIME_LONG +BattleScript_GulpMissileGulpingEnd: + swapattackerwithtarget @ restore the battlers, just in case return BattleScript_SeedSowerActivates:: @@ -7152,7 +7149,8 @@ BattleScript_CottonDownLoop: jumpiffainted BS_TARGET, TRUE, BattleScript_CottonDownLoopIncrement setstatchanger STAT_SPEED, 1, TRUE jumpifbyteequal gBattlerTarget, gEffectBattler, BattleScript_CottonDownLoopIncrement - statbuffchange STAT_CHANGE_NOT_PROTECT_AFFECTED, BattleScript_CottonDownTargetSpeedCantGoLower + statbuffchange STAT_CHANGE_NOT_PROTECT_AFFECTED | STAT_CHANGE_ALLOW_PTR, BattleScript_CottonDownLoopIncrement + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_CottonDownTargetSpeedCantGoLower setgraphicalstatchangevalues playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 printfromtable gStatDownStringIds diff --git a/test/battle/ability/cotton_down.c b/test/battle/ability/cotton_down.c index 4d0dab9dcc..02a0f18f63 100644 --- a/test/battle/ability/cotton_down.c +++ b/test/battle/ability/cotton_down.c @@ -62,3 +62,37 @@ DOUBLE_BATTLE_TEST("Cotton Down drops speed by one of all other battlers on the EXPECT_EQ(opponentRight->statStages[STAT_SPEED], DEFAULT_STAT_STAGE - 1); } } + +DOUBLE_BATTLE_TEST("Cotton Down correctly gets blocked by stat reduction preventing abilities") +{ + GIVEN { + PLAYER(SPECIES_METAGROSS) { Ability(ABILITY_CLEAR_BODY); } + PLAYER(SPECIES_WYNAUT) { Item(ITEM_CLEAR_AMULET); } + OPPONENT(SPECIES_ELDEGOSS) { Ability(ABILITY_COTTON_DOWN); } + OPPONENT(SPECIES_CORVIKNIGHT) { Ability(ABILITY_MIRROR_ARMOR); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_TACKLE, target: opponentLeft); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, playerLeft); + ABILITY_POPUP(opponentLeft, ABILITY_COTTON_DOWN); + NONE_OF { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + MESSAGE("Metagross's Speed fell!"); + } + ABILITY_POPUP(playerLeft, ABILITY_CLEAR_BODY); + NONE_OF { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerRight); + MESSAGE("Wynaut's Speed fell!"); + } + MESSAGE("The effects of the Clear Amulet held by Wynaut prevents its stats from being lowered!"); + NONE_OF { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponentRight); + MESSAGE("The opposing Corviknight's Speed fell!"); + } + ABILITY_POPUP(opponentRight, ABILITY_MIRROR_ARMOR); + } THEN { + EXPECT_EQ(playerLeft->statStages[STAT_SPEED], DEFAULT_STAT_STAGE); + EXPECT_EQ(playerRight->statStages[STAT_SPEED], DEFAULT_STAT_STAGE); + EXPECT_EQ(opponentRight->statStages[STAT_SPEED], DEFAULT_STAT_STAGE); + } +} diff --git a/test/battle/ability/gulp_missile.c b/test/battle/ability/gulp_missile.c index f5e1fd9d9d..189702a4be 100644 --- a/test/battle/ability/gulp_missile.c +++ b/test/battle/ability/gulp_missile.c @@ -92,6 +92,7 @@ SINGLE_BATTLE_TEST("(Gulp Missile) Transformed Cramorant deal 1/4 of damage oppo MESSAGE("The opposing Wobbuffet's Defense fell!"); } THEN { EXPECT_EQ(gulpMissileDamage, opponent->maxHP / 4); + EXPECT_EQ(opponent->statStages[STAT_DEF], DEFAULT_STAT_STAGE - 1); } } @@ -133,3 +134,59 @@ SINGLE_BATTLE_TEST("(Gulp Missile) triggers even if the user is fainted by oppos STATUS_ICON(opponent, paralysis: TRUE); } } + +SINGLE_BATTLE_TEST("(Gulp Missile) Transformed Cramorant Gulping lowers defense but is prevented by stat reduction preventing abilities") +{ + u32 species, ability; + PARAMETRIZE { species = SPECIES_METAGROSS; ability = ABILITY_CLEAR_BODY; } + PARAMETRIZE { species = SPECIES_CORVIKNIGHT; ability = ABILITY_MIRROR_ARMOR; } + PARAMETRIZE { species = SPECIES_CHATOT; ability = ABILITY_BIG_PECKS; } + GIVEN { + PLAYER(SPECIES_CRAMORANT) { Ability(ABILITY_GULP_MISSILE); } + OPPONENT(species) { Ability(ability); } + } WHEN { + TURN { MOVE(player, MOVE_SURF); MOVE(opponent, MOVE_TACKLE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SURF, player); + HP_BAR(opponent); + ABILITY_POPUP(player, ABILITY_GULP_MISSILE); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + HP_BAR(player); + ABILITY_POPUP(player, ABILITY_GULP_MISSILE); + ABILITY_POPUP(opponent, ability); + NOT ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); + } THEN { + EXPECT_EQ(opponent->statStages[STAT_DEF], DEFAULT_STAT_STAGE); + } +} + +SINGLE_BATTLE_TEST("(Gulp Missile) Transformed Cramorant Gulping lowers defense and still triggers other effects after") +{ + // Make sure attacker and target are correct after triggering the ability + u32 ability; + PARAMETRIZE { ability = ABILITY_INFILTRATOR; } + PARAMETRIZE { ability = ABILITY_CLEAR_BODY; } + GIVEN { + ASSUME(gMovesInfo[MOVE_TACKLE].makesContact == TRUE); + PLAYER(SPECIES_CRAMORANT) { Ability(ABILITY_GULP_MISSILE); Item(ITEM_ROCKY_HELMET); } + OPPONENT(SPECIES_DRAGAPULT) { Ability(ability); } + } WHEN { + TURN { MOVE(player, MOVE_SURF); MOVE(opponent, MOVE_TACKLE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SURF, player); + HP_BAR(opponent); + ABILITY_POPUP(player, ABILITY_GULP_MISSILE); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + HP_BAR(player); + ABILITY_POPUP(player, ABILITY_GULP_MISSILE); + HP_BAR(opponent); + if (ability == ABILITY_INFILTRATOR) { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponent); + MESSAGE("The opposing Dragapult's Defense fell!"); + } else { + ABILITY_POPUP(opponent, ABILITY_CLEAR_BODY); + } + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); + HP_BAR(opponent); + } +}