summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/game.hpp3
-rw-r--r--src/game/unit_soldier.cpp22
-rw-r--r--src/game/unit_spider.cpp4
3 files changed, 15 insertions, 14 deletions
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 908d73b..e35f156 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -183,7 +183,7 @@ namespace game {
class unit_t : public entity_t {
protected:
double next_targetting = -INFINITY;
- double last_attack = -INFINITY;
+ ntime_t next_attack = 0;
public:
size_t selected = 0;
@@ -248,6 +248,7 @@ namespace game {
public:
double last_target_time = -INFINITY;
v2f_t last_target_x;
+ ntime_t last_attack = 0;
std::unique_ptr<fx_move_marker_t> move_marker;
std::unique_ptr<fx_aim_marker_t> aim_marker;
diff --git a/src/game/unit_soldier.cpp b/src/game/unit_soldier.cpp
index 886e09d..db206d1 100644
--- a/src/game/unit_soldier.cpp
+++ b/src/game/unit_soldier.cpp
@@ -56,7 +56,7 @@ unit_soldier_t::unit_soldier_t(game::state_t *game) : unit_t(game, UNIT_SOLDIER)
friendly = true;
controllable = true;
- health = max_health = 20;
+ health = max_health = 28;
}
static v2f_t spread_aim(v2f_t x, v2f_t aim, float cof, procgen::prng_t *prng)
@@ -103,6 +103,9 @@ void unit_soldier_t::fire_shotgun(v2f_t aim)
world::trace_t trace;
fx_flash_t *flash;
+ if (next_attack && game->time < next_attack)
+ return;
+
muzzle_point = x + v2f_t(0, -0.7f);
trace = world->ray_v_all_p3d(x, aim, CF_SOLID|CF_BODY|CF_BODY_SMALL, -1, this);
@@ -115,21 +118,21 @@ void unit_soldier_t::fire_shotgun(v2f_t aim)
return;
}
- for (size_t i = 0; i < 5; i++) {
+ for (size_t i = 0; i < 7; i++) {
v2f_t end;
- end = spread_aim(muzzle_point, aim, 0.1f, &game->prng);
- shoot(muzzle_point, end, 1);
+ end = spread_aim(muzzle_point, aim, 0.15f, &game->prng);
+ shoot(muzzle_point, end, 2);
}
flash = new fx_flash_t(game, muzzle_point, 5.0f, sf::Color(255, 170, 50, 80));
flash->place(&game->world);
- last_attack = game->now;
assets::soldier.fire.play_3d(x);
-
game->hivemind_alert(x, 14.0f, true, x);
-}
+ next_attack = game->time + MSEC(1000);
+ last_attack = game->time;
+}
void unit_soldier_t::target_and_attack(void)
{
@@ -160,9 +163,6 @@ void unit_soldier_t::target_and_attack(void)
skip_targetting:
aim_marker = std::make_unique<fx_aim_marker_t>(game, aim);
- if (last_attack + game->prng.next_float(1.4f, 1.6f) > game->now)
- return;
-
fire_shotgun(aim);
}
@@ -249,7 +249,7 @@ void unit_soldier_t::render_to(render::state_t *render)
legs = &assets::soldier.legs_idle;
if (manual_firing || last_target_time + 3 > game->now) {
- if (last_attack + 0.1 > game->now)
+ if (last_attack && last_attack + MSEC(100) > game->time)
body = &assets::soldier.body_firing;
else
body = &assets::soldier.body_aiming;
diff --git a/src/game/unit_spider.cpp b/src/game/unit_spider.cpp
index c6f5755..6bd7509 100644
--- a/src/game/unit_spider.cpp
+++ b/src/game/unit_spider.cpp
@@ -60,7 +60,7 @@ void unit_spider_t::target_and_attack(void)
start_moving(target->x);
next_targetting = game->now + game->prng.next_float(0.2f, 0.4f);
- if (last_attack + 0.5 > game->now)
+ if (next_attack && game->time < next_attack)
return;
if ((x - target->x).len() >= 1.0f)
@@ -70,9 +70,9 @@ void unit_spider_t::target_and_attack(void)
if (trace.hit)
return;
- last_attack = game->now;
target->damage(15, this);
assets::spider.bite.play_3d(x);
+ next_attack = game->time + MSEC(500);
}
void unit_spider_t::on_wake(void)