Simplify HP Logic (#5403)
This commit is contained in:
parent
fee26e29f5
commit
64d4d7e570
1 changed files with 13 additions and 23 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue