summaryrefslogtreecommitdiff
path: root/universe/src
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-02-27 23:40:59 +0100
committerAki <please@ignore.pl>2023-02-27 23:40:59 +0100
commit5f59cc347bcfd2236f01532511974078aacde980 (patch)
tree2c0367ecb0aa860ce95fbba6f2cfd062473b5bec /universe/src
parent54fdda07eb769df0075784d4f7311ec2ec13fbba (diff)
downloadkurator-5f59cc347bcfd2236f01532511974078aacde980.zip
kurator-5f59cc347bcfd2236f01532511974078aacde980.tar.gz
kurator-5f59cc347bcfd2236f01532511974078aacde980.tar.bz2
Extracted range modifier into own method
Diffstat (limited to 'universe/src')
-rw-r--r--universe/src/TurretType.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/universe/src/TurretType.cpp b/universe/src/TurretType.cpp
index 78887d7..0dc6be6 100644
--- a/universe/src/TurretType.cpp
+++ b/universe/src/TurretType.cpp
@@ -13,9 +13,16 @@ namespace universe
double
TurretType::effective_damage(const double distance) const
{
+ return base_damage * std::round(range_modifier(distance) * 1000) / 1000;
+}
+
+
+double
+TurretType::range_modifier(const double distance) const
+{
const auto overflow = distance - optimal_range;
const auto falloff = std::max(0.0, overflow / optimal_range / falloff_modifier);
- return base_damage * std::round(std::pow(falloff_intensity, std::pow(falloff, 2)) * 1000) / 1000;
+ return std::pow(falloff_intensity, std::pow(falloff, 2));
}