diff options
Diffstat (limited to 'sim/src')
-rw-r--r-- | sim/src/HitPoints.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sim/src/HitPoints.cpp b/sim/src/HitPoints.cpp index a214f42..251454d 100644 --- a/sim/src/HitPoints.cpp +++ b/sim/src/HitPoints.cpp @@ -18,11 +18,11 @@ HitPoints::HitPoints(double base_shield, double base_armour, double base_structu double HitPoints::Layer::consume(double& damage) { - if (damage <= 0.0) + if (damage <= 0.0 || points <= 0.0) return 0.0; - const double left_to_deal = damage - points; const double actual_damage = damage * resists; - points -= damage * resists; + const double left_to_deal = (actual_damage - points) / resists; + points -= actual_damage; damage = left_to_deal; return actual_damage; } |