local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") 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("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() getObjectFromGUID("85c4c6").call("addVal", 1) 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.tag == "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.tag == "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.updateClueClicker(playerColor, playmatApi.getClueCount(clickableClues, playerColor) + 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