summaryrefslogtreecommitdiff
path: root/universe
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-02-28 01:17:48 +0100
committerAki <please@ignore.pl>2023-02-28 01:17:48 +0100
commit09c65f2822b99e43ccbc20a84998b1cc3e26eae8 (patch)
treed8bcf0886ca04c90bffa09ec0861e9d0368b2bc2 /universe
parent4e1f59b5c6689e38023f12daee7d5c6f3d4715e5 (diff)
downloadkurator-09c65f2822b99e43ccbc20a84998b1cc3e26eae8.zip
kurator-09c65f2822b99e43ccbc20a84998b1cc3e26eae8.tar.gz
kurator-09c65f2822b99e43ccbc20a84998b1cc3e26eae8.tar.bz2
Added tracking to damage calculations
Diffstat (limited to 'universe')
-rw-r--r--universe/include/kurator/universe/TurretType.h6
-rw-r--r--universe/resources/universe/turret_types.json18
-rw-r--r--universe/src/JsonRepository.cpp3
-rw-r--r--universe/src/TurretType.cpp14
4 files changed, 32 insertions, 9 deletions
diff --git a/universe/include/kurator/universe/TurretType.h b/universe/include/kurator/universe/TurretType.h
index c00c2ea..7b3ebdc 100644
--- a/universe/include/kurator/universe/TurretType.h
+++ b/universe/include/kurator/universe/TurretType.h
@@ -19,8 +19,12 @@ struct TurretType
double optimal_range = 0.0;
double falloff_modifier = 0.05;
double falloff_intensity = 0.2;
- double effective_damage(double distance) const;
+ double tracking = 1000;
+ double tracking_factor = 3.0;
+ double tracking_exponent = 0.5;
+ double effective_damage(double distance, double speed) const;
double range_modifier(double distance) const;
+ double tracking_modifier(double distance, double speed) const;
double effective_range() const;
double damage_per_second() const;
};
diff --git a/universe/resources/universe/turret_types.json b/universe/resources/universe/turret_types.json
index 0b4e3ca..0004ef1 100644
--- a/universe/resources/universe/turret_types.json
+++ b/universe/resources/universe/turret_types.json
@@ -6,7 +6,8 @@
"rate_of_fire": 4.5,
"reload": 0.0,
"optimal_range": 7000.0,
- "falloff_modifier": 0.05
+ "falloff_modifier": 0.05,
+ "tracking": 150.0
},
{
"name": "BurstLaser",
@@ -15,7 +16,8 @@
"rate_of_fire": 0.25,
"reload": 2.75,
"optimal_range": 3500.0,
- "falloff_modifier": 0.05
+ "falloff_modifier": 0.05,
+ "tracking": 260.0
},
{
"name": "GaussCannon",
@@ -24,7 +26,8 @@
"rate_of_fire": 0.0,
"reload": 5.5,
"optimal_range": 12000.0,
- "falloff_modifier": 0.2
+ "falloff_modifier": 0.2,
+ "tracking": 35.0
},
{
"name": "Autocannon",
@@ -33,7 +36,8 @@
"rate_of_fire": 0.15,
"reload": 1.5,
"optimal_range": 2000,
- "falloff_modifier": 0.8
+ "falloff_modifier": 0.8,
+ "tracking": 350.0
},
{
"name": "Howitzer",
@@ -42,7 +46,8 @@
"rate_of_fire": 7.5,
"reload": 0,
"optimal_range": 5600,
- "falloff_modifier": 0.5
+ "falloff_modifier": 0.5,
+ "tracking": 60.0
},
{
"name": "Blaster",
@@ -51,6 +56,7 @@
"rate_of_fire": 0,
"reload": 2,
"optimal_range": 750,
- "falloff_modifier": 0.45
+ "falloff_modifier": 0.45,
+ "tracking": 450.0
}
]
diff --git a/universe/src/JsonRepository.cpp b/universe/src/JsonRepository.cpp
index 5d15646..dbfb8ea 100644
--- a/universe/src/JsonRepository.cpp
+++ b/universe/src/JsonRepository.cpp
@@ -56,6 +56,9 @@ from_json(const json& item, TurretType& turret)
maybe_to(item, "optimal_range", turret.optimal_range);
maybe_to(item, "falloff_modifier", turret.falloff_modifier);
maybe_to(item, "falloff_intensity", turret.falloff_intensity);
+ maybe_to(item, "tracking", turret.tracking);
+ maybe_to(item, "tracking_factor", turret.tracking_factor);
+ maybe_to(item, "tracking_exponent", turret.tracking_exponent);
}
diff --git a/universe/src/TurretType.cpp b/universe/src/TurretType.cpp
index b64efd4..4da47ef 100644
--- a/universe/src/TurretType.cpp
+++ b/universe/src/TurretType.cpp
@@ -11,9 +11,9 @@ namespace universe
double
-TurretType::effective_damage(const double distance) const
+TurretType::effective_damage(const double distance, const double speed) const
{
- return base_damage * std::round(range_modifier(distance) * 1000) / 1000;
+ return base_damage * std::round(range_modifier(distance) * tracking_modifier(distance, speed) * 1000) / 1000;
}
@@ -27,6 +27,16 @@ TurretType::range_modifier(const double distance) const
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;