diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 9638ec344846a7d55d6afe1c1c38fb9236879851..7f3271f3a1f845a56b6f5014440ad9575fe5e680 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -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() diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 06a39f0e27b6e9471cb69c932d9c4d1136e0ee30..7e25dc82ea9917a269c27e51ca0fd256ea7f6b33 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -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