Test battlers always have their forced abilities (#4707)

* Test battlers always have their forced abilities

* indentation
This commit is contained in:
sneed 2024-07-21 22:20:39 +03:00 committed by GitHub
parent 0b02527e5c
commit 3fa6bf46db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 65 additions and 0 deletions

View file

@ -1609,6 +1609,15 @@ static u32 GetBattlerMonData(u32 battler, struct Pokemon *party, u32 monId, u8 *
src = (u8 *)&battleMon;
for (size = 0; size < sizeof(battleMon); size++)
dst[size] = src[size];
#if TESTING
if (gTestRunnerEnabled)
{
u32 side = GetBattlerSide(battler);
u32 partyIndex = gBattlerPartyIndexes[battler];
if (TestRunner_Battle_GetForcedAbility(side, partyIndex))
gBattleMons[battler].ability = gBattleStruct->overwrittenAbilities[battler] = TestRunner_Battle_GetForcedAbility(side, partyIndex);
}
#endif
break;
case REQUEST_SPECIES_BATTLE:
data16 = GetMonData(&party[monId], MON_DATA_SPECIES);

View file

@ -3477,6 +3477,15 @@ static void DoBattleIntro(void)
gBattleMons[battler].status2 = 0;
for (i = 0; i < NUM_BATTLE_STATS; i++)
gBattleMons[battler].statStages[i] = DEFAULT_STAT_STAGE;
#if TESTING
if (gTestRunnerEnabled)
{
u32 side = GetBattlerSide(battler);
u32 partyIndex = gBattlerPartyIndexes[battler];
if (TestRunner_Battle_GetForcedAbility(side, partyIndex))
gBattleMons[battler].ability = gBattleStruct->overwrittenAbilities[battler] = TestRunner_Battle_GetForcedAbility(side, partyIndex);
}
#endif
}
// Draw sprite.

View file

@ -6518,6 +6518,15 @@ static void Cmd_switchindataupdate(void)
gBattleMons[battler].type2 = gSpeciesInfo[gBattleMons[battler].species].types[1];
gBattleMons[battler].type3 = TYPE_MYSTERY;
gBattleMons[battler].ability = GetAbilityBySpecies(gBattleMons[battler].species, gBattleMons[battler].abilityNum);
#if TESTING
if (gTestRunnerEnabled)
{
u32 side = GetBattlerSide(battler);
u32 partyIndex = gBattlerPartyIndexes[battler];
if (TestRunner_Battle_GetForcedAbility(side, partyIndex))
gBattleMons[battler].ability = gBattleStruct->overwrittenAbilities[battler] = TestRunner_Battle_GetForcedAbility(side, partyIndex);
}
#endif
// check knocked off item
i = GetBattlerSide(battler);
@ -13232,7 +13241,17 @@ static void Cmd_healpartystatus(void)
else if (isDoublesPartner)
ability = GetBattlerAbility(partner);
else
{
ability = GetAbilityBySpecies(species, abilityNum);
#if TESTING
if (gTestRunnerEnabled)
{
u32 side = GetBattlerSide(gBattlerAttacker);
if (TestRunner_Battle_GetForcedAbility(side, i))
ability = TestRunner_Battle_GetForcedAbility(side, i);
}
#endif
}
if (ability != ABILITY_SOUNDPROOF)
toHeal |= (1 << i);

View file

@ -0,0 +1,27 @@
#include "global.h"
#include "test/battle.h"
ASSUMPTIONS {
int i;
for (i = 0; i < NUM_ABILITY_SLOTS; i++) {
ASSUME(gSpeciesInfo[SPECIES_KADABRA].abilities[i] != ABILITY_QUARK_DRIVE);
ASSUME(gSpeciesInfo[SPECIES_ALAKAZAM].abilities[i] != ABILITY_ELECTRIC_SURGE);
}
}
SINGLE_BATTLE_TEST("Forced abilities activate on switch-in")
{
GIVEN {
PLAYER(SPECIES_ALAKAZAM);
PLAYER(SPECIES_KADABRA) { Ability(ABILITY_QUARK_DRIVE); SpAttack(400);}
OPPONENT(SPECIES_ARON);
OPPONENT(SPECIES_ALAKAZAM) { Ability(ABILITY_ELECTRIC_SURGE); };
} WHEN {
TURN { SWITCH(player, 1); SWITCH(opponent, 1);}
} SCENE {
ABILITY_POPUP(opponent, ABILITY_ELECTRIC_SURGE);
ABILITY_POPUP(player, ABILITY_QUARK_DRIVE);
MESSAGE("The Electric Terrain activated Kadabra's Quark Drive!");
MESSAGE("Kadabra's Sp. Atk was heightened!");
}
}

View file

@ -1624,6 +1624,7 @@ void Ability_(u32 sourceLine, u32 ability)
u32 species;
const struct SpeciesInfo *info;
INVALID_IF(!DATA.currentMon, "Ability outside of PLAYER/OPPONENT");
INVALID_IF(ability >= ABILITIES_COUNT, "Illegal ability id: %d", ability);
species = GetMonData(DATA.currentMon, MON_DATA_SPECIES);
info = &gSpeciesInfo[species];
for (i = 0; i < NUM_ABILITY_SLOTS; i++)