From d044f53c722fdddcbef836a659edbc922eb85dd9 Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Wed, 16 Oct 2024 10:51:41 +0200 Subject: [PATCH] Adds tests and Costar fix from PR #5526 --- data/battle_scripts_1.s | 3 +++ src/battle_util.c | 6 +++--- test/battle/ability/costar.c | 24 +++++++++++++++++++++++- test/battle/ability/download.c | 25 +++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index fa56c3ff7a..0a694d846f 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8016,9 +8016,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 33063cd542..2f00f48cf9 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4873,10 +4873,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++; } @@ -6312,7 +6312,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 } break; case ABILITY_PROTOSYNTHESIS: - if (!gDisableStructs[battler].weatherAbilityDone + if (!gDisableStructs[battler].weatherAbilityDone && (gBattleWeather & B_WEATHER_SUN) && WEATHER_HAS_EFFECT && !(gBattleMons[battler].status2 & STATUS2_TRANSFORMED) && !(gBattleStruct->boosterEnergyActivates & (1u << battler))) 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); + } +}