Simplify HP Logic (#5403)

This commit is contained in:
Rose Silicon 2024-09-19 12:03:13 -04:00 committed by GitHub
parent fee26e29f5
commit 64d4d7e570
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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, &currentHP);
}