Skip to content

Commit

Permalink
Adds tests and Costar fix from PR #5526 (#5529)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoulslash authored Oct 16, 2024
2 parents ed65c4a + d044f53 commit 29e37a0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
3 changes: 3 additions & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
6 changes: 3 additions & 3 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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)))
Expand Down
24 changes: 23 additions & 1 deletion test/battle/ability/costar.c
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
25 changes: 25 additions & 0 deletions test/battle/ability/download.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 29e37a0

Please sign in to comment.