From e9187a92220a62337d83a18aa973a8e86d3014a4 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 12 Jan 2023 22:14:50 +0100 Subject: Fixed edge cases in inter-layer damage consumption --- sim/src/HitPoints.cpp | 6 +++--- 1 file 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; } -- cgit v1.1