-
Notifications
You must be signed in to change notification settings - Fork 2
/
OneWorldFogOfWarSpawner.lua
251 lines (243 loc) · 6.87 KB
/
OneWorldFogOfWarSpawner.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
versionNumber = "2.5.0"
function onload(saved_data)
self.clearButtons()
self.createButton({
label = "FoW",
click_function = "buttonClick_spawnFOW",
function_owner = self,
position = {0,0.3,0},
rotation = {0,180,0},
height = 350,
width = 800,
font_size = 250,
color = {0,0,0},
font_color = {1,1,1}
})
self.clearContextMenu()
self.addContextMenuItem("Remove All Fogs", removeAllFogs, true)
self.addContextMenuItem("Hide OW Minimaps", hideOWMinimaps, true)
self.addContextMenuItem("Hide OW Hub", hideOWHub, true)
self.setName("OneWorld Fog-Of-War Spawner " .. versionNumber)
end
function removeAllFogs()
local counter = 0
for _, obj in ipairs(getAllObjects()) do
if obj ~= self and obj ~= nil and obj.type == "FogOfWar" then
obj.destruct()
counter = counter + 1
end
end
if counter > 0 then
print("Removed " .. counter .. " fogs!")
else
print("No fogs found!")
end
end
function hideOWMinimaps()
print("Hiding OneWorld Minimaps!")
spawnObjectData({
data = {
Name = "FogOfWarTrigger",
Transform = {
posX = 65.0,
posY = 65.0,
posZ = 65.0,
rotX = 0.0,
rotY = 0.0,
rotZ = 0.0,
scaleX = 3.0,
scaleY = 0.13,
scaleZ = 3.0
},
Nickname = "",
Description = "",
GMNotes = "",
ColorDiffuse = {
r = 0.25,
g = 0.25,
b = 0.25,
a = 0.1025644
},
LayoutGroupSortIndex = 0,
Value = 0,
Locked = true,
Grid = true,
Snap = true,
IgnoreFoW = false,
MeasureMovement = false,
DragSelectable = true,
Autoraise = true,
Sticky = true,
Tooltip = true,
GridProjection = false,
HideWhenFaceDown = false,
Hands = false,
FogColor = "Black",
FogHidePointers = false,
FogReverseHiding = false,
FogSeethrough = false,
LuaScript = "",
LuaScriptState = "",
XmlUI = ""
}
})
end
function hideOWHub()
local owHub = getOneWorldHub()
if owHub == nil then
print("OneWorld is not available! Unable to spawn hidden zone.")
return
end
local pos = owHub.getPosition()
local rot = owHub.getRotation()
print("Hiding OneWorld Hub!")
spawnObjectData({
data = {
Name = "FogOfWarTrigger",
Transform = {
posX = pos.x,
posY = pos.y,
posZ = pos.z,
rotX = rot.x,
rotY = rot.y,
rotZ = rot.z,
scaleX = 12.00,
scaleY = 0.40,
scaleZ = 10.20
},
Nickname = "",
Description = "",
GMNotes = "",
ColorDiffuse = {
r = 0.25,
g = 0.25,
b = 0.25,
a = 0.1025644
},
LayoutGroupSortIndex = 0,
Value = 0,
Locked = true,
Grid = true,
Snap = true,
IgnoreFoW = false,
MeasureMovement = false,
DragSelectable = true,
Autoraise = true,
Sticky = true,
Tooltip = true,
GridProjection = false,
HideWhenFaceDown = false,
Hands = false,
FogColor = "Black",
FogHidePointers = false,
FogReverseHiding = false,
FogSeethrough = false,
LuaScript = "",
LuaScriptState = "",
XmlUI = ""
}
})
end
-- Handles clicks on the setup button
function buttonClick_spawnFOW()
local vars = getMapVars(true)
local thickness = vars.bounds.y
vars.bounds.y = 20
spawnObjectData({
data = {
Name = "FogOfWar",
Transform = {
posX = 0,
posY = 0,
posZ = 0,
rotX = 0,
rotY = 0,
rotZ = 0,
scaleX = 1,
scaleY = 1,
scaleZ = 1
},
Nickname = "",
Description = "",
GMNotes = "",
ColorDiffuse = {
r = 0.25,
g = 0.25,
b = 0.25,
a = 0.1025644
},
LayoutGroupSortIndex = 0,
Value = 0,
Locked = true,
Grid = true,
Snap = true,
IgnoreFoW = false,
MeasureMovement = false,
DragSelectable = true,
Autoraise = true,
Sticky = true,
Tooltip = true,
GridProjection = false,
HideWhenFaceDown = false,
Hands = false,
FogOfWar = {
HideGmPointer = false,
HideObjects = true,
ReHideObjects = false,
Height = 0,
RevealedLocations = {}
},
LuaScript = "",
LuaScriptState = "",
XmlUI = ""
},
position = {vars.position.x, 100, vars.position.z},
rotation = {0, 0, 0},
scale = vars.bounds,
sound = false,
callback_function = function(spawned_object)
spawned_object.setPositionSmooth({vars.position.x, vars.position.y + (thickness/2.0) + 9.88, vars.position.z})
end
})
end
function getOneWorldHub()
for _, obj in ipairs(getAllObjects()) do
if obj ~= self and obj ~= nil and obj.getName() == "OW_Hub" then
return obj
end
end
return nil
end
function getOneWorldMap()
for _, obj in ipairs(getAllObjects()) do
if obj ~= self and obj ~= nil and obj.getName() == "_OW_vBase" then
return obj
end
end
return nil
end
function getMapVars(debug)
local defaultVars = {
position = {x = 0.0, y = 0.91, z = 0.0},
bounds = {x = 88.07, y = 0.2, z = 52.02}
}
local oneWorldMap = getOneWorldMap()
if oneWorldMap ~= nil then
local oneWorldBounds = oneWorldMap.getBounds();
if oneWorldBounds.size.x > 10 then
print("Using OneWorld map bounds.")
return {
position = oneWorldMap.getPosition(),
bounds = oneWorldBounds.size
}
end
if debug then
print("A OneWorld map is not deployed! Using default bounds.")
end
return defaultVars
end
if debug then
print("OneWorld is not available! Using default bounds.")
end
return defaultVars
end