Fix Rare Candy reviving fainted level 100 Pokémon (#9117)
This commit is contained in:
parent
32d1777b7a
commit
eb7d055d6b
@ -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))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user