diff --git a/src/pokemon.c b/src/pokemon.c index d76d1df58c..faa1a65aef 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1800,29 +1800,19 @@ void CalculateMonStats(struct Pokemon *mon) CALC_STAT(baseSpAttack, spAttackIV, spAttackEV, STAT_SPATK, MON_DATA_SPATK) CALC_STAT(baseSpDefense, spDefenseIV, spDefenseEV, STAT_SPDEF, MON_DATA_SPDEF) - if (species == SPECIES_SHEDINJA) - { - if (currentHP != 0 || oldMaxHP == 0) - currentHP = 1; - else - return; - } - else - { - if (currentHP == 0 && oldMaxHP == 0) - currentHP = newMaxHP; - else if (currentHP != 0) - { - if (newMaxHP > oldMaxHP) - currentHP += newMaxHP - oldMaxHP; - if (currentHP <= 0) - currentHP = 1; - if (currentHP > newMaxHP) - currentHP = newMaxHP; - } - else - return; - } + // Since a pokemon's maxHP data could either not have + // been initialized at this point or this pokemon is + // just fainted, the check for oldMaxHP is important. + if (currentHP == 0 && oldMaxHP != 0) + return; + + // Only add to currentHP if newMaxHP went up. + if (newMaxHP > oldMaxHP) + currentHP += newMaxHP - oldMaxHP; + + // Ensure currentHP does not surpass newMaxHP. + if (currentHP > newMaxHP) + currentHP = newMaxHP; SetMonData(mon, MON_DATA_HP, ¤tHP); }