diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 6124f72fa8..c05991da46 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7887,10 +7887,11 @@ BattleScript_IllusionOff:: return BattleScript_CottonDownActivates:: - setbyte sFIXED_ABILITY_POPUP, TRUE - call BattleScript_AbilityPopUp + showabilitypopup BS_TARGET + pause B_WAIT_TIME_LONG + destroyabilitypopup copybyte gEffectBattler, gBattlerTarget - savetarget + swapattackerwithtarget setbyte gBattlerTarget, 0 BattleScript_CottonDownLoop: jumpiffainted BS_TARGET, TRUE, BattleScript_CottonDownLoopIncrement @@ -7909,8 +7910,7 @@ BattleScript_CottonDownLoopIncrement: addbyte gBattlerTarget, 1 jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_CottonDownLoop BattleScript_CottonDownReturn: - restoretarget - destroyabilitypopup + swapattackerwithtarget return BattleScript_AnticipationActivates:: diff --git a/test/battle/ability/cotton_down.c b/test/battle/ability/cotton_down.c new file mode 100644 index 0000000000..8e15283926 --- /dev/null +++ b/test/battle/ability/cotton_down.c @@ -0,0 +1,64 @@ +#include "global.h" +#include "test/battle.h" + +SINGLE_BATTLE_TEST("Cotton Down drops speed by one of opposing battler if hit by a damaging move") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ELDEGOSS) { Ability(ABILITY_COTTON_DOWN); } + } WHEN { + TURN { MOVE(player, MOVE_TACKLE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player); + ABILITY_POPUP(opponent, ABILITY_COTTON_DOWN); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + MESSAGE("Wobbuffet's Speed fell!"); + } THEN { + EXPECT_EQ(player->statStages[STAT_SPEED], DEFAULT_STAT_STAGE - 1); + } +} + +SINGLE_BATTLE_TEST("Cotton Down drops speed by one for each multi hit") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ELDEGOSS) { Ability(ABILITY_COTTON_DOWN); } + } WHEN { + TURN { MOVE(player, MOVE_DOUBLE_KICK); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_DOUBLE_KICK, player); + ABILITY_POPUP(opponent, ABILITY_COTTON_DOWN); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + MESSAGE("Wobbuffet's Speed fell!"); + ABILITY_POPUP(opponent, ABILITY_COTTON_DOWN); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + MESSAGE("Wobbuffet's Speed fell!"); + } THEN { + EXPECT_EQ(player->statStages[STAT_SPEED], DEFAULT_STAT_STAGE - 2); + } +} + +DOUBLE_BATTLE_TEST("Cotton Down drops speed by one of all other battlers on the field") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_ELDEGOSS) { Ability(ABILITY_COTTON_DOWN); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(playerLeft, MOVE_TACKLE, target: opponentLeft); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, playerLeft); + ABILITY_POPUP(opponentLeft, ABILITY_COTTON_DOWN); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + MESSAGE("Wobbuffet's Speed fell!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerRight); + MESSAGE("Wynaut's Speed fell!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponentRight); + MESSAGE("Foe Wobbuffet's Speed fell!"); + } THEN { + EXPECT_EQ(playerLeft->statStages[STAT_SPEED], DEFAULT_STAT_STAGE - 1); + EXPECT_EQ(playerRight->statStages[STAT_SPEED], DEFAULT_STAT_STAGE - 1); + EXPECT_EQ(opponentRight->statStages[STAT_SPEED], DEFAULT_STAT_STAGE - 1); + } +} diff --git a/test/battle/ability/defiant.c b/test/battle/ability/defiant.c index e8443ecc5f..3463cad18d 100644 --- a/test/battle/ability/defiant.c +++ b/test/battle/ability/defiant.c @@ -138,3 +138,40 @@ SINGLE_BATTLE_TEST("Defiant activates after Sticky Web lowers Speed") MESSAGE("Mankey's Attack sharply rose!"); } } + + +DOUBLE_BATTLE_TEST("Defiant is activated by Cotton Down for non-ally pokemon") +{ + GIVEN { + PLAYER(SPECIES_MANKEY) { Ability(ABILITY_DEFIANT); } + PLAYER(SPECIES_MANKEY) { Ability(ABILITY_DEFIANT); } + OPPONENT(SPECIES_ELDEGOSS) { Ability(ABILITY_COTTON_DOWN); } + OPPONENT(SPECIES_MANKEY) { Ability(ABILITY_DEFIANT); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_TACKLE, target: opponentLeft); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, playerLeft); + ABILITY_POPUP(opponentLeft, ABILITY_COTTON_DOWN); + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + MESSAGE("Mankey's Speed fell!"); + ABILITY_POPUP(playerLeft, ABILITY_DEFIANT); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + MESSAGE("Mankey's Attack sharply rose!"); + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerRight); + MESSAGE("Mankey's Speed fell!"); + ABILITY_POPUP(playerRight, ABILITY_DEFIANT); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerRight); + MESSAGE("Mankey's Attack sharply rose!"); + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponentRight); + MESSAGE("Foe Mankey's Speed fell!"); + } THEN { + EXPECT_EQ(playerLeft->statStages[STAT_SPEED], DEFAULT_STAT_STAGE - 1); + EXPECT_EQ(playerRight->statStages[STAT_SPEED], DEFAULT_STAT_STAGE - 1); + EXPECT_EQ(opponentRight->statStages[STAT_SPEED], DEFAULT_STAT_STAGE - 1); + EXPECT_EQ(playerLeft->statStages[STAT_ATK], DEFAULT_STAT_STAGE + 2); + EXPECT_EQ(playerRight->statStages[STAT_ATK], DEFAULT_STAT_STAGE + 2); + } +}