summaryrefslogtreecommitdiff
path: root/universe/src/TurretType.cpp
blob: a215b32ac092b1474492874144322f731d1b58a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#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;
}


double
TurretType::effective_range() const
{
	const double target = std::log2(0.01) / std::log2(falloff_intensity);
	const double one_percent_falloff = target * falloff_modifier * optimal_range;
	return one_percent_falloff + optimal_range;
}


}  // namespace universe
}  // namespace kurator