summaryrefslogtreecommitdiff
path: root/sim/src
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-12-12 18:38:14 +0100
committerAki <please@ignore.pl>2022-12-12 18:38:14 +0100
commitf315fbc3406b13aef4712d391661fad6bcf4872c (patch)
tree7b768545b3aff91ac31387b954b06942f8ca9564 /sim/src
parent97257c552c546c1924ccc9348f0ad7a95dea169b (diff)
downloadkurator-f315fbc3406b13aef4712d391661fad6bcf4872c.zip
kurator-f315fbc3406b13aef4712d391661fad6bcf4872c.tar.gz
kurator-f315fbc3406b13aef4712d391661fad6bcf4872c.tar.bz2
Extracted effective damage calculation to universe
Diffstat (limited to 'sim/src')
-rw-r--r--sim/src/BaseBattle.cpp14
1 files changed, 1 insertions, 13 deletions
diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp
index 17dc739..448a5d7 100644
--- a/sim/src/BaseBattle.cpp
+++ b/sim/src/BaseBattle.cpp
@@ -1,8 +1,5 @@
#include "BaseBattle.h"
-#include <algorithm>
-#include <cmath>
-
#include <entt/entity/registry.hpp>
#include <entt/signal/dispatcher.hpp>
@@ -109,15 +106,6 @@ BaseBattle::floating_movement(const float dt)
}
-double
-effective_damage(const universe::TurretType& def, const double distance)
-{
- const auto overflow = distance - def.optimal_range;
- const auto falloff = std::max(0.0, overflow / def.optimal_range / def.falloff_modifier);
- return def.base_damage * std::round(std::pow(def.falloff_intensity, std::pow(falloff, 2)) * 1000) / 1000;
-}
-
-
void
BaseBattle::turrets(const float dt)
{
@@ -138,7 +126,7 @@ BaseBattle::turrets(const float dt)
const auto distance = transform.position - target.position;
if (distance.magnitude() > def.optimal_range * 2.5)
continue;
- const auto damage = effective_damage(def, distance.magnitude());
+ const auto damage = def.effective_damage(distance.magnitude());
if (damage > 0.0) {
target_points.health -= damage;
_dispatcher.trigger(Hit{damage, control.owner, state.target});