From e323b622506d800ba4460e25e2b867bc41ca2cdf Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 28 Aug 2021 12:20:22 +0200 Subject: [PATCH] Damage calculation can only return 0 if effectiveness is 0. --- src/Battling/Library/DamageLibrary.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Battling/Library/DamageLibrary.cpp b/src/Battling/Library/DamageLibrary.cpp index 12787d6..12f67ec 100644 --- a/src/Battling/Library/DamageLibrary.cpp +++ b/src/Battling/Library/DamageLibrary.cpp @@ -34,7 +34,7 @@ uint32_t PkmnLib::Battling::DamageLibrary::GetDamage(CreatureLib::Battling::Exec if (_hasRandomness) { Ensure(attack->GetUser()->GetBattle().GetValue()); float randPercentage = 85 + attack->GetUser()->GetBattle().GetValue()->GetRandom()->Get(0, 16); - floatDamage = fl(floatDamage * (randPercentage / 100.0)); + floatDamage = fl(floatDamage * (randPercentage / 100.0f)); } if (attack->GetUser()->HasType(hitData.GetType())) { @@ -46,8 +46,12 @@ uint32_t PkmnLib::Battling::DamageLibrary::GetDamage(CreatureLib::Battling::Exec floatDamage = fl(floatDamage * hitData.GetEffectiveness()); uint32_t damage = 0; - if (floatDamage < 0) { - damage = 0; + if (floatDamage <= 0) { + if (hitData.GetEffectiveness() == 0) { + damage = 0; + } else { + damage = 1; + } } else if (floatDamage >= (float)UINT32_MAX) { damage = UINT32_MAX; } else {