Skip to content

Commit

Permalink
Fixes Cotton Down and Gulp Missile not interacting correctly with sta…
Browse files Browse the repository at this point in the history
…t reduction prevention effects (#5841)
  • Loading branch information
PhallenTree authored Dec 20, 2024
1 parent 5cc0b35 commit 742f7a4
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 9 deletions.
16 changes: 7 additions & 9 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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::
Expand Down Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions test/battle/ability/cotton_down.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
57 changes: 57 additions & 0 deletions test/battle/ability/gulp_missile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 742f7a4

Please sign in to comment.