Skip to content

Commit

Permalink
More logging - onSeen #16
Browse files Browse the repository at this point in the history
  • Loading branch information
khonkhortisan committed Nov 21, 2018
1 parent 364624f commit 1ff0044
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 42 deletions.
80 changes: 61 additions & 19 deletions superload/mod/class/uiset/Classic.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
-- This file shows messages for players whose turn it currently isn't, as they'd see things happen to them out of turn in singleplayer. See Classic.lua

--[[
require "engine.class"
local UISet = require "mod.class.uiset.UISet"
local DebugConsole = require "engine.DebugConsole"
local PlayerDisplay = require "mod.class.uiset.ClassicPlayerDisplay"
local HotkeysDisplay = require "engine.HotkeysDisplay"
local HotkeysIconsDisplay = require "engine.HotkeysIconsDisplay"
local ActorsSeenDisplay = require "engine.ActorsSeenDisplay"
local LogDisplay = require "engine.LogDisplay"
local LogFlasher = require "engine.LogFlasher"
local FlyingText = require "engine.FlyingText"
local Tooltip = require "mod.class.Tooltip"
local Dialog = require "engine.ui.Dialog"
--]]
-- This file shows messages for players whose turn it currently isn't, as they'd see things happen to them out of turn in singleplayer. See Minimalist.lua, Classic.lua

local _M = loadPrevious(...)

local showplayername = true --debug
local showplayername = true -- debug

local base_activate = _M.activate
function _M:activate()
Expand All @@ -30,14 +15,71 @@ function _M:activate()
game.logPlayer = function(e, style, ...)

if showplayername then
style = '['..e.name.."] "..style
style = "logPlayer["..e.name.."] "..style
end

--might need to allow game.player back in for controlled alchemist golems
if (game.party.members[e] and game.party.members[e].main) or e == game.party then
game.log(style, ...)
end
end

--- Output a message to the log based on the visibility of an actor to the player
-- @param e the actor(entity) to check visibility for
-- @param style the message to display
-- @param ... arguments to be passed to format for style
function game.logSeen(e, style, ...)

--if e and e.player or (not e.dead and e.x and e.y and game.level and game.level.map.seens(e.x, e.y) and game.player:canSee(e)) then game.log(style, ...) end
if
--if specific player mentioned, log immediately ("I've been shot!")
--e and e.player or
e and e.player then
if showplayername then
style = "logSeen["..e.name.."] "..style
end
game.log(style, ...)
return
--elseif
end
--e is a living monster? Or controllable party member?
--should loop this whole line for party members.
--map.seens might require a fog of war change.
--or (not e.dead and e.x and e.y and game.level and game.level.map.seens(e.x, e.y) and game.player:canSee(e)) then
if (not e.dead and e.x and e.y and game.level and game.level.map.seens(e.x, e.y)) then
if game.player:canSee(e) then
if showplayername then
--seen by game.player
style = "logSeen["..e.name..'|'..game.player.name.."] "..style
end
game.log(style, ...)
return
end
for act, _ in pairs(self.party.members) do
--don't log non-player party members (escorts/uncontrolled alchemist golems)
if game.party.members[act].main and game.party.members[act]:canSee(e) then
if showplayername then
--seen by game.player
style = "logSeen["..e.name..'|'..act.name.."] "..style
end
game.log(style, ...)
return
end
end
end
end

--logVisible

--logMessage

--delayedLogMessage - a killed b happening ~~after player switch~~ at next player turn?

--displayDelayedLogMessage
--displayDelayedLogDamage

--delayedLogDamage

return retval
return retval --does nothing but keeping it in
end
return _M
83 changes: 60 additions & 23 deletions superload/mod/class/uiset/Minimalist.lua
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
-- This file shows messages for players whose turn it currently isn't, as they'd see things happen to them out of turn in singleplayer. See Minimalist.lua

--[[
require "engine.class"
local UI = require "engine.ui.Base"
local UISet = require "mod.class.uiset.UISet"
local DebugConsole = require "engine.DebugConsole"
local HotkeysDisplay = require "engine.HotkeysDisplay"
local HotkeysIconsDisplay = require "engine.HotkeysIconsDisplay"
local ActorsSeenDisplay = require "engine.ActorsSeenDisplay"
local LogDisplay = require "engine.LogDisplay"
local LogFlasher = require "engine.LogFlasher"
local FlyingText = require "engine.FlyingText"
local Shader = require "engine.Shader"
local ActorResource = require "engine.interface.ActorResource"
local Tooltip = require "mod.class.Tooltip"
local TooltipsData = require "mod.class.interface.TooltipsData"
local Dialog = require "engine.ui.Dialog"
local Map = require "engine.Map"
local FontPackage = require "engine.FontPackage"
--]]
-- This file shows messages for players whose turn it currently isn't, as they'd see things happen to them out of turn in singleplayer. See Minimalist.lua, Classic.lua

local _M = loadPrevious(...)

Expand All @@ -35,14 +15,71 @@ function _M:activate()
game.logPlayer = function(e, style, ...)

if showplayername then
style = '['..e.name.."] "..style
style = "logPlayer["..e.name.."] "..style
end

--might need to allow game.player back in for controlled alchemist golems
if (game.party.members[e] and game.party.members[e].main) or e == game.party then
game.log(style, ...)
end
end

--- Output a message to the log based on the visibility of an actor to the player
-- @param e the actor(entity) to check visibility for
-- @param style the message to display
-- @param ... arguments to be passed to format for style
function game.logSeen(e, style, ...)

--if e and e.player or (not e.dead and e.x and e.y and game.level and game.level.map.seens(e.x, e.y) and game.player:canSee(e)) then game.log(style, ...) end
if
--if specific player mentioned, log immediately ("I've been shot!")
--e and e.player or
e and e.player then
if showplayername then
style = "logSeen["..e.name.."] "..style
end
game.log(style, ...)
return
--elseif
end
--e is a living monster? Or controllable party member?
--should loop this whole line for party members.
--map.seens might require a fog of war change.
--or (not e.dead and e.x and e.y and game.level and game.level.map.seens(e.x, e.y) and game.player:canSee(e)) then
if (not e.dead and e.x and e.y and game.level and game.level.map.seens(e.x, e.y)) then
if game.player:canSee(e) then
if showplayername then
--seen by game.player
style = "logSeen["..e.name..'|'..game.player.name.."] "..style
end
game.log(style, ...)
return
end
for act, _ in pairs(self.party.members) do
--don't log non-player party members (escorts/uncontrolled alchemist golems)
if game.party.members[act].main and game.party.members[act]:canSee(e) then
if showplayername then
--seen by game.player
style = "logSeen["..e.name..'|'..act.name.."] "..style
end
game.log(style, ...)
return
end
end
end
end

--logVisible

--logMessage

--delayedLogMessage - a killed b happening ~~after player switch~~ at next player turn?

--displayDelayedLogMessage
--displayDelayedLogDamage

--delayedLogDamage

return retval
return retval --does nothing but keeping it in
end
return _M

0 comments on commit 1ff0044

Please sign in to comment.