From fade55e67e1a6944461c16c1495dea9546243756 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 19 Apr 2018 18:50:39 +0200 Subject: Improve the hivemind. --- src/game/units.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/game/units.cpp') diff --git a/src/game/units.cpp b/src/game/units.cpp index 11379cb..968e93e 100644 --- a/src/game/units.cpp +++ b/src/game/units.cpp @@ -288,13 +288,13 @@ void unit_t::random_walk(void) move.random_walk_time = game->time; } -void hivemind_attack(unit_t *source, v2f_t target) +void hivemind_attack(unit_t *source, bool have_target, v2f_t target) { rectf_t search; std::list ents; - search[0] = source->x - v2f_t(5, 5); - search[1] = source->x + v2f_t(5, 5); + search[0] = source->x - v2f_t(12, 12); + search[1] = source->x + v2f_t(12, 12); ents = source->game->world.get_entities(search, CF_BODY_SMALL); @@ -314,6 +314,9 @@ void hivemind_attack(unit_t *source, v2f_t target) unit->wake(); + if (!have_target) + continue; + // Move towards the target if it's close, otherwise walk // randomly to avoid fire. if ((unit->x - target).len() > 25.0f) -- cgit