Fixed visual glitch where a Pokémon's HP would raise then lower if its substitute took damage

This commit is contained in:
Maruno17
2022-01-08 18:11:02 +00:00
parent f623fad42e
commit f853816d63

View File

@@ -245,8 +245,14 @@ class Battle::Move
targets.each do |b|
next if b.damageState.unaffected || b.damageState.hpLost == 0
next if (side == 0 && b.opposes?(user)) || (side == 1 && !b.opposes?(user))
oldHP = b.hp + b.damageState.hpLost
PBDebug.log("[Move damage] #{b.pbThis} lost #{b.damageState.hpLost} HP (#{oldHP}=>#{b.hp})")
oldHP = b.hp
if b.damageState.substitute
old_sub_hp = b.effects[PBEffects::Substitute] + b.damageState.hpLost
PBDebug.log("[Move damage] #{b.pbThis}'s substitute lost #{b.damageState.hpLost} HP (#{old_sub_hp}=>#{b.effects[PBEffects::Substitute]})")
else
oldHP += b.damageState.hpLost
PBDebug.log("[Move damage] #{b.pbThis} lost #{b.damageState.hpLost} HP (#{oldHP}=>#{b.hp})")
end
effectiveness = 0
if Effectiveness.resistant?(b.damageState.typeMod)
effectiveness = 1