summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-04-12 23:23:27 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-04-12 23:23:27 +0200
commita71ed71be94a9fec8660ea0aa060ab9fcf7f860a (patch)
treebbaf1647ce84920bfe1a2fc9730f59dcae82dabb /src/game
parenta9b423230bbd10c5e5140ab6d5b9b7f452090646 (diff)
Prevent soldiers from shooting each other.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/unit_soldier.cpp7
1 files changed, 7 insertions, 0 deletions
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<unit_t*>(trace.ent);
+
+ // Refuse to shoot friendlies.
+ if (unit->friendly)
+ return;
+ }
muzzle_point = x + v2f_t(0, -1.0f);