Fixes EVO_BATTLE_END evolutions not removing item with additional conditions (#7841)

This commit is contained in:
PhallenTree 2025-10-03 15:43:03 +01:00 committed by GitHub
parent d2e8afa13a
commit 1856688ea0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 10 deletions

View File

@ -5719,20 +5719,24 @@ static void TryEvolvePokemon(void)
if (!(sTriedEvolving & (1u << i)))
{
bool32 canStopEvo = TRUE;
u32 species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_SPECIAL, i, NULL, &canStopEvo, CHECK_EVO);
enum EvolutionMode mode = EVO_MODE_BATTLE_SPECIAL;
u32 evolutionItemArg = i;
u32 species = GetEvolutionTargetSpecies(&gPlayerParty[i], mode, evolutionItemArg, NULL, &canStopEvo, CHECK_EVO);
sTriedEvolving |= 1u << i;
if (species == SPECIES_NONE && (gLeveledUpInBattle & (1u << i)))
{
gLeveledUpInBattle &= ~(1u << i);
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_ONLY, gLeveledUpInBattle, NULL, &canStopEvo, CHECK_EVO);
mode = EVO_MODE_BATTLE_ONLY;
evolutionItemArg = gLeveledUpInBattle;
species = GetEvolutionTargetSpecies(&gPlayerParty[i], mode, evolutionItemArg, NULL, &canStopEvo, CHECK_EVO);
}
if (species != SPECIES_NONE)
{
FreeAllWindowBuffers();
gBattleMainFunc = WaitForEvoSceneToFinish;
GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_ONLY, gLeveledUpInBattle, NULL, &canStopEvo, DO_EVO);
GetEvolutionTargetSpecies(&gPlayerParty[i], mode, evolutionItemArg, NULL, &canStopEvo, DO_EVO);
EvolutionScene(&gPlayerParty[i], species, canStopEvo, i);
return;
}

View File

@ -4836,7 +4836,7 @@ u32 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
case EVO_MODE_ITEM_CHECK:
for (i = 0; evolutions[i].method != EVOLUTIONS_END; i++)
{
bool32 conditionMet = FALSE;
bool32 conditionsMet = FALSE;
if (SanitizeSpeciesId(evolutions[i].targetSpecies) == SPECIES_NONE)
continue;
@ -4844,11 +4844,11 @@ u32 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
{
case EVO_ITEM:
if (evolutions[i].param == evolutionItem)
conditionMet = TRUE;
conditionsMet = TRUE;
break;
}
if (conditionMet && DoesMonMeetAdditionalConditions(mon, evolutions[i].params, NULL, PARTY_SIZE, canStopEvo, evoState))
if (conditionsMet && DoesMonMeetAdditionalConditions(mon, evolutions[i].params, NULL, PARTY_SIZE, canStopEvo, evoState))
{
// All checks passed, so stop checking the rest of the evolutions.
// This is different from vanilla where the loop continues.
@ -4870,9 +4870,9 @@ u32 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
switch (evolutions[i].method)
{
case EVO_BATTLE_END:
conditionsMet = TRUE;
break;
case EVO_BATTLE_END:
conditionsMet = TRUE;
break;
}
if (conditionsMet && DoesMonMeetAdditionalConditions(mon, evolutions[i].params, NULL, evolutionItem, canStopEvo, evoState))
@ -4898,7 +4898,6 @@ u32 GetEvolutionTargetSpecies(struct Pokemon *mon, enum EvolutionMode mode, u16
case EVO_SPIN:
if (gSpecialVar_0x8000 == evolutions[i].param)
conditionsMet = TRUE;
break;
}