updated scripting

This commit is contained in:
Chr1Z93 2024-06-01 23:26:10 +02:00
parent 150e0e18d3
commit 37a1f71ecf
12 changed files with 77 additions and 85 deletions

View File

@ -225,7 +225,6 @@
"Tokencache_Curse.16a9a7", "Tokencache_Curse.16a9a7",
"Tokencache_Frost.b2b7be", "Tokencache_Frost.b2b7be",
"PhysicsDetector.b300d8", "PhysicsDetector.b300d8",
"Universal.834ad5",
"ArkhamSCE380-5122024-Page1.bd6b3e" "ArkhamSCE380-5122024-Page1.bd6b3e"
], ],
"PlayArea": 1, "PlayArea": 1,

View File

@ -12,7 +12,7 @@
"z": 0.118 "z": 0.118
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -22,7 +22,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -32,7 +32,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -42,7 +42,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -52,7 +52,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {

View File

@ -12,7 +12,7 @@
"z": 0.118 "z": 0.118
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -22,7 +22,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -32,7 +32,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -42,7 +42,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -52,7 +52,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {

View File

@ -12,7 +12,7 @@
"z": 0.118 "z": 0.118
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -22,7 +22,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -32,7 +32,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -42,7 +42,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -52,7 +52,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {

View File

@ -12,7 +12,7 @@
"z": 0.118 "z": 0.118
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -22,7 +22,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -32,7 +32,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -42,7 +42,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {
@ -52,7 +52,7 @@
"z": -0.28 "z": -0.28
}, },
"Tags": [ "Tags": [
"ActionToken" "UniversalToken"
] ]
}, },
{ {

View File

@ -20,7 +20,7 @@
"Path.7234af", "Path.7234af",
"Resource.910e09", "Resource.910e09",
"ResourceCounter.498ec0", "ResourceCounter.498ec0",
"Neutral.04765c" "UniversalActionAbilityToken.834ad5"
], ],
"ContainedObjects_path": "TokenSource.124381", "ContainedObjects_path": "TokenSource.124381",
"Description": "", "Description": "",

View File

@ -163,10 +163,14 @@
"LuaScript": "require(\"core/UniversalActionAbilityToken\")", "LuaScript": "require(\"core/UniversalActionAbilityToken\")",
"LuaScriptState": "", "LuaScriptState": "",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "universalActionAbility",
"Name": "Custom_Tile", "Name": "Custom_Tile",
"Nickname": "Universal", "Nickname": "Universal Action Ability Token",
"Snap": true, "Snap": true,
"Sticky": true, "Sticky": true,
"Tags": [
"UniversalToken"
],
"Tooltip": true, "Tooltip": true,
"Transform": { "Transform": {
"posX": -50.981, "posX": -50.981,

View File

@ -1387,7 +1387,7 @@ function removePlayermat(matColor)
if not matObjects.Playermat then return end if not matObjects.Playermat then return end
-- remove action tokens -- remove action tokens
local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isActionToken") local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isUniversalToken")
for _, obj in ipairs(actionTokens) do for _, obj in ipairs(actionTokens) do
obj.destruct() obj.destruct()
end end

View File

@ -98,6 +98,8 @@ function updateDisplay()
tag = "Image", tag = "Image",
attributes = { attributes = {
image = "Border", image = "Border",
-- update color on the back for neutral
color = (class == "Neutral") and "#000000" or "#FFFFFF",
height = "200", height = "200",
width = "200", width = "200",
position = "0 0 -10.2", position = "0 0 -10.2",
@ -110,7 +112,7 @@ function updateDisplay()
attributes = { attributes = {
id = "SymbolBack", id = "SymbolBack",
image = symbol, image = symbol,
-- update color of symbol on the back for neutral -- update color on the back for neutral
color = (class == "Neutral") and "#000000" or "#FFFFFF", color = (class == "Neutral") and "#000000" or "#FFFFFF",
height = "200", height = "200",
width = "200", width = "200",
@ -127,6 +129,13 @@ function updateDisplay()
else else
self.setName(class .. " " .. symbol) self.setName(class .. " " .. symbol)
end end
-- update scale
if symbol == "FreeTrigger" or symbol == "Reaction" then
self.setScale({0.35, 1, 0.35})
else
self.setScale({0.45, 1, 0.45})
end
end end
function addContextMenu() function addContextMenu()
@ -140,18 +149,18 @@ function addContextMenu()
end end
function updateClass(newClass) function updateClass(newClass)
class = newClass class = newClass or "Neutral"
updateDisplay() updateDisplay()
end end
function updateSymbol(newSymbol) function updateSymbol(newSymbol)
symbol = newSymbol symbol = newSymbol or class
updateDisplay() updateDisplay()
end end
function updateClassAndSymbol(newClass, newSymbol) function updateClassAndSymbol(params)
class = newClass class = params.class or "Neutral"
symbol = newSymbol symbol = params.symbol or class
updateDisplay() updateDisplay()
end end

View File

@ -846,11 +846,13 @@ function maybeUpdateActiveInvestigator(card)
if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end if not inArea(self.positionToLocal(card.getPosition()), INVESTIGATOR_AREA) then return end
local notes = JSON.decode(card.getGMNotes()) local notes = JSON.decode(card.getGMNotes())
local class local class = "Neutral"
local extraToken
if notes ~= nil and notes.type == "Investigator" and notes.id ~= nil then if notes ~= nil and notes.type == "Investigator" and notes.id ~= nil then
if notes.id == activeInvestigatorId then return end if notes.id == activeInvestigatorId then return end
class = notes.class class = notes.class
extraToken = notes.extraToken
activeInvestigatorId = notes.id activeInvestigatorId = notes.id
ownedObjects.InvestigatorSkillTracker.call("updateStats", { ownedObjects.InvestigatorSkillTracker.call("updateStats", {
notes.willpowerIcons, notes.willpowerIcons,
@ -866,46 +868,33 @@ function maybeUpdateActiveInvestigator(card)
return return
end end
-- change state of action tokens -- remove old action tokens
local search = searchArea(self.positionToWorld({ -1.1, 0.05, -0.27 }), { 4, 1, 1 }) for _, obj in ipairs(searchAroundSelf("isUniversalToken")) do
local smallToken = nil obj.destruct()
local STATE_TABLE = {
["Guardian"] = 1,
["Seeker"] = 2,
["Rogue"] = 3,
["Mystic"] = 4,
["Survivor"] = 5,
["Neutral"] = 6
}
for _, obj in ipairs(search) do
if obj.getDescription() == "Action Token" and obj.getStateId() > 0 then
if obj.getScale().x < 0.4 then
smallToken = obj
else
setObjectState(obj, STATE_TABLE[class])
end
end
end end
-- update the small token with special action for certain investigators -- spawn three regular action tokens (investigator specific one in the bottom spot)
local SPECIAL_ACTIONS = { for i = 1, 3 do
["04002"] = 8, -- Ursula Downs -- get position
["01002"] = 9, -- Daisy Walker local pos = self.positionToWorld(Vector(-1.54 + i * 0.18, 0, -0.28)):setAt("y", 0.1)
["01502"] = 9, -- Daisy Walker
["01002-pb"] = 9, -- Daisy Walker
["06003"] = 10, -- Tony Morgan
["04003"] = 11, -- Finn Edwards
["08016"] = 14 -- Bob Jenkins
}
if smallToken ~= nil then tokenManager.spawnToken(pos, "universalActionAbility", self.getRotation(), function(spawned)
setObjectState(smallToken, SPECIAL_ACTIONS[activeInvestigatorId] or STATE_TABLE[class]) spawned.call("updateClassAndSymbol", { class = class, symbol = class })
end)
end end
end
function setObjectState(obj, stateId) -- spawn additional token (maybe specific for investigator)
if obj.getStateId() ~= stateId then obj.setState(stateId) end if extraToken ~= "None" then
-- set value to class if currently "nil"
extraToken = extraToken or class
-- get position
local pos = self.positionToWorld(Vector(-1, 0, 0.118)):setAt("y", 0.1)
tokenManager.spawnToken(pos, "universalActionAbility", self.getRotation(), function(spawned)
spawned.call("updateClassAndSymbol", { class = class, symbol = extraToken })
end)
end
end end
--------------------------------------------------------- ---------------------------------------------------------

View File

@ -1,12 +1,12 @@
do do
local SearchLib = {} local SearchLib = {}
local filterFunctions = { local filterFunctions = {
isActionToken = function(x) return x.getDescription() == "Action Token" end,
isCard = function(x) return x.type == "Card" end, isCard = function(x) return x.type == "Card" end,
isDeck = function(x) return x.type == "Deck" end, isDeck = function(x) return x.type == "Deck" end,
isCardOrDeck = function(x) return x.type == "Card" or x.type == "Deck" end, isCardOrDeck = function(x) return x.type == "Card" or x.type == "Deck" end,
isClue = function(x) return x.memo == "clueDoom" and x.is_face_down == false end, isClue = function(x) return x.memo == "clueDoom" and x.is_face_down == false end,
isTileOrToken = function(x) return x.type == "Tile" end isTileOrToken = function(x) return x.type == "Tile" end,
isUniversalToken = function(x) return x.getMemo() == "universalActionAbility" end,
} }
-- performs the actual search and returns a filtered list of object references -- performs the actual search and returns a filtered list of object references

View File

@ -3,7 +3,7 @@ local searchLib = require("util/SearchLib")
local tokenManager = require("core/token/TokenManager") local tokenManager = require("core/token/TokenManager")
local TOKEN_INDEX = {} local TOKEN_INDEX = {}
TOKEN_INDEX[1] = "actionToken" TOKEN_INDEX[1] = "universalActionAbility"
TOKEN_INDEX[3] = "resourceCounter" TOKEN_INDEX[3] = "resourceCounter"
TOKEN_INDEX[4] = "damage" TOKEN_INDEX[4] = "damage"
TOKEN_INDEX[5] = "path" TOKEN_INDEX[5] = "path"
@ -23,15 +23,6 @@ local stateTable = {
["offering"] = 8 ["offering"] = 8
} }
local actionStateTable = {
["Guardian"] = 1,
["Seeker"] = 2,
["Rogue"] = 3,
["Mystic"] = 4,
["Survivor"] = 5,
["Neutral"] = 6
}
---@param index number Index of the pressed key ---@param index number Index of the pressed key
---@param playerColor string Color of the triggering player ---@param playerColor string Color of the triggering player
function onScriptingButtonDown(index, playerColor) function onScriptingButtonDown(index, playerColor)
@ -87,20 +78,20 @@ function onScriptingButtonDown(index, playerColor)
end end
end end
-- check for nearest investigator card and change action token state to its class -- check for nearest investigator card and change action token state to its class
elseif tokenType == "actionToken" then elseif tokenType == "universalActionAbility" then
local matColor = playmatApi.getMatColorByPosition(position) local matColor = playmatApi.getMatColorByPosition(position)
local result = playmatApi.searchAroundPlaymat(matColor, "isCard") local result = playmatApi.searchAroundPlaymat(matColor, "isCard")
local investigatorClass = "Neutral" local class = "Neutral"
for j, card in ipairs(result) do for j, card in ipairs(result) do
local metadata = JSON.decode(card.getGMNotes()) or {} local metadata = JSON.decode(card.getGMNotes()) or {}
if metadata.type == "Investigator" then if metadata.type == "Investigator" then
investigatorClass = metadata.class class = metadata.class
break
end end
end end
local stateID = actionStateTable[investigatorClass] callback = function(spawned)
if stateID ~= nil and stateID ~= 6 then spawned.call("updateClassAndSymbol", { class = class, symbol = class })
callback = function(spawned) spawned.setState(stateID) end
end end
end end