blob: 4da47efd0facde82af17684428284f763d321abf (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include <kurator/universe/TurretType.h>
#include <algorithm>
#include <cmath>
namespace kurator
{
namespace universe
{
double
TurretType::effective_damage(const double distance, const double speed) const
{
return base_damage * std::round(range_modifier(distance) * tracking_modifier(distance, speed) * 1000) / 1000;
}
double
TurretType::range_modifier(const double distance) const
{
const auto overflow = distance - optimal_range;
const auto falloff = std::max(0.0, overflow / optimal_range / falloff_modifier);
return std::pow(falloff_intensity, std::pow(falloff, 2));
}
double
TurretType::tracking_modifier(const double distance, const double speed) const
{
const auto simplified_falloff = optimal_range + optimal_range * falloff_modifier;
const auto by_distance = (distance + 1.0) / simplified_falloff;
const auto by_speed = tracking / (speed + 1.0);
return std::min(1.0, std::pow(tracking_factor * by_distance * by_speed, tracking_exponent));
}
double
TurretType::effective_range() const
{
const double one_point = 1.0 / base_damage;
const double target_falloff = std::sqrt(std::log2(one_point) / std::log2(falloff_intensity));
const double one_point_overflow = target_falloff * falloff_modifier * optimal_range;
return one_point_overflow + optimal_range;
}
double
TurretType::damage_per_second() const
{
return (base_damage * rounds) / (rounds * rate_of_fire + reload);
}
} // namespace universe
} // namespace kurator
|