summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-12-12 18:42:52 +0100
committerAki <please@ignore.pl>2022-12-12 18:42:52 +0100
commit42d5170e3add3dc5e7ea2c944bcfd785a5390586 (patch)
treebe9fcdc1912a957bee316dd710159e91e99bf7c7
parentf315fbc3406b13aef4712d391661fad6bcf4872c (diff)
downloadkurator-42d5170e3add3dc5e7ea2c944bcfd785a5390586.zip
kurator-42d5170e3add3dc5e7ea2c944bcfd785a5390586.tar.gz
kurator-42d5170e3add3dc5e7ea2c944bcfd785a5390586.tar.bz2
Extracted preferred keep at range distance to AI
-rw-r--r--sim/include/kurator/sim/components.h1
-rw-r--r--sim/src/BaseBattle.cpp2
-rw-r--r--sim/src/Builder.cpp2
3 files changed, 3 insertions, 2 deletions
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<Transform>(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<AIState>(entity, Point{0.0, 0.0});
+ registry.emplace<AIState>(entity, 6000.0, Point{0.0, 0.0});
registry.emplace<HitPoints>(entity, ship_type.base_health_points);
return entity;
}