local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local guidReferenceApi = require("core/GUIDReferenceApi") local optionPanelApi = require("core/OptionPanelApi") local playmatApi = require("playermat/PlaymatApi") local victoryDisplayApi = require("core/VictoryDisplayApi") function onLoad() addHotkey("Add Doom to Agenda", addDoomToAgenda) addHotkey("Bless/Curse Status", showBlessCurseStatus) addHotkey("Discard Object", discardObject) addHotkey("Move card to Victory Display", moveCardToVictoryDisplay) addHotkey("Take clue from location", takeClueFromLocation) addHotkey("Upkeep", triggerUpkeep) addHotkey("Upkeep (Multi-handed)", triggerUpkeepMultihanded) addHotkey("Wendy's Menu", addWendysMenu) end -- triggers the "Upkeep" function of the calling player's playmat function triggerUpkeep(playerColor) if playerColor == "Black" then broadcastToColor("Triggering 'Upkeep (Multihanded)' instead", playerColor, "Yellow") triggerUpkeepMultihanded(playerColor) return end local matColor = playmatApi.getMatColor(playerColor) playmatApi.doUpkeepFromHotkey(matColor, playerColor) end -- triggers the "Upkeep" function of the calling player's playmat AND -- for all playmats that don't have a seated player, but a investigator card function triggerUpkeepMultihanded(playerColor) if playerColor ~= "Black" then triggerUpkeep(playerColor) end local colors = Player.getAvailableColors() for _, handColor in ipairs(colors) do local matColor = playmatApi.getMatColor(handColor) if playmatApi.returnInvestigatorId(matColor) ~= "00000" and Player[handColor].seated == false then playmatApi.doUpkeepFromHotkey(matColor, playerColor) end end end -- adds 1 doom to the agenda function addDoomToAgenda() local doomCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomCounter") doomCounter.call("addVal", 1) end -- discard the hovered object to the respective trashcan and discard tokens on it if it was a card function discardObject(playerColor, hoveredObject) if hoveredObject == nil then broadcastToColor("Hover a token/tile or a card/deck and try again.", playerColor, "Yellow") return end -- check if in playareazone local playAreaZone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone") local isInPlayAreaZone = false for _, zone in ipairs(hoveredObject.getZones()) do if zone == playAreaZone then isInPlayAreaZone = true break end end if hoveredObject.type == "Card" or hoveredObject.type == "Deck" then if hoveredObject.hasTag("Location") then broadcastToAll("Watch out: A location was discarded.", "Yellow") end -- discard tokens / tiles on it local discardTheseObjects = { hoveredObject } for _, v in ipairs(searchOnObj(hoveredObject)) do if v.hit_object.type == "Tile" then table.insert(discardTheseObjects, v.hit_object) end end local matColor if isInPlayAreaZone then matColor = playmatApi.getMatColor(playerColor) else matColor = playmatApi.getMatColorByPosition(hoveredObject.getPosition()) end playmatApi.discardListOfObjects(matColor, discardTheseObjects) elseif hoveredObject.type == "Tile" and not hoveredObject.locked then local owner if isInPlayAreaZone then owner = "Mythos" else owner = playmatApi.getMatColorByPosition(hoveredObject.getPosition()) end local trash = guidReferenceApi.getObjectByOwnerAndType(owner, "Trash") trash.putObject(hoveredObject) end end -- moves the hovered card to the victory display function moveCardToVictoryDisplay(_, hoveredObject) victoryDisplayApi.placeCard(hoveredObject) end -- takes a clue from a location, player needs to hover the clue directly or the location function takeClueFromLocation(playerColor, hoveredObject) local cardName, clue if hoveredObject == nil then broadcastToColor("Hover a clue or card with clues and try again.", playerColor, "Yellow") return elseif hoveredObject.type == "Card" then cardName = hoveredObject.getName() for _, v in ipairs(searchOnObj(hoveredObject)) do local obj = v.hit_object if obj.memo == "clueDoom" and obj.is_face_down == false then clue = obj break end end if clue == nil then broadcastToColor("This card does not have any clues on it.", playerColor, "Yellow") return end elseif hoveredObject.memo == "clueDoom" then if hoveredObject.is_face_down then broadcastToColor("This is a doom token and not a clue.", playerColor, "Yellow") return end clue = hoveredObject local search = Physics.cast({ direction = { 0, -1, 0 }, max_distance = 0.1, type = 3, size = { 0.1, 0.1, 0.1 }, origin = clue.getPosition() }) for _, v in ipairs(search) do local obj = v.hit_object if obj.type == "Card" then cardName = obj.getName() break end end else broadcastToColor("Hover a clue or card with clues and try again.", playerColor, "Yellow") return end local clickableClues = optionPanelApi.getOptions()["useClueClickers"] local playerName = Player[playerColor].steam_name local matColor = playmatApi.getMatColor(playerColor) local pos = nil if clickableClues then pos = {x = 0.49, y = 2.66, z = 0.00} playmatApi.updateCounter(matColor, "ClickableClueCounter", _, 1) else pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor) end local rot = playmatApi.returnRotation(matColor) -- check if found clue is a stack or single token if clue.getQuantity() > 1 then clue.takeObject({position = pos, rotation = rot}) else clue.setPositionSmooth(pos) clue.setRotation(rot) end if cardName then broadcastToAll(playerName .. " took one clue from " .. cardName .. ".", playerColor) else broadcastToAll(playerName .. " took one clue.", "Green") end victoryDisplayApi.update() end -- broadcasts the bless/curse status to the calling player function showBlessCurseStatus(playerColor) blessCurseManagerApi.broadcastStatus(playerColor) end -- adds Wendy's menu to the hovered card function addWendysMenu(playerColor, hoveredObject) blessCurseManagerApi.addWendysMenu(playerColor, hoveredObject) end -- searches on an object (by using its bounds) ---@param obj Object Object to search on function searchOnObj(obj) return Physics.cast({ direction = { 0, 1, 0 }, max_distance = 0.5, type = 3, size = obj.getBounds().size, origin = obj.getPosition() }) end