additional features
This commit is contained in:
parent
af026e8ee5
commit
c9dfdc9171
@ -168,6 +168,12 @@ function resetDoomCounter()
|
|||||||
else
|
else
|
||||||
printToAll("Doom counter could not be found.", "Yellow")
|
printToAll("Doom counter could not be found.", "Yellow")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- reset subtractDoom setting
|
||||||
|
local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomInPlayCounter")
|
||||||
|
if doomInPlayCounter ~= nil then
|
||||||
|
toggleSubtractDoom(false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- adds the ignore tag to the custom data helper
|
-- adds the ignore tag to the custom data helper
|
||||||
|
@ -71,13 +71,28 @@ function onNumberTyped(_, number)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- called by updateVal and addVal to broadcast total doom in play or on the agenda
|
-- called by updateVal and addVal to broadcast total doom in play or on the agenda
|
||||||
-- shows the "Doom on the Agenda / Doom Treshold" if metadata is present
|
-- shows "Doom on the Agenda / Doom Threshold" if metadata is present
|
||||||
-- otherwise shows total "Doom in Play"
|
-- otherwise shows total "Doom in Play"
|
||||||
function broadcastDoom(val)
|
function broadcastDoom(val)
|
||||||
|
local md = getDoomMetadata()
|
||||||
|
local mod = getDoomThresholdModifier()
|
||||||
|
local invCount = playAreaApi.getInvestigatorCount()
|
||||||
|
|
||||||
|
-- maybe apply additional doom threshold for solo play
|
||||||
|
local soloDoomThreshold = 0
|
||||||
|
if invCount == 1 then
|
||||||
|
soloDoomThreshold = md.additionalDoomForSolo or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- sum the doom thresholds and modifiers
|
||||||
|
local doomThreshold = (md.doomThreshold or 0) + mod + (md.doomThresholdPerInvestigator or 0) * invCount + soloDoomThreshold
|
||||||
|
|
||||||
local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomInPlayCounter")
|
local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomInPlayCounter")
|
||||||
|
if doomInPlayCounter and md.subtractDoomInPlay then
|
||||||
|
toggleSubtractDoom(true)
|
||||||
|
end
|
||||||
local doomInPlay = doomInPlayCounter and doomInPlayCounter.call("getDoomCount") or 0
|
local doomInPlay = doomInPlayCounter and doomInPlayCounter.call("getDoomCount") or 0
|
||||||
local totalDoom = val + doomInPlay
|
local totalDoom = val + doomInPlay
|
||||||
local doomThreshold = getDoomThreshold()
|
|
||||||
|
|
||||||
local broadcastParts = {}
|
local broadcastParts = {}
|
||||||
|
|
||||||
@ -107,6 +122,11 @@ function broadcastDoom(val)
|
|||||||
end
|
end
|
||||||
|
|
||||||
broadcastToAll(table.concat(broadcastParts, ""))
|
broadcastToAll(table.concat(broadcastParts, ""))
|
||||||
|
|
||||||
|
-- maybe let players know about modifier
|
||||||
|
if mod ~= 0 then
|
||||||
|
printToAll("Doom Threshold was modified by " .. mod .. " due to cards in play.", "Orange")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- called by "Reset" button to remove doom
|
-- called by "Reset" button to remove doom
|
||||||
@ -122,32 +142,50 @@ function startReset()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- get doom threshold from top card of Agenda deck
|
-- get doom threshold from top card of Agenda deck
|
||||||
function getDoomThreshold()
|
function getDoomMetadata()
|
||||||
local agendaPos = { -2.72, 1.6, 0.37 }
|
local agendaPos = Vector(-2.72, 1.6, 0.37)
|
||||||
local searchResult = searchLib.atPosition(agendaPos, "isCardOrDeck")
|
local searchResult = searchLib.atPosition(agendaPos, "isCardOrDeck")
|
||||||
|
|
||||||
if #searchResult == 1 then
|
if #searchResult == 1 then
|
||||||
local obj = searchResult[1]
|
local obj = searchResult[1]
|
||||||
if obj.type == "Card" then
|
if obj.type == "Card" then
|
||||||
return getDoomThresholdFromGMNotes(obj.getGMNotes())
|
return JSON.decode(obj.getGMNotes()) or {}
|
||||||
else
|
else
|
||||||
-- handle agenda deck
|
-- handle agenda deck
|
||||||
local containedObjects = obj.getData().ContainedObjects
|
local containedObjects = obj.getData().ContainedObjects
|
||||||
local topCardData = containedObjects[#containedObjects]
|
local topCardData = containedObjects[#containedObjects]
|
||||||
return getDoomThresholdFromGMNotes(topCardData.GMNotes)
|
return JSON.decode(topCardData.GMNotes) or {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- decodes the gm notes and return the doom treshhold
|
function getDoomThresholdModifier()
|
||||||
function getDoomThresholdFromGMNotes(notes)
|
local mod = 0
|
||||||
local metadata = JSON.decode(notes) or {}
|
local appliedModifierGUIDs = {}
|
||||||
if metadata.doomThresholdPerInvestigator then
|
|
||||||
return metadata.doomThresholdPerInvestigator * playAreaApi.getInvestigatorCount() + metadata.doomThreshold
|
-- check playarea
|
||||||
else
|
local playAreaZone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone")
|
||||||
return metadata.doomThreshold
|
for _, obj in ipairs(playAreaZone.getObjects()) do
|
||||||
|
if not obj.is_face_down and obj.type == "Card" then
|
||||||
|
local md = JSON.decode(obj.getGMNotes()) or {}
|
||||||
|
mod = mod + (md.modifyDoomThreshold or 0)
|
||||||
|
appliedModifierGUIDs[obj.getGUID()] = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- check mythos area (make sure we don't apply cards twice that are in both areas)
|
||||||
|
local searchPos = Vector(-1.31, 2, -4)
|
||||||
|
local searchRot = Vector(0, 270, 0)
|
||||||
|
local searchSize = Vector(25, 1, 13.5)
|
||||||
|
local searchFilter = "isCard"
|
||||||
|
for _, obj in ipairs(searchLib.inArea(searchPos, searchRot, searchSize, searchFilter)) do
|
||||||
|
if not obj.is_face_down and appliedModifierGUIDs[obj.getGUID()] == nil then
|
||||||
|
local md = JSON.decode(obj.getGMNotes()) or {}
|
||||||
|
mod = mod + (md.modifyDoomThreshold or 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return mod
|
||||||
end
|
end
|
||||||
|
|
||||||
-- XML UI functions
|
-- XML UI functions
|
||||||
|
@ -45,8 +45,12 @@ function onLoad(savedData)
|
|||||||
Wait.time(updateCounter, 2, -1)
|
Wait.time(updateCounter, 2, -1)
|
||||||
end
|
end
|
||||||
|
|
||||||
function toggleSubtractDoom()
|
function toggleSubtractDoom(override)
|
||||||
subtractDoom = not subtractDoom
|
if override then
|
||||||
|
subtractDoom = override
|
||||||
|
else
|
||||||
|
subtractDoom = not subtractDoom
|
||||||
|
end
|
||||||
updateSave()
|
updateSave()
|
||||||
|
|
||||||
if subtractDoom then
|
if subtractDoom then
|
||||||
|
@ -31,10 +31,10 @@ function onLoad()
|
|||||||
searchParam.filter = "isClue"
|
searchParam.filter = "isClue"
|
||||||
|
|
||||||
-- start loop
|
-- start loop
|
||||||
Wait.time(countItems, 1.5, -1)
|
Wait.time(countItems, 1.75, -1)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- activated once per second, counts clues on the playermat
|
-- counts clues on the playermat
|
||||||
function countItems()
|
function countItems()
|
||||||
local totalValue = 0
|
local totalValue = 0
|
||||||
for _, item in ipairs(getClues()) do
|
for _, item in ipairs(getClues()) do
|
||||||
|
@ -18,10 +18,7 @@ do
|
|||||||
---@param direction? table Direction (positive is up)
|
---@param direction? table Direction (positive is up)
|
||||||
---@param maxDistance? number Distance for the cast
|
---@param maxDistance? number Distance for the cast
|
||||||
local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)
|
local function returnSearchResult(pos, rot, size, filter, direction, maxDistance)
|
||||||
local filterFunc
|
local filterFunc = filter and filterFunctions[filter]
|
||||||
if filter then
|
|
||||||
filterFunc = filterFunctions[filter]
|
|
||||||
end
|
|
||||||
local searchResult = Physics.cast({
|
local searchResult = Physics.cast({
|
||||||
origin = pos,
|
origin = pos,
|
||||||
direction = direction or { 0, 1, 0 },
|
direction = direction or { 0, 1, 0 },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user