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

fix FOV when running

git-svn-id: http://svn.net-core.org/repos/t-engine4@514 51575b47-30f0-44d4-a5cc-537603b46e54
parent 25d1baae
No related branches found
No related tags found
No related merge requests found
......@@ -303,30 +303,7 @@ function _M:display()
if self.level and self.level.map and self.level.map.finished then
-- Display the map and compute FOV for the player if needed
if self.level.map.changed then
-- Clean FOV before computing it
self.level.map:cleanFOV()
-- Compute ESP FOV, using cache
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
-- Compute both the normal and the lite FOV, using cache
self.player:computeFOV(self.player.sight or 20, "block_sight", function(x, y, dx, dy, sqdist) self.level.map:apply(x, y) end, true, false, true)
self.player:computeFOV(self.player.lite, "block_sight", function(x, y, dx, dy, sqdist) self.level.map:applyLite(x, y) end, true, true, true)
-- Handle Sense spell, a simple FOV, using cache. Note that this means some terrain features can be made to block sensing
if self.player:attr("detect_range") then
self.player:computeFOV(self.player:attr("detect_range"), "block_sense", function(x, y)
local ok = false
if self.player:attr("detect_actor") and self.level.map(x, y, self.level.map.ACTOR) then ok = true end
if self.player:attr("detect_object") and self.level.map(x, y, self.level.map.OBJECT) then ok = true end
if self.player:attr("detect_trap") and self.level.map(x, y, self.level.map.TRAP) then
self.level.map(x, y, self.level.map.TRAP):setKnown(self.player, true)
ok = true
end
if ok then
self.level.map.seens(x, y, true)
end
end, true, true, true)
end
self.player:playerFOV()
end
self.level.map:display()
......
......@@ -124,6 +124,33 @@ function _M:act()
end
end
function _M:playerFOV()
-- Clean FOV before computing it
game.level.map:cleanFOV()
-- Compute ESP FOV, using cache
if game.zone.short_name ~= "wilderness" then self:computeFOV(self.esp.range or 10, "block_esp", function(x, y) game.level.map:applyESP(x, y) end, true, true) end
-- Compute both the normal and the lite FOV, using cache
self:computeFOV(self.sight or 20, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:apply(x, y) end, true, false, true)
self:computeFOV(self.lite, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:applyLite(x, y) end, true, true, true)
-- Handle Sense spell, a simple FOV, using cache. Note that this means some terrain features can be made to block sensing
if self:attr("detect_range") then
self:computeFOV(self:attr("detect_range"), "block_sense", function(x, y)
local ok = false
if self:attr("detect_actor") and game.level.map(x, y, game.level.map.ACTOR) then ok = true end
if self:attr("detect_object") and game.level.map(x, y, game.level.map.OBJECT) then ok = true end
if self:attr("detect_trap") and game.level.map(x, y, game.level.map.TRAP) then
game.level.map(x, y, game.level.map.TRAP):setKnown(self, true)
ok = true
end
if ok then
game.level.map.seens(x, y, true)
end
end, true, true, true)
end
end
--- Called before taking a hit, overload mod.class.Actor:onTakeHit() to stop resting and running
function _M:onTakeHit(value, src)
self:runStop("taken damage")
......@@ -249,6 +276,8 @@ function _M:runCheck()
end)
if noticed then return false, noticed end
self:playerFOV()
return engine.interface.PlayerRun.runCheck(self)
end
......
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