Skip to content
Snippets Groups Projects
Commit 123f3af1 authored by DarkGod's avatar DarkGod
Browse files

Default targetting now prioritizes targets in line of sight over ESP ones

parent 7a4668e0
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment