From a71ed71be94a9fec8660ea0aa060ab9fcf7f860a Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 12 Apr 2018 23:23:27 +0200 Subject: Prevent soldiers from shooting each other. --- src/game/unit_soldier.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/game/unit_soldier.cpp b/src/game/unit_soldier.cpp index 351970e..e49c25a 100644 --- a/src/game/unit_soldier.cpp +++ b/src/game/unit_soldier.cpp @@ -85,6 +85,13 @@ void unit_soldier_t::shoot(v2f_t aim) end = x + (aim - x).norm() * 40; trace = world->ray_v_all(x, end, CF_SOLID|CF_BODY|CF_BODY_SMALL, this); + if (trace.hit && trace.ent && trace.ent->type == ET_UNIT) { + unit_t *unit = dynamic_cast(trace.ent); + + // Refuse to shoot friendlies. + if (unit->friendly) + return; + } muzzle_point = x + v2f_t(0, -1.0f); -- cgit