Fix special evolution triggering twice in certain situations (#4553)
This commit is contained in:
parent
d235a716fe
commit
6f12da0a67
1 changed files with 17 additions and 38 deletions
|
@ -115,7 +115,6 @@ static void HandleEndTurn_MonFled(void);
|
|||
static void HandleEndTurn_FinishBattle(void);
|
||||
static void SpriteCB_UnusedBattleInit(struct Sprite *sprite);
|
||||
static void SpriteCB_UnusedBattleInit_Main(struct Sprite *sprite);
|
||||
static void TrySpecialEvolution(void);
|
||||
static u32 Crc32B (const u8 *data, u32 size);
|
||||
static u32 GeneratePartyHash(const struct Trainer *trainer, u32 i);
|
||||
|
||||
|
@ -5808,7 +5807,7 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void)
|
|||
|| gBattleOutcome == B_OUTCOME_WON
|
||||
|| gBattleOutcome == B_OUTCOME_CAUGHT))
|
||||
{
|
||||
gBattleMainFunc = TrySpecialEvolution;
|
||||
gBattleMainFunc = TryEvolvePokemon;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5826,61 +5825,41 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void TrySpecialEvolution(void) // Attempts to perform non-level related battle evolutions (not the script command).
|
||||
static void TryEvolvePokemon(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, NULL);
|
||||
if (species != SPECIES_NONE && !(sTriedEvolving & gBitTable[i]))
|
||||
if (!(sTriedEvolving & gBitTable[i]))
|
||||
{
|
||||
u16 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, NULL);
|
||||
sTriedEvolving |= gBitTable[i];
|
||||
FreeAllWindowBuffers();
|
||||
gBattleMainFunc = WaitForEvoSceneToFinish;
|
||||
EvolutionScene(&gPlayerParty[i], species, TRUE, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
sTriedEvolving = 0;
|
||||
gBattleMainFunc = TryEvolvePokemon;
|
||||
}
|
||||
|
||||
static void TryEvolvePokemon(void)
|
||||
{
|
||||
s32 i;
|
||||
if (species == SPECIES_NONE && (gLeveledUpInBattle & gBitTable[i]))
|
||||
{
|
||||
gLeveledUpInBattle &= ~(gBitTable[i]);
|
||||
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_NORMAL, gLeveledUpInBattle, NULL);
|
||||
}
|
||||
|
||||
while (gLeveledUpInBattle != 0)
|
||||
{
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (gLeveledUpInBattle & gBitTable[i])
|
||||
if (species != SPECIES_NONE)
|
||||
{
|
||||
u16 species;
|
||||
u8 levelUpBits = gLeveledUpInBattle;
|
||||
|
||||
levelUpBits &= ~(gBitTable[i]);
|
||||
gLeveledUpInBattle = levelUpBits;
|
||||
|
||||
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_NORMAL, levelUpBits, NULL);
|
||||
if (species != SPECIES_NONE)
|
||||
{
|
||||
FreeAllWindowBuffers();
|
||||
gBattleMainFunc = WaitForEvoSceneToFinish;
|
||||
EvolutionScene(&gPlayerParty[i], species, TRUE, i);
|
||||
return;
|
||||
}
|
||||
FreeAllWindowBuffers();
|
||||
gBattleMainFunc = WaitForEvoSceneToFinish;
|
||||
EvolutionScene(&gPlayerParty[i], species, TRUE, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sTriedEvolving = 0;
|
||||
gLeveledUpInBattle = 0;
|
||||
gBattleMainFunc = ReturnFromBattleToOverworld;
|
||||
}
|
||||
|
||||
static void WaitForEvoSceneToFinish(void)
|
||||
{
|
||||
if (gMain.callback2 == BattleMainCB2)
|
||||
gBattleMainFunc = TrySpecialEvolution;
|
||||
gBattleMainFunc = TryEvolvePokemon;
|
||||
}
|
||||
|
||||
static void ReturnFromBattleToOverworld(void)
|
||||
|
|
Loading…
Reference in a new issue