@jtff/miztemplate-lib 3.10.4 → 3.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,686 +0,0 @@
1
-
2
- -- Hercules Cargo Drop Events by Anubis Yinepu
3
-
4
- -- This script will only work for the Herculus mod by Anubis
5
- -- Payloads carried by pylons 11, 12 and 13 need to be declared in the Herculus_Loadout.lua file
6
- -- Except for Ammo pallets, this script will spawn whatever payload gets launched from pylons 11, 12 and 13
7
- -- Pylons 11, 12 and 13 are moveable within the Herculus cargobay area
8
- -- Ammo pallets can only be jettisoned from these pylons with no benefit to DCS world
9
- -- To benefit DCS world, Ammo pallets need to be off/on loaded using DCS arming and refueling window
10
- -- Cargo_Container_Enclosed = true: Cargo enclosed in container with parachute, need to be dropped from 100m (300ft) or more, except when parked on ground
11
- -- Cargo_Container_Enclosed = false: Open cargo with no parachute, need to be dropped from 10m (30ft) or less
12
-
13
- Hercules_Cargo = {}
14
- Hercules_Cargo.Hercules_Cargo_Drop_Events = {}
15
- local GT_DisplayName = ""
16
- local GT_Name = ""
17
- local Cargo_Drop_initiator = ""
18
- local Cargo_Container_Enclosed = false
19
- local SoldierGroup = false
20
- local ParatrooperCount = 1
21
- local ParatrooperGroupSpawnInit = false
22
- local ParatrooperGroupSpawn = false
23
-
24
- local Herc_j = 0
25
- local Herc_Cargo = {}
26
- Herc_Cargo.Cargo_Drop_Direction = 0
27
- Herc_Cargo.Cargo_Contents = ""
28
- Herc_Cargo.Cargo_Type_name = ""
29
- Herc_Cargo.Cargo_over_water = false
30
- Herc_Cargo.Container_Enclosed = false
31
- Herc_Cargo.offload_cargo = false
32
- Herc_Cargo.all_cargo_survive_to_the_ground = false
33
- Herc_Cargo.all_cargo_gets_destroyed = false
34
- Herc_Cargo.destroy_cargo_dropped_without_parachute = false
35
- Herc_Cargo.scheduleFunctionID = 0
36
-
37
- local CargoHeading = 0
38
- local Cargo_Drop_Position = {}
39
-
40
- local SoldierUnitID = 12000
41
- local SoldierGroupID = 12000
42
- local GroupSpacing = 0
43
- --added by wrench
44
- Hercules_Cargo.types = {
45
- ["ATGM M1045 HMMWV TOW Air [7183lb]"] = {['name'] = "M1045 HMMWV TOW", ['container'] = true},
46
- ["ATGM M1045 HMMWV TOW Skid [7073lb]"] = {['name'] = "M1045 HMMWV TOW", ['container'] = false},
47
- ["APC M1043 HMMWV Armament Air [7023lb]"] = {['name'] = "M1043 HMMWV Armament", ['container'] = true},
48
- ["APC M1043 HMMWV Armament Skid [6912lb]"] = {['name'] = "M1043 HMMWV Armament", ['container'] = false},
49
- ["SAM Avenger M1097 Air [7200lb]"] = {['name'] = "M1097 Avenger", ['container'] = true},
50
- ["SAM Avenger M1097 Skid [7090lb]"] = {['name'] = "M1097 Avenger", ['container'] = false},
51
- ["APC Cobra Air [10912lb]"] = {['name'] = "Cobra", ['container'] = true},
52
- ["APC Cobra Skid [10802lb]"] = {['name'] = "Cobra", ['container'] = false},
53
- ["APC M113 Air [21624lb]"] = {['name'] = "M-113", ['container'] = true},
54
- ["APC M113 Skid [21494lb]"] = {['name'] = "M-113", ['container'] = false},
55
- ["Tanker M978 HEMTT [34000lb]"] = {['name'] = "M978 HEMTT Tanker", ['container'] = false},
56
- ["HEMTT TFFT [34400lb]"] = {['name'] = "HEMTT TFFT", ['container'] = false},
57
- ["SPG M1128 Stryker MGS [33036lb]"] = {['name'] = "M1128 Stryker MGS", ['container'] = false},
58
- ["AAA Vulcan M163 Air [21666lb]"] = {['name'] = "Vulcan", ['container'] = true},
59
- ["AAA Vulcan M163 Skid [21577lb]"] = {['name'] = "Vulcan", ['container'] = false},
60
- ["APC M1126 Stryker ICV [29542lb]"] = {['name'] = "M1126 Stryker ICV", ['container'] = false},
61
- ["ATGM M1134 Stryker [30337lb]"] = {['name'] = "M1134 Stryker ATGM", ['container'] = false},
62
- ["APC LAV-25 Air [22520lb]"] = {['name'] = "LAV-25", ['container'] = true},
63
- ["APC LAV-25 Skid [22514lb]"] = {['name'] = "LAV-25", ['container'] = false},
64
- ["M1025 HMMWV Air [6160lb]"] = {['name'] = "Hummer", ['container'] = true},
65
- ["M1025 HMMWV Skid [6050lb]"] = {['name'] = "Hummer", ['container'] = false},
66
- ["IFV M2A2 Bradley [34720lb]"] = {['name'] = "M-2 Bradley", ['container'] = false},
67
- ["IFV MCV-80 [34720lb]"] = {['name'] = "MCV-80", ['container'] = false},
68
- ["IFV BMP-1 [23232lb]"] = {['name'] = "BMP-1", ['container'] = false},
69
- ["IFV BMP-2 [25168lb]"] = {['name'] = "BMP-2", ['container'] = false},
70
- ["IFV BMP-3 [32912lb]"] = {['name'] = "BMP-3", ['container'] = false},
71
- ["ARV BRDM-2 Air [12320lb]"] = {['name'] = "BRDM-2", ['container'] = true},
72
- ["ARV BRDM-2 Skid [12210lb]"] = {['name'] = "BRDM-2", ['container'] = false},
73
- ["APC BTR-80 Air [23936lb]"] = {['name'] = "BTR-80", ['container'] = true},
74
- ["APC BTR-80 Skid [23826lb]"] = {['name'] = "BTR-80", ['container'] = false},
75
- ["APC BTR-82A Air [24998lb]"] = {['name'] = "BTR-82A", ['container'] = true},
76
- ["APC BTR-82A Skid [24888lb]"] = {['name'] = "BTR-82A", ['container'] = false},
77
- ["SAM ROLAND ADS [34720lb]"] = {['name'] = "Roland Radar", ['container'] = false},
78
- ["SAM ROLAND LN [34720b]"] = {['name'] = "Roland ADS", ['container'] = false},
79
- ["SAM SA-13 STRELA [21624lb]"] = {['name'] = "Strela-10M3", ['container'] = false},
80
- ["AAA ZSU-23-4 Shilka [32912lb]"] = {['name'] = "ZSU-23-4 Shilka", ['container'] = false},
81
- ["SAM SA-19 Tunguska 2S6 [34720lb]"] = {['name'] = "2S6 Tunguska", ['container'] = false},
82
- ["Transport UAZ-469 Air [3747lb]"] = {['name'] = "UAZ-469", ['container'] = true},
83
- ["Transport UAZ-469 Skid [3630lb]"] = {['name'] = "UAZ-469", ['container'] = false},
84
- ["AAA GEPARD [34720lb]"] = {['name'] = "Gepard", ['container'] = false},
85
- ["SAM CHAPARRAL Air [21624lb]"] = {['name'] = "M48 Chaparral", ['container'] = true},
86
- ["SAM CHAPARRAL Skid [21516lb]"] = {['name'] = "M48 Chaparral", ['container'] = false},
87
- ["SAM LINEBACKER [34720lb]"] = {['name'] = "M6 Linebacker", ['container'] = false},
88
- ["Transport URAL-375 [14815lb]"] = {['name'] = "Ural-375", ['container'] = false},
89
- ["Transport M818 [16000lb]"] = {['name'] = "M 818", ['container'] = false},
90
- ["IFV MARDER [34720lb]"] = {['name'] = "Marder", ['container'] = false},
91
- ["Transport Tigr Air [15900lb]"] = {['name'] = "Tigr_233036", ['container'] = true},
92
- ["Transport Tigr Skid [15730lb]"] = {['name'] = "Tigr_233036", ['container'] = false},
93
- ["IFV TPZ FUCH [33440lb]"] = {['name'] = "TPZ", ['container'] = false},
94
- ["IFV BMD-1 Air [18040lb]"] = {['name'] = "BMD-1", ['container'] = true},
95
- ["IFV BMD-1 Skid [17930lb]"] = {['name'] = "BMD-1", ['container'] = false},
96
- ["IFV BTR-D Air [18040lb]"] = {['name'] = "BTR_D", ['container'] = true},
97
- ["IFV BTR-D Skid [17930lb]"] = {['name'] = "BTR_D", ['container'] = false},
98
- ["EWR SBORKA Air [21624lb]"] = {['name'] = "Dog Ear radar", ['container'] = true},
99
- ["EWR SBORKA Skid [21624lb]"] = {['name'] = "Dog Ear radar", ['container'] = false},
100
- ["ART 2S9 NONA Air [19140lb]"] = {['name'] = "SAU 2-C9", ['container'] = true},
101
- ["ART 2S9 NONA Skid [19030lb]"] = {['name'] = "SAU 2-C9", ['container'] = false},
102
- ["ART GVOZDIKA [34720lb]"] = {['name'] = "SAU Gvozdika", ['container'] = false},
103
- ["APC MTLB Air [26400lb]"] = {['name'] = "MTLB", ['container'] = true},
104
- ["APC MTLB Skid [26290lb]"] = {['name'] = "MTLB", ['container'] = false},
105
- --["Generic Crate [20000lb]"] = {['name'] = "Hercules_Container_Parachute", ['container'] = true}
106
- }
107
- function Hercules_Cargo.Soldier_SpawnGroup(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, Cargo_Country, GroupSpacing)
108
- SoldierUnitID = SoldierUnitID + 30
109
- SoldierGroupID = SoldierGroupID + 1
110
- local Herc_Soldier_Spawn =
111
- {
112
- ["visible"] = false,
113
- ["tasks"] =
114
- {
115
- }, -- end of ["tasks"]
116
- ["uncontrollable"] = false,
117
- ["task"] = "Ground Nothing",
118
- ["taskSelected"] = true,
119
- ["groupId"] = SoldierGroupID,
120
- ["hidden"] = false,
121
- ["units"] =
122
- {
123
- [1] =
124
- {
125
- ["type"] = Cargo_Type_name,
126
- ["transportable"] =
127
- {
128
- ["randomTransportable"] = true,
129
- }, -- end of ["transportable"]
130
- ["unitId"] = SoldierUnitID + 1,
131
- ["skill"] = "Excellent",
132
- ["y"] = Cargo_Drop_Position.z + 0.5 + GroupSpacing,
133
- ["x"] = Cargo_Drop_Position.x + 0.5 + GroupSpacing,
134
- ["name"] = "Soldier Unit "..SoldierUnitID,
135
- ["heading"] = CargoHeading,
136
- ["playerCanDrive"] = false,
137
- }, -- end of [1]
138
- [2] =
139
- {
140
- ["type"] = Cargo_Type_name,
141
- ["transportable"] =
142
- {
143
- ["randomTransportable"] = true,
144
- }, -- end of ["transportable"]
145
- ["unitId"] = SoldierUnitID + 1,
146
- ["skill"] = "Excellent",
147
- ["y"] = Cargo_Drop_Position.z + 1.0 + GroupSpacing,
148
- ["x"] = Cargo_Drop_Position.x + 1.0 + GroupSpacing,
149
- ["name"] = "Soldier Unit "..SoldierUnitID,
150
- ["heading"] = CargoHeading,
151
- ["playerCanDrive"] = false,
152
- }, -- end of [2]
153
- [3] =
154
- {
155
- ["type"] = Cargo_Type_name,
156
- ["transportable"] =
157
- {
158
- ["randomTransportable"] = true,
159
- }, -- end of ["transportable"]
160
- ["unitId"] = SoldierUnitID + 1,
161
- ["skill"] = "Excellent",
162
- ["y"] = Cargo_Drop_Position.z + 1.5 + GroupSpacing,
163
- ["x"] = Cargo_Drop_Position.x + 1.0 + GroupSpacing,
164
- ["name"] = "Soldier Unit "..SoldierUnitID,
165
- ["heading"] = CargoHeading,
166
- ["playerCanDrive"] = false,
167
- }, -- end of [3]
168
- [4] =
169
- {
170
- ["type"] = Cargo_Type_name,
171
- ["transportable"] =
172
- {
173
- ["randomTransportable"] = true,
174
- }, -- end of ["transportable"]
175
- ["unitId"] = SoldierUnitID + 1,
176
- ["skill"] = "Excellent",
177
- ["y"] = Cargo_Drop_Position.z + 2.0 + GroupSpacing,
178
- ["x"] = Cargo_Drop_Position.x + 2.0 + GroupSpacing,
179
- ["name"] = "Soldier Unit "..SoldierUnitID,
180
- ["heading"] = CargoHeading,
181
- ["playerCanDrive"] = false,
182
- }, -- end of [4]
183
- [5] =
184
- {
185
- ["type"] = Cargo_Type_name,
186
- ["transportable"] =
187
- {
188
- ["randomTransportable"] = true,
189
- }, -- end of ["transportable"]
190
- ["unitId"] = SoldierUnitID + 1,
191
- ["skill"] = "Excellent",
192
- ["y"] = Cargo_Drop_Position.z + 2.5 + GroupSpacing,
193
- ["x"] = Cargo_Drop_Position.x + 2.5 + GroupSpacing,
194
- ["name"] = "Soldier Unit "..SoldierUnitID,
195
- ["heading"] = CargoHeading,
196
- ["playerCanDrive"] = false,
197
- }, -- end of [5]
198
- [6] =
199
- {
200
- ["type"] = Cargo_Type_name,
201
- ["transportable"] =
202
- {
203
- ["randomTransportable"] = true,
204
- }, -- end of ["transportable"]
205
- ["unitId"] = SoldierUnitID + 1,
206
- ["skill"] = "Excellent",
207
- ["y"] = Cargo_Drop_Position.z + 3.0 + GroupSpacing,
208
- ["x"] = Cargo_Drop_Position.x + 3.0 + GroupSpacing,
209
- ["name"] = "Soldier Unit "..SoldierUnitID,
210
- ["heading"] = CargoHeading,
211
- ["playerCanDrive"] = false,
212
- }, -- end of [6]
213
- [7] =
214
- {
215
- ["type"] = "Soldier M249",
216
- ["transportable"] =
217
- {
218
- ["randomTransportable"] = true,
219
- }, -- end of ["transportable"]
220
- ["unitId"] = SoldierUnitID + 1,
221
- ["skill"] = "Excellent",
222
- ["y"] = Cargo_Drop_Position.z + 3.5 + GroupSpacing,
223
- ["x"] = Cargo_Drop_Position.x + 3.5 + GroupSpacing,
224
- ["name"] = "Soldier Unit "..SoldierUnitID,
225
- ["heading"] = CargoHeading,
226
- ["playerCanDrive"] = false,
227
- }, -- end of [7]
228
- [8] =
229
- {
230
- ["type"] = "Soldier M249",
231
- ["transportable"] =
232
- {
233
- ["randomTransportable"] = true,
234
- }, -- end of ["transportable"]
235
- ["unitId"] = SoldierUnitID + 1,
236
- ["skill"] = "Excellent",
237
- ["y"] = Cargo_Drop_Position.z + 4.0 + GroupSpacing,
238
- ["x"] = Cargo_Drop_Position.x + 4.0 + GroupSpacing,
239
- ["name"] = "Soldier Unit "..SoldierUnitID,
240
- ["heading"] = CargoHeading,
241
- ["playerCanDrive"] = false,
242
- }, -- end of [8]
243
- [9] =
244
- {
245
- ["type"] = Cargo_Type_name,
246
- ["transportable"] =
247
- {
248
- ["randomTransportable"] = true,
249
- }, -- end of ["transportable"]
250
- ["unitId"] = SoldierUnitID + 1,
251
- ["skill"] = "Excellent",
252
- ["y"] = Cargo_Drop_Position.z + 4.5 + GroupSpacing,
253
- ["x"] = Cargo_Drop_Position.x + 4.5 + GroupSpacing,
254
- ["name"] = "Soldier Unit "..SoldierUnitID,
255
- ["heading"] = CargoHeading,
256
- ["playerCanDrive"] = false,
257
- }, -- end of [9]
258
- [10] =
259
- {
260
- ["type"] = "Paratrooper RPG-16",
261
- ["transportable"] =
262
- {
263
- ["randomTransportable"] = true,
264
- }, -- end of ["transportable"]
265
- ["unitId"] = SoldierUnitID + 1,
266
- ["skill"] = "Excellent",
267
- ["y"] = Cargo_Drop_Position.z + 5.0 + GroupSpacing,
268
- ["x"] = Cargo_Drop_Position.x + 5.0 + GroupSpacing,
269
- ["name"] = "Soldier Unit "..SoldierUnitID,
270
- ["heading"] = CargoHeading,
271
- ["playerCanDrive"] = false,
272
- }, -- end of [10]
273
- }, -- end of ["units"]
274
- ["y"] = Cargo_Drop_Position.z,
275
- ["x"] = Cargo_Drop_Position.x,
276
- ["name"] = "Soldier_Group_"..SoldierGroupID,
277
- ["start_time"] = 0,
278
- }
279
- coalition.addGroup(Cargo_Country, Group.Category.GROUND, Herc_Soldier_Spawn)
280
- end
281
-
282
- local CargoUnitID = 10000
283
- local CargoGroupID = 10000
284
- local CargoStaticGroupID = 11000
285
-
286
- function Hercules_Cargo.Cargo_SpawnGroup(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, Cargo_Country)
287
- CargoUnitID = CargoUnitID + 1
288
- CargoGroupID = CargoGroupID + 1
289
- local Herc_Cargo_Spawn =
290
- {
291
- ["visible"] = false,
292
- ["tasks"] =
293
- {
294
- }, -- end of ["tasks"]
295
- ["uncontrollable"] = false,
296
- ["task"] = "Ground Nothing",
297
- ["groupId"] = CargoGroupID,
298
- ["hidden"] = false,
299
- ["units"] =
300
- {
301
- [1] =
302
- {
303
- ["type"] = Cargo_Type_name,
304
- ["transportable"] =
305
- {
306
- ["randomTransportable"] = false,
307
- }, -- end of ["transportable"]
308
- ["unitId"] = CargoUnitID,
309
- ["skill"] = "Excellent",
310
- ["y"] = Cargo_Drop_Position.z,
311
- ["x"] = Cargo_Drop_Position.x,
312
- ["name"] = "Cargo Unit "..CargoUnitID,
313
- ["heading"] = CargoHeading,
314
- ["playerCanDrive"] = true,
315
- }, -- end of [1]
316
- }, -- end of ["units"]
317
- ["y"] = Cargo_Drop_Position.z,
318
- ["x"] = Cargo_Drop_Position.x,
319
- ["name"] = "Cargo Group "..CargoUnitID,
320
- ["start_time"] = 0,
321
- }
322
- coalition.addGroup(Cargo_Country, Group.Category.GROUND, Herc_Cargo_Spawn)
323
- end
324
-
325
- function Hercules_Cargo.Cargo_SpawnStatic(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, dead, Cargo_Country)
326
- CargoStaticGroupID = CargoStaticGroupID + 1
327
- local Herc_CargoObject_Spawn =
328
- {
329
- ["type"] = Cargo_Type_name,
330
- ["y"] = Cargo_Drop_Position.z,
331
- ["x"] = Cargo_Drop_Position.x,
332
- ["name"] = "Cargo Static Group "..CargoStaticGroupID,
333
- ["heading"] = CargoHeading,
334
- ["dead"] = dead,
335
- }
336
- coalition.addStaticObject(Cargo_Country, Herc_CargoObject_Spawn)
337
- end
338
-
339
- function Hercules_Cargo.Cargo_SpawnObjects(Cargo_Drop_Direction, Cargo_Content_position, Cargo_Type_name, Cargo_over_water, Container_Enclosed, ParatrooperGroupSpawn, offload_cargo, all_cargo_survive_to_the_ground, all_cargo_gets_destroyed, destroy_cargo_dropped_without_parachute, Cargo_Country)
340
- if offload_cargo == true then
341
- ------------------------------------------------------------------------------
342
- if CargoHeading >= 3.14 then
343
- CargoHeading = 0
344
- Cargo_Drop_Position = {["x"] = Cargo_Content_position.x - (30.0 * math.cos(Cargo_Drop_Direction - 1.0)),
345
- ["z"] = Cargo_Content_position.z - (30.0 * math.sin(Cargo_Drop_Direction - 1.0))}
346
- else
347
- if CargoHeading >= 1.57 then
348
- CargoHeading = 3.14
349
- Cargo_Drop_Position = {["x"] = Cargo_Content_position.x - (20.0 * math.cos(Cargo_Drop_Direction + 0.5)),
350
- ["z"] = Cargo_Content_position.z - (20.0 * math.sin(Cargo_Drop_Direction + 0.5))}
351
- else
352
- if CargoHeading >= 0 then
353
- CargoHeading = 1.57
354
- Cargo_Drop_Position = {["x"] = Cargo_Content_position.x - (10.0 * math.cos(Cargo_Drop_Direction + 1.5)),
355
- ["z"] = Cargo_Content_position.z - (10.0 * math.sin(Cargo_Drop_Direction + 1.5))}
356
- end
357
- end
358
- end
359
- ------------------------------------------------------------------------------
360
- if ParatrooperGroupSpawn == true then
361
- Hercules_Cargo.Soldier_SpawnGroup(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, Cargo_Country, 0)
362
- Hercules_Cargo.Soldier_SpawnGroup(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, Cargo_Country, 5)
363
- Hercules_Cargo.Soldier_SpawnGroup(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, Cargo_Country, 10)
364
- else
365
- Hercules_Cargo.Cargo_SpawnGroup(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, Cargo_Country, 0)
366
- end
367
- else
368
- ------------------------------------------------------------------------------
369
- CargoHeading = 0
370
- Cargo_Drop_Position = {["x"] = Cargo_Content_position.x - (20.0 * math.cos(Cargo_Drop_Direction)),
371
- ["z"] = Cargo_Content_position.z - (20.0 * math.cos(Cargo_Drop_Direction))}
372
- ------------------------------------------------------------------------------
373
- if all_cargo_gets_destroyed == true or Cargo_over_water == true then
374
- if Container_Enclosed == true then
375
- Hercules_Cargo.Cargo_SpawnStatic(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, true, Cargo_Country)
376
- if ParatrooperGroupSpawn == false then
377
- Hercules_Cargo.Cargo_SpawnStatic(Cargo_Drop_Position, "Hercules_Container_Parachute_Static", CargoHeading, true, Cargo_Country)
378
- end
379
- else
380
- Hercules_Cargo.Cargo_SpawnStatic(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, true, Cargo_Country)
381
- end
382
- else
383
- ------------------------------------------------------------------------------
384
- if all_cargo_survive_to_the_ground == true then
385
- if ParatrooperGroupSpawn == true then
386
- Hercules_Cargo.Cargo_SpawnStatic(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, true, Cargo_Country)
387
- else
388
- Hercules_Cargo.Cargo_SpawnGroup(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, Cargo_Country)
389
- end
390
- if Container_Enclosed == true then
391
- if ParatrooperGroupSpawn == false then
392
- Hercules_Cargo.Cargo_SpawnStatic({["z"] = Cargo_Drop_Position.z + 10.0,["x"] = Cargo_Drop_Position.x + 10.0}, "Hercules_Container_Parachute_Static", CargoHeading, false, Cargo_Country)
393
- end
394
- end
395
- end
396
- ------------------------------------------------------------------------------
397
- if destroy_cargo_dropped_without_parachute == true then
398
- if Container_Enclosed == true then
399
- if ParatrooperGroupSpawn == true then
400
- Hercules_Cargo.Soldier_SpawnGroup(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, Cargo_Country, 0)
401
- else
402
- Hercules_Cargo.Cargo_SpawnGroup(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, Cargo_Country)
403
- Hercules_Cargo.Cargo_SpawnStatic({["z"] = Cargo_Drop_Position.z + 10.0,["x"] = Cargo_Drop_Position.x + 10.0}, "Hercules_Container_Parachute_Static", CargoHeading, false, Cargo_Country)
404
- end
405
- else
406
- Hercules_Cargo.Cargo_SpawnStatic(Cargo_Drop_Position, Cargo_Type_name, CargoHeading, true, Cargo_Country)
407
- end
408
- end
409
- ------------------------------------------------------------------------------
410
- end
411
- end
412
- end
413
-
414
- function Hercules_Cargo.Calculate_Object_Height_AGL(object)
415
- return object:getPosition().p.y - land.getHeight({x = object:getPosition().p.x, y = object:getPosition().p.z})
416
- end
417
-
418
- function Hercules_Cargo.Check_SurfaceType(object)
419
- -- LAND,--1 SHALLOW_WATER,--2 WATER,--3 ROAD,--4 RUNWAY--5
420
- return land.getSurfaceType({x = object:getPosition().p.x, y = object:getPosition().p.z})
421
- end
422
-
423
- function Hercules_Cargo.Cargo_Track(Arg, time)
424
- local status, result = pcall(
425
- function()
426
- local next = next
427
- if next(Arg[1].Cargo_Contents) ~= nil then
428
- if Hercules_Cargo.Calculate_Object_Height_AGL(Arg[1].Cargo_Contents) < 5.0 then--pallet less than 5m above ground before spawning
429
- if Hercules_Cargo.Check_SurfaceType(Arg[1].Cargo_Contents) == 2 or Hercules_Cargo.Check_SurfaceType(Arg[1].Cargo_Contents) == 3 then
430
- Arg[1].Cargo_over_water = true--pallets gets destroyed in water
431
- end
432
- Arg[1].Cargo_Contents:destroy()--remove pallet+parachute before hitting ground and replace with Cargo_SpawnContents
433
- Hercules_Cargo.Cargo_SpawnObjects(Arg[1].Cargo_Drop_Direction, Object.getPoint(Arg[1].Cargo_Contents), Arg[1].Cargo_Type_name, Arg[1].Cargo_over_water, Arg[1].Container_Enclosed, Arg[1].ParatrooperGroupSpawn, Arg[1].offload_cargo, Arg[1].all_cargo_survive_to_the_ground, Arg[1].all_cargo_gets_destroyed, Arg[1].destroy_cargo_dropped_without_parachute, Arg[1].Cargo_Country)
434
- timer.removeFunction(Arg[1].scheduleFunctionID)
435
- Arg[1] = {}
436
- end
437
- return time + 0.1
438
- end
439
- end) -- pcall
440
- if not status then
441
- -- env.error(string.format("Cargo_Spawn: %s", result))
442
- else
443
- return result
444
- end
445
- end
446
-
447
- function Hercules_Cargo.Calculate_Cargo_Drop_initiator_NorthCorrection(point) --correction needed for true north
448
- if not point.z then --Vec2; convert to Vec3
449
- point.z = point.y
450
- point.y = 0
451
- end
452
- local lat, lon = coord.LOtoLL(point)
453
- local north_posit = coord.LLtoLO(lat + 1, lon)
454
- return math.atan2(north_posit.z - point.z, north_posit.x - point.x)
455
- end
456
-
457
- function Hercules_Cargo.Calculate_Cargo_Drop_initiator_Heading(Cargo_Drop_initiator)
458
- local Heading = math.atan2(Cargo_Drop_initiator:getPosition().x.z, Cargo_Drop_initiator:getPosition().x.x)
459
- Heading = Heading + Hercules_Cargo.Calculate_Cargo_Drop_initiator_NorthCorrection(Cargo_Drop_initiator:getPosition().p)
460
- if Heading < 0 then
461
- Heading = Heading + (2 * math.pi)-- put heading in range of 0 to 2*pi
462
- end
463
- return Heading + 0.06 -- rad
464
- end
465
-
466
- function Hercules_Cargo.Cargo_Initialize(initiator, Cargo_Contents, Cargo_Type_name, Container_Enclosed)
467
- local status, result = pcall(
468
- function()
469
- Cargo_Drop_initiator = Unit.getByName(initiator:getName())
470
- local next = next
471
- if next(Cargo_Drop_initiator) ~= nil then
472
- if ParatrooperGroupSpawnInit == true then
473
- if (ParatrooperCount == 1 or ParatrooperCount == 2 or ParatrooperCount == 3) then
474
- Herc_j = Herc_j + 1
475
- Herc_Cargo[Herc_j] = {}
476
- Herc_Cargo[Herc_j].Cargo_Drop_Direction = Hercules_Cargo.Calculate_Cargo_Drop_initiator_Heading(Cargo_Drop_initiator)
477
- Herc_Cargo[Herc_j].Cargo_Contents = Cargo_Contents
478
- Herc_Cargo[Herc_j].Cargo_Type_name = Cargo_Type_name
479
- Herc_Cargo[Herc_j].Container_Enclosed = Container_Enclosed
480
- Herc_Cargo[Herc_j].ParatrooperGroupSpawn = ParatrooperGroupSpawnInit
481
- Herc_Cargo[Herc_j].Cargo_Country = initiator:getCountry()
482
- ------------------------------------------------------------------------------
483
- if Hercules_Cargo.Calculate_Object_Height_AGL(Cargo_Drop_initiator) < 5.0 then--aircraft on ground
484
- Herc_Cargo[Herc_j].offload_cargo = true
485
- ParatrooperCount = 0
486
- ParatrooperGroupSpawnInit = false
487
- else
488
- ------------------------------------------------------------------------------
489
- if Hercules_Cargo.Calculate_Object_Height_AGL(Cargo_Drop_initiator) < 10.0 then--aircraft less than 10m above ground
490
- Herc_Cargo[Herc_j].all_cargo_survive_to_the_ground = true
491
- else
492
- ------------------------------------------------------------------------------
493
- if Hercules_Cargo.Calculate_Object_Height_AGL(Cargo_Drop_initiator) < 152.4 then--aircraft more than 30ft but less than 500ft above ground
494
- Herc_Cargo[Herc_j].all_cargo_gets_destroyed = true
495
- else
496
- ------------------------------------------------------------------------------
497
- Herc_Cargo[Herc_j].destroy_cargo_dropped_without_parachute = true--aircraft more than 152.4m (500ft)above ground
498
- end
499
- end
500
- end
501
- ------------------------------------------------------------------------------
502
- Herc_Cargo[Herc_j].scheduleFunctionID = timer.scheduleFunction(Hercules_Cargo.Cargo_Track, {Herc_Cargo[Herc_j]}, timer.getTime() + 0.1)
503
- ParatrooperCount = ParatrooperCount + 1.0
504
- else
505
- if (ParatrooperCount == 30) then
506
- ParatrooperGroupSpawnInit = false
507
- ParatrooperCount = 1
508
- else
509
- ParatrooperCount = ParatrooperCount + 1.0
510
- end
511
- end
512
- else
513
- Herc_j = Herc_j + 1
514
- Herc_Cargo[Herc_j] = {}
515
- Herc_Cargo[Herc_j].Cargo_Drop_Direction = Hercules_Cargo.Calculate_Cargo_Drop_initiator_Heading(Cargo_Drop_initiator)
516
- Herc_Cargo[Herc_j].Cargo_Contents = Cargo_Contents
517
- Herc_Cargo[Herc_j].Cargo_Type_name = Cargo_Type_name
518
- Herc_Cargo[Herc_j].Container_Enclosed = Container_Enclosed
519
- Herc_Cargo[Herc_j].ParatrooperGroupSpawn = ParatrooperGroupSpawnInit
520
- Herc_Cargo[Herc_j].Cargo_Country = initiator:getCountry()
521
- ------------------------------------------------------------------------------
522
- if Hercules_Cargo.Calculate_Object_Height_AGL(Cargo_Drop_initiator) < 5.0 then--aircraft on ground
523
- Herc_Cargo[Herc_j].offload_cargo = true
524
- else
525
- ------------------------------------------------------------------------------
526
- if Hercules_Cargo.Calculate_Object_Height_AGL(Cargo_Drop_initiator) < 10.0 then--aircraft less than 10m above ground
527
- Herc_Cargo[Herc_j].all_cargo_survive_to_the_ground = true
528
- else
529
- ------------------------------------------------------------------------------
530
- if Hercules_Cargo.Calculate_Object_Height_AGL(Cargo_Drop_initiator) < 100.0 then--aircraft more than 10m but less than 100m above ground
531
- Herc_Cargo[Herc_j].all_cargo_gets_destroyed = true
532
- else
533
- ------------------------------------------------------------------------------
534
- Herc_Cargo[Herc_j].destroy_cargo_dropped_without_parachute = true--aircraft more than 100m above ground
535
- end
536
- end
537
- end
538
- ------------------------------------------------------------------------------
539
- Herc_Cargo[Herc_j].scheduleFunctionID = timer.scheduleFunction(Hercules_Cargo.Cargo_Track, {Herc_Cargo[Herc_j]}, timer.getTime() + 0.1)
540
- end
541
- end
542
- end) -- pcall
543
- if not status then
544
- -- env.error(string.format("Cargo_Initialize: %s", result))
545
- else
546
- return result
547
- end
548
- end
549
-
550
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
551
- -- EventHandlers
552
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
553
- function Hercules_Cargo.Hercules_Cargo_Drop_Events:onEvent(Cargo_Drop_Event)
554
- if Cargo_Drop_Event.id == world.event.S_EVENT_SHOT then
555
- GT_DisplayName = Weapon.getDesc(Cargo_Drop_Event.weapon).typeName:sub(15, -1)--Remove "weapons.bombs." from string
556
- -- trigger.action.outTextForCoalition(coalition.side.BLUE, string.format("Cargo_Drop_Event: %s", Weapon.getDesc(Cargo_Drop_Event.weapon).typeName), 10)
557
- -- trigger.action.outTextForCoalition(coalition.side.RED, string.format("Cargo_Drop_Event: %s", Weapon.getDesc(Cargo_Drop_Event.weapon).typeName), 10)
558
- ---------------------------------------------------------------------------------------------------------------------------------
559
- if (GT_DisplayName == "Squad 30 x Soldier [7950lb]") then
560
- GT_Name = "Soldier M4 GRG"
561
- SoldierGroup = true
562
- ParatrooperGroupSpawnInit = true
563
- Hercules_Cargo.Cargo_Initialize(Cargo_Drop_Event.initiator, Cargo_Drop_Event.weapon, GT_Name, SoldierGroup)
564
- end
565
- ---------------------------------------------------------------------------------------------------------------------------------
566
- if Hercules_Cargo.types[GT_DisplayName] then
567
- local GT_Name = Hercules_Cargo.types[GT_DisplayName]['name']
568
- local Cargo_Container_Enclosed = Hercules_Cargo.types[GT_DisplayName]['container']
569
- Hercules_Cargo.Cargo_Initialize(Cargo_Drop_Event.initiator, Cargo_Drop_Event.weapon, GT_Name, Cargo_Container_Enclosed)
570
- end
571
- end
572
- end
573
- world.addEventHandler(Hercules_Cargo.Hercules_Cargo_Drop_Events)
574
-
575
- -- trigger.action.outTextForCoalition(coalition.side.BLUE, string.format("Cargo_Drop_Event.weapon: %s", Weapon.getDesc(Cargo_Drop_Event.weapon).typeName), 10)
576
- -- trigger.action.outTextForCoalition(coalition.side.BLUE, tostring('Calculate_Object_Height_AGL: ' .. aaaaa), 10)
577
- -- trigger.action.outTextForCoalition(coalition.side.BLUE, string.format("Speed: %.2f", Calculate_Object_Speed(Cargo_Drop_initiator)), 10)
578
- -- trigger.action.outTextForCoalition(coalition.side.BLUE, string.format("Russian Interceptor Patrol scrambled from Nalchik"), 10)
579
-
580
- -- function basicSerialize(var)
581
- -- if var == nil then
582
- -- return "\"\""
583
- -- else
584
- -- if ((type(var) == 'number') or
585
- -- (type(var) == 'boolean') or
586
- -- (type(var) == 'function') or
587
- -- (type(var) == 'table') or
588
- -- (type(var) == 'userdata') ) then
589
- -- return tostring(var)
590
- -- else
591
- -- if type(var) == 'string' then
592
- -- var = string.format('%q', var)
593
- -- return var
594
- -- end
595
- -- end
596
- -- end
597
- -- end
598
-
599
- -- function tableShow(tbl, loc, indent, tableshow_tbls) --based on serialize_slmod, this is a _G serialization
600
- -- tableshow_tbls = tableshow_tbls or {} --create table of tables
601
- -- loc = loc or ""
602
- -- indent = indent or ""
603
- -- if type(tbl) == 'table' then --function only works for tables!
604
- -- tableshow_tbls[tbl] = loc
605
- -- local tbl_str = {}
606
- -- tbl_str[#tbl_str + 1] = indent .. '{\n'
607
- -- for ind,val in pairs(tbl) do -- serialize its fields
608
- -- if type(ind) == "number" then
609
- -- tbl_str[#tbl_str + 1] = indent
610
- -- tbl_str[#tbl_str + 1] = loc .. '['
611
- -- tbl_str[#tbl_str + 1] = tostring(ind)
612
- -- tbl_str[#tbl_str + 1] = '] = '
613
- -- else
614
- -- tbl_str[#tbl_str + 1] = indent
615
- -- tbl_str[#tbl_str + 1] = loc .. '['
616
- -- tbl_str[#tbl_str + 1] = basicSerialize(ind)
617
- -- tbl_str[#tbl_str + 1] = '] = '
618
- -- end
619
- -- if ((type(val) == 'number') or (type(val) == 'boolean')) then
620
- -- tbl_str[#tbl_str + 1] = tostring(val)
621
- -- tbl_str[#tbl_str + 1] = ',\n'
622
- -- elseif type(val) == 'string' then
623
- -- tbl_str[#tbl_str + 1] = basicSerialize(val)
624
- -- tbl_str[#tbl_str + 1] = ',\n'
625
- -- elseif type(val) == 'nil' then -- won't ever happen, right?
626
- -- tbl_str[#tbl_str + 1] = 'nil,\n'
627
- -- elseif type(val) == 'table' then
628
- -- if tableshow_tbls[val] then
629
- -- tbl_str[#tbl_str + 1] = tostring(val) .. ' already defined: ' .. tableshow_tbls[val] .. ',\n'
630
- -- else
631
- -- tableshow_tbls[val] = loc .. '[' .. basicSerialize(ind) .. ']'
632
- -- tbl_str[#tbl_str + 1] = tostring(val) .. ' '
633
- -- tbl_str[#tbl_str + 1] = tableShow(val, loc .. '[' .. basicSerialize(ind).. ']', indent .. ' ', tableshow_tbls)
634
- -- tbl_str[#tbl_str + 1] = ',\n'
635
- -- end
636
- -- elseif type(val) == 'function' then
637
- -- if debug and debug.getinfo then
638
- -- local fcnname = tostring(val)
639
- -- local info = debug.getinfo(val, "S")
640
- -- if info.what == "C" then
641
- -- tbl_str[#tbl_str + 1] = string.format('%q', fcnname .. ', C function') .. ',\n'
642
- -- else
643
- -- if (string.sub(info.source, 1, 2) == [[./]]) then
644
- -- tbl_str[#tbl_str + 1] = string.format('%q', fcnname .. ', defined in (' .. info.linedefined .. '-' .. info.lastlinedefined .. ')' .. info.source) ..',\n'
645
- -- else
646
- -- tbl_str[#tbl_str + 1] = string.format('%q', fcnname .. ', defined in (' .. info.linedefined .. '-' .. info.lastlinedefined .. ')') ..',\n'
647
- -- end
648
- -- end
649
- -- else
650
- -- tbl_str[#tbl_str + 1] = 'a function,\n'
651
- -- end
652
- -- else
653
- -- tbl_str[#tbl_str + 1] = 'unable to serialize value type ' .. basicSerialize(type(val)) .. ' at index ' .. tostring(ind)
654
- -- end
655
- -- end
656
- -- tbl_str[#tbl_str + 1] = indent .. '}'
657
- -- return table.concat(tbl_str)
658
- -- end
659
- -- end
660
-
661
-
662
-
663
-
664
- -- function F10CargoDrop(GroupId, Unitname)
665
- -- local rootPath = missionCommands.addSubMenuForGroup(GroupId, "Cargo Drop")
666
- -- missionCommands.addCommandForGroup(GroupId, "Drop direction", rootPath, CruiseMissilesMessage, {GroupId, Unitname})
667
- -- missionCommands.addCommandForGroup(GroupId, "Drop distance", rootPath, ForwardConvoy, nil)
668
- -- local measurementsSetPath = missionCommands.addSubMenuForGroup(GroupId,"Set measurement units",rootPath)
669
- -- missionCommands.addCommandForGroup(GroupId, "Set to Imperial (feet, knts)",measurementsSetPath,setMeasurements,{GroupId, "imperial"})
670
- -- missionCommands.addCommandForGroup(GroupId, "Set to Metric (meters, km/h)",measurementsSetPath,setMeasurements,{GroupId, "metric"})
671
- -- end
672
-
673
- -- function Calculate_Object_Speed(object)
674
- -- return math.sqrt(object:getVelocity().x^2 + object:getVelocity().y^2 + object:getVelocity().z^2) * 3600 / 1852 -- knts
675
- -- end
676
-
677
- -- function vecDotProduct(vec1, vec2)
678
- -- return vec1.x*vec2.x + vec1.y*vec2.y + vec1.z*vec2.z
679
- -- end
680
-
681
- -- function Calculate_Aircraft_ForwardVelocity(Drop_initiator)
682
- -- return vecDotProduct(Drop_initiator:getPosition().x, Drop_initiator:getVelocity())
683
- -- end
684
-
685
-
686
-