summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common.hpp1
-rw-r--r--src/game/units.cpp13
-rw-r--r--src/procgen.cpp5
3 files changed, 12 insertions, 7 deletions
diff --git a/src/common.hpp b/src/common.hpp
index 6042e08..c45836a 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -48,6 +48,7 @@ namespace procgen {
void seed(uint32_t seed);
uint32_t next(void);
float next_float(void);
+ float next_float(float n, float p);
void unit_vec(float out[2]);
v2f_t unit_vec2(void);
diff --git a/src/game/units.cpp b/src/game/units.cpp
index 0bf46a2..bc3a80d 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -368,14 +368,14 @@ void unit_soldier_t::target_and_attack(void)
next_targetting = game->now + 0.2;
- target = find_target(world, x, 10.0f, false);
+ target = find_target(world, x, 5.0f, false);
if (!target)
return;
last_target_time = game->now;
last_target_x = target->x;
- if (last_attack + 1.5 > game->now)
+ if (last_attack + game->dice_prng.next_float(1.4f, 1.6f) > game->now)
return;
trace = world->trace(x, target->x, CF_SOLID);
@@ -443,12 +443,12 @@ void unit_soldier_t::on_think(void)
if (!panic) {
target_and_attack();
- keep_moving(4.0);
+ keep_moving(2.0);
if (!move.moving)
move_marker.reset();
} else {
move.moving = true;
- keep_moving(6.0);
+ keep_moving(3.0);
if (game->now >= panic_turn) {
v2f_t t;
@@ -567,8 +567,7 @@ void unit_spider_t::target_and_attack(void)
return;
start_moving(target->x);
- next_targetting = game->now + remap(game->dice_prng.next_float(),
- 0.0f, 1.0f, 0.8f, 1.2f);
+ next_targetting = game->now + game->dice_prng.next_float(0.2f, 0.4f);
if (last_attack + 0.5 > game->now)
return;
@@ -588,7 +587,7 @@ void unit_spider_t::on_think(void)
{
target_and_attack();
- keep_moving(7.0);
+ keep_moving(4.0);
if (!move.moving && wake_time + 5 < game->now)
sleep();
diff --git a/src/procgen.cpp b/src/procgen.cpp
index 440056a..5cda92e 100644
--- a/src/procgen.cpp
+++ b/src/procgen.cpp
@@ -40,6 +40,11 @@ float prng_t::next_float(void)
return (float)next() / 4294967295.0f;
}
+float prng_t::next_float(float n, float p)
+{
+ return remap(0.0f, 1.0f, n, p, next_float());
+}
+
void prng_t::unit_vec(float out[2])
{
float t;