Fix Rare Candy reviving fainted level 100 Pokémon (#9117)

This commit is contained in:
GGbond 2026-02-07 01:45:36 +08:00 committed by GitHub
parent 32d1777b7a
commit eb7d055d6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3725,6 +3725,9 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
u8 effectFlags; u8 effectFlags;
s8 evChange; s8 evChange;
u16 evCount; u16 evCount;
u8 levelBefore;
bool8 didLevelUp = FALSE;
bool8 isLevelUpItem;
// Determine the EV cap to use // Determine the EV cap to use
u32 maxAllowedEVs = !B_EV_ITEMS_CAP ? MAX_TOTAL_EVS : GetCurrentEVCap(); u32 maxAllowedEVs = !B_EV_ITEMS_CAP ? MAX_TOTAL_EVS : GetCurrentEVCap();
@ -3746,6 +3749,8 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
// Get item effect // Get item effect
itemEffect = GetItemEffect(item); itemEffect = GetItemEffect(item);
isLevelUpItem = (itemEffect[3] & ITEM3_LEVEL_UP) != 0;
levelBefore = GetMonData(mon, MON_DATA_LEVEL, NULL);
// Do item effect // Do item effect
for (i = 0; i < ITEM_EFFECT_ARG_START; i++) for (i = 0; i < ITEM_EFFECT_ARG_START; i++)
@ -3800,6 +3805,8 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
{ {
SetMonData(mon, MON_DATA_EXP, &dataUnsigned); SetMonData(mon, MON_DATA_EXP, &dataUnsigned);
CalculateMonStats(mon); CalculateMonStats(mon);
if (GetMonData(mon, MON_DATA_LEVEL, NULL) > levelBefore)
didLevelUp = TRUE;
retVal = FALSE; retVal = FALSE;
} }
} }
@ -3918,6 +3925,11 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
{ {
u32 currentHP = GetMonData(mon, MON_DATA_HP, NULL); u32 currentHP = GetMonData(mon, MON_DATA_HP, NULL);
u32 maxHP = GetMonData(mon, MON_DATA_MAX_HP, NULL); u32 maxHP = GetMonData(mon, MON_DATA_MAX_HP, NULL);
if (isLevelUpItem && !didLevelUp && (effectFlags & (ITEM4_REVIVE >> 2)))
{
itemEffectParam++;
break;
}
// Check use validity. // Check use validity.
if ((effectFlags & (ITEM4_REVIVE >> 2) && currentHP != 0) if ((effectFlags & (ITEM4_REVIVE >> 2) && currentHP != 0)
|| (!(effectFlags & (ITEM4_REVIVE >> 2)) && currentHP == 0)) || (!(effectFlags & (ITEM4_REVIVE >> 2)) && currentHP == 0))