162 lines
4.8 KiB
Plaintext
162 lines
4.8 KiB
Plaintext
|
ALL_LOCATIONS = {
|
||
|
"Southside",
|
||
|
"Rivertown",
|
||
|
"Merchant District",
|
||
|
"French Hill",
|
||
|
"South Church",
|
||
|
"Uptown",
|
||
|
"Hangman's Hill",
|
||
|
"Silver Twilight Lodge"
|
||
|
}
|
||
|
|
||
|
RANDOMIZED_LOCATIONS = {
|
||
|
{ name = "Southside", guids = { "c898a0", "e7f5fa" }, position = {-30.22, 1.64, -0.03} },
|
||
|
{ name = "Rivertown", guids = { "db4b20", "92ee68" }, position = {-23.68, 1.65, -3.83} },
|
||
|
{ name = "Merchant District", guids = { "bed0da", "b568b8" }, position = {-23.68, 1.63, 3.86} },
|
||
|
{ name = "French Hill", guids = { "fc9d97", "6ed2ae" }, position = {-30.24, 1.63, -7.70} },
|
||
|
{ name = "South Church", guids = { "3d2a8a", "1a0ad2" }, position = {-36.77, 1.65, -0.03} },
|
||
|
{ name = "Uptown", guids = { "9484e9", "441006" }, position = {-30.22, 1.64, 7.57} },
|
||
|
}
|
||
|
|
||
|
SET_ASIDE = {
|
||
|
position = { x=-2.52, y=2, z=14.87 },
|
||
|
rotation = { x=0, y=270, z=0 }
|
||
|
}
|
||
|
|
||
|
PLAYAREA = {
|
||
|
position = {-27.92, 4.04, -0.20},
|
||
|
rotation = {0.00, 90, 0.00},
|
||
|
scale = {37.63, 5.10, 37.19}
|
||
|
}
|
||
|
|
||
|
function onLoad()
|
||
|
self.createButton({
|
||
|
label="Set Up",
|
||
|
click_function="setup",
|
||
|
function_owner=self,
|
||
|
position={0,0.1,-0.6},
|
||
|
height=120,
|
||
|
width=300,
|
||
|
scale={x=1.75, y=1.75, z=1.75},
|
||
|
font_size=75
|
||
|
})
|
||
|
|
||
|
self.createButton({
|
||
|
label="Place Clue",
|
||
|
click_function="placeClue",
|
||
|
function_owner=self,
|
||
|
position={0,0.1,0},
|
||
|
height=120,
|
||
|
width=400,
|
||
|
scale={x=1.75, y=1.75, z=1.75},
|
||
|
font_size=75
|
||
|
})
|
||
|
|
||
|
self.createButton({
|
||
|
label="Add Breaches",
|
||
|
click_function="addBreaches",
|
||
|
function_owner=self,
|
||
|
position={0,0.1,0.6},
|
||
|
height=120,
|
||
|
width=500,
|
||
|
scale={x=1.75, y=1.75, z=1.75},
|
||
|
font_size=75
|
||
|
})
|
||
|
|
||
|
PLAYER_COUNTER = getObjectFromGUID('f182ee')
|
||
|
math.randomseed(os.time())
|
||
|
end
|
||
|
|
||
|
function setup(_obj, _color, alt_click)
|
||
|
locationData = {}
|
||
|
-- find Hangman's Hill and Silver Twilight Lodge
|
||
|
local objs = Physics.cast({
|
||
|
origin = PLAYAREA.position,
|
||
|
direction = { x=0, y=1, z=0 },
|
||
|
type = 3,
|
||
|
size = PLAYAREA.scale,
|
||
|
orientation = PLAYAREA.rotation
|
||
|
})
|
||
|
for i,v in ipairs(objs) do
|
||
|
local obj = v.hit_object
|
||
|
if obj.tag == "Card" then
|
||
|
if obj.getName() == "Hangman's Hill" then
|
||
|
locationData["Hangman's Hill"] = { guid = obj.getGUID(), breach = 0, clue=0 }
|
||
|
elseif obj.getName() == "Silver Twilight Lodge" then
|
||
|
locationData["Silver Twilight Lodge"] = { guid = obj.getGUID(), breach = 0, clue=0 }
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if locationData["Hangman's Hill"] == nil or locationData["Silver Twilight Lodge"] == nil then
|
||
|
printToColor("Place Hangman's Hill and Silver Twilight Lodge first", _color)
|
||
|
return
|
||
|
end
|
||
|
|
||
|
for k,loc in pairs(RANDOMIZED_LOCATIONS) do
|
||
|
local chosen = math.random(2)
|
||
|
local guid = loc.guids[chosen]
|
||
|
local card = getObjectFromGUID(loc.guids[3 - chosen])
|
||
|
card.setPosition(SET_ASIDE.position)
|
||
|
card.setRotation(SET_ASIDE.rotation)
|
||
|
card = getObjectFromGUID(guid)
|
||
|
card.setPosition(loc.position)
|
||
|
card.setRotation(SET_ASIDE.rotation)
|
||
|
locationData[loc.name] = { guid = guid, breach = 0, clue=0 }
|
||
|
end
|
||
|
|
||
|
local numPlayers = PLAYER_COUNTER.getVar("val")
|
||
|
local numLocations = 2
|
||
|
local numDraws = numPlayers
|
||
|
if numPlayers == 4 then
|
||
|
numDraws = 3
|
||
|
numLocations = 3
|
||
|
end
|
||
|
for i = 1,numDraws do
|
||
|
placeBreaches(numLocations)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function placeClue()
|
||
|
local index = math.random(1, #ALL_LOCATIONS)
|
||
|
local name = ALL_LOCATIONS[index]
|
||
|
local location = locationData[name]
|
||
|
local clue = location.clue
|
||
|
local pos = getObjectFromGUID(location.guid).getPosition()
|
||
|
local cluePos = {
|
||
|
x = pos.x + 0.85, y = pos.y + 1, z = pos.z - 0.8 + (0.55 * clue)
|
||
|
}
|
||
|
clue = clue + 1
|
||
|
if clue > 3 then clue = 0 end
|
||
|
location.clue = clue
|
||
|
printToAll("Clue placed at: " .. name)
|
||
|
Global.call("spawnToken", { cluePos, "clue" })
|
||
|
end
|
||
|
|
||
|
function addBreaches()
|
||
|
placeBreaches(PLAYER_COUNTER.getVar("val") + 1)
|
||
|
end
|
||
|
|
||
|
function placeBreaches(numBreaches)
|
||
|
local shuffled = { }
|
||
|
for i,v in ipairs(ALL_LOCATIONS) do
|
||
|
local pos = math.random(1, #shuffled+1)
|
||
|
table.insert(shuffled, pos, v)
|
||
|
end
|
||
|
|
||
|
printToAll("Breaches added to:")
|
||
|
for j = 1,numBreaches do
|
||
|
printToAll(shuffled[j])
|
||
|
local location = locationData[shuffled[j]]
|
||
|
local pos = getObjectFromGUID(location.guid).getPosition()
|
||
|
local breach = location.breach
|
||
|
local breachPos = {
|
||
|
x = pos.x + 0.3, y = pos.y + 1, z = pos.z - 0.8 + (0.55 * breach)
|
||
|
}
|
||
|
breach = breach + 1
|
||
|
if breach > 3 then breach = 0 end
|
||
|
location.breach = breach
|
||
|
Global.call("spawnToken", { breachPos, "resource" })
|
||
|
end
|
||
|
end
|