removed old tokens and updated script

This commit is contained in:
Chr1Z93 2024-06-02 12:25:37 +02:00
parent 1f75ac5012
commit be03d5345c
39 changed files with 129 additions and 36682 deletions

View File

@ -127,7 +127,6 @@
"ChaosBag.fea079",
"DataHelper.708279",
"BlessCurseManager.5933fb",
"Notecard.d8d357",
"ScriptingTrigger.a2f932",
"EdgeoftheEarth.895eaa",
"TheDream-Eaters.a16a1a",
@ -138,22 +137,6 @@
"Playermat2Orange.bd0ff4",
"Playermat3Green.383d8b",
"Playermat4Red.0840d5",
"Neutral.2691e1",
"Neutral.748245",
"Neutral.271b17",
"Neutral.5bafdf",
"Neutral.012577",
"Neutral.04765b",
"Neutral.b71036",
"Neutral.1cb302",
"Neutral.bbc5d4",
"Neutral.429bb3",
"Neutral.183dbe",
"Neutral.b80db6",
"Neutral.af1927",
"Neutral.0329cc",
"Neutral.5bec40",
"Neutral.5825ca",
"LeadInvestigator.acaa93",
"ArkhamDBDeckImporter.a28140",
"Configuration.03804b",

View File

@ -5,5 +5,12 @@
"cost": 0,
"level": 3,
"traits": "Trick.",
"uses": [
{
"count": 3,
"type": "Universal",
"token": "universalActionAbility"
}
],
"cycle": "The Dunwich Legacy"
}

View File

@ -5,5 +5,12 @@
"cost": 0,
"level": 3,
"traits": "Trick.",
"uses": [
{
"count": 3,
"type": "Universal",
"token": "universalActionAbility"
}
],
"cycle": "The Dunwich Legacy"
}

View File

@ -6,5 +6,12 @@
"level": 0,
"traits": "Double.",
"wildIcons": 1,
"uses": [
{
"count": 2,
"type": "Universal",
"token": "universalActionAbility"
}
],
"cycle": "The Feast of Hemlock Vale"
}

View File

@ -5,5 +5,12 @@
"cost": 0,
"level": 0,
"traits": "Insight. Spirit.",
"uses": [
{
"count": 1,
"type": "Universal",
"token": "universalActionAbility"
}
],
"cycle": "The Scarlet Keys"
}

View File

@ -5,5 +5,12 @@
"cost": 2,
"traits": "Item. Tome.",
"intellectIcons": 2,
"uses": [
{
"count": 1,
"type": "Explore",
"token": "universalActionAbility"
}
],
"cycle": "The Forgotten Age"
}

View File

@ -6,5 +6,12 @@
"level": 1,
"traits": "Spirit.",
"willpowerIcons": 2,
"uses": [
{
"count": 1,
"type": "Fight",
"token": "universalActionAbility"
}
],
"cycle": "Investigator Packs"
}

View File

@ -6,5 +6,12 @@
"level": 0,
"traits": "Insight.",
"wildIcons": 1,
"uses": [
{
"count": 1,
"type": "Universal",
"token": "universalActionAbility"
}
],
"cycle": "The Path to Carcosa"
}

View File

@ -7,5 +7,12 @@
"traits": "Insight.",
"willpowerIcons": 1,
"wildIcons": 1,
"uses": [
{
"count": 1,
"type": "Universal",
"token": "universalActionAbility"
}
],
"cycle": "The Scarlet Keys"
}

View File

@ -10,5 +10,12 @@
"level": 0,
"traits": "Ally. Criminal.",
"intellectIcons": 1,
"uses": [
{
"count": 1,
"type": "Universal",
"token": "universalActionAbility"
}
],
"cycle": "Core"
}

View File

@ -10,5 +10,12 @@
"level": 1,
"traits": "Ally. Criminal.",
"intellectIcons": 1,
"uses": [
{
"count": 1,
"type": "Universal",
"token": "universalActionAbility"
}
],
"cycle": "Core"
}

View File

@ -7,5 +7,12 @@
"level": 0,
"traits": "Item. Tool.",
"willpowerIcons": 1,
"uses": [
{
"count": 1,
"type": "Engage",
"token": "universalActionAbility"
}
],
"cycle": "The Innsmouth Conspiracy"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +0,0 @@
{
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"ColorDiffuse": {
"b": 1,
"g": 1,
"r": 1
},
"Description": "lua setNotes(getObjectFromGUID('the objects guid').getJSON())",
"DragSelectable": true,
"GMNotes": "",
"GUID": "d8d357",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Notecard",
"Nickname": "",
"Snap": true,
"Sticky": true,
"Tooltip": false,
"Transform": {
"posX": 78,
"posY": 1.244,
"posZ": 33.583,
"rotX": 0,
"rotY": 90,
"rotZ": 0,
"scaleX": 0.25,
"scaleY": 0.25,
"scaleZ": 0.25
},
"Value": 0,
"XmlUI": ""
}

View File

@ -1 +1 @@
{"activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"White","slotData":["any","any","any","Tarot","Hand (left)","Hand (right)","Ally","any","any","any","Accessory","Arcane","Arcane","Body"]}
{"activeInvestigatorClass":"Neutral","activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"White","slotData":["any","any","any","Tarot","Hand (left)","Hand (right)","Ally","any","any","any","Accessory","Arcane","Arcane","Body"]}

View File

@ -1 +1 @@
{"activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"Orange","slotData":["any","any","any","Tarot","Hand (left)","Hand (right)","Ally","any","any","any","Accessory","Arcane","Arcane","Body"]}
{"activeInvestigatorClass":"Neutral","activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"Orange","slotData":["any","any","any","Tarot","Hand (left)","Hand (right)","Ally","any","any","any","Accessory","Arcane","Arcane","Body"]}

View File

@ -1 +1 @@
{"activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"Green","slotData":["any","any","any","Tarot","Hand (left)","Hand (right)","Ally","any","any","any","Accessory","Arcane","Arcane","Body"]}
{"activeInvestigatorClass":"Neutral","activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"Green","slotData":["any","any","any","Tarot","Hand (left)","Hand (right)","Ally","any","any","any","Accessory","Arcane","Arcane","Body"]}

View File

@ -1 +1 @@
{"activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"Red","slotData":["any","any","any","Tarot","Hand (left)","Hand (right)","Ally","any","any","any","Accessory","Arcane","Arcane","Body"]}
{"activeInvestigatorClass":"Neutral","activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"Red","slotData":["any","any","any","Tarot","Hand (left)","Hand (right)","Ally","any","any","any","Accessory","Arcane","Arcane","Body"]}

View File

@ -315,32 +315,11 @@ function tidyPlayerMatCoroutine()
for _, obj in ipairs(objList) do
-- ignore these elements
if obj.hasTag(IGNORE_TAG) == false
and obj.getDescription() ~= "Action Token"
and obj.hasTag("UniversalToken") == false
and obj.hasTag("chaosBag") == false
and (obj.locked == false or obj.hasTag("Investigator"))
and obj.interactable == true then
trash.putObject(obj)
-- action token handling
elseif obj.getDescription() == "Action Token" then
-- move the small action token to the proper position
if obj.getScale().x < 0.4 then
local pos = playmatApi.transformLocalPosition(Vector(-0.865, 0.1, -0.28), COLORS[i])
obj.setPosition(pos)
end
-- flip action tokens back to ready
if obj.is_face_down then
local rot = playmatApi.returnRotation(COLORS[i])
obj.setRotation(rot)
end
-- reset action token state
local stateId = obj.getStateId()
if stateId ~= -1 and stateId ~= 6 then
coroutine.yield(0)
obj.setState(6)
end
end
end

View File

@ -146,8 +146,8 @@ function updateDisplay()
-- update front image
xml[3].attributes.image = symbols[1]
xml[3].attributes.height = xml[3].attributes.height / 2
xml[3].attributes.width = xml[3].attributes.width / 2
xml[3].attributes.height = xml[3].attributes.height * 0.6
xml[3].attributes.width = xml[3].attributes.width * 0.6
xml[3].attributes.position = "35 0 -10.3"
-- add 2nd image element to front
@ -158,8 +158,8 @@ function updateDisplay()
-- update back image
xml[6].attributes.image = symbols[1]
xml[6].attributes.height = xml[6].attributes.height / 2
xml[6].attributes.width = xml[6].attributes.width / 2
xml[6].attributes.height = xml[6].attributes.height * 0.6
xml[6].attributes.width = xml[6].attributes.width * 0.6
xml[6].attributes.position = "35 0 0.3"
-- add 2nd image element to back

View File

@ -2,6 +2,7 @@ do
local guidReferenceApi = require("core/GUIDReferenceApi")
local optionPanelApi = require("core/OptionPanelApi")
local playAreaApi = require("core/PlayAreaApi")
local playmatApi = require("playermat/PlaymatApi")
local searchLib = require("util/SearchLib")
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
@ -153,7 +154,7 @@ do
-- Spawns a set of tokens on the given card.
---@param card tts__Object Card to spawn tokens on
---@param tokenType string Type of token to spawn, for example "damage", "horror" or "resource"
---@param tokenType string Type of token to spawn (template needs to be in source bag)
---@param tokenCount number How many tokens to spawn. For damage or horror this value will be set to the
-- spawned state object rather than spawning multiple tokens
---@param shiftDown? number An offset for the z-value of this group of tokens
@ -174,8 +175,7 @@ do
-- Spawns a single counter token and sets the value to tokenValue. Used for damage and horror tokens.
---@param card tts__Object Card to spawn tokens on
---@param tokenType string type of token to spawn, valid values are "damage" and "horror". Other
-- types should use spawnMultipleTokens()
---@param tokenType string Type of token to spawn (template needs to be in source bag)
---@param tokenValue number Value to set the damage/horror to
TokenManager.spawnCounterToken = function(card, tokenType, tokenValue, shiftDown)
if tokenValue < 1 or tokenValue > 50 then return end
@ -199,11 +199,10 @@ do
end
-- Spawns a number of tokens.
---@param tokenType string type of token to spawn, valid values are resource", "doom", or "clue".
-- Other types should use spawnCounterToken()
---@param tokenType string Type of token to spawn (template needs to be in source bag)
---@param tokenCount number How many tokens to spawn
---@param shiftDown? number An offset for the z-value of this group of tokens
---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource tokens
---@param subType? string Subtype of token to spawn. This will only differ from the tokenName for resource or action tokens
TokenManager.spawnMultipleTokens = function(card, tokenType, tokenCount, shiftDown, subType)
-- not checking the max at this point since clue offsets are calculated dynamically
if tokenCount < 1 then return end
@ -239,16 +238,16 @@ do
return
end
-- handling for not provided subtype (for example when spawning from custom data helpers)
if subType == nil then
subType = ""
end
-- this is used to load the correct state for additional resource tokens (e.g. "Ammo")
local callback = nil
local stateID = stateTable[string.lower(subType)]
local stateID = stateTable[string.lower(subType or "")]
if tokenType == "resource" and stateID ~= nil and stateID ~= 1 then
callback = function(spawned) spawned.setState(stateID) end
elseif tokenType == "universalActionAbility" then
local matColor = playmatApi.getMatColorByPosition(card.getPosition())
local class = playmatApi.returnInvestigatorClass(matColor)
callback = function(spawned) spawned.call("updateClassAndSymbol", { class = class, symbol = subType or class }) end
end
for i = 1, tokenCount do
@ -258,9 +257,8 @@ do
-- Spawns a single token at the given global position by copying it from the template bag.
---@param position tts__Vector Global position to spawn the token
---@param tokenType string type of token to spawn, valid values are "damage", "horror",
-- "resource", "doom", or "clue"
---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,
---@param tokenType string Type of token to spawn (template needs to be in source bag)
---@param rotation tts__Vector Rotation to be used for the new token. Only the y-value will be used,
-- x and z will use the default rotation from the source bag
---@param callback? function A callback function triggered after the new token is spawned
TokenManager.spawnToken = function(position, tokenType, rotation, callback)
@ -513,7 +511,7 @@ do
-- if there are already more uses than the replenish amount, keep them
if foundTokens > uses[1].count then
newCount = foundTokens
-- only replenish up until the replenish amount
-- only replenish up until the replenish amount
elseif newCount > uses[1].count then
newCount = uses[1].count
end

View File

@ -82,8 +82,10 @@ local defaultSlotData = {
"any", "any", "any", "Accessory", "Arcane", "Arcane", "Body"
}
-- global variable so it can be reset by the Clean Up Helper
-- global variables for access
activeInvestigatorClass = "Neutral"
activeInvestigatorId = "00000"
local isDrawButtonVisible = false
-- global variable to report "Dream-Enhancing Serum" status
@ -95,20 +97,22 @@ local matColor = self.getMemo()
function onSave()
return JSON.encode({
playerColor = playerColor,
activeInvestigatorClass = activeInvestigatorClass,
activeInvestigatorId = activeInvestigatorId,
isDrawButtonVisible = isDrawButtonVisible,
playerColor = playerColor,
slotData = slotData
})
end
function onLoad(savedData)
if savedData and savedData ~= "" then
local loadedData = JSON.decode(savedData)
playerColor = loadedData.playerColor
activeInvestigatorId = loadedData.activeInvestigatorId
isDrawButtonVisible = loadedData.isDrawButtonVisible
slotData = loadedData.slotData
local loadedData = JSON.decode(savedData)
activeInvestigatorClass = loadedData.activeInvestigatorClass
activeInvestigatorId = loadedData.activeInvestigatorId
isDrawButtonVisible = loadedData.isDrawButtonVisible
playerColor = loadedData.playerColor
slotData = loadedData.slotData
end
self.interactable = false
@ -291,7 +295,7 @@ function doUpkeep(_, clickedByColor, isRightClick)
local forcedLearning = false
local rot = self.getRotation()
for _, obj in ipairs(searchAroundSelf()) do
if obj.getDescription() == "Action Token" and obj.is_face_down then
if obj.hasTag("UniversalToken") == true and obj.is_face_down then
obj.flip()
elseif obj.type == "Card" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then
local cardMetadata = JSON.decode(obj.getGMNotes()) or {}
@ -829,8 +833,7 @@ function removeTokensFromObject(object)
obj.type ~= "Deck" and
obj.type ~= "Card" and
obj.memo ~= nil and
obj.getLock() == false and
obj.getDescription() ~= "Action Token" then
obj.getLock() == false then
ownedObjects.Trash.putObject(obj)
end
end
@ -846,14 +849,13 @@ function maybeUpdateActiveInvestigator(card)
if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end
local notes = JSON.decode(card.getGMNotes())
local class = "Neutral"
local extraToken
if notes ~= nil and notes.type == "Investigator" and notes.id ~= nil then
if notes.id == activeInvestigatorId then return end
class = notes.class
extraToken = notes.extraToken
activeInvestigatorClass = notes.class
activeInvestigatorId = notes.id
extraToken = notes.extraToken
ownedObjects.InvestigatorSkillTracker.call("updateStats", {
notes.willpowerIcons,
notes.intellectIcons,
@ -861,7 +863,7 @@ function maybeUpdateActiveInvestigator(card)
notes.agilityIcons
})
elseif activeInvestigatorId ~= "00000" then
class = "Neutral"
activeInvestigatorClass = "Neutral"
activeInvestigatorId = "00000"
ownedObjects.InvestigatorSkillTracker.call("updateStats", { 1, 1, 1, 1 })
else
@ -879,14 +881,14 @@ function maybeUpdateActiveInvestigator(card)
local pos = self.positionToWorld(Vector(-1.54 + i * 0.17, 0, -0.28)):add(Vector(0, 0.2, 0))
tokenManager.spawnToken(pos, "universalActionAbility", self.getRotation(), function(spawned)
spawned.call("updateClassAndSymbol", { class = class, symbol = class })
spawned.call("updateClassAndSymbol", { class = activeInvestigatorClass, symbol = activeInvestigatorClass })
end)
end
-- spawn additional token (maybe specific for investigator)
if extraToken ~= "None" then
-- set value to class if currently "nil"
extraToken = extraToken or class
extraToken = extraToken or activeInvestigatorClass
-- get position (on the investigator card for abilities)
local pos
@ -897,7 +899,7 @@ function maybeUpdateActiveInvestigator(card)
end
tokenManager.spawnToken(pos, "universalActionAbility", self.getRotation(), function(spawned)
spawned.call("updateClassAndSymbol", { class = class, symbol = extraToken })
spawned.call("updateClassAndSymbol", { class = activeInvestigatorClass, symbol = extraToken })
end)
end
end

View File

@ -169,6 +169,14 @@ do
end
end
-- Returns the class of the active investigator
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
PlaymatApi.returnInvestigatorClass = function(matColor)
for _, mat in pairs(getMatForColor(matColor)) do
return mat.getVar("activeInvestigatorClass")
end
end
-- Returns the position for encounter card drawing
---@param matColor string Color of the playmat - White, Orange, Green or Red (does not support "All")
---@param stack boolean If true, returns the leftmost position instead of the first empty from the right

View File

@ -80,19 +80,8 @@ function onScriptingButtonDown(index, playerColor)
-- check for nearest investigator card and change action token state to its class
elseif tokenType == "universalActionAbility" then
local matColor = playmatApi.getMatColorByPosition(position)
local result = playmatApi.searchAroundPlaymat(matColor, "isCard")
local class = "Neutral"
for j, card in ipairs(result) do
local metadata = JSON.decode(card.getGMNotes()) or {}
if metadata.type == "Investigator" then
class = metadata.class
break
end
end
callback = function(spawned)
spawned.call("updateClassAndSymbol", { class = class, symbol = class })
end
local class = playmatApi.returnInvestigatorClass(matColor)
callback = function(spawned) spawned.call("updateClassAndSymbol", { class = class, symbol = class }) end
end
tokenManager.spawnToken(position, tokenType, rotation, callback)