summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--campaign/src/scenarios.cpp4
-rw-r--r--sim/include/kurator/sim/components.h2
-rw-r--r--sim/src/BaseBattle.cpp16
-rw-r--r--sim/src/Builder.cpp2
-rw-r--r--universe/include/kurator/universe/TurretType.h12
-rw-r--r--universe/src/SampleRepository.cpp3
6 files changed, 25 insertions, 14 deletions
diff --git a/campaign/src/scenarios.cpp b/campaign/src/scenarios.cpp
index 2a18d22..bbb01f4 100644
--- a/campaign/src/scenarios.cpp
+++ b/campaign/src/scenarios.cpp
@@ -19,9 +19,9 @@ example(int teams, int anvils, int warbringers, int eclipses, double distance)
Scenario scenario {"Example", distance, {}};
for (int team = 0; team < teams; ++team) {
for (int i = 0; i < anvils; ++i)
- scenario.ships.push_back(ShipConfig{{id++}, team, "Anvil", {"ChargeLaser", "ChargeLaser"}});
+ scenario.ships.push_back(ShipConfig{{id++}, team, "Anvil", {"ChargeLaser", "BurstLaser"}});
for (int i = 0; i < warbringers; ++i)
- scenario.ships.push_back(ShipConfig{{id++}, team, "Warbringer", {"ChargeLaser"}});
+ scenario.ships.push_back(ShipConfig{{id++}, team, "Warbringer", {"BurstLaser"}});
for (int i = 0; i < eclipses; ++i)
scenario.ships.push_back(ShipConfig{{id++}, team, "Eclipse", {"ChargeLaser"}});
}
diff --git a/sim/include/kurator/sim/components.h b/sim/include/kurator/sim/components.h
index 47ff5b2..7190369 100644
--- a/sim/include/kurator/sim/components.h
+++ b/sim/include/kurator/sim/components.h
@@ -41,7 +41,9 @@ struct HitPoints
struct TurretControl
{
+ double delay;
double reload;
+ int rounds;
entt::entity owner;
};
diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp
index 46c98ed..5f72483 100644
--- a/sim/src/BaseBattle.cpp
+++ b/sim/src/BaseBattle.cpp
@@ -104,18 +104,24 @@ BaseBattle::turrets(const float dt)
continue;
if (control.reload > 0.0)
control.reload -= dt;
- if (control.reload <= 0.0) {
+ if (control.rounds < 1 && control.reload <= 0.0)
+ control.rounds = def.rounds;
+ if (control.delay > 0.0)
+ control.delay -= dt;
+ if (control.rounds > 0 && control.delay <= 0.0) {
auto& target_points = _registry.get<HitPoints>(state.target);
const auto& target = _registry.get<Transform>(state.target);
- const auto distance = transform.position - target.position;
- if (distance.magnitude() > def.optimal_range * 2.5)
+ const auto distance = transform.position.distance(target.position);
+ if (distance > def.optimal_range * 2.5)
continue;
- const auto damage = def.effective_damage(distance.magnitude());
+ const auto damage = def.effective_damage(distance);
if (damage > 0.0) {
target_points.health -= damage;
_dispatcher.trigger(Hit{damage, control.owner, state.target});
}
- control.reload = def.rate_of_fire;
+ control.delay = def.rate_of_fire;
+ if (--control.rounds < 1)
+ control.reload = def.reload;
}
}
}
diff --git a/sim/src/Builder.cpp b/sim/src/Builder.cpp
index e0198a1..068d012 100644
--- a/sim/src/Builder.cpp
+++ b/sim/src/Builder.cpp
@@ -47,7 +47,7 @@ Builder::operator()(const universe::TurretType& turret_type, const entt::entity&
{
const auto entity = registry.create();
registry.emplace<universe::TurretType>(entity, turret_type);
- registry.emplace<TurretControl>(entity, 0.0, owner);
+ registry.emplace<TurretControl>(entity, 0.0, 0.0, turret_type.rounds, owner);
registry.emplace<Transform>(entity, Point{0.0, 0.0}, 0.0, owner);
return entity;
}
diff --git a/universe/include/kurator/universe/TurretType.h b/universe/include/kurator/universe/TurretType.h
index ff67cfe..553894b 100644
--- a/universe/include/kurator/universe/TurretType.h
+++ b/universe/include/kurator/universe/TurretType.h
@@ -12,11 +12,13 @@ namespace universe
struct TurretType
{
std::string name;
- double base_damage;
- double rate_of_fire;
- double optimal_range;
- double falloff_modifier;
- double falloff_intensity;
+ int rounds = 1;
+ double base_damage = 0.0;
+ double rate_of_fire = 1.0;
+ double reload = 0.0;
+ double optimal_range = 0.0;
+ double falloff_modifier = 0.05;
+ double falloff_intensity = 0.2;
double effective_damage(double distance) const;
};
diff --git a/universe/src/SampleRepository.cpp b/universe/src/SampleRepository.cpp
index 31f7807..857d175 100644
--- a/universe/src/SampleRepository.cpp
+++ b/universe/src/SampleRepository.cpp
@@ -23,7 +23,8 @@ static const std::unordered_map<std::string, ShipType> ships {
static const std::unordered_map<std::string, TurretType> turrets {
- {"ChargeLaser", {"ChargeLaser", 85.0, 4.5, 7000.0, 0.05, 0.2}},
+ {"ChargeLaser", {"ChargeLaser", 1, 85.0, 4.5, 0.0, 7000.0, 0.05}},
+ {"BurstLaser", {"BurstLaser", 3, 21.0, 0.25, 2.75, 3500.0, 0.05}},
};