From 123f3af13c3f682492f2f5ae0f50d7df41578020 Mon Sep 17 00:00:00 2001 From: DarkGod <darkgod@net-core.org> Date: Thu, 2 Feb 2017 21:45:56 +0100 Subject: [PATCH] Default targetting now prioritizes targets in line of sight over ESP ones --- game/engines/default/engine/Target.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/game/engines/default/engine/Target.lua b/game/engines/default/engine/Target.lua index 724edb2e4d..2bcf4f76dc 100644 --- a/game/engines/default/engine/Target.lua +++ b/game/engines/default/engine/Target.lua @@ -704,7 +704,8 @@ function _M:scan(dir, radius, sx, sy, filter, kind) if (not self.source_actor or self.source_actor:canSee(a)) and (not filter or filter(a)) then table.insert(actors, { a = a, - dist = math.abs(sx - x)*math.abs(sx - x) + math.abs(sy - y)*math.abs(sy - y) + dist = math.abs(sx - x)*math.abs(sx - x) + math.abs(sy - y)*math.abs(sy - y), + has_los = (self.source_actor and self.source_actor:hasLOS(x, y)) and 1 or 0, }) actors[a] = true end @@ -720,7 +721,10 @@ function _M:scan(dir, radius, sx, sy, filter, kind) core.fov.calc_circle(sx, sy, game.level.map.w, game.level.map.h, radius, checker, function()end, nil) end - table.sort(actors, function(a,b) return a.dist<b.dist end) + table.sort(actors, function(a,b) + if a.has_los == b.has_los then return a.dist<b.dist + else return a.has_los > b.has_los end + end) if #actors > 0 then self.target.entity = actors[1].a self.target.x = self.target.entity.x -- GitLab