From 5f59cc347bcfd2236f01532511974078aacde980 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 27 Feb 2023 23:40:59 +0100 Subject: Extracted range modifier into own method --- universe/include/kurator/universe/TurretType.h | 1 + universe/src/TurretType.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'universe') diff --git a/universe/include/kurator/universe/TurretType.h b/universe/include/kurator/universe/TurretType.h index c7ba5a3..c00c2ea 100644 --- a/universe/include/kurator/universe/TurretType.h +++ b/universe/include/kurator/universe/TurretType.h @@ -20,6 +20,7 @@ struct TurretType double falloff_modifier = 0.05; double falloff_intensity = 0.2; double effective_damage(double distance) const; + double range_modifier(double distance) const; double effective_range() const; double damage_per_second() const; }; 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)); } -- cgit v1.1