diff options
author | Aki <please@ignore.pl> | 2022-12-12 18:38:14 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-12-12 18:38:14 +0100 |
commit | f315fbc3406b13aef4712d391661fad6bcf4872c (patch) | |
tree | 7b768545b3aff91ac31387b954b06942f8ca9564 /universe/src | |
parent | 97257c552c546c1924ccc9348f0ad7a95dea169b (diff) | |
download | kurator-f315fbc3406b13aef4712d391661fad6bcf4872c.zip kurator-f315fbc3406b13aef4712d391661fad6bcf4872c.tar.gz kurator-f315fbc3406b13aef4712d391661fad6bcf4872c.tar.bz2 |
Extracted effective damage calculation to universe
Diffstat (limited to 'universe/src')
-rw-r--r-- | universe/src/TurretType.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/universe/src/TurretType.cpp b/universe/src/TurretType.cpp new file mode 100644 index 0000000..d213d07 --- /dev/null +++ b/universe/src/TurretType.cpp @@ -0,0 +1,23 @@ +#include <kurator/universe/TurretType.h> + +#include <algorithm> +#include <cmath> + + +namespace kurator +{ +namespace universe +{ + + +double +TurretType::effective_damage(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; +} + + +} // namespace universe +} // namespace kurator |