diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 4e29e3be03..356723daab 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8023,9 +8023,12 @@ BattleScript_SupremeOverlordActivates:: BattleScript_CostarActivates:: pause B_WAIT_TIME_SHORT + savetarget + copybyte gBattlerTarget, sBATTLER call BattleScript_AbilityPopUp printstring STRINGID_PKMNCOPIEDSTATCHANGES waitmessage B_WAIT_TIME_LONG + restoretarget end3 BattleScript_ZeroToHeroActivates:: diff --git a/src/battle_util.c b/src/battle_util.c index 38e4b1e61d..a8e8ebcd39 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4980,10 +4980,10 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 && CountBattlerStatIncreases(BATTLE_PARTNER(battler), FALSE)) { gSpecialStatuses[battler].switchInAbilityDone = TRUE; - gBattlerAttacker = battler; + gBattlerAttacker = gBattlerAbility = battler; for (i = 0; i < NUM_BATTLE_STATS; i++) gBattleMons[battler].statStages[i] = gBattleMons[BATTLE_PARTNER(battler)].statStages[i]; - gBattlerTarget = BATTLE_PARTNER(battler); + gBattleScripting.battler = BATTLE_PARTNER(battler); BattleScriptPushCursorAndCallback(BattleScript_CostarActivates); effect++; } diff --git a/test/battle/ability/costar.c b/test/battle/ability/costar.c index 7674ab0966..c42871bb45 100644 --- a/test/battle/ability/costar.c +++ b/test/battle/ability/costar.c @@ -1,7 +1,29 @@ #include "global.h" #include "test/battle.h" -TO_DO_BATTLE_TEST("Costar copies an ally's stat stages upon entering battle"); +DOUBLE_BATTLE_TEST("Costar copies an ally's stat stages upon entering battle") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WYNAUT); + OPPONENT(SPECIES_FLAMIGO) { Ability(ABILITY_COSTAR); } + } WHEN { + TURN { MOVE(opponentLeft, MOVE_SWORDS_DANCE); } + TURN { SWITCH(opponentRight, 2); MOVE(playerLeft, MOVE_CELEBRATE); } + } SCENE { + // Turn 1 - buff up + MESSAGE("Foe Wobbuffet used Swords Dance!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponentLeft); + // Turn 2 - Switch into Flamigo + MESSAGE("2 sent out Flamigo!"); + ABILITY_POPUP(opponentRight, ABILITY_COSTAR); + MESSAGE("Foe Flamigo copied Foe Wobbuffet's stat changes!"); + } THEN { + EXPECT_EQ(opponentRight->statStages[STAT_ATK], DEFAULT_STAT_STAGE + 2); + } +} // Copy from Ruin ability tests TO_DO_BATTLE_TEST("Costar's message displays correctly after all battlers fainted - Player"); diff --git a/test/battle/ability/download.c b/test/battle/ability/download.c index 9fecda400d..e96b0ddeb9 100644 --- a/test/battle/ability/download.c +++ b/test/battle/ability/download.c @@ -94,3 +94,28 @@ SINGLE_BATTLE_TEST("Download doesn't activate if target hasn't been sent out yet EXPECT_MUL_EQ(results[0].damageSpecial, Q_4_12(1.5), results[1].damageSpecial); } } + +DOUBLE_BATTLE_TEST("Download raises Sp.Attack if enemies have lower total Sp. Def than Def", s16 damage) +{ + u32 ability; + PARAMETRIZE { ability = ABILITY_TRACE; } + PARAMETRIZE { ability = ABILITY_DOWNLOAD; } + GIVEN { + PLAYER(SPECIES_PORYGON) { Ability(ability); SpAttack(100); } + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET) { Defense(200); SpDefense(100); } + OPPONENT(SPECIES_WOBBUFFET) { Defense(100); SpDefense(150); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_TRI_ATTACK, target: opponentLeft ); } + } SCENE { + if (ability == ABILITY_DOWNLOAD) + { + ABILITY_POPUP(playerLeft, ABILITY_DOWNLOAD); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + MESSAGE("Porygon's Download raised its Sp. Atk!"); + } + HP_BAR(opponentLeft, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + } +}