Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Sets the default spd and acc to these values
- attackValues = {speed = 0, accuracy = 0}
- monsterStats = {
- {name = "White Lion", speed = 2, accuracy = 2},
- {name = "Screaming Antelope", speed = 1, accuracy = 2},
- {name = "Butcher", speed = 2, accuracy = 4},
- {name = "King's Man", speed = 3, accuracy = 3},
- {name = "Phoenix", speed = 2, accuracy = 2},
- {name = "The Hand", speed = 2, accuracy = 2},
- {name = "The Watcher", speed = 4, accuracy = 2},
- {name = "Dragon King", speed = 2, accuracy = 2},
- {name = "Dung Beetle Knight", speed = 3, accuracy = 3},
- {name = "Flower Knight", speed = 3, accuracy = 2},
- {name = "Gorm", speed = 2, accuracy = 2},
- {name = "Lion God", speed = 2, accuracy = 3},
- {name = "Lion Knight", speed = 4, accuracy = 2},
- {name = "Lonely Tree", speed = 3, accuracy = 3},
- {name = "Manhunter", speed = 1, accuracy = 4},
- {name = "Slenderman", speed = 3, accuracy = 4},
- {name = "Spidicules", speed = 2, accuracy = 2},
- {name = "Sunstalker", speed = 3, accuracy = 4},
- {name = "The Tyrant", speed = 2, accuracy = 3}
- }
- playerTable = {
- P1 = {
- playerName = "Player One", sigil = "", fontColor = nil, name = "", grid = Global.getTable("grids").red.guid,
- pos_toSpawn = { - 5.85, 4.34, - 7.22}, surv_pos_toMove = { - 5.85, 5, - 7.22}
- },
- P2 = {
- playerName = "Player Two", sigil = "", fontColor = nil, name = "", grid = Global.getTable("grids").yellow.guid,
- pos_toSpawn = { - 2.82, 4.34, - 7.22}, surv_pos_toMove = { - 2.82, 5, - 7.22}
- },
- P3 = {
- playerName = "Player Three", sigil = "", fontColor = nil, name = "", grid = Global.getTable("grids").green.guid,
- pos_toSpawn = {2.34, 4.34, - 7.21}, surv_pos_toMove = {2.34, 5, - 7.21}
- },
- P4 = {
- playerName = "Player Four", sigil = "", fontColor = nil, name = "", grid = Global.getTable("grids").blue.guid,
- pos_toSpawn = {5.55, 4.34, - 7.22}, surv_pos_toMove = {5.55, 5, - 7.22}
- }
- }
- function onLoad()
- initCustomButtons()
- spawnedDice = {}
- zoneShowdown = getObjectFromGUID(Global.getTable('zonesDestruct').zoneShowdown.guid)
- zoneInjuryBoard = getObjectFromGUID(Global.getTable('zones').zoneInjuryBoard.guid)
- end
- -- Buttons ---------------------------------------------------------------------
- function initCustomButtons()
- setupButton("Attack", 0, - 0.6)
- setupButton("Priority", - 7.5, - 0.6)
- setupButton("Move Monster", - 8, 11.2, "moveMonster")
- setupButton("Bird's Eye View", 0, - 10, "birds_eye_view")
- setupButton("Remove Priority", 7.5, - 0.6, "remove_priorityTargetToken")
- end
- function createButtons_damage_display()
- local btn_params = {}
- btn_params.width = 0
- btn_params.height = 0
- btn_params.font_size = 600
- btn_params.font_color = {0.5, 0.5, 0.5}
- btn_params.click_function = "removeOnClear"
- btn_params.label = "Damage"
- btn_params.position = {88.5, 7.3, 54.1}
- self.createButton(btn_params)
- btn_params.label = "Damage"
- btn_params.position = { - 88.8, 7.3, 54.1}
- self.createButton(btn_params)
- bonus_damage = tostring(getObjectFromGUID(Global.getTable("boards").modTable.guid).call("getStats", {"damage"}))
- btn_params.font_size = 800
- btn_params.label = "+ " .. bonus_damage
- btn_params.position = { - 88.9, 7.8, 52.9}
- self.createButton(btn_params)
- btn_params.label = "+ " .. bonus_damage
- btn_params.position = {88.3, 7.8, 52.9}
- self.createButton(btn_params)
- end
- function setupButton(name, x, z, click_function)
- local button_parameters = {}
- button_parameters.height = 700
- button_parameters.width = 3500
- button_parameters.font_size = 700
- button_parameters.label = name
- button_parameters.color = {1, 1, 1, 0}
- button_parameters.rotation = { - 15, 0, 0}
- button_parameters.position = {x, 0.85, z}
- button_parameters.function_owner = self
- if click_function then
- button_parameters.click_function = click_function
- else
- self.setVar(name, function() showMenu(name) end)
- button_parameters.click_function = name
- end
- self.createButton(button_parameters)
- end
- -- Priority Target Token -------------------------------------------------------
- function remove_priorityTargetToken()
- for _, object in ipairs(zoneShowdown.getObjects()) do
- if object.getName() == "Priority Target" then
- if string.find(object.getDescription(), "permanent") then
- broadcastToAll("A Survivor has the Priority Target Permanently ~ From a Game Effect", {1, 1, 1})
- broadcastToAll("\\u{2612} Cannot Be Removed \\u{2612} ", {1, 1, 1})
- else
- object.destroy()
- end
- end
- end
- end
- function removeButton_removePriority()
- broadcastToAll("This function was deprecated, remove the calling function", {1, 1, 1})
- end
- function removeButton_gainPriority()
- broadcastToAll("This function was deprecated, remove the calling function", {1, 1, 1})
- end
- -- Dice Roller Functions -------------------------------------------------------
- function spawnDice(id)
- local number = attackValues.speed
- local step = 0.7
- if tonumber(attackValues.speed) < 1 then
- number = 1
- end
- local pointerPosition = {x = 22.18, y = 3, z = -28.3}
- if id == "P1" or id == "P2" then
- pointerPosition = {x = -22.18, y = 3, z = -28.3}
- end
- pointerPosition.x = pointerPosition.x - (number < 5 and ((number - 1)%4)*step/2 or 1.5*step)
- pointerPosition.z = pointerPosition.z - math.floor(number/4)*step/2
- for i = 0, number-1 do
- local posX = pointerPosition.x + (i%4)*step
- local posY = pointerPosition.y
- local posZ = pointerPosition.z + math.floor(i/4)*step
- self.takeObject({
- position = {posX, posY + 2, posZ},
- callback = 'rollTheDice',
- callback_owner = self,
- params = {num = number}
- })
- end
- end
- function rollTheDice(obj, params)
- table.insert(spawnedDice, obj.guid)
- obj.setScale({0.55, 0.55, 0.55})
- local oldDiceCount = #spawnedDice - params.num
- if #spawnedDice == (params.num + oldDiceCount) then
- startLuaCoroutine(self, "watchDice")
- end
- obj.roll()
- end
- function clearDice()
- for i, v in pairs(spawnedDice) do
- local die = getObjectFromGUID(v)
- if die ~= nil then destroyObject(die) end
- end
- spawnedDice = {}
- local zones = {
- a = getObjectFromGUID(Global.getTable('zones').zone_HL_roller_L.guid),
- b = getObjectFromGUID(Global.getTable('zones').zoneLeft_drawnHit.guid),
- c = getObjectFromGUID(Global.getTable('zones').zone_HL_roller_R.guid),
- d = getObjectFromGUID(Global.getTable('zones').zoneRight_drawnHit.guid),
- }
- for zoneKey, zoneGUIDtable in pairs(zones) do
- local zoneGUID = zoneGUIDtable.guid
- local zone = getObjectFromGUID(zoneGUID)
- local objectsInZone = zone.getObjects()
- for _, obj in ipairs(objectsInZone) do
- if obj.tag == "Dice" then
- obj.destroy()
- end
- end
- end
- for _, v in pairs(self.getButtons()) do
- if v.click_function == "removeOnClear" then
- self.removeButton(v.index)
- end
- end
- end
- function watchDice()
- local startTime = os.time()
- repeat
- local restingCount = 0
- for i, dieGUID in ipairs(spawnedDice) do
- local die = getObjectFromGUID(dieGUID)
- if die ~= nil then
- if not die or die.resting == true then
- restingCount = restingCount + 1
- if die.getValue() > attackValues.accuracy - 1 then
- die.setColorTint({1, 0, 0})
- hasBloodThirsty = false
- for _, card in ipairs(zoneInjuryBoard.getObjects()) do
- if card.getName() == "Bloodthirsty" then
- hasBloodThirsty = true
- end
- end
- else
- die.setColorTint({0.1, 0.1, 0.1})
- end
- end
- end
- end
- if hasBloodThirsty then
- broadcastToAll("Bloodthirsty ~ If you suffer damage from this attack, place a token on Bloodthirsty", {1, 1, 1})
- end
- coroutine.yield(0)
- until restingCount == #spawnedDice or os.time() > startTime + 6
- return 1
- end
- function showMenu(action)
- Global.UI.setAttribute("AttackRoller", "action", action)
- if action == "Attack" then
- Global.UI.setAttribute("AttackText", "text", "Select a survivor to be attacked.")
- Global.UI.setAttribute("AditionalText", "text", "Spd Acc")
- Global.UI.setAttribute("Priority", "active", "false")
- Global.UI.setAttribute("spd", "text", getMonster("spd"))
- Global.UI.setAttribute("acc", "text", getMonster("acc"))
- elseif action == "Priority" then
- Global.UI.setAttribute("AttackText", "text", "Select a survivor to gain the Priority Token.")
- Global.UI.setAttribute("AditionalText", "text", "? Permanent ?")
- Global.UI.setAttribute("Attack", "active", "false")
- end
- for k, v in pairs(playerTable) do
- local token = getObjectFromGUID(Global.getTable('user_settings')["settings_" .. k .. "_token"].guid)
- playerTable[k].sigil = token.getName()
- playerTable[k].fontColor = token.getColorTint()
- for _, obj in ipairs(getObjectFromGUID(Global.getTable('zones')["zone" .. k].guid).getObjects()) do
- if string.find(obj.getDescription(), "SurvivorSheet") then
- playerTable[k].name = obj.getName()
- Global.UI.setAttribute(k, "text", v.sigil .. " " .. v.name .. " " .. v.sigil)
- Global.UI.setAttribute(k, "textColor", "rgb(" .. v.fontColor.r .. "," .. v.fontColor.g .. "," .. v.fontColor.b .. ")")
- end
- end
- end
- Global.UI.setAttribute(action, "active", "true")
- Global.UI.show("AttackRoller")
- end
- function selectSurvivor(player, value, id)
- if Global.UI.getAttribute("AttackRoller", "action") == "Attack" then
- local hasWireFighting = false
- local grid = getObjectFromGUID(playerTable[id].grid)
- local zonePlayer = getObjectFromGUID(Global.getTable('zones')["zone" .. id].guid)
- local role = nil
- local isInsane = false
- local hitsOn2 = false
- attackValues.speed = tonumber(Global.UI.getAttribute("spd", "text")) + getObjectFromGUID(Global.getTable("boards").modTable.guid).call("getStats", {"speed"})
- attackValues.accuracy = tonumber(Global.UI.getAttribute("acc", "text")) - getObjectFromGUID(Global.getTable("boards").modTable.guid).call("getStats", {"accuracy"}) + getObjectFromGUID(grid.getVar("FullCharSheetGUID")).call("getStats", {"evasion"})
- for _, object in ipairs(zonePlayer.getObjects()) do
- if object.getName() == "Flower Knight Helm" and object.getRotation().z > 165 then
- broadcastToColor("Flower Knight Helm ~ The Monster Suffers (-1) Speed attacking you", player.color, playerTable[id].fontColor)
- attackValues.speed = attackValues.speed - 1
- end
- if object.getName() == "isInsane" and object.getRotation().z > 165 and object.getRotation().z < 195 then
- isInsane = true
- end
- end -- end
- local insanity_value = getObjectFromGUID(grid.getVar("FullCharSheetGUID")).call("getStats", {"insanity"})
- if insanity_value >= 3 then
- isInsane = true
- end
- for _, card in ipairs(zoneInjuryBoard.getObjects()) do
- if card.getName() == "Wire-Fighting" then
- grid.call("return_role")
- role = grid.getVar("role")
- end
- if string.find(card.getName(), "Embrace the Eons") then
- attackValues.accuracy = 2
- end
- if card.getName() == "Deep Paralysis" then
- broadcastToAll("Deep Paralysis ~ You are Insane ~ Slenderman gained (+2) Speed ", msg_color)
- attackValues.speed = attackValues.speed + 2
- end
- end
- move_camera(player.color, ((id == "P1" or id == "P2") and { - 22.19, 1.79, - 32.23} or {21.94, 1.84, - 32.23}), 60, 13)
- if role == "Villain" then
- local tokSpawner = getObjectFromGUID(Global.getTable('tokSpawn').pos_mov.guid)
- tokSpawner.setVar("phase", "endOfMonsterTurn")
- broadcastToAll("Wire-Fighting ~ The Lion Knight gained (+5) Movement for its next activation for attacking the Villain", {1, 1, 1})
- Wait.time(function() tokSpawner.call('spawn_token') end, 0.5, 5)
- end
- clearDice()
- Wait.time(function() spawnDice(id) end, 1.2)
- createButtons_damage_display()
- else
- local zoneShowdown = getObjectFromGUID(Global.getTable('zonesDestruct').zoneShowdown.guid)
- local hasPriority = false
- local priority_target = nil
- for _, tok in ipairs(zoneShowdown.getObjects()) do
- if tok.getName() == "Priority Target" then
- hasPriority = true
- priority_target = tok
- if string.find(tok.getDescription(), "permanent") then
- broadcastToAll("A Survivor already has the Priority Target Permanently ~ From a Game Effect", {1, 1, 1})
- return
- end
- end
- end
- for _, surv in ipairs(zoneShowdown.getObjects()) do
- if surv.getName() == playerTable[id].playerName then
- local pos = surv.getPosition()
- if hasPriority then
- surv.translate({0, 2, 0})
- priority_target.setPosition(pos)
- else
- local obj = getObjectFromGUID(Global.getTable('main_tokens').priority_token.guid)
- local objPos = obj.getPosition()
- priority_target = obj.clone({position = objPos})
- surv.translate({0, 2, 0})
- priority_target.setPosition(pos)
- end
- end
- end
- end
- Global.UI.hide("AttackRoller")
- end
- function changeCounter(player, value, id)
- local counterID = id:sub(1, 3)
- local addRemove = (id:sub(4) == "-") and - 1 or 1
- Global.UI.setAttribute(counterID, "text", tonumber(Global.UI.getAttribute(counterID, "text")) + addRemove)
- end
- -- Utility Functions -----------------------------------------------------------
- function birds_eye_view(object, player_color)
- move_camera(player_color, {0, 0.6, 0.68}, 55, 30)
- end
- function moveMonster(object, player_color)
- for _, object in ipairs(zoneShowdown.getObjects()) do
- local desc = object.getDescription()
- if string.find(desc, "monster") and string.find(desc, "figurine") then
- move_camera(player_color, object.getPosition(), 55, 10)
- end
- end
- end
- function getMonster(stat)
- local monsterCards = getAllObjects(getObjectFromGUID(Global.getTable("zones").zoneAIBoard.guid))
- local found = nil
- local sub = ""
- for _, v in pairs(monsterCards) do
- found = v.getName():find(" Basic Action Card")
- if found then
- sub = v:getName():sub(1, found - 1)
- for _, u in pairs(monsterStats) do
- if sub == u.name then
- if stat == "spd" then
- return u.speed
- else
- return u.accuracy
- end
- end
- end
- end
- end
- return 2
- end
- function dud() end
- function removeOnClear() end
- function playerLookAt(player_color, position)
- local parameters = {}
- parameters.position = position
- parameters.yaw = 0
- parameters.pitch = 60
- parameters.distance = 15
- if( player_color ~= nil ) then
- Player[player_color].lookAt(parameters)
- end
- end
- function move_camera(player_color, position, pitch, dist)
- local parameters = {}
- parameters.position = position
- parameters.yaw = 0
- parameters.pitch = pitch
- parameters.distance = dist
- if player_color ~= nil then
- Player[player_color].lookAt(parameters)
- end
- end
- function isCampaignLoaded()
- for _, object in ipairs(getObjectFromGUID(Global.getTable('zones').zoneSettlement.guid).getObjects()) do
- local desc = object.getDescription()
- if string.find(desc, "SettlementSheet") then
- return true
- end
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement