From 42d5170e3add3dc5e7ea2c944bcfd785a5390586 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 12 Dec 2022 18:42:52 +0100 Subject: Extracted preferred keep at range distance to AI --- sim/include/kurator/sim/components.h | 1 + sim/src/BaseBattle.cpp | 2 +- sim/src/Builder.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'sim') diff --git a/sim/include/kurator/sim/components.h b/sim/include/kurator/sim/components.h index 41c8053..6fbab55 100644 --- a/sim/include/kurator/sim/components.h +++ b/sim/include/kurator/sim/components.h @@ -27,6 +27,7 @@ struct Team struct AIState { + double keep_at_range; Point destination; entt::entity target = entt::null; }; diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp index 448a5d7..945ef89 100644 --- a/sim/src/BaseBattle.cpp +++ b/sim/src/BaseBattle.cpp @@ -78,7 +78,7 @@ BaseBattle::keep_at_range() continue; const auto target = _registry.get(ai.target); const Point offset = target.position - self.position; - ai.destination = target.position - offset.normalized().scale(6000.0); + ai.destination = target.position - offset.normalized().scale(ai.keep_at_range); } } diff --git a/sim/src/Builder.cpp b/sim/src/Builder.cpp index dd10326..a5319fd 100644 --- a/sim/src/Builder.cpp +++ b/sim/src/Builder.cpp @@ -36,7 +36,7 @@ Builder::operator()(const universe::ShipType& ship_type, const int team) const ship_type.max_speed * 2.0, ship_type.max_speed * 3.0, 100.0); - registry.emplace(entity, Point{0.0, 0.0}); + registry.emplace(entity, 6000.0, Point{0.0, 0.0}); registry.emplace(entity, ship_type.base_health_points); return entity; } -- cgit v1.1