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_Frost.b2b7be",
"PhysicsDetector.b300d8",
"Universal.834ad5",
"ArkhamSCE380-5122024-Page1.bd6b3e"
],
"PlayArea": 1,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -98,6 +98,8 @@ function updateDisplay()
tag = "Image",
attributes = {
image = "Border",
-- update color on the back for neutral
color = (class == "Neutral") and "#000000" or "#FFFFFF",
height = "200",
width = "200",
position = "0 0 -10.2",
@ -110,7 +112,7 @@ function updateDisplay()
attributes = {
id = "SymbolBack",
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",
height = "200",
width = "200",
@ -127,6 +129,13 @@ function updateDisplay()
else
self.setName(class .. " " .. symbol)
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
function addContextMenu()
@ -140,18 +149,18 @@ function addContextMenu()
end
function updateClass(newClass)
class = newClass
class = newClass or "Neutral"
updateDisplay()
end
function updateSymbol(newSymbol)
symbol = newSymbol
symbol = newSymbol or class
updateDisplay()
end
function updateClassAndSymbol(newClass, newSymbol)
class = newClass
symbol = newSymbol
function updateClassAndSymbol(params)
class = params.class or "Neutral"
symbol = params.symbol or class
updateDisplay()
end

View File

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

View File

@ -1,12 +1,12 @@
do
local SearchLib = {}
local filterFunctions = {
isActionToken = function(x) return x.getDescription() == "Action Token" end,
isCard = function(x) return x.type == "Card" end,
isDeck = function(x) return 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,
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

View File

@ -3,7 +3,7 @@ local searchLib = require("util/SearchLib")
local tokenManager = require("core/token/TokenManager")
local TOKEN_INDEX = {}
TOKEN_INDEX[1] = "actionToken"
TOKEN_INDEX[1] = "universalActionAbility"
TOKEN_INDEX[3] = "resourceCounter"
TOKEN_INDEX[4] = "damage"
TOKEN_INDEX[5] = "path"
@ -23,15 +23,6 @@ local stateTable = {
["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 playerColor string Color of the triggering player
function onScriptingButtonDown(index, playerColor)
@ -58,7 +49,7 @@ function onScriptingButtonDown(index, playerColor)
break
end
end
-- this is used to load the correct state for additional resource tokens (e.g. "Ammo")
local stateID = stateTable[string.lower(subType)]
if stateID ~= nil and stateID ~= 1 then
@ -87,20 +78,20 @@ function onScriptingButtonDown(index, playerColor)
end
end
-- 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 result = playmatApi.searchAroundPlaymat(matColor, "isCard")
local investigatorClass = "Neutral"
local class = "Neutral"
for j, card in ipairs(result) do
local metadata = JSON.decode(card.getGMNotes()) or {}
if metadata.type == "Investigator" then
investigatorClass = metadata.class
class = metadata.class
break
end
end
local stateID = actionStateTable[investigatorClass]
if stateID ~= nil and stateID ~= 6 then
callback = function(spawned) spawned.setState(stateID) end
callback = function(spawned)
spawned.call("updateClassAndSymbol", { class = class, symbol = class })
end
end