diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-04-12 23:17:02 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-04-12 23:17:02 +0200 |
commit | 545b0a1e0870aaf5032d8b2b96dcfc13ae97126f (patch) | |
tree | 11ab528d70030e3b89a6b84b09de7ff202c83b28 /src/game/units.cpp | |
parent | f274f281da32c829e20c5012d67431d6a4348cce (diff) |
Misc. gameplay improvements.
Diffstat (limited to 'src/game/units.cpp')
-rw-r--r-- | src/game/units.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/game/units.cpp b/src/game/units.cpp index f777400..fb0ce3c 100644 --- a/src/game/units.cpp +++ b/src/game/units.cpp @@ -209,6 +209,8 @@ void unit_t::damage(int points, unit_t *attacker) health -= points; if (health <= 0) die(attacker); + else + wake(); } void unit_t::die(unit_t *killer) @@ -261,4 +263,14 @@ unit_t *find_target(world::world_t *world, v2f_t x, float r, return nearest; } +void unit_t::random_walk(void) +{ + if (move.random_walk_time && + game->time - move.random_walk_time < MSEC(1000)) + return; + + start_moving(x + game->prng.unit_vec2() * 10); + move.random_walk_time = game->time; +} + } // namespace game |