Skip to content
Snippets Groups Projects
Commit a8da0fb2 authored by dg's avatar dg
Browse files

compute FOV and Lite FOV in the same call

git-svn-id: http://svn.net-core.org/repos/t-engine4@444 51575b47-30f0-44d4-a5cc-537603b46e54
parent 388df50b
No related branches found
No related tags found
No related merge requests found
......@@ -267,7 +267,7 @@ function _M:display()
local z = i + j * self.w
if self.seens[z] then
e = self(i, j, ACTOR)
if e then
if e and (not self.actor_player or self.actor_player:canSee(e)) then
-- Tactical overlay ?
if e.faction then
friend = Faction:factionReaction(self.view_faction, e.faction)
......
......@@ -33,8 +33,8 @@ function _M:computeFOV(radius, block, apply, force, no_store, cache)
local map = game.level.map
core.fov.calc_circle(self.x, self.y, radius, function(_, x, y)
if map:checkAllEntities(x, y, block, self) then return true end
end, function(_, x, y, dx, dy)
apply(x, y, dx, dy)
end, function(_, x, y, dx, dy, sqdist)
apply(x, y, dx, dy, sqdist)
end, cache and game.level.map._fovcache[block])
-- FOV + storage
......@@ -46,13 +46,13 @@ function _M:computeFOV(radius, block, apply, force, no_store, cache)
local map = game.level.map
core.fov.calc_circle(self.x, self.y, radius, function(_, x, y)
if map:checkAllEntities(x, y, block, self) then return true end
end, function(_, x, y, dx, dy)
if apply then apply(x, y, dx, dy) end
end, function(_, x, y, dx, dy, sqdist)
if apply then apply(x, y, dx, dy, sqdist) end
-- Note actors
local a = map(x, y, Map.ACTOR)
if a and a ~= self and not a.dead then
local t = {x=x,y=y, dx=dx, dy=dy, sqdist=dx*dx+dy*dy}
local t = {x=x,y=y, dx=dx, dy=dy, sqdist=sqdist}
fov.actors[a] = t
fov.actors_dist[#fov.actors_dist+1] = a
a:updateFOV(self, t.sqdist)
......
......@@ -248,8 +248,13 @@ function _M:display()
-- Compute FOV, if needed
self.level.map:cleanFOV()
if self.zone.short_name ~= "wilderness" then self.player:computeFOV(self.player.esp.range or 10, "block_esp", function(x, y) self.level.map:applyESP(x, y) end, true, true) end
self.player:computeFOV(self.player.sight or 20, "block_sight", function(x, y) self.level.map:apply(x, y) end, true, false, true)
if self.player.lite > 0 then self.player:computeFOV(self.player.lite, "block_sight", function(x, y) self.level.map:applyLite(x, y) end, true, true, true) end
self.player:computeFOV(self.player.sight or 20, "block_sight", function(x, y, dx, dy, sqdist)
if sqdist <= self.player.lite * self.player.lite then
self.level.map:applyLite(x, y)
else
self.level.map:apply(x, y)
end
end, true, false, true)
--
-- Handle Sense spell
......
......@@ -46,7 +46,8 @@ static void map_seen(void *m, int x, int y, int dx, int dy, int radius, void *sr
lua_pushnumber(L, y);
lua_pushnumber(L, dx);
lua_pushnumber(L, dy);
lua_call(L, 5, 0);
lua_pushnumber(L, dx*dx + dy*dy);
lua_call(L, 6, 0);
}
}
......
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