summaryrefslogtreecommitdiff
path: root/universe/src/TurretType.cpp
blob: b6e006d7cf7cdd9a1fb502161a5200531fe71d4e (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_falloff = std::sqrt(std::log2(0.01) / std::log2(falloff_intensity));
	const double one_percent_overflow = target_falloff * falloff_modifier * optimal_range;
	return one_percent_overflow + optimal_range;
}


}  // namespace universe
}  // namespace kurator