summaryrefslogtreecommitdiff
path: root/universe/src/TurretType.cpp
blob: 78887d7818a1af2fa5e49796fae396e471710527 (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
33
34
35
36
37
38
39
#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;
}


double
TurretType::damage_per_second() const
{
	return (base_damage * rounds) / (rounds * rate_of_fire + reload);
}


}  // namespace universe
}  // namespace kurator