-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAreas.lua
57 lines (44 loc) · 1.51 KB
/
Areas.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
--- Made by GaryTheGoat ---
--- Please do not amend / upload / copy any content without permission
--- feedback welcome [email protected]
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')
spawnNavyArea = { }
spawnLandArea = { }
function PickRandomArea(areas)
local n = table.getn(areas)
local i = math.floor(Random() * n) + 1
return areas[i]
end
function PickRandomPointInArea(area)
local diffx = area.x1 - area.x0
local diffy = area.y1 - area.y0
local rx = Random() * diffx
local ry = Random() * diffy
local x = area.x0 + rx
local z = area.y0 + ry
local y = GetSurfaceHeight(x, z)
return VECTOR3(x, y, z)
end
function OnStart()
-- get the navy spawn areas
local areas = ScenarioInfo.Env.Scenario.Areas
for k = 1, 10, 1 do
local name = "NavySpawn_" .. k
if areas[name] then
local area = areas[name]
local rect = Rect(area.rectangle[1], area.rectangle[2], area.rectangle[3], area.rectangle[4])
table.insert(spawnNavyArea, rect)
end
end
-- get the land spawn areas
local areas = ScenarioInfo.Env.Scenario.Areas
for k = 1, 10, 1 do
local name = "LandSpawn_" .. k
if areas[name] then
local area = areas[name]
local rect = Rect(area.rectangle[1], area.rectangle[2], area.rectangle[3], area.rectangle[4])
table.insert(spawnLandArea, rect)
end
end
end