summaryrefslogtreecommitdiff
path: root/src/game/unit_soldier.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-04-12 21:27:07 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-04-12 21:27:07 +0200
commitf405c37daccac93323081216b2484da498e2fecf (patch)
treec61932fa3036f1185a1f8fc0dbffdd084c1da12a /src/game/unit_soldier.cpp
parentd307234efb1e687bfac06d48b01eb56d748e8510 (diff)
Tracing vs entities, bullets can now hit.
Diffstat (limited to 'src/game/unit_soldier.cpp')
-rw-r--r--src/game/unit_soldier.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/game/unit_soldier.cpp b/src/game/unit_soldier.cpp
index e44e8a2..b3e93d1 100644
--- a/src/game/unit_soldier.cpp
+++ b/src/game/unit_soldier.cpp
@@ -84,7 +84,7 @@ void unit_soldier_t::shoot(v2f_t aim)
end = x + (aim - x).norm() * 40;
- trace = world->ray_v_all(x, end, CF_SOLID, this);
+ trace = world->ray_v_all(x, end, CF_SOLID|CF_BODY|CF_BODY_SMALL, this);
muzzle_point = x + v2f_t(0, -1.0f);
@@ -95,8 +95,15 @@ void unit_soldier_t::shoot(v2f_t aim)
flash->place(&game->world);
last_attack = game->now;
+
assets::soldier.fire.play_3d(x);
- //target->damage(3, this); FIXME
+
+ if (trace.hit && trace.ent) {
+ if (trace.ent->type == ET_UNIT) {
+ unit_t *unit = dynamic_cast<unit_t*>(trace.ent);
+ unit->damage(3, this);
+ }
+ }
}
void unit_soldier_t::target_and_attack(void)
@@ -127,7 +134,7 @@ skip_targetting:
if (last_attack + game->prng.next_float(1.4f, 1.6f) > game->now)
return;
- shoot(spread_aim(aim, 0.2, &game->prng));
+ shoot(spread_aim(aim, 0.01, &game->prng));
}
void unit_soldier_t::on_think(void)