summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/unit_spider.cpp18
-rw-r--r--src/game/units.cpp6
2 files changed, 17 insertions, 7 deletions
diff --git a/src/game/unit_spider.cpp b/src/game/unit_spider.cpp
index 4f0fbd9..5d6253d 100644
--- a/src/game/unit_spider.cpp
+++ b/src/game/unit_spider.cpp
@@ -82,15 +82,21 @@ void unit_spider_t::on_wake(void)
void unit_spider_t::on_think(void)
{
+ if (game->now - wake_time > 10.0) {
+ sleep();
+ return;
+ }
+
target_and_attack();
- if (have_target || game->now - wake_time < 10.0) {
- if (!have_target && !move.moving)
- random_walk();
+ if (!have_target && !move.moving)
+ random_walk();
- keep_moving(4.0);
- } else
- sleep();
+ if (!keep_moving(4.0)) {
+ // Try to get unstuck.
+ next_targetting = game->now + 0.6;
+ random_walk();
+ }
}
void unit_spider_t::on_damage(unit_t *attacker)
diff --git a/src/game/units.cpp b/src/game/units.cpp
index 6bce474..e7263c0 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -271,7 +271,11 @@ void unit_t::random_walk(void)
game->time - move.random_walk_time < MSEC(1000))
return;
- start_moving(x + game->prng.unit_vec2() * 10);
+ move.moving = true;
+ move.blocked = false;
+ move.dst = x + game->prng.unit_vec2() * 10;
+ move.path.clear();
+ move.path.push_back(move.dst);
move.random_walk_time = game->time;
}