Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- playerTable = {
- P1 = {
- color = "red", playerZone = "zoneP1", playerName = "Player One", grave_pos = { - 12.84, 4.12, - 58.74}
- , skullDeadPos = { - 5.85, 4.32, - 7.22}, survDiedPos = { - 5.76, 4.36, - 9.26}, survDiedRot = {323.13, 90.00, 90.00}
- , cannibalizeResourcePos = {}, gainedResourcePos = {}, rolePosition = {}
- , gridGUID = "d6d0e5", skullDeadToken = "11ddbb", extraBleed = "d7a48a", bleedTool = "a6b9f6", extraSlots = "696d34"
- , affinityRed = "eb1f26", affinityGreen = "17e382", affinityBlue = "e915b0", zoneGraveyard = "zoneGraveyard_Left"
- , fistToothToken = "6d4a2a", frenzyToken = ""
- }
- , P2 = {
- color = "yellow", playerZone = "zoneP2", playerName = "Player Two", grave_pos = { - 12.84, 4.12, - 58.74}
- , skullDeadPos = { - 2.82, 4.32, - 7.22}, survDiedPos = { - 2.79, 4.54, - 9.26}, survDiedRot = {0.00, 90.00, 90.00}
- , cannibalizeResourcePos = {}, gained_resource_pos = {}, rolePosition = {}
- , gridGUID = "f24977", skullDeadToken = "7e71e0", extraBleed = "4de12c", bleedTool = "a4f09f", extraSlots = "02f864"
- , affinityRed = "429814", affinityGreen = "e1e89f", affinityBlue = "e9db49", zoneGraveyard = "zoneGraveyard_Left"
- , fistToothToken = "099bb2", frenzyToken = ""
- }
- , P3 = {
- color = "green", playerZone = "zoneP3", playerName = "Player Three", grave_pos = {12.84, 4.12, - 58.74}
- , skullDeadPos = {2.44, 4.32, - 7.21}, survDiedPos = {2.44, 4.55, - 9.26}, survDiedRot = {270.00, 180.00, 0.00}
- , cannibalizeResourcePos = {}, gained_resource_pos = {}, rolePosition = {}
- , gridGUID = "d7d8ee", skullDeadToken = "c7d338", extraBleed = "e51595", bleedTool = "06764c", extraSlots = "b044de"
- , affinityRed = "48c3e9", affinityGreen = "c54f3c", affinityBlue = "7d41b3", zoneGraveyard = "zoneGraveyard_Right"
- , fistToothToken = "bce349", frenzyToken = ""
- }
- , P4 = {
- color = "blue", playerZone = "zoneP4", playerName = "Player Four", grave_pos = {12.84, 4.12, - 58.74}
- , skullDeadPos = {5.55, 4.32, - 7.22}, survDiedPos = {5.51, 4.56, - 9.26}, survDiedRot = {303.87, 88.95, 90.95}
- , cannibalizeResourcePos = {}, gained_resource_pos = {}, rolePosition = {}
- , gridGUID = "f14367", skullDeadToken = "b2fefd", extraBleed = "a40619", bleedTool = "'cb6334'", extraSlots = "2916f5"
- , affinityRed = "dee6a3", affinityGreen = "c2c15a", affinityBlue = "d130c1", zoneGraveyard = "zoneGraveyard_Right"
- , fistToothToken = "868eb0", frenzyToken = ""
- }
- }
- weapon = {strength = 0, speed = 2, accuracy = 2, luck = 1, name = "FistAndTooth"}
- wounds = {"headH", "bodyL", "bodyH", "waistL", "waistH", "armsL", "armsH", "legsL", "legsH"}
- -- cannibalizeResourcePos = {-33.20, 2, -35.90} -- surv sheet pos
- -- gained_resource_pos = {-14.16, 1.08, -18.80} -- avatar pos
- -- extraSlots = '696d34'
- -- extraSlots_pos_on = {-30.88, 0.24, -35.79}
- extraSlots_rot = {3.12, 0.00, 0.00}
- -- momentum_Counter = '7dd43d'
- -- momentum_on_pos = { - 7.40, 4.17, - 8.19}
- -- Offset Positions
- offsets = {
- movToken = {x = -0.18, y = 6, z = 2.19}
- , spdToken = {x = 0.48, y = 6, z = 2.19}
- , accToken = {x = 1.15, y = 6, z = 2.19}
- , strToken = {x = 1.78, y = 6, z = 2.19}
- , lckToken = {x = 2.44, y = 6, z = 2.19}
- , evaToken = {x = 3.13, y = 6, z = 2.19}
- , negativeZ = 1.09
- , extraBleed = {x = 0.2, y = 0, z = 0}
- , weaponProf = {x = 2.95, y = 1.08, z = 2.14}
- }
- statsBag = {}
- SurvSheetScript = "357074"
- SurvMemBag = 'c1d766'
- survivorBags = {
- male = {
- {mesh = "http://pastebin.com/raw/tg6gzM2f", diffuse = "http://u.cubeupload.com/redcore/standingman.jpg"},
- {mesh = "http://pastebin.com/raw/hnx90H3a", diffuse = "http://u.cubeupload.com/redcore/walkingman.jpg"}
- },
- female = {
- {mesh = "http://pastebin.com/raw/GK305Abh", diffuse = "http://u.cubeupload.com/redcore/woman1.jpg"},
- {mesh = "http://pastebin.com/raw/GGj34rtV", diffuse = "http://u.cubeupload.com/redcore/woman2.jpg"}
- }
- }
- function onload(saved_data)
- -- ÄNDERN!!!!!!!!!!!
- -- affinity_red = getObjectFromGUID('eb1f26')
- -- affinity_green = getObjectFromGUID('17e382')
- -- affinity_blue = getObjectFromGUID('e915b0')
- -- zones
- zonesTable = Global.getTable('zones')
- survCardsTable = Global.getTable('survCards')
- menuTokensTable = Global.getTable('menu_tokens')
- user_settings = Global.getTable('user_settings')
- zoneShowdown = getObjectFromGUID(Global.getTable('zonesDestruct').zoneShowdown.guid)
- zoneSurvivorStatus = getObjectFromGUID(Global.getTable('zonesDestruct').zoneSurvivorStatus.guid)
- zoneInjuryBoard = getObjectFromGUID(zonesTable.zoneInjuryBoard.guid)
- zoneInnovations = getObjectFromGUID(zonesTable.zoneInnovations.guid)
- gameBox = getObjectFromGUID(Global.getTable('bags').gameBox.guid)
- statsBag = {
- strTokenPos = getObjectFromGUID(Global.getTable('bags_stats').bag_str.guid)
- , strTokenNeg = getObjectFromGUID(Global.getTable('bags_stats_neg').bag_str.guid)
- , accTokenPos = getObjectFromGUID(Global.getTable('bags_stats').bag_acc.guid)
- , accTokenNeg = getObjectFromGUID(Global.getTable('bags_stats_neg').bag_acc.guid)
- , movTokenPos = getObjectFromGUID(Global.getTable('bags_stats').bag_mov.guid)
- , movTokenNeg = getObjectFromGUID(Global.getTable('bags_stats_neg').bag_mov.guid)
- , spdTokenPos = getObjectFromGUID(Global.getTable('bags_stats').bag_spd.guid)
- , spdTokenNeg = getObjectFromGUID(Global.getTable('bags_stats_neg').bag_spd.guid)
- , lckTokenPos = getObjectFromGUID(Global.getTable('bags_stats').bag_lck.guid)
- , lckTokenNeg = getObjectFromGUID(Global.getTable('bags_stats_neg').bag_lck.guid)
- , evaTokenPos = getObjectFromGUID(Global.getTable('bags_stats').bag_eva.guid)
- , evaTokenNeg = getObjectFromGUID(Global.getTable('bags_stats_neg').bag_eva.guid)
- }
- -- need update
- token_startShowdown = getObjectFromGUID('9091f8')
- grave_stone_object = getObjectFromGUID("416864")
- for i, v in pairs(playerTable) do
- local survSheet = nil
- local zonePlayer = getObjectFromGUID(zonesTable[v.playerZone].guid)
- local survCard = getObjectFromGUID(survCardsTable[v.color].guid)
- for k, object in pairs(zonePlayer.getObjects()) do
- if object.getVar("isSurvSheet") then
- survSheet = object
- getObjectFromGUID(v.gridGUID).setVar("survSheetGUID", object.getGUID())
- getObjectFromGUID(v.gridGUID).setColorTint(getObjectFromGUID(user_settings["settings_" .. i .. "_token"].guid).getColorTint())
- end
- end
- Wait.time(function() checkTokenDelayed(zonePlayer, survCard, survSheet, i) end, 2)
- end
- end
- function toggleCheckBox(params)
- local name = params.id:sub(1, - 3)
- local num = tonumber(params.id:sub(-2))
- if params.obj.UI.getAttribute(params.id, "value") == "false" then
- params.obj.UI.setAttribute(params.id, "value", "true")
- params.obj.UI.setAttribute(params.id, "color", "#000000")
- else
- params.obj.UI.setAttribute(params.id, "value", "false")
- params.obj.UI.setAttribute(params.id, "color", "#00000000")
- end
- end
- function counter(params)
- local possibleHL = {head = 0, body = 0, waist = 0, arms = 0, legs = 0}
- for h, _ in pairs(possibleHL) do
- if params.value == h then
- local hasCrystalSkin = false
- local zonePlayer = nil
- local activePlayer = ""
- for k, v in pairs(playerTable) do
- if params.obj.getGUID() == v.gridGUID then
- zonePlayer = getObjectFromGUID(zonesTable[v.playerZone].guid)
- activePlayer = k
- end
- end
- for _, obj in pairs(zonePlayer.getObjects()) do
- if obj.getName() == "Crystal Skin" then
- hasCrystalSkin = true
- end
- end
- for _, obj in pairs(zonePlayer.getObjects()) do
- if obj.tag == 'Card' then
- local descript = obj.getDescription()
- if (string.find(descript, 'armor') and (not hasCrystalSkin)) or string.find(descript, 'accessory') or string.find(descript, 'shield') or string.find(descript, 'set') then
- possibleHL = checkCardString(possibleHL, descript, activePlayer)
- end -- end if string.find
- end -- end if obj.tag
- end -- end for loop
- params.obj.UI.setAttribute(params.value, "text", math.max(math.min(tonumber(params.obj.UI.getAttribute(params.value, "text")) + tonumber(params.id), possibleHL[params.value]), 0))
- return
- end
- end
- local stats = {movement = "mov", speed = "spd", accuracy = "acc", strength = "str", luck = "lck", evasion = "eva"}
- local bag = nil
- local pos = params.obj.getPosition()
- if params.id == "+1" then
- bag = Global.getTable('bags_stats')
- pos = {x = pos.x + offsets[stats[params.value] .. "Token"].x, y = pos.y + offsets[stats[params.value] .. "Token"].y, z = pos.z + offsets[stats[params.value] .. "Token"].z}
- elseif params.id == "-1" then
- bag = Global.getTable('bags_stats_neg')
- pos = {x = pos.x + offsets[stats[params.value] .. "Token"].x, y = pos.y + offsets[stats[params.value] .. "Token"].y, z = pos.z + negativeZ}
- end
- spawn_token({obj = params.obj, bag = getObjectFromGUID(bag["bag_" .. stats[params.value]].guid), pos = pos})
- end
- function spawn_token(params)
- -- params.obj, params.bag, params.pos
- local bag = params.bag
- local token_pos = params.pos
- local gridObject = params.obj
- local rot = {0, 180, 0}
- local token = bag.takeObject({position = token_pos, rotation = rot, smooth = false})
- token.setScale({0.25, 0.25, 0.25})
- if gridObject.getName() == "Inventory P1" then
- table_toGet = "stats_red"
- elseif gridObject.getName() == "Inventory P2" then
- table_toGet = "stats_yellow"
- elseif gridObject.getName() == "Inventory P3" then
- table_toGet = "stats_green"
- elseif gridObject.getName() == "Inventory P4" then
- table_toGet = "stats_blue"
- end
- phase = Global.getTable(table_toGet).phase
- if phase == nil then
- phase = Global.getTable('temp').phase
- end
- if phase == "endOfround" then
- token.setDescription('temp, end of round')
- elseif phase == "endOfattack" then
- token.setDescription('temp, end of attack')
- elseif phase == "endOfwoundattempt" then
- token.setDescription('temp, end of wound attempt')
- elseif phase == "endOfwound" then
- token.setDescription('temp, end of wound')
- elseif phase == "haze" then
- token.setDescription('temp, haze')
- else
- token.setDescription('token, plus1mov')
- end
- end
- function collision(params)
- local obj = params.collision_info.collision_object
- local grid = params.obj
- if obj.getVar("isSurvSheet") then
- grid.setVar("survSheetGUID", obj.guid)
- elseif obj.getName() == "Monster Controller" then
- for k, v in pairs(playerTable) do
- if v.gridGUID == grid.getGUID() then
- for _, figure in ipairs(zoneShowdown.getObjects()) do
- if figure.getName() == v.playerName then
- figure.highlightOn(figure.getColorTint(), 500)
- end
- end
- end
- end
- end
- end
- function collisionExit(params)
- local obj = params.collision_info.collision_object
- local grid = params.obj
- if obj.getVar("isSurvSheet") then
- grid.setVar("survSheetGUID", "")
- elseif obj.getName() == "Monster Controller" then
- for k, v in pairs(playerTable) do
- if v.gridGUID == grid.getGUID() then
- for _, figure in ipairs(zoneShowdown.getObjects()) do
- if figure.getName() == v.playerName then
- figure.highlightOff()
- end
- end
- end
- end
- end
- end
- --------------------------------------------------------------------------------
- -- TABLE OF CONTENTS --
- -- Scripts created by Maximo and Kijan --
- --------------------------------------------------------------------------------
- -- Weapon and Armor ------------------------------------------------------------
- -- function checkWeapon
- -- function SetWeapon
- -- function FistWeapon
- -- function CleanWeapon
- -- function reset_Weapon_Prof
- -- function resetArmor
- -- function checkCards
- -- function removeCard
- -- Tokens ----------------------------------------------------------------------
- -- function checkToken
- -- function checkTokenDelayed
- -- function parseEffects
- -- Event Handlers --------------------------------------------------------------
- -- function onObjectEnterScriptingZone
- -- function onObjectLeaveScriptingZone
- -- function onObjectDestroyed
- -- function onPickedUp
- -- function onCollisionEnter
- -- function onCollisionExit
- -- Survivor Died ---------------------------------------------------------------
- -- function survDied
- -- function get_basic_for_cannibalize
- -- function set_skull_dead_token
- -- function updatePopulation
- -- Save Survivor ---------------------------------------------------------------
- -- function buttonClick_SaveSurv
- -- function saveSurv
- -- function setModel
- -- Utility Functions -----------------------------------------------------------
- -- function findProximity
- -- function get_player_pos
- -- function wait
- -- function set_portrait_buttons
- -- function return_role
- -- Buttons ---------------------------------------------------------------------
- -- function initCustomButtons
- -- function initButtonsTable
- -- function clickedToggle
- -- function setupButton
- -- function createpm
- -- function add
- -- function diceStats
- -- END TABLE OF CONTENTS -------------------------------------------------------
- function clickedSurvDied(params)
- local HL_discard_pos = Global.getTable("HL_discard_pos")
- local zonePlayer = nil
- local msgColor = nil
- local activePlayer = ""
- for k, v in pairs(playerTable) do
- if params.obj.getGUID() == v.gridGUID then
- zonePlayer = getObjectFromGUID(zonesTable[v.playerZone].guid)
- activePlayer = k
- msgColor = getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint()
- end
- end
- if zonePlayer == nil then
- printToAll("Grid (", params.obj.getGUID(), ") not found in playerTable! (clickedSurvDied)", {1, 0, 0})
- return
- end
- local phase = token_startShowdown.getDescription()
- -- Check Death Principle
- for _, object in ipairs(zoneInnovations.getObjects()) do
- if object.getName() == "Cannibalize" then
- Wait.time(function() get_basic_for_cannibalize(activePlayer) end, 2)
- broadcastToAll("Cannibalize ~ The Settlement gained 1 Basic Resource", {1, 1, 1})
- elseif object.getName() == "Graves" then
- if phase == "showdown started" then
- broadcastToAll("Graves ~ Gain 2 Endeavors", {1, 1, 1})
- elseif phase == "showdown ended" then
- broadcastToAll("Graves ~ Gain 1 Endeavor", {1, 1, 1})
- end
- end -- end Death Principle
- end
- if phase == "showdown started" then
- -- Bone Whisperer
- for k, v in pairs(playerTable) do
- local zone = getObjectFromGUID(zonesTable[v.playerZone].guid)
- local objectsInZone = zone.getObjects()
- for _, object in ipairs(objectsInZone) do
- if object.getName() == "Bone Whisperer" then
- local skull_token = getObjectFromGUID("dcdc21")
- skull_token.clone({position = get_player_pos(v.playerName)})
- end
- end
- end -- end Bone Whisperer
- -- When a Survivor Dies - Monster AI Card effects
- for _, card in ipairs(zoneInjuryBoard.getObjects()) do
- -- Enraged
- if card.getName() == "Enraged" then
- broadcastToAll("Enraged ~ was discarded when a Survivor Dies", {1, 1, 1})
- card.setPosition(HL_discard_pos)
- -- Deep Paralysis
- elseif card.getName() == "Deep Paralysis" then
- broadcastToAll("Deep Paralysis ~ was discarded when a Survivor Dies", {1, 1, 1})
- card.setPosition(HL_discard_pos)
- -- You've Already Lost
- elseif card.getName() == "You've Already Lost" then
- broadcastToAll("You've Already Lost ~ was discarded when a Survivor Dies", {1, 1, 1})
- card.setPosition(HL_discard_pos)
- -- Upstage
- elseif card.getName() == "Upstage" then
- broadcastToAll("Upstage ~ was discarded when a Survivor Dies", {1, 1, 1})
- card.setPosition(HL_discard_pos)
- -- God Parasites
- elseif card.getName() == "God Parasites" then
- broadcastToAll("God Parasites ~ was discarded when a Survivor Dies", {1, 1, 1})
- card.setPosition(HL_discard_pos)
- -- Screaming
- elseif card.getName() == "Screaming" then
- broadcastToAll("Screaming ~ was discarded when a Survivor Dies", {1, 1, 1})
- card.setPosition(HL_discard_pos)
- end
- end -- end
- local hasOrator = false
- for _, object in ipairs(zonePlayer.getObjects()) do
- if object.getName() == "Orator of Death" then
- hasOrator = true
- end
- end
- if hasOrator then
- for _, object in ipairs(zonePlayer.getObjects()) do
- if object.getVar("isSurvSheet") then
- broadcastToAll(object.getName() .. " was the Orator of Death", {1, 1, 1})
- end
- end
- for _, object in ipairs(zoneShowdown.getObjects()) do
- local rotZ = object.getRotation().z
- for k, v in pairs(playerTable) do
- if playerTable[activePlayer].playerName ~= v.playerName and object.getName() == v.playerName and (rotZ > 165 and rotZ < 195) then
- object.setRotation({0, 0, 0})
- broadcastToAll("You were Encouraged by their Dying Words", getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint())
- end
- end
- end
- end
- -- When a Survivor Dies
- for k, v in pairs(playerTable) do
- if playerTable[activePlayer].playerName ~= v.playerName then
- for _, object in ipairs(getObjectFromGUID(zonesTable[v.playerZone].guid).getObjects()) do
- local grid = getObjectFromGUID(v.gridGUID)
- local pos = v.gainedResourcePos
- local effects = {"Ruthless", "Vengeance", "Revenge"}
- for _, effect in pairs(effects) do
- if object.getName() == effect then
- local scale = object.getScale()
- broadcastToAll(v.playerName .. " ~ " .. effect .. " ~ Effect Triggered", getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint())
- object.setScale({0.49, 1.00, 0.49})
- object.clone({position = pos})
- object.setScale(scale)
- end
- end
- end
- end
- end
- Wait.time(function() set_skull_dead_token(activePlayer) end, 1)
- end
- updatePopulation()
- resetArmor(activePlayer)
- local survSheetGUID = params.obj.getVar("survSheetGUID")
- if survSheetGUID ~= "" then
- getObjectFromGUID(survSheetGUID).call("onSave")
- end
- local pos = params.obj.getPosition()
- --Gets Gravestone Marker
- graveObj = grave_stone_object.clone({position = {pos.x, pos.y, pos.z - 8}, rotation = {0, 0, 0}})
- Wait.condition(function() survDiedButton(graveObj, msgColor, activePlayer) Wait.time(function() survDied(graveObj, getObjectFromGUID(survSheetGUID), msgColor, activePlayer) end, 0.2) end, function() return checkLoaded(graveObj) end)
- end
- function burySurvivor(activePlayer)
- local objectsInZone = getObjectFromGUID(zonesTable[playerTable[activePlayer].zoneGraveyard].guid).getObjects()
- graveObj.setPosition({playerTable[activePlayer].grave_pos.x - #objectsInZone * 1.64, playerTable[activePlayer].grave_pos.y, playerTable[activePlayer].grave_pos.z})
- graveObj.removeButton(0)
- broadcastToAll("Population Updated", {1, 1, 1})
- end
- -- Weapon and Armor ------------------------------------------------------------
- function checkWeaponEx(params)
- checkWeapon(params[1])
- end
- function checkWeapon(activePlayer)
- local foundWeapon = nil
- local selector = nil
- local gridObject = getObjectFromGUID(playerTable[activePlayer].gridGUID)
- local pos = gridObject.getPosition()
- pos.x = pos.x - 0.03
- pos.y = pos.y + 0.6
- for i = 0, 2 do
- for j = 0, 2 do
- foundWeapon = nil
- selector = nil
- local hitList = Physics.cast({
- origin = {pos.x + i * 1.5, pos.y, pos.z - j * 1.35},
- direction = {0, 1, 0},
- type = 2,
- size = {1, 1, 1},
- max_distance = 0,
- debug = true
- })
- for _, entry in ipairs(hitList) do
- if entry.hit_object.getDescription():find("weapon") then
- foundWeapon = entry.hit_object
- end
- if entry.hit_object.getName() == "Selected Weapon" then
- selector = entry.hit_object
- end
- end
- if foundWeapon ~= nil and selector ~= nil then
- -- sets GUID so any functions on the weapon can be called
- gridObject.setVar("weaponGUID", foundWeapon.getGUID())
- -- sets Weapon name and description
- SetWeapon({obj = gridObject, WpnStat = {foundWeapon.getName(), foundWeapon.getDescription()}})
- return
- end
- end
- end
- SetWeapon({obj = gridObject, WpnStat = {"Bases", "Bases"}})
- gridObject.setVar("weaponGUID", playerTable[activePlayer].fistToothToken)
- end
- function SetWeapon(params)
- local WpnStat = params.WpnStat
- local gridObject = params.obj
- if WpnStat ~= nil then
- local survSheet = getObjectFromGUID(gridObject.getVar("survSheetGUID"))
- local WeaponName = WpnStat[1]
- if WeaponName ~= 'Bases' then
- local weapon = {}
- local descript = WpnStat[2]
- local regxEverythingExceptComma = '([^,]+)'
- local BaseSpeed = 0
- local Basecrit = 0
- local BaseStr = 0
- local Baseacc = 0
- for x in string.gmatch(descript, regxEverythingExceptComma) do
- if x:find("spd") then
- BaseSpeed = tonumber(string.match (x, "%d+"))
- end
- if x:find("acc") then
- if x:find("acc%+weaponProf") then
- if survSheet ~= nil then
- for wp = 1, 8 do
- if survSheet.UI.getAttribute("weaponProficiency0" .. wp, "value") == "true" then
- Baseacc = Baseacc + 1
- end
- end
- end
- else
- Baseacc = tonumber(string.match(x, "%d+"))
- end
- end
- if x:find("str") then
- if x:find("str%+insanity") then
- BaseStr = tonumber(survSheet.UI.getAttribute("insanity", "text"))
- elseif x:find("str%+courage") then
- if survSheet ~= nil then
- for wp = 1, 9 do
- if survSheet.UI.getAttribute("courage0" .. wp, "value") == "true" then
- BaseStr = BaseStr + 1
- end
- end
- end
- else
- BaseStr = tonumber(string.match(x, "%d+"))
- end
- end
- if x:find("lck") then
- Basecrit = tonumber(string.match(x, "%d+"))
- end
- end
- weapon["strength"] = BaseStr
- weapon["speed"] = BaseSpeed
- weapon["accuracy"] = 10 - Baseacc
- weapon["luck"] = Basecrit
- weapon['name'] = WeaponName
- gridObject.setTable("weapon", weapon)
- else
- FistWeapon(gridObject)
- end
- end
- Wait.frames(function() diceStats(gridObject) end, 1)
- end
- function FistWeapon(gridObject)
- local activePlayer = ""
- local zonePlayer = nil
- local msgColor = nil
- for k, v in pairs(playerTable) do
- if gridObject.getGUID() == v.gridGUID then
- zonePlayer = getObjectFromGUID(zonesTable[v.playerZone].guid)
- activePlayer = k
- msgColor = getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint()
- end
- end
- if zonePlayer == nil then
- printToAll("Grid (", gridObject.getGUID(), ") not found in playerTable! (FistWeapon)", {1, 0, 0})
- return
- end
- weapon['strength'] = 0
- weapon['speed'] = 2
- weapon['accuracy'] = 2
- weapon['luck'] = 1
- weapon['name'] = "FistAndTooth"
- for _, object in ipairs(zonePlayer.getObjects()) do
- -- Monster Claw Style
- if object.getName() == "Monster Claw Style" then
- weapon['strength'] = weapon['strength'] + 1
- weapon['accuracy'] = weapon['accuracy'] + 1
- broadcastToColor("Monster Claw Style ~ (+1) Accuracy ~ (+1) Strength Calculated", playerTable[activePlayer].color, msgColor)
- end
- -- Brawler Armor
- if object.getName() == "Brawler Armor" then
- weapon['accuracy'] = weapon['accuracy'] + 2
- broadcastToColor("Brawler Armor Set ~ (+2) Accuracy Calculated", playerTable[activePlayer].color, msgColor)
- end
- -- Death Touch
- if object.getName() == "Death Touch" then
- weapon['strength'] = weapon['strength'] + 1
- broadcastToColor("Death Touch ~ (+1) Strength Calculated", playerTable[activePlayer].color, msgColor)
- end
- end
- gridObject.setTable("weapon", weapon)
- end
- function CleanWeapon()
- printToAll("Need gridObject to function in CleanWeapon", {1, 0, 0})
- FistWeapon(gridObject)
- Wait.frames(function() diceStats(gridObject) end, 1)
- end
- -- Kijan
- -- maximo is it needed?
- -- function reset_Weapon_Prof()
- -- -- Enables Weapon Prof / Mastery
- -- local pos = fistToothToken.getPosition()
- -- local hitList = Physics.cast({
- -- origin = {pos.x, pos.y, pos.z - 4},
- -- direction = {0, 1, 0},
- -- type = 2,
- -- size = {1, 1, 1},
- -- max_distance = 0,
- -- })
- -- for _, entry in ipairs(hitList) do
- -- if string.find(entry.hit_object.getDescription(), "proficiency, mastery") then
- -- entry.hit_object.setPosition(weapon_prof_pos)
- -- broadcastToAll("Your Weapon Proficiency / Mastery was Enabled", msg_color)
- -- end
- -- end
- -- end
- function resetArmor(activePlayer)
- local zonePlayer = getObjectFromGUID(zonesTable[playerTable[activePlayer].playerZone].guid)
- local gridObject = getObjectFromGUID(playerTable[activePlayer].gridGUID)
- for _, wound in pairs(wounds) do
- gridObject.UI.setAttribute(wound, "value", "false")
- gridObject.UI.setAttribute(wound, "color", "#00000000")
- end
- local objs = zonePlayer.getObjects()
- hasCrystalSkin = false
- for _, obj in pairs(objs) do
- if obj.getName() == "Crystal Skin" then
- hasCrystalSkin = true
- end
- end
- local possibleHL = {head = 0, body = 0, waist = 0, arms = 0, legs = 0}
- for _, obj in pairs(objs) do
- if obj.tag == 'Card' then
- local descript = obj.getDescription()
- if (string.find(descript, 'armor') and (not hasCrystalSkin)) or string.find(descript, 'accessory') or string.find(descript, 'shield') or string.find(descript, 'set') then
- possibleHL = checkCardString(possibleHL, descript, activePlayer)
- end -- end if string.find
- end -- end if obj.tag
- end -- end for loop
- for location, value in pairs(possibleHL) do
- gridObject.UI.setAttribute(location, "text", value)
- end
- -- reset_Weapon_Prof()
- --removes extra bleeding tokens for unconscious Fighter
- local extraBleedPos = gridObject.getPosition()
- extraBleedPos = {x = extraBleedPos.x + offsets.extraBleed.x, y = extraBleedPos.y + offsets.extraBleed.y - 3, z = extraBleedPos.z + offsets.extraBleed.z}
- getObjectFromGUID(playerTable[activePlayer].extraBleed).setPosition(extraBleedPos)
- --resets stat mods
- for k, object in pairs(objs) do
- local desc = object.getDescription()
- if string.find(desc, 'token') or string.find(desc, "temp") then
- object.destruct()
- end
- end
- --removes extra bleeding tokens for unconscious Fighter
- local bleedTool = getObjectFromGUID(playerTable[activePlayer].bleedTool)
- local isExtraButtons = bleedTool.getVar("extraBleed")
- if isExtraButtons == true then
- bleedTool.removeButton(5)
- bleedTool.removeButton(6)
- bleedTool.setVar("extraBleed", false)
- end
- --this is the line that updates the tokens
- survSheet = getObjectFromGUID(gridObject.getVar("survSheetGUID"))
- if survSheet ~= nil then
- getObjectFromGUID(SurvSheetScript).call("resetStats", {obj = survSheet})
- getObjectFromGUID(SurvSheetScript).call("resetBrain", {obj = survSheet})
- end
- checkToken(survSheet, zonePlayer)
- end
- function removeCard(descript, activePlayer)
- local gridObject = getObjectFromGUID(playerTable[activePlayer].gridGUID)
- local possibleHL = {head = 0, body = 0, waist = 0, arms = 0, legs = 0}
- if string.find(descript, 'armor') or string.find(descript, 'accessory') or string.find(descript, 'shield') or string.find(descript, 'set') then
- possibleHL = checkCardString(possibleHL, descript, activePlayer)
- end
- for location, value in pairs(possibleHL) do
- gridObject.UI.setAttribute(location, "text", gridObject.UI.getAttribute(location, "text") - value)
- end
- end
- function checkCardString(possibleHL, descript, activePlayer)
- for location, bonus in pairs(possibleHL) do
- if string.find(descript, location) then
- possibleHL[location] = bonus + tonumber(string.match(string.match(descript, '%d' .. location), '%d'))
- end
- end
- return possibleHL
- end
- -- Event Handlers --------------------------------------------------------------
- function onObjectEnterScriptingZone(zone, enter_object)
- if enter_object ~= nil then
- -------------------------- Start Body For Loop -----------------------------
- local activePlayer = ""
- local gridObject = nil
- local msgColor = nil
- local survCard = nil
- for k, v in pairs(playerTable) do
- if zonesTable[v.playerZone].guid == zone.getGUID() then
- activePlayer = k
- survCard = getObjectFromGUID(survCardsTable[v.color].guid)
- msgColor = getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint()
- end
- end
- if activePlayer ~= "" then
- gridObject = getObjectFromGUID(playerTable[activePlayer].gridGUID)
- local descript = enter_object.getDescription()
- local rotZ = enter_object.getRotation().z
- -- Survivor Portrait
- if enter_object.getName() == "Portrait" then
- enter_object.setDescription(playerTable[activePlayer].playerName)
- enter_object.call("clearButtons")
- enter_object.call("createButtons")
- end
- -- Heavy Gear while using People of the Sun
- if string.find(descript, "heavy") then
- local zoneNewSurvivors = getObjectFromGUID(zonesTable.zoneNewSurvivors.guid)
- for _, obj in ipairs(zoneNewSurvivors.getObjects()) do
- if string.find(obj.getDescription(), "sun") then
- sunCampaign_loaded = true
- end
- end
- if sunCampaign_loaded then
- broadcastToAll("People of the Sun cannot use 'Heavy' Gear", {1, 1, 1})
- end
- end
- -- Darkness Awareness
- if string.find(descript, "disorder") then
- for k, v in pairs(playerTable) do
- for _, obj in ipairs(getObjectFromGUID(zonesTable[v.playerZone].guid).getObjects()) do
- if obj.getName() == "Darkness Awareness" then
- if k == "P1" then
- broadcastToAll("Darkness Awareness ~ A Survivor gained a Disorder ~ You gain (+1) Survival and 1 Synapse Token", getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint())
- elseif k == "P2" then
- broadcastToAll("Darkness Awareness ~ A Survivor gained a Disorder ~ You gain (+1) Survival and 1 Synapse Token", getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint())
- elseif k == "P3" then
- broadcastToAll("Darkness Awareness ~ A Survivor gained a Disorder ~ You gain (+1) Survival and 1 Synapse Token", getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint())
- elseif k == "P4" then
- broadcastToAll("Darkness Awareness ~ A Survivor gained a Disorder ~ You gain (+1) Survival and 1 Synapse Token", getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint())
- end
- end
- end
- end
- end
- -- -- Lantern Helm
- -- if enter_object.getName() == "Lantern Helm" and (rotZ > 165 and rotZ < 195) then
- -- isDeaf.setRotation({0, 0, 180})
- -- -- Glyph of Solitude
- -- elseif enter_object.getName() == "Glyph of Solitude" and (rotZ > 165 and rotZ < 195) then
- -- isDeaf.setRotation({0, 0, 180})
- -- -- Deaf
- -- elseif enter_object.getName() == "Deaf" then
- -- isDeaf.setRotation({0, 0, 180})
- -- end
- if ((enter_object.getName() == "Lantern Helm" or enter_object.getName() == "Glyph of Solitude") and (rotZ > 165 and rotZ < 195)) or enter_object.getName() == "Deaf" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "isDeaf" then
- object.setRotation({0, 0, 180})
- end
- end
- end
- -- Husk of Destiny
- -- Stark Raving
- if enter_object.getName() == "Husk of Destiny" or enter_object.getName() == "Stark Raving" then
- for _, obj in ipairs(zone.getObjects()) do
- if obj.getName() == "isInsane" then
- obj.setRotation({0, 0, 180})
- end
- end
- end
- -- True Blade
- if enter_object.getName() == "True Blade" then
- for _, object in ipairs(zone.getObjects()) do
- local desc = object.getDescription()
- if string.find(desc, "sword") then
- object.setDescription(desc .. ", deadly, true blade")
- end
- end
- end
- if string.find(descript, "sword") then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "True Blade" then
- enter_object.setDescription(enter_object.getDescription() .. ", deadly, true blade")
- end
- end
- end
- -- Emotionless
- if enter_object.getName() == "Strength" and enter_object.getDescription() == 'token, plus1str' then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Emotionless" then
- broadcastToAll("Emotionless ~ You cannot gain (+1) Strength Tokens", msgColor)
- enter_object.destroy()
- end
- end
- end
- --Creates Armor Set Buttons on Survivor Cards
- checkForArmorSets(enter_object.getName(), survCard, "create")
- -- Momentum
- -- maximo
- if enter_object.getName() == "Momentum" then
- local obj = gameBox.takeObject({guid = momentum_Counter, position = momentum_on_pos, rotation = {0, 180, 0}, smooth = false})
- obj.setLock(true)
- survCard.call("createMomentumButton")
- end
- -- Hissing Cockroach
- if enter_object.getName() == "Hissing Cockroach" then
- insanity = tonumber(gridObject.getVar("survSheetGUID").UI.getAttribute("insanity", "text"))
- for _, obj in ipairs(zone.getObjects()) do
- if (obj.getName() == "Husk of Destiny" or obj.getName() == "Stark Raving" or insanity >= 3) then
- broadcastToAll("You are Insane and must consume the Hissing Cockroach", msgColor)
- break
- end
- end
- end -- end
- -- Possessed
- -- maximo Why do you flip, set scale, clone and destroy? why not only setpos without clone and destroy? ;)
- -- also for Hamstrung and Ruptured Muscle
- if enter_object.getName() == "Possessed" then
- for _, obj in ipairs(zone.getObjects()) do
- local desc = obj.getDescription()
- if string.find(desc, "fighting art") and (rotZ < 10 and rotZ > 350) then
- local pos = obj.getPosition()
- obj.flip()
- obj.setScale({0.47, 1.00, 0.47})
- obj.clone({position = pos})
- obj.destroy()
- elseif string.find(desc, "proficiency") then
- obj.destroy()
- end
- end
- broadcastToAll("Possessed ~ You cannot use Fighting Arts or Weapon Proficiencies", msgColor)
- end -- end possessed
- -- Hamstrung Card Check
- if enter_object.getName() == "Hamstrung" then
- for _, object in ipairs(zone.getObjects()) do
- local desc = object.getDescription()
- if string.find(desc, "fighting art") and (rotZ < 10 or rotZ > 350) then
- local pos = object.getPosition()
- object.flip()
- object.setScale({0.47, 1.00, 0.47})
- object.clone({position = pos})
- object.destroy()
- elseif string.find(desc, "ability") and (rotZ < 10 or rotZ > 350) then
- local pos = object.getPosition()
- object.flip()
- object.setScale({0.47, 1.00, 0.47})
- object.clone({position = pos})
- object.destroy()
- end
- end
- broadcastToAll("Hamstrung ~ You can no longer Activate Fighting Arts or Abilities", msgColor)
- end -- end Hamstrung
- -- Ruptured Muscle
- if enter_object.getName() == "Ruptured Muscle" then
- for _, object in ipairs(zone.getObjects()) do
- local desc = object.getDescription()
- if string.find(desc, "fighting art") and (rotZ < 10 or rotZ > 350) then
- local pos = object.getPosition()
- object.flip()
- object.setScale({0.47, 1.00, 0.47})
- object.clone({position = pos})
- object.destroy()
- end
- end
- broadcastToAll("Ruptured Muscle ~ You can no longer Activate Fighting Arts", msgColor)
- end -- end Ruptured Muscle
- if (enter_object.getName() == "Strength"
- or enter_object.getName() == "Speed"
- or enter_object.getName() == "Accuracy"
- or enter_object.getName() == "Movement Token"
- or enter_object.getName() == "Evasion"
- or enter_object.getName() == "Luck") then
- -- Altered Destiny
- if rotZ > 165 then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Altered Destiny" and (rotZ < 10 or rotZ > 350) then
- -- have to work on it for other token to spawn
- -- Kijan
- object.setRotation({0, 180, 0})
- broadcastToAll("Altered Destiny ~ You gain a Positive Token Instead", msgColor)
- end
- end
- end -- end Altered Destiny
- -- Reset Display Stats on Avatars
- Wait.time(function() set_portrait_buttons(survCard) end, 0.25)
- end
- -- Eternal Will
- if enter_object.getName() == "Eternal Will" and (rotZ < 10 or rotZ > 350) then
- -- check for injuries
- injury = 0
- hasInjuries = false
- for _, object in ipairs(zone.getObjects()) do
- if string.find(object.getDescription(), "injury") then
- hasInjuries = true
- injury = injury + 1
- end
- end -- end check for injuries
- -- if has injuries gain +1 acc and +1 str
- if hasInjuries then
- for i = 1, injury do
- statsBag.accTokenPos.takeObject({position = {offsets.accToken.x, offsets.accToken.y + i * 0.5, offsets.accToken.z}, rotation = {0, 180, 0}})
- statsBag.strTokenPos.takeObject({position = {offsets.strToken.x, offsets.strToken.y + i * 0.5, offsets.strToken.z}, rotation = {0, 180, 0}})
- end
- broadcastToAll("Eternal Will ~ You gained (+1) Accuracy and (+1) Strength for each Injury", msgColor)
- end
- end -- end Eternal Will
- -- Check for already has Eternal Will when gaining an injury
- hasEternalWill = false
- if enter_object.getDescription() == "essential, character, injury, drawn, copy" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Eternal Will" and (rotZ < 10 or rotZ > 350) then
- hasEternalWill = true
- end
- end
- if hasEternalWill then
- statsBag.accTokenPos.takeObject({position = {offsets.accToken.x, offsets.accToken.y, offsets.accToken.z}, rotation = {0, 180, 0}})
- statsBag.strTokenPos.takeObject({position = {offsets.strToken.x, offsets.strToken.y, offsets.strToken.z}, rotation = {0, 180, 0}})
- broadcastToAll("Eternal Will ~ You gained (+1) Accuracy ~ (+1) Strength for this injury", msgColor)
- end
- end -- end Eternal Will
- -- When you gain a Bleeding Token
- if enter_object.getName() == "Bleeding" then
- for _, object in ipairs(zone.getObjects()) do
- -- Ink Blood Bow
- if object.getName() == "Ink Blood Bow" then
- local token = statsBag.strTokenPos.takeObject({rotation = {0, 180, 0}, position = {offsets.strToken.x, offsets.strToken.y, offsets.strToken.z}})
- token.setDescription("token, plus1str, str_inkBow")
- broadcastToAll("Ink Blood Bow ~ You gained a (+1) Strength Token for gaining this Bleeding Token", msgColor)
- end
- -- Way of the Rust
- if object.getName() == "Way of the Rust" and (rotZ < 10 or rotZ > 350) then
- local token = statsBag.evaTokenPos.takeObject({position = offsets.evaToken, rotation = {0, 180, 0}})
- token.setDescription("token, plus1eva, eva_wayOfRust")
- broadcastToAll("Way of the Rust ~ You gained a (+1) Evasion Token for gaining this Bleeding Token", msgColor)
- end
- end
- end
- -- Red Power Core
- if enter_object.getName() == "Red Power Core" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Nuclear Knife" or object.getName() == "Nuclear Scythe" then
- object.setDescription(object.getDescription() .. ", sharp")
- broadcastToAll("Your " .. object.getName() .. " gained 'Sharp'", msgColor)
- end
- end
- -- Blue Power Core
- elseif enter_object.getName() == "Blue Power Core" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Nuclear Knife" or object.getName() == "Nuclear Scythe" then
- object.setDescription(object.getDescription() .. ", 2lck")
- broadcastToAll("Your " .. object.getName() .. " gained 'Deadly 2'", msgColor)
- end
- end
- end
- -- Nuclear Knife
- -- Nuclear Scythe
- if enter_object.getName() == "Nuclear Knife" or enter_object.getName() == "Nuclear Scythe" then
- for _, object in ipairs(zone.getObjects()) do
- -- Red Power Core
- if object.getName() == "Red Power Core" then
- local desc = enter_object.getDescription()
- enter_object.setDescription(desc .. ", sharp")
- broadcastToAll("Your " .. enter_object.getName() .. " gained 'Sharp'", {1, 1, 1})
- -- Blue Power Core
- elseif object.getName() == "Blue Power Core" then
- local desc = enter_object.getDescription()
- enter_object.setDescription(desc .. ", 2lck")
- broadcastToAll("Your " .. enter_object.getName() .. " gained 'Deadly 2'", msgColor)
- end
- end
- end -- end Power Cores
- --Black Sword
- if enter_object.getName() == "Black Sword" then
- for _, object in ipairs(zone.getObjects()) do
- -- Sword Proficiency
- if object.getName() == "Sword" and (rotZ < 10 or rotZ > 350) then
- local new_desc = string.gsub(enter_object.getDescription(), "10str", "30str")
- enter_object.setDescription(new_desc)
- broadcastToAll("Sword Master ~ Black Sword gained (+20) Strength", msgColor)
- end
- end
- end
- if enter_object.getName() == "Sword" and (rotZ < 10 or rotZ > 350) then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Black Sword" then
- local new_desc = string.gsub(object.getDescription(), "10str", "30str")
- object.setDescription(new_desc)
- broadcastToAll("Sword Master ~ Black Sword gained (+20) Strength", msgColor)
- end
- end
- end -- end Black Sword
- -- Crystal Skin
- hasGloom = false
- if enter_object.getName() == "Crystal Skin" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Gloom Mehndi" then
- hasGloom = true
- end
- end
- end
- if hasGloom then
- local deck = getObjectFromGUID(Global.getTable("decks_toSearch").deckSTRANGE.guid)
- foundCard = false
- for _, card in ipairs(deck.getObjects()) do
- -- Crystal Sword Mold
- if string.find(card.description, "crystal sword mold") then
- foundCard = true
- deck.takeObject({guid = card.guid, position = playerTable[activePlayer].gained_resource_pos, callback_owner = Global, callback = "flipCard"})
- end
- end
- if foundCard then
- broadcastToAll("You gained the Crystal Sword Mold", msgColor)
- end
- end -- end Gloom Mehndi
- if enter_object.getName() == "Sword of Silence" then
- local survSheet = getObjectFromGUID(gridObject.getVar("survSheetGUID"))
- -- Get Understanding Value
- local understanding = 0
- for i = 1, 9 do
- if survSheet.UI.getAttribute("understanding0" .. i, "value") == "true" then
- understanding = understanding + 1
- end
- end -- end
- if understanding >= 5 then
- enter_object.setDescription(enter_object.getDescription() .. ", sharp")
- broadcastToAll("Sword of Silence ~ gained sharp due to your understanding", msgColor)
- end
- end
- -- Tool belt
- if enter_object.getName() == "Tool Belt" then
- for _, object in ipairs(zone.getObjects()) do
- local desc = object.getDescription()
- -- Bone Sickle
- if object.getName() == "Bone Sickle" then
- object.setDescription('gear, weapon, tool, bonesmith, 3spd, 5acc, 1str, green_up, copy')
- broadcastToAll("Tool Belt ~ Your Bone Sickle lost 'frail' and gained (+1) Speed and (+3) Accuracy", msgColor)
- end
- -- Bone Pickaxe
- if object.getName() == "Bone Pickaxe" then
- object.setDescription('gear, weapon, tool, bonesmith, 2spd, 5acc, 2str, green_up, copy')
- broadcastToAll("Tool Belt ~ Your Bone Pickaxe lost 'frail' and gained (+1) Speed and (+3) Accuracy", msgColor)
- end
- end
- end
- if enter_object.getName() == "Bone Sickle" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Tool Belt" then
- object.setDescription('gear, weapon, tool, bonesmith, 3spd, 5acc, 1str, green_up, copy')
- broadcastToAll("Tool Belt ~ Your Bone Sickle lost 'frail' and gained (+1) Speed and (+3) Accuracy", msgColor)
- end
- end
- end
- if enter_object.getName() == "Bone Pickaxe" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Tool Belt" then
- object.setDescription('gear, weapon, tool, bonesmith, 2spd, 5acc, 2str, green_up, copy')
- broadcastToAll("Tool Belt ~ Your Bone Pickaxe lost 'frail' and gained (+1) Speed and (+3) Accuracy", msgColor)
- end
- end
- end -- end Tool Belt
- -- Shielded Quiver
- if enter_object.getName() == "Shielded Quiver" then
- for _, object in ipairs(zone.getObjects()) do
- if string.find(object.getDescription(), "arrow") then
- object.call("setStartAmmoPlus1")
- end
- end
- end
- if string.find(descript, "arrow") then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Shielded Quiver" then
- object.call("setStartAmmoPlus1")
- end
- end
- end -- end shielded quiver
- -- Quiver & Sun String
- if enter_object.getName() == "Quiver & Sun String" then
- local obj = gameBox.takeObject({guid = playerTable[activePlayer].extraSlots, position = gridObject.getPosition(), rotation = {0, 180, 0}, smooth = false})
- obj.setLock(true)
- end
- -- Silk Body Suit
- if enter_object.getName() == "Silk Body Suit" then
- for _, object in ipairs(zone.getObjects()) do
- local desc = object.getDescription()
- if string.find(desc, 'heavy') or string.find(desc, 'metal') then
- broadcastToAll("Silk Body Suit ~ You cannot use this ~ You have 'Heavy' or 'Metal' Gear", msgColor)
- end
- end
- end
- if string.find(descript, "heavy") or string.find(descript, "metal") then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Silk Body Suit" then
- broadcastToAll("You cannot use Silk Body Suit while ----> " .. enter_object.getName() .. " is in your grid", msgColor)
- end
- end
- end -- end silk body suit
- --Resize Resources to fit card grid
- if string.find(descript, "resource") then
- enter_object.setScale({0.87, 1.00, 0.87})
- end -- resize resources
- if enter_object.getVar("isSurvSheet") then
- gridObject.setVar("survSheetGUID", enter_object.getGUID())
- gridObject.UI.setAttribute("movement", "text", enter_object.UI.getAttribute("movement", "text"))
- gridObject.UI.setAttribute("evasion", "text", enter_object.UI.getAttribute("evasion", "text"))
- enter_object.setVar("GridGUID", gridObject.getGUID())
- checkToken(enter_object, zone)
- end
- if enter_object.getVar("isKdmEffectsObject") then
- if gridObject.getVar("survSheetGUID") ~= "" then
- parseEffects(enter_object.call("getEffects"), 1, getObjectFromGUID(gridObject.getVar("survSheetGUID")))
- end
- end
- -- checks for gear bonus
- if enter_object.tag == 'Card' then
- if string.find(descript, 'armor') or string.find(descript, 'accessory') or string.find(descript, 'shield') or string.find(descript, 'set') or string.find(descript, 'set') then
- local possibleHL = {head = 0, body = 0, waist = 0, arms = 0, legs = 0}
- possibleHL = checkCardString(possibleHL, descript, activePlayer)
- for location, value in pairs(possibleHL) do
- gridObject.UI.setAttribute(location, "text", gridObject.UI.getAttribute(location, "text") + value)
- end
- end -- end if string.find(descript, 'armor')
- end -- if enter_object.tag == 'Card'
- Wait.frames(function() diceStats(gridObject) end, 1)
- end -- if activePlayer ~= "" then
- end -- end if enter_object ~= nil
- end
- function onObjectLeaveScriptingZone(zone, leave_object)
- if leave_object ~= nil then
- ----------------------------- Start Body ---------------------------------
- local activePlayer = ""
- local msgColor = nil
- local survCard = nil
- for k, v in pairs(playerTable) do
- if zonesTable[v.playerZone].guid == zone.getGUID() then
- activePlayer = k
- survCard = getObjectFromGUID(survCardsTable[v.color].guid)
- msgColor = getObjectFromGUID(user_settings["settings_" .. k .. "_token"].guid).getColorTint()
- end
- end
- if activePlayer ~= "" then
- local descript = leave_object.getDescription()
- local rotZ = leave_object.getRotation().z
- -- Reset Display Stats on Avatars
- if (leave_object.getName() == "Strength"
- or leave_object.getName() == "Speed"
- or leave_object.getName() == "Accuracy"
- or leave_object.getName() == "Movement Token"
- or leave_object.getName() == "Evasion"
- or leave_object.getName() == "Luck") then
- Wait.time(function() set_portrait_buttons(survCard) end, 0.25)
- end -- end display stats on avatars
- if ((leave_object.getName() == "Lantern Helm" or leave_object.getName() == "Glyph of Solitude") and (rotZ > 165 and rotZ < 195)) or leave_object.getName() == "Deaf" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "isDeaf" then
- object.setRotation({0, 0, 0})
- end
- end
- end
- -- Husk of Destiny
- -- Stark Raving
- if leave_object.getName() == "Husk of Destiny" or leave_object.getName() == "Stark Raving" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "isInsane" then
- object.setRotation({0, 0, 0})
- end
- end
- end
- if leave_object.getName() == "Sword of Silence" then
- if string.find(descript, ", sharp") then
- leave_object.setDescription("gear, weapon, melee, sword, other, 2spd, 5acc, 6str, sentient, irreplaceable, unique, blue_left, red_up, green_right, copy")
- broadcastToAll("Sword of Silence ~ lost sharp", msgColor)
- end
- end
- -- Ink Blood Bow
- if leave_object.getName() == "Bleeding" then
- hasInkBow = false
- count_blood = 0
- count_strength = 0
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Ink Blood Bow" then
- hasInkBow = true
- end
- if object.getName() == "Bleeding" then
- count_blood = count_blood + 1
- end
- if string.find(object.getDescription(), "str_inkBow") then
- count_strength = count_strength + 1
- str_token = object
- end
- end
- if hasInkBow then
- -- maximo
- -- why loop that trigger only once?^^
- for i = 1, 2 do
- str_token.destroy()
- break
- end
- end
- end
- -- True Blade
- if leave_object.getName() == "True Blade" then
- for _, object in ipairs(zone.getObjects()) do
- local desc = object.getDescription()
- if string.find(desc, "sword") and string.find(desc, ", deadly, true blade") then
- local new_desc = string.gsub(desc, ", deadly, true blade", "")
- object.setDescription(new_desc)
- end
- end
- end
- -- Bitter Frenzy
- if leave_object.getName() == "Bitter Frenzy" then
- getObjectFromGUID(playerTable[activePlayer].frenzyToken).setRotationSmooth({0, 180, 0}, false, false)
- end
- -- Fist & Tooth
- if leave_object.getName() == "Fist & Tooth" then
- survCard.call("remove_Fist_and_Tooth")
- end
- checkForArmorSets(leave_object.getName(), survCard, "remove")
- -- Momentum
- -- maximo
- if leave_object.getName() == "Momentum" then
- for _, obj in ipairs(zoneSurvivorStatus.getObjects()) do
- if obj.getName() == "momentum_Counter" and obj.getDescription() == color then
- gameBox.putObject(obj)
- survCard.call("removeMomentumButton")
- end
- end
- end
- -- Eternal Will
- if leave_object.getName() == "Eternal Will" then
- injury = 0
- hasInjuries = false
- for _, object in ipairs(zone.getObjects()) do
- local desc = object.getDescription()
- if string.find(desc, "injury") then
- hasInjuries = true
- injury = injury + 1
- end
- if hasInjuries then
- if object.getName() == "Strength" then
- for i = 1, injury do
- object.destroy()
- end
- end
- if object.getName() == "Accuracy" then
- for i = 1, injury do
- object.destroy()
- end
- end
- end -- end if hasInjuries
- end -- end for loop
- end -- end Eternal Will
- -- Red Power Core
- if leave_object.getName() == "Red Power Core" then
- for _, obj in ipairs(zone.getObjects()) do
- if obj.getName() == "Nuclear Knife" or obj.getName() == "Nuclear Scythe" then
- local desc = string.gsub(obj.getDescription(), ", sharp", "")
- obj.setDescription(desc)
- broadcastToAll("Your " .. obj.getName() .. " lost 'Sharp'", msgColor)
- end
- end
- -- Blue Power Core
- elseif leave_object.getName() == "Blue Power Core" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Nuclear Knife" or object.getName() == "Nuclear Scythe" then
- local desc = string.gsub(object.getDescription(), ", 2lck", "")
- object.setDescription(desc)
- broadcastToAll("Your " .. object.getName() .. " lost 'Deadly 2'", msgColor)
- end
- end
- end
- -- Nuclear Knife
- if leave_object.getName() == "Nuclear Knife" then
- if string.find(descript, ", 2lck") or string.find(descript, ", sharp") then
- leave_object.setDescription("gear, weapon, dragon armory, 3spd, 6acc, 3str, copy")
- end
- -- Nuclear Scythe
- elseif leave_object.getName() == "Nuclear Scythe" then
- --local desc = leave_object.getDescription()
- if string.find(descript, ", 2lck") or string.find(descript, ", sharp") then
- leave_object.setDescription("gear, weapon, dragon armory, 2spd, 6acc, 4str, copy")
- end
- end -- end Power Cores, Nuclear
- --Black Sword
- if leave_object.getName() == "Black Sword" then
- if string.find(descript, "20str") then
- local new_desc = string.gsub(descript, "30str", "10str")
- leave_object.setDescription(new_desc)
- end
- end -- end Black Sword
- -- Tool belt
- -- maximo
- if leave_object.getName() == "Tool Belt" then
- for _, object in ipairs(zone.getObjects()) do
- if object.getName() == "Bone Sickle" then
- object.setDescription('gear, weapon, tool, bonesmith, 2spd, 8acc, 1str, green_up, frail, copy')
- broadcastToAll("Tool Belt ~ Your Bone Sickle lost 'frail' and gained (+1) Speed and (+3) Accuracy", msgColor)
- end
- if object.getName() == "Bone Pickaxe" then
- object.setDescription('gear, weapon, tool, bonesmith, 1spd, 8acc, 2str, green_up, frail, copy')
- broadcastToAll("Tool Belt ~ Your Bone Pickaxe lost 'frail' and gained (+1) Speed and (+3) Accuracy", msgColor)
- end
- end
- end
- if leave_object.getName() == "Bone Sickle" then
- leave_object.setDescription('gear, weapon, tool, bonesmith, 2spd, 8acc, 1str, green_up, frail, copy')
- end
- if leave_object.getName() == "Bone Pickaxe" then
- leave_object.setDescription('gear, weapon, tool, bonesmith, 1spd, 8acc, 2str, green_up, frail, copy')
- end -- end Tool Belt
- -- Shielded Quiver
- if leave_object.getName() == "Shielded Quiver" then
- for _, object in ipairs(zone.getObjects()) do
- local desc = object.getDescription()
- if string.find(desc, "ammunition") then
- object.call("setStartAmmo")
- end
- end
- end -- end shielded quiver
- -- Quiver & Sun String
- if leave_object.getName() == "Quiver & Sun String" then
- for _, obj in ipairs(zone.getObjects()) do
- if obj.getName() == "Extra Slots" then
- gameBox.putObject(obj)
- end
- end
- end -- end
- --Resize resources to fit card grid
- if leave_object.tag == 'Card' then
- if string.find(descript, "resource") then
- leave_object.setScale({1.10, 1.00, 1.10})
- end
- end -- end resource size
- if leave_object.getVar("isSurvSheet") then
- getObjectFromGUID(playerTable[activePlayer].gridGUID).setVar("survSheetGUID", "")
- getObjectFromGUID(SurvSheetScript).call("resetStats", {obj = leave_object})
- getObjectFromGUID(SurvSheetScript).call("resetBrain", {obj = leave_object})
- leave_object.setVar("GridGUID", "")
- end
- if leave_object.getVar("isKdmEffectsObject") then
- local survSheet = nil
- survSheet = getObjectFromGUID(getObjectFromGUID(playerTable[activePlayer].gridGUID).getVar("survSheetGUID"))
- if survSheet ~= nil then
- parseEffects(leave_object.call("getEffects"), - 1, survSheet)
- end
- end
- --gear bonus
- if leave_object.tag == 'Card' then
- removeCard(leave_object.getDescription(), activePlayer)
- end
- Wait.frames(function() diceStats(getObjectFromGUID(playerTable[activePlayer].gridGUID)) end, 1)
- end -- end if activePlayer ~= ""
- end -- end if leave_object ~= nil
- end
- function onObjectDestroyed(dying_object)
- for k, v in pairs(playerTable) do
- zone = getObjectFromGUID(zonesTable[v.playerZone].guid)
- for _, obj in pairs(zone.getObjects()) do
- if obj == dying_object then
- onObjectLeaveScriptingZone(zone, dying_object)
- end
- end
- end
- end
- -- Survivor Died ---------------------------------------------------------------
- function survDiedButton(graveObj, msgColor, activePlayer)
- graveObj.setScale({1.35, 1.35, 1.35})
- graveObj.setLock(true)
- graveObj.createButton({
- -- click_function = 'burySurvivor',
- click_function = function() burySurvivor(activePlayer) end,
- function_owner = self,
- label = 'Bury this Survivor',
- position = {0, 0, - 0.6},
- rotation = {0, 180, 0},
- scale = { 0.5, 1, 0.5},
- width = 2700,
- height = 400,
- font_size = 300,
- color = {0, 0, 0},
- font_color = msgColor
- })
- end
- function survDied(graveObj, survSheet, msgColor, activePlayer)
- --Gets Survivor Storage Bag
- infiBag = getObjectFromGUID(SurvMemBag)
- bag = infiBag.clone({position = graveObj.getPosition()})
- setModel(bag, survSheet, msgColor)
- Wait.time(
- function()
- bag.call('recallZone', {zonesTable[playerTable[activePlayer].playerZone].guid, self.guid, true})
- return_role(activePlayer)
- graveObj.setName(bag.getName())
- end
- , 0.2
- )
- end
- function get_basic_for_cannibalize()
- deckBasicResourcesZone = getObjectFromGUID(zonesTable.deckBasicResources.guid)
- for _, obj in ipairs(deckBasicResourcesZone.getObjects()) do
- if obj.getName() == "Basic Resources Deck" then
- obj.shuffle()
- obj.takeObject({top = true, position = playerTable[activePlayer].cannibalizeResourcePos, callback_owner = Global, callback = "flipCard"})
- broadcastToAll("Cannibalize Death Principle Triggered", {1, 1, 1})
- break
- end
- end
- end
- function set_skull_dead_token(activePlayer)
- -- Spawns Dead Skull Token
- local skull_dead_token = gameBox.takeObject({guid = playerTable[activePlayer].skullDeadToken, position = playerTable[activePlayer].skullDeadPos, rotation = {0.00, 180.00, 0.00}, smooth = false, callback = "lockShadowToken", callback_owner = Global})
- getObjectFromGUID(menuTokensTable[playerTable[activePlayer].color].guid).call("removeButtons_all")
- getObjectFromGUID(survCardsTable[playerTable[activePlayer].color].guid).call("clearButtons")
- --Sets Survivor miniature on survCards
- found_dreadedTrophies = false
- for _, card in ipairs(zoneInjuryBoard.getObjects()) do
- -- Dreaded Trophies
- if card.getName() == "Dreaded Trophies" then
- found_dreadedTrophies = true
- end
- end
- for _, object in ipairs(zoneShowdown.getObjects()) do
- if object.getName() == playerTable[activePlayer].playerName then
- object.setScale({0.25, 0.25, 0.25})
- if found_dreadedTrophies then
- trophy_count = 0
- for _, surv in ipairs(zoneInjuryBoard.getObjects()) do
- if string.find(surv.getName(), "Player") then
- trophy_count = trophy_count + 1
- end
- end
- if trophy_count < 1 then
- object.setPosition({ - 2.64, 4.63, - 20.40})
- elseif trophy_count == 1 then
- object.setPosition({ - 2.64, 4.63, - 21.40})
- elseif trophy_count == 2 then
- object.setPosition({ - 2.65, 4.63, - 22.44})
- end
- else
- object.setRotation(surv_died_rot)
- object.setPosition(surv_died_pos)
- object.setScale({0.25, 0.25, 0.25})
- object.setLock(true)
- end
- end
- end
- end
- function updatePopulation()
- local zoneSettlement = getObjectFromGUID(zonesTable.zoneSettlement.guid)
- for _, object in ipairs(zoneSettlement.getObjects()) do
- if string.find(object.getDescription(), "SettlementSheet") then
- object.call("add", {"population", - 1})
- end
- end
- end
- -- Save Survivor ---------------------------------------------------------------
- function clickedSaveSurv(params)
- local activePlayer = ""
- for k, v in pairs(playerTable) do
- if v.gridGUID == params.obj.getGUID() then
- activePlayer = k
- end
- end
- local pos = params.obj.getPosition()
- local hitList = Physics.cast({
- origin = {pos.x, pos.y + 2, pos.z - 8},
- direction = {0, 1, 0},
- type = 2,
- size = {3, 1, 3},
- max_distance = 0,
- })
- for _, entry in ipairs(hitList) do
- if next(hitList) ~= nil then
- broadcastToColor("Move Current saved Survivor First!", playerTable.color, getObjectFromGUID(user_settings["settings_" .. activePlayer .. "_token"].guid).getColorTint())
- return
- end
- end
- resetArmor(activePlayer)
- -- Destined
- for _, object in ipairs( getObjectFromGUID(zonesTable[playerTable[activePlayer].playerZone].guid).getObjects()) do
- if object.getName() == "Destined" then
- broadcastToColor("Destined ~ If you do not Depart, lose all Survival and Insanity", player_color, msg_color)
- end
- end
- infiBag = getObjectFromGUID(SurvMemBag)
- local bag = infiBag.clone({position = {pos.x, pos.y, pos.z - 8}})
- setModel(bag)
- Wait.time(function() saveSurv(bag) end, 0.3)
- end
- function saveSurv(bag)
- bag.call('recallZone', {zonesTable[playerTable[activePlayer].playerZone].guid, params.obj.getGUID()})
- -- activePlayer instead of role
- return_role(activePlayer)
- end
- function setModel(bag, survSheet, msgColor)
- if survSheet.UI.getAttribute("male", "value") then
- local rand = math.random(#survivorBags.male)
- bag.setCustomObject({mesh = survivorBags.male[rand].mesh, diffuse = survivorBags.male[rand].diffuse})
- else
- local rand = math.random(#survivorBags.female)
- bag.setCustomObject({mesh = survivorBags.female[rand].mesh, diffuse = survivorBags.female[rand].diffuse})
- end
- bag.setColorTint(msgColor)
- end
- -- Utility Functions -----------------------------------------------------------
- -- function findProximity(targetPos, object)
- -- local objectPos = object.getPosition()
- -- local xDistance = math.abs(targetPos.x - objectPos.x)
- -- local zDistance = math.abs(targetPos.z - objectPos.z)
- -- local distance = xDistance^2 + zDistance^2
- -- return math.sqrt(distance)
- -- end
- function get_player_pos(PlayerName)
- for _, object in ipairs(zoneShowdown.getObjects()) do
- if object.getName() == PlayerName then
- pos_player = object.getPosition()
- end
- end
- return pos_player
- end
- function set_portrait_buttons(survCard)
- local pos = survCard.getPosition()
- local hitList = Physics.cast({
- origin = {pos.x, pos.y, pos.z},
- direction = {0, 1, 0},
- type = 2,
- size = {2, 2, 2},
- max_distance = 0,
- })
- for _, entry in ipairs(hitList) do
- if entry.hit_object.getName() == "Portrait" then
- entry.hit_object.call("createButtons")
- end
- end
- end
- function return_role(activePlayer)
- local hitList = Physics.cast({
- origin = playerTable[activePlayer].rolePosition,
- direction = {0, 1, 0},
- type = 2,
- size = {1, 1, 1},
- max_distance = 0
- })
- for _, entry in ipairs(hitList) do
- if string.find(entry.hit_object.getDescription(), "role") then
- getObjectFromGUID(playerTable[activePlayer].gridGUID).setVar("role", entry.hit_object.getName())
- end
- if entry.hit_object.getName() == "Portrait" then
- local pos = getObjectFromGUID(playerTable[activePlayer].gridGUID).getPosition()
- entry.hit_object.setPosition({pos.x, 10, pos.z - 8})
- end
- end
- end
- function deleteCard(objGUID)
- printToAll("Need activePlayer for deleteCard!", {1, 0, 0})
- obj = getObjectFromGUID(objGUID[1])
- removeCard(obj.getDescription(), activePlayer)
- obj.destruct()
- end
- function diceStatsEx(params)
- diceStats(params[1])
- end
- function diceStats(gridObject)
- survSheet = getObjectFromGUID(gridObject.getVar("survSheetGUID"))
- if survSheet == nil then
- return
- end
- -- local EvaBtn = FullCharSheet.getTable("buttons")
- -- if EvaBtn == nil then
- -- return
- -- end
- local monstr = getObjectFromGUID(Global.getTable("boards").boardMonster.guid)
- local butn = {toughness = {label = 0}, evasion = {label = 0}, luck = {label = 0}}
- local weapon = gridObject.getTable("weapon")
- if weapon == nil then return end
- if monstr ~= nil then
- butn = monstr.getTable("buttons")
- end
- -- buttons['attack'].label
- gridObject.UI.setAttribute("speed", "text", tonumber(survSheet.UI.getAttribute("speed", "text")) + weapon['speed'])
- -- buttons['wound'].label =
- gridObject.UI.setAttribute("strength", "text", tonumber(butn['toughness'].label) - tonumber(survSheet.UI.getAttribute("strength", "text")) - weapon['strength'])
- -- buttons['hit'].label =
- gridObject.UI.setAttribute("accuracy", "text", 10 - tonumber(survSheet.UI.getAttribute("accuracy", "text")) - weapon['accuracy'] + tonumber(butn['evasion'].label))
- -- buttons['crit'].label =
- gridObject.UI.setAttribute("luck", "text", 10 + tonumber(butn['luck'].label) - tonumber(survSheet.UI.getAttribute("luck", "text")) - weapon['luck'])
- gridObject.UI.setAttribute("movement", "text", survSheet.UI.getAttribute("movement", "text"))
- gridObject.UI.setAttribute("evasion", "text", survSheet.UI.getAttribute("evasion", "text"))
- -- portrait stat display
- -- portrait_attack = tonumber(survSheet.UI.getAttribute("speed", "text")) + weapon['speed']
- -- portrait_wound = tonumber(butn['toughness'].label) - tonumber(survSheet.UI.getAttribute("strength", "text")) - weapon['strength']
- -- portrait_hit = 10 - tonumber(survSheet.UI.getAttribute("accuracy", "text")) - weapon['accuracy'] + tonumber(butn['evasion'].label)
- -- portrait_crit = 10 + tonumber(butn['luck'].label) - tonumber(survSheet.UI.getAttribute("luck", "text")) - weapon['luck']
- end
- -- end InventoryP1 -------------------------------------------------------------
- -- Tokens ----------------------------------------------------------------------
- function checkToken(survSheet, zonePlayer)
- for _, v in pairs(zonePlayer.getObjects()) do
- if v.getVar("isKdmEffectsObject") then
- if survSheet ~= nil then
- parseEffects(v.call("getEffects"), 1, survSheet)
- end
- end
- end
- end
- function checkTokenDelayed(zonePlayer, survCard, survSheet, activePlayer)
- for _, object in ipairs(zonePlayer.getObjects()) do
- -- Momentum
- if object.getName() == "Momentum" then
- survCard.call("createMomentumButton")
- end
- checkForArmorSets(object.getName(), survCard, "create")
- end
- if survSheet ~= nil then
- getObjectFromGUID(SurvSheetScript).call("resetStats", {obj = survSheet})
- Wait.frames(function() checkToken(survSheet, zonePlayer) end, 1)
- end
- Wait.frames(function() checkWeapon(activePlayer) end, 2)
- end
- function checkForArmorSets(name, survCard, createRemove)
- -- Crossarm Block
- if name == "Crossarm Block" then
- survCard.call(createRemove .. "CrossarmBlockButton")
- end
- -- Century Shoulder Pads
- if name == "Century Shoulder Pads" or name == "Calcified Shoulder Pads" then
- survCard.call(createRemove .. "RipplePatternButton")
- end
- -- Fencing
- if name == "Fencing" then
- survCard.call(createRemove .. "FencingButton")
- end
- -- Steadfast
- if name == "Steadfast" then
- survCard.call(createRemove .. "SteadfastButton")
- end
- -- Stalwart
- if name == "Stalwart" then
- survCard.call(createRemove .. "StalwartButton")
- end
- -- Leather Armor
- -- Burnt Nerves
- if name == "Leather Armor" or name == "Burnt Nerves" then
- survCard.call(createRemove .. "BashButton")
- end
- -- Honorable
- if name == "Honorable" then
- local buttons = survCard.getButtons()
- for i, v in pairs(buttons) do
- if createRemove == "create" and v.label == "Attack Blind" then
- survCard.removeButton(v.index)
- survCard.call('create_Honorable_Button')
- elseif createRemove == "remove" and v.label == "Honorable" then
- survCard.removeButton(v.index)
- survCard.call('create_AttackBlind_Button')
- end
- end
- end
- end
- function parseEffects(effects, multiplier, survSheet)
- for i, v in pairs(effects) do
- if i == "move" then
- i = "movement"
- end
- survSheet.UI.setAttribute(i, "text", survSheet.UI.getAttribute(i, "text") + (v * multiplier))
- end
- end
- function checkLoaded(obj)
- if not obj.loading_custom and not obj.spawning then
- return true
- end
- return false
- end
- --------------------------------------------------------------------------------
- -- Survivor Sheet Code
- NEXT = 1
- PREV = -1
- playerTable = {
- P1 = {msg_color = {0.118, 0.53, 1}}
- , P2 = {msg_color = {0.192, 0.701, 0.168}}
- , P3 = {msg_color = {0.905, 0.898, 0.172}}
- , P4 = {msg_color = {1, 0.14, 0}}
- }
- function toggleCheckBox(params)
- local name = params.id:sub(1, - 3)
- local num = tonumber(params.id:sub(-2))
- if params.id == "female" or params.id == "femaleB" then
- params.obj.UI.setAttribute("male", "value", "false")
- params.obj.UI.setAttribute("male", "color", "#00000000")
- params.obj.UI.setAttribute("maleB", "value", "false")
- params.obj.UI.setAttribute("maleB", "color", "#00000000")
- elseif params.id == "male" or params.id == "maleB" then
- params.obj.UI.setAttribute("female", "value", "false")
- params.obj.UI.setAttribute("female", "color", "#00000000")
- params.obj.UI.setAttribute("femaleB", "value", "false")
- params.obj.UI.setAttribute("femaleB", "color", "#00000000")
- end
- if params.obj.UI.getAttribute(params.id, "value") == "false" and checkForPreviousNext(params.obj, name, num, PREV) then
- params.obj.UI.setAttribute(params.id, "value", "true")
- params.obj.UI.setAttribute(params.id, "color", "#000000")
- if params.id:sub(-1) == "B" then
- params.obj.UI.setAttribute(params.id:sub(1, - 2), "value", "true")
- params.obj.UI.setAttribute(params.id:sub(1, - 2), "color", "#000000")
- end
- params.obj.UI.setAttribute(params.id .. "B", "value", "true")
- params.obj.UI.setAttribute(params.id .. "B", "color", "#000000")
- elseif num == nil or not checkForPreviousNext(params.obj, name, num, NEXT) then
- params.obj.UI.setAttribute(params.id, "value", "false")
- params.obj.UI.setAttribute(params.id, "color", "#00000000")
- if params.id:sub(-1) == "B" then
- params.obj.UI.setAttribute(params.id:sub(1, - 2), "value", "false")
- params.obj.UI.setAttribute(params.id:sub(1, - 2), "color", "#00000000")
- end
- params.obj.UI.setAttribute(params.id .. "B", "value", "false")
- params.obj.UI.setAttribute(params.id .. "B", "color", "#00000000")
- end
- end
- function checkForPreviousNext(obj, name, num, prevNext)
- if num ~= nil then
- if obj.UI.getAttribute(name .. string.format("%02d", num + prevNext), "value") ~= nil then
- if obj.UI.getAttribute(name .. string.format("%02d", num + prevNext), "value") == "true" then
- return true
- else
- return false
- end
- else
- return prevNext == PREV and true or false
- end
- end
- return true
- end
- function onValueChanged(params)
- params.obj.UI.setAttribute(params.id, "text", params.value)
- if params.id:find("name") and params.id ~= "nickname" then
- params.obj.UI.setAttribute("name", "text", params.value)
- params.obj.UI.setAttribute("nameB", "text", params.value)
- params.obj.UI.setAttribute("nameFamily", "text", params.value)
- params.obj.setName(params.value)
- end
- end
- function counter(params)
- local amount = tonumber(params.id)
- local isInsane = (tonumber(params.obj.UI.getAttribute("insanity", "text")) > 2) and true or false
- local grid = nil
- if params.grid ~= "" then
- grid = getObjectFromGUID(params.grid)
- end
- if params.value == "survival" then
- local apathetic = false
- -- when survival is been added
- if amount > 0 then
- if grid ~= nil then
- local bounds = grid.getBounds()
- local hitlist = Physics.cast({
- origin = bounds.center,
- direction = {0, 5, 0},
- type = 3,
- size = bounds.size,
- max_distance = 0,
- debug = false
- }) -- returns {{Vector point, Vector normal, float distance, Object hit_object}, ...}
- for _, t in pairs(hitlist) do
- if t.hit_object.getName() == "Thrill Seeker" then
- local check_current_phase_tok = getObjectFromGUID('9091f8')
- local desc = check_current_phase_tok.getDescription()
- if desc == "Showdown Started" then
- amount = amount + 1
- broadcastToAll("Thrill Seeker ~ You gained an Additional Survival", msg_color)
- end
- elseif t.hit_object.getName() == "Apathetic" then
- amount = 0
- broadcastToAll("Apathetic ~ You cannot gain Survival", msg_color)
- end
- end
- end
- -- when survival is been removed
- elseif amount < 0 then
- if grid ~= nil then
- local bounds = grid.getBounds()
- local hitlist = Physics.cast({
- origin = bounds.center,
- direction = {0, 5, 0},
- type = 3,
- size = bounds.size,
- max_distance = 0,
- debug = false
- }) -- returns {{Vector point, Vector normal, float distance, Object hit_object}, ...}
- for _, t in pairs(hitlist) do
- if t.hit_object.getName() == "Immortal" and isInsane then
- amount = 0
- broadcastToAll("Immortal ~ You cannot spend Survival while insane", msg_color)
- elseif t.hit_object.getName() == "Prey" and not isInsane then
- amount = 0
- broadcastToAll("Prey ~ You can only spend Survival while insane", msg_color)
- elseif t.hit_object.getName() == "Apathetic" then
- amount = 0
- broadcastToAll("Apathetic ~ You cannot use Survival", msg_color)
- elseif t.hit_object.getName() == "Ghostly Beauty" then
- amount = amount * 2
- if tonumber(params.obj.UI.getAttribute(params.value, "text")) + amount < 0 then
- amount = 0
- broadcastToAll("Ghostly Beauty ~ You cannot spend survival because it is doubled", msg_color)
- else
- broadcastToAll("Ghostly Beauty ~ Your Survival use was Doubled", msg_color)
- end
- end
- end
- end
- end
- end
- if params.value == "insanity" and amount > 0 and grid ~= nil then
- local bounds = grid.getBounds()
- local hitlist = Physics.cast({
- origin = bounds.center,
- direction = {0, 5, 0},
- type = 3,
- size = bounds.size,
- max_distance = 0,
- debug = false
- }) -- returns {{Vector point, Vector normal, float distance, Object hit_object}, ...}
- for _, t in pairs(hitlist) do
- if t.hit_object.getName() == "Ghostly Beauty" then
- amount = amount * 2
- broadcastToAll("Ghostly Beauty ~ Doubled all Insanity you gain", msg_color)
- end
- end
- end
- local value = tonumber(params.obj.UI.getAttribute(params.value, "text")) + amount
- local base = tonumber(params.obj.UI.getAttribute(params.value, "base")) + amount
- if params.value == "survival" or params.value == "insanity" then
- value = math.max(value, 0)
- base = math.max(base, 0)
- end
- if params.value == "survival" then
- -- zoneGuid = Global.getTable("zones").zoneSettlement.guid
- -- zoneObj = getObjectFromGUID(zoneGuid).getObjects()
- -- for _, v in pairs(zoneObj) do
- -- if v.getDescription() == "SettlementSheet" then
- -- survlimit = v.getTable("buttons").survival_limit.label
- -- end
- -- end
- survlimit = 4
- value = math.min(value, survlimit)
- base = math.min(base, survlimit)
- end
- params.obj.UI.setAttribute(params.value, "text", value)
- params.obj.UI.setAttribute(params.value, "base", base)
- if params.value ~= "survival" and params.value ~= "insanity" and grid ~= nil then
- Wait.frames(function() getObjectFromGUID(grid.getVar("gridScript")).call("diceStatsEx", {grid}) end, 1)
- end
- end
- function resetStats(params)
- for _, v in pairs({'movement', 'speed', 'accuracy', 'strength', 'luck', 'evasion'}) do
- params.obj.UI.setAttribute(v, "text", params.obj.UI.getAttribute(v, "base"))
- end
- end
- function resetBrain(params)
- params.obj.UI.setAttribute("brainL", "value", "false")
- params.obj.UI.setAttribute("brainL", "color", "#00000000")
- end
Add Comment
Please, Sign In to add comment