ah_sce_unpacked/unpacked/Custom_Model_Bag Return to The Dunwich Legacy ce9130/Custom_Model_Bag 4 Blood on the Altar 1536e7/Bag Locations 55cac8.ttslua
2021-03-23 10:59:55 -04:00

159 lines
4.3 KiB
Plaintext

PLAYAREA = {
position = {-20.04, 4.13, 0.37},
rotation = { x=0, y=90, z=0 },
scale = {34.11, 5.10, 49.91}
}
ASSEMBLY = {
position = { x=68, y=2, z=36 },
rotation = { x=0, y=270, z=180 }
}
LOCATIONS = {
{ name = "House in the Reeds", position = Vector({-23.68, 1.65, 7.57}), offset = Vector({3.25, 0, 0}) },
{ name = "Schoolhouse", position = Vector({-23.68, 1.65, -0.03}), offset = Vector({3.25, 0, 0}) },
{ name = "Congregational Church", position = Vector({-30.22, 1.66, 7.57}), offset = Vector({0, 0, 2.5}) },
{ name = "Osborn's General Store", position = Vector({-30.22, 1.65, -7.70}), offset = Vector({0, 0, -2.5}) },
{ name = "Burned Ruins", position = Vector({-36.77, 1.67, 7.57}), offset = Vector({-3.25, 0, 0}) },
{ name = "Bishop's Brook", position = Vector({-36.77, 1.66, -0.03}), offset = Vector({-3.25, 0, 0}) }
}
function onLoad()
self.createButton({
label="Place\nLocations", click_function="setup", function_owner=self,
position={2,0.3,0}, rotation={0,270,0}, height=600, width=1200,
font_size=250, color={0,0,0}, font_color={1,1,1}
})
makeIndexes()
math.randomseed(os.time())
end
function makeIndexes()
local removedLoc = math.random(6)
locationMap = {}
for i,loc in ipairs(LOCATIONS) do
if i ~= removedLoc then
locationMap[loc.name] = loc
end
end
end
function getPlayAreaObjects()
return Physics.cast({
origin = PLAYAREA.position,
direction = { x=0, y=1, z=0 },
type = 3,
size = PLAYAREA.scale,
orientation = PLAYAREA.rotation
})
end
function getAssemblyDeck()
local objs = Physics.cast({
origin = ASSEMBLY.position,
direction = { x=0, y=1, z=0 },
type = 3,
size = { x=3, y=3, z=3 },
orientation = ASSEMBLY.rotation
})
for i,v in ipairs(objs) do
if v.hit_object.tag == "Deck" then
return v.hit_object
end
end
return nil
end
function setup(obj, color, alt_click)
if DISABLED then return end
DISABLED = true
playerColor = color
local objs = self.getObjects()
for i=#objs,1,-1 do
local name = objs[i].name
local loc = locationMap[name]
if name ~= nil and loc ~= nil then
self.takeObject({
position = loc.position,
rotation = { 0, 270, 0 },
smooth = false,
index = i - 1
})
end
end
Wait.time(setup_2, 1)
end
function setup_2()
local objs = getPlayAreaObjects()
for i,v in ipairs(objs) do
local obj = v.hit_object
local name = obj.getName()
if name == "Set-aside" then
takeObjectiveCards(obj)
elseif name == "Encounter Deck" then
takeEncounterCards(obj)
else
local loc = locationMap[name]
if loc ~= nil then
obj.shuffle()
for i=1,2 do
obj.takeObject({
position = self.getPosition() + Vector({ 0, 5, 0}),
smooth = false
})
end
end
end
end
Wait.time(setup_3, 1)
end
function setup_3()
local deck = getAssemblyDeck()
deck.shuffle()
local i = 1
for name,loc in pairs(locationMap) do
if i < (#LOCATIONS - 1) then
deck.takeObject({
position = loc.position + loc.offset,
rotation = ASSEMBLY.rotation,
smooth = false
})
else
deck.remainder.setPosition(loc.position + loc.offset)
end
i = i + 1
end
end
function takeObjectiveCards(chest)
local objs = chest.getObjects()
for i=#objs,1,-1 do
local name = objs[i].name
if name == "The Hidden Chamber" or name == "Key to the Chamber" then
chest.takeObject({
position = ASSEMBLY.position,
rotation = ASSEMBLY.rotation,
smooth = false,
index = i - 1
})
end
end
end
function takeEncounterCards(deck)
deck.shuffle()
for i=1,3 do
deck.takeObject({
position = ASSEMBLY.position,
rotation = ASSEMBLY.rotation,
smooth = false,
index = i - 1
})
end
end