Commit 69c48d6691f9ea5924eeef388ab54d81cb87d89a

Authored by DarkGod
1 parent 7d678382

plop

@@ -2947,7 +2947,7 @@ end @@ -2947,7 +2947,7 @@ end
2947 -- @param radius the radius in which to search 2947 -- @param radius the radius in which to search
2948 -- @param block true if we only consider line of sight 2948 -- @param block true if we only consider line of sight
2949 -- @param what a table which can have the fields Map.ACTOR, Map.OBJECT, ..., set to true. If so it will only return grids that are free of this kind of entities. 2949 -- @param what a table which can have the fields Map.ACTOR, Map.OBJECT, ..., set to true. If so it will only return grids that are free of this kind of entities.
2950 -function util.findFreeGrid(sx, sy, radius, block, what) 2950 +function util.findFreeGrid(sx, sy, radius, block, what, checker)
2951 if not sx or not sy then return nil, nil, {} end 2951 if not sx or not sy then return nil, nil, {} end
2952 what = what or {} 2952 what = what or {}
2953 local grids = core.fov.circle_grids(sx, sy, radius, block) 2953 local grids = core.fov.circle_grids(sx, sy, radius, block)
@@ -2961,6 +2961,7 @@ function util.findFreeGrid(sx, sy, radius, block, what) @@ -2961,6 +2961,7 @@ function util.findFreeGrid(sx, sy, radius, block, what)
2961 end 2961 end
2962 if game.level.map:checkEntity(x, y, game.level.map.TERRAIN, "block_move") then ok = false end 2962 if game.level.map:checkEntity(x, y, game.level.map.TERRAIN, "block_move") then ok = false end
2963 -- print("findFreeGrid", x, y, "from", sx,sy,"=>", ok) 2963 -- print("findFreeGrid", x, y, "from", sx,sy,"=>", ok)
  2964 + if checker and not checker(x, y) then ok = false end
2964 if ok then 2965 if ok then
2965 gs[#gs+1] = {x, y, core.fov.distance(sx, sy, x, y), rng.range(1, 1000)} 2966 gs[#gs+1] = {x, y, core.fov.distance(sx, sy, x, y), rng.range(1, 1000)}
2966 end 2967 end
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 -- returns detect, closest = total detection power, distance to closest enemy 22 -- returns detect, closest = total detection power, distance to closest enemy
23 -- if estimate is true, only counts the detection power of seen actors 23 -- if estimate is true, only counts the detection power of seen actors
24 local function stealthDetection(self, radius, estimate) 24 local function stealthDetection(self, radius, estimate)
25 - if not self.x then return nil end 25 + if not self.x then return 0, math.huge end
26 local dist = 0 26 local dist = 0
27 local closest, detect = math.huge, 0 27 local closest, detect = math.huge, 0
28 for i, act in ipairs(self.fov.actors_dist) do 28 for i, act in ipairs(self.fov.actors_dist) do