diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-04-19 18:50:39 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-04-19 18:50:39 +0200 |
commit | fade55e67e1a6944461c16c1495dea9546243756 (patch) | |
tree | 6fd02d2f6ba1b28b98ac62e4fe51064c4bfede28 /src/game/units.cpp | |
parent | aea9498a593321a3cb34fa93d3d4734ebd8370c1 (diff) |
Improve the hivemind.
Diffstat (limited to 'src/game/units.cpp')
-rw-r--r-- | src/game/units.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
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<world::entity_t*> 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) |