From eb7d055d6bb78f19dbeb2a842236be6337903aee Mon Sep 17 00:00:00 2001 From: GGbond Date: Sat, 7 Feb 2026 01:45:36 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Rare=20Candy=20reviving=20fainted=20level?= =?UTF-8?q?=20100=20Pok=C3=A9mon=20(#9117)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pokemon.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pokemon.c b/src/pokemon.c index 90273d1709..96b661bf52 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3725,6 +3725,9 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov u8 effectFlags; s8 evChange; u16 evCount; + u8 levelBefore; + bool8 didLevelUp = FALSE; + bool8 isLevelUpItem; // Determine the EV cap to use 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 itemEffect = GetItemEffect(item); + isLevelUpItem = (itemEffect[3] & ITEM3_LEVEL_UP) != 0; + levelBefore = GetMonData(mon, MON_DATA_LEVEL, NULL); // Do item effect 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); CalculateMonStats(mon); + if (GetMonData(mon, MON_DATA_LEVEL, NULL) > levelBefore) + didLevelUp = TRUE; 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 maxHP = GetMonData(mon, MON_DATA_MAX_HP, NULL); + if (isLevelUpItem && !didLevelUp && (effectFlags & (ITEM4_REVIVE >> 2))) + { + itemEffectParam++; + break; + } // Check use validity. if ((effectFlags & (ITEM4_REVIVE >> 2) && currentHP != 0) || (!(effectFlags & (ITEM4_REVIVE >> 2)) && currentHP == 0))