diff options
author | Aki <please@ignore.pl> | 2023-01-12 22:14:50 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-01-12 22:14:50 +0100 |
commit | e9187a92220a62337d83a18aa973a8e86d3014a4 (patch) | |
tree | 3d6b1c7b3c1fc37a0dbd966aeeb290a172e56146 | |
parent | 71c845e53bcbe1e5019735e154ea5bbb0b3c83d7 (diff) | |
download | kurator-e9187a92220a62337d83a18aa973a8e86d3014a4.zip kurator-e9187a92220a62337d83a18aa973a8e86d3014a4.tar.gz kurator-e9187a92220a62337d83a18aa973a8e86d3014a4.tar.bz2 |
Fixed edge cases in inter-layer damage consumption
-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; } |