summaryrefslogtreecommitdiff
path: root/sim/src
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-01-12 22:14:50 +0100
committerAki <please@ignore.pl>2023-01-12 22:14:50 +0100
commite9187a92220a62337d83a18aa973a8e86d3014a4 (patch)
tree3d6b1c7b3c1fc37a0dbd966aeeb290a172e56146 /sim/src
parent71c845e53bcbe1e5019735e154ea5bbb0b3c83d7 (diff)
downloadkurator-e9187a92220a62337d83a18aa973a8e86d3014a4.zip
kurator-e9187a92220a62337d83a18aa973a8e86d3014a4.tar.gz
kurator-e9187a92220a62337d83a18aa973a8e86d3014a4.tar.bz2
Fixed edge cases in inter-layer damage consumption
Diffstat (limited to 'sim/src')
-rw-r--r--sim/src/HitPoints.cpp6
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;
}