@jtff/miztemplate-lib 2.2.0 → 3.0.0-rc2

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.
Files changed (65) hide show
  1. package/index.js +4 -3
  2. package/lib/jtff-lib-ci.js +1 -307
  3. package/lib/mizlib.js +337 -0
  4. package/lua/lib/Hercules_Cargo.lua +686 -0
  5. package/lua/lib/Moose_.lua +117314 -0
  6. package/lua/lib/Splash_Damage_2_0.lua +472 -0
  7. package/lua/lib/gemman.lua +1 -0
  8. package/lua/lib/mist_4_5_107.lua +9084 -0
  9. package/lua/lib/skynet-iads-compiled.lua +3864 -0
  10. package/lua/settings/settings-RAT.lua +235 -0
  11. package/lua/settings/settings-airboss.lua +142 -0
  12. package/lua/settings/settings-atis.lua +31 -0
  13. package/lua/settings/settings-awacs.lua +58 -0
  14. package/lua/settings/settings-awacsondemand.lua +26 -0
  15. package/lua/settings/settings-beacons.lua +10 -0
  16. package/lua/settings/settings-capwarzone.lua +164 -0
  17. package/lua/settings/settings-capzone.lua +32 -0
  18. package/lua/settings/settings-fac_ranges.lua +17 -0
  19. package/lua/settings/settings-foxzone.lua +14 -0
  20. package/lua/settings/settings-gemman.lua +6 -0
  21. package/lua/settings/settings-global.lua +31 -0
  22. package/lua/settings/settings-intercept.lua +23 -0
  23. package/lua/settings/settings-logistics.lua +22 -0
  24. package/lua/settings/settings-ondemandawacs.lua +29 -0
  25. package/lua/settings/settings-ondemandtankers.lua +29 -0
  26. package/lua/settings/settings-pedros.lua +11 -0
  27. package/lua/settings/settings-ranges.lua +28 -0
  28. package/lua/settings/settings-reapers.lua +25 -0
  29. package/lua/settings/settings-sams.lua +19 -0
  30. package/lua/settings/settings-skynet.lua +239 -0
  31. package/lua/settings/settings-tankers.lua +32 -0
  32. package/lua/settings/settings-training_ranges.lua +37 -0
  33. package/lua/src/010-root_menus.lua +5 -0
  34. package/lua/src/020-mission_functions.lua +1059 -0
  35. package/lua/src/110-set_clients.lua +61 -0
  36. package/lua/src/120-tankers.lua +589 -0
  37. package/lua/src/130-airboss.lua +621 -0
  38. package/lua/src/135-pedro.lua +21 -0
  39. package/lua/src/140-beacons.lua +19 -0
  40. package/lua/src/150-awacs.lua +599 -0
  41. package/lua/src/160-atis.lua +53 -0
  42. package/lua/src/170-cap_zone_training.lua +127 -0
  43. package/lua/src/172-cap_zone_war.lua +190 -0
  44. package/lua/src/173-fox_zone_training.lua +87 -0
  45. package/lua/src/176-random_air_traffic.lua +73 -0
  46. package/lua/src/178-training-intercept.lua +263 -0
  47. package/lua/src/180-logistics.lua +80 -0
  48. package/lua/src/190-ranges.lua +54 -0
  49. package/lua/src/191-sams.lua +49 -0
  50. package/lua/src/193-training_ranges.lua +191 -0
  51. package/lua/src/195-reaper-ondemand.lua +522 -0
  52. package/lua/src/196-fac_ranges.lua +34 -0
  53. package/lua/src/199-skynet.lua +721 -0
  54. package/lua/src/200-mission.lua +3 -0
  55. package/package.json +4 -3
  56. package/resources/radios/.gitkeep +0 -0
  57. package/resources/sounds/CTLD/beacon.ogg +0 -0
  58. package/resources/sounds/CTLD/beaconsilent.ogg +0 -0
  59. package/resources/sounds/Misc/.gitkeep +0 -0
  60. package/resources/sounds/Misc/2_Bips.ogg +0 -0
  61. package/resources/sounds/Misc/Bip.ogg +0 -0
  62. package/resources/sounds/Misc/crash_wood.ogg +0 -0
  63. package/scripts/build.js +2 -1
  64. package/scripts/inject-scripts.js +127 -230
  65. package/scripts/template-update.js +1 -1
@@ -0,0 +1,721 @@
1
+ -- *****************************************************************************
2
+ -- ** Skynet Groups **
3
+ -- *********************************************************
4
+
5
+ function SpawnIADSDelayed(param)
6
+ local parentMenu = param[1]
7
+ local iadsConfig = param[2]
8
+ local IADSObjectIndex = param[3]
9
+ local delay = param[4] or 10
10
+ local difficulty = param[5] or "easy"
11
+ MESSAGE:NewType(string.format("Warning, IADS [%s] Units %s will spawn in %d sec", difficulty, iadsConfig.name, delay), MESSAGE.Type.Update):ToAll()
12
+ TIMER:New(SpawnIADSUnits, param):Start(delay)
13
+ end
14
+
15
+ function attachSAMSiteToSkynet(site, samGroupName, IADSObjectIndex, connectionNode)
16
+ if type(site) == "string" then
17
+ IADSArray[IADSObjectIndex].IADSObject:addSAMSite(samGroupName)
18
+ IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(samGroupName):addConnectionNode(StaticObject.getByName(connectionNode))
19
+ elseif type(site) == "table" then
20
+ IADSArray[IADSObjectIndex].IADSObject:addSAMSite(samGroupName)
21
+ local skynetSam = IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(samGroupName)
22
+ skynetSam:addConnectionNode(StaticObject.getByName(connectionNode))
23
+ if (type(site.actAsEW) == "boolean") then
24
+ debug_msg(string.format("IADS - actAsEW %s", tostring(site.actAsEW)))
25
+ skynetSam:setActAsEW(site.actAsEW)
26
+ end
27
+ if (type(site.harmDetectionChance) == "number") then
28
+ debug_msg(string.format("IADS - HARM detection chance : %i", site.harmDetectionChance))
29
+ skynetSam:setHARMDetectionChance(site.harmDetectionChance)
30
+ end
31
+ if (type(site.goLiveRangePercent) == "number") then
32
+ debug_msg(string.format("IADS - Go Live Range : %i perc", site.goLiveRangePercent))
33
+ skynetSam
34
+ :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE)
35
+ :setGoLiveRangeInPercent(site.goLiveRangePercent)
36
+ else
37
+ skynetSam
38
+ :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE)
39
+ end
40
+ end
41
+ end
42
+
43
+ function attachPdSiteToSkynet(site, pdGroupName, samGroupName, IADSObjectIndex, connectionNode)
44
+ local skynetSam = IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(samGroupName)
45
+ if (type(site.pointDefenses) == "string") then
46
+ IADSArray[IADSObjectIndex].IADSObject:addSAMSite(pdGroupName)
47
+ local skynetPdSam = IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(pdGroupName)
48
+ skynetPdSam:addConnectionNode(StaticObject.getByName(connectionNode))
49
+ if (type(site.pdactAsEw) == "boolean") then
50
+ debug_msg(string.format("IADS - actAsEW %s", tostring(site.pdactAsEw)))
51
+ skynetPdSam:setActAsEW(site.pdactAsEw)
52
+ end
53
+ if (type(site.pdharmDetectionChance) == "number") then
54
+ debug_msg(string.format("IADS - HARM detection chance : %i", site.pdharmDetectionChance))
55
+ skynetPdSam:setHARMDetectionChance(site.pdharmDetectionChance)
56
+ end
57
+ if (type(site.pdgoLiveRangePercent) == "number") then
58
+ debug_msg(string.format("IADS - Go Live Range : %i perc", site.pdgoLiveRangePercent))
59
+ skynetPdSam
60
+ :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE)
61
+ :setGoLiveRangeInPercent(site.pdgoLiveRangePercent)
62
+ else
63
+ skynetPdSam
64
+ :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE)
65
+ end
66
+ debug_msg(string.format("IADS - Point Defense Sam Group %s Defending SAM %s", pdGroupName, samGroupName))
67
+ skynetSam:addPointDefence(skynetPdSam)
68
+ elseif (type(site.pointDefenses) == "table") then
69
+ IADSArray[IADSObjectIndex].IADSObject:addSAMSite(pdGroupName)
70
+ local skynetPdSam = IADSArray[IADSObjectIndex].IADSObject:getSAMSiteByGroupName(pdGroupName)
71
+ skynetPdSam:addConnectionNode(StaticObject.getByName(connectionNode))
72
+ if (type(site.pdactAsEw) == "boolean") then
73
+ debug_msg(string.format("IADS - actAsEW %s", tostring(site.pdactAsEw)))
74
+ skynetPdSam:setActAsEW(site.pdactAsEw)
75
+ end
76
+ if (type(site.pdharmDetectionChance) == "number") then
77
+ debug_msg(string.format("IADS - HARM detection chance : %i", site.pdharmDetectionChance))
78
+ skynetPdSam:setHARMDetectionChance(site.pdharmDetectionChance)
79
+ end
80
+ if (type(site.pdgoLiveRangePercent) == "number") then
81
+ debug_msg(string.format("IADS - Go Live Range : %i perc", site.pdgoLiveRangePercent))
82
+ skynetPdSam
83
+ :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE)
84
+ :setGoLiveRangeInPercent(site.pdgoLiveRangePercent)
85
+ else
86
+ skynetPdSam
87
+ :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE)
88
+ end
89
+ debug_msg(string.format("IADS - Point Defense Sam Group %s Defending SAM %s", pdGroupName, samGroupName))
90
+ skynetSam:addPointDefence(skynetPdSam)
91
+ end
92
+ end
93
+
94
+ function SpawnIADSUnits(param)
95
+ local parentMenu = param[1]
96
+ local iadsConfig = param[2]
97
+ local IADSObjectIndex = param[3]
98
+ local delay = param[4]
99
+ local difficulty = param[5]
100
+ local iadsName = iadsConfig.name
101
+ local nodesConfig = iadsConfig.nodes
102
+ local difficultyArray = {"easy","medium","hard","extreme"}
103
+ local somethingAlreadySpawned = false
104
+ for indexdiff, currentdifficulty in ipairs(difficultyArray) do
105
+ somethingAlreadySpawned = somethingAlreadySpawned or IADSArray[IADSObjectIndex].spawned[currentdifficulty]
106
+ end
107
+
108
+ for nodeIndex, nodeConfig in ipairs(nodesConfig) do
109
+ local connection = nodeConfig.connection
110
+ if (type(connection) == "table") then
111
+ if ( connection.type ~= nil and connection.category ~= nil and connection.name ~= nil ) then
112
+ local staticTypeToSpawn = string.format("%s", connection.type)
113
+ local staticCategoryToSpawn = string.format("%s", connection.category)
114
+ local spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn)
115
+ if (connection.coalition ~= nil) then
116
+ if (connection.coalition == coalition.side.BLUE) then
117
+ spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn,
118
+ country.id.CJTF_BLUE)
119
+ elseif (connection.coalition == coalition.side.RED) then
120
+ spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn,
121
+ country.id.CJTF_RED)
122
+ else
123
+ spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn,
124
+ country.id.UN_PEACEKEEPERS)
125
+ end
126
+ end
127
+ local x = connection.x
128
+ local y = connection.y
129
+ local heading = connection.heading
130
+ local name = string.format("%s", connection.name)
131
+ debug_msg(string.format("Static type to spawn %s at %i,%i -> %s", staticTypeToSpawn, x, y, name))
132
+ local static = spawnStatic:SpawnFromPointVec2(POINT_VEC2:New(x, y), heading, name)
133
+ else
134
+ debug_msg(string.format("Static to spawn has no type, category, name or position!"))
135
+ end
136
+ end
137
+ local ewrList = nodeConfig.ewrs
138
+ local siteList = nodeConfig.sites[difficulty]
139
+ for ewrIndex, ewrGroup in ipairs(ewrList) do
140
+ if (not(somethingAlreadySpawned)) then
141
+ local groupNameToSpawn = string.format("%s", ewrGroup)
142
+ if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
143
+ local spawnGroup = SPAWN:New(groupNameToSpawn)
144
+ debug_msg(string.format("IADS - SPAWN EWR : %s", groupNameToSpawn))
145
+ local groupSpawning = spawnGroup:Spawn():OptionAlarmStateRed()
146
+ else
147
+ debug_msg(string.format("IADS - EWR GROUP to spawn %s not found in mission", groupNameToSpawn))
148
+ end
149
+ end
150
+ end
151
+ local samGroupsSpawned = {}
152
+ for siteIndex, site in ipairs(siteList) do
153
+ if (type(site) == "string") then
154
+ local groupNameToSpawn = string.format("%s", site)
155
+ if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
156
+ local spawnGroup = SPAWN:New(groupNameToSpawn)
157
+ debug_msg(string.format("IADS - SPAWN SAM : %s", groupNameToSpawn))
158
+ samGroupsSpawned[siteIndex] = spawnGroup:Spawn():OptionAlarmStateRed()
159
+ --if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then
160
+ -- attachSAMSiteToSkynet(site, samGroupsSpawned[siteIndex]:GetName(), IADSObjectIndex, nodeConfig.connection)
161
+ --end
162
+ else
163
+ debug_msg(string.format("IADS - SAM GROUP to spawn %s not found in mission", groupNameToSpawn))
164
+ end
165
+ elseif (type(site) == "table") then
166
+ debug_msg(string.format("IADS - SAM in config file is table"))
167
+ if (site.staticsToSpawn ~= nil) then
168
+ for index, staticToSpawn in ipairs(site.staticsToSpawn) do
169
+ local spawnStatic = nil
170
+ if (staticToSpawn.name ~= nil) then
171
+ local staticNameToSpawn = string.format("%s", staticToSpawn.name)
172
+ spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn)
173
+ if (staticToSpawn.coalition ~= nil) then
174
+ if (staticToSpawn.coalition == coalition.side.BLUE) then
175
+ spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.CJTF_BLUE)
176
+ elseif (staticToSpawn.coalition == coalition.side.RED) then
177
+ spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.CJTF_RED)
178
+ else
179
+ spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.UN_PEACEKEEPERS)
180
+ end
181
+ end
182
+ local x = staticToSpawn.x
183
+ local y = staticToSpawn.y
184
+ local heading = staticToSpawn.heading
185
+ local name = string.format("%s_%s_%i", site.sam, staticNameToSpawn,index)
186
+ local static = spawnStatic:SpawnFromPointVec2( POINT_VEC2:New( x, y ), heading, name )
187
+ debug_msg(string.format("IADS - Static %s to spawn at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()))
188
+ elseif (staticToSpawn.type ~= nil and staticToSpawn.category ~= nil) then
189
+ local staticTypeToSpawn = string.format("%s", staticToSpawn.type)
190
+ local staticCategoryToSpawn = string.format("%s", staticToSpawn.category)
191
+ spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn)
192
+ if (staticToSpawn.coalition ~= nil) then
193
+ if (staticToSpawn.coalition == coalition.side.BLUE) then
194
+ spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.CJTF_BLUE)
195
+ elseif (staticToSpawn.coalition == coalition.side.RED) then
196
+ spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.CJTF_RED)
197
+ else
198
+ spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.UN_PEACEKEEPERS)
199
+ end
200
+ end
201
+ local x = staticToSpawn.x
202
+ local y = staticToSpawn.y
203
+ local heading = staticToSpawn.heading
204
+ local name = string.format("%s_%s_%i", site.sam, staticTypeToSpawn, index)
205
+ local static = spawnStatic:SpawnFromPointVec2( POINT_VEC2:New( x, y ), heading, name )
206
+ debug_msg(string.format("IADS - Static %s to spawn at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()))
207
+ else
208
+ debug_msg(string.format("IADS - Static to spawn has no name or type!"))
209
+ end
210
+ end
211
+ end
212
+
213
+ local groupNameToSpawn = string.format("%s", site.sam)
214
+ if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
215
+ local spawnGroup = SPAWN:New(groupNameToSpawn)
216
+ debug_msg(string.format("IADS - SPAWN SAM : %s", groupNameToSpawn))
217
+ samGroupsSpawned[siteIndex] = spawnGroup:Spawn():OptionAlarmStateRed()
218
+ --if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then
219
+ -- attachSAMSiteToSkynet(site, samGroupsSpawned[siteIndex]:GetName(), IADSObjectIndex, nodeConfig.connection)
220
+ --end
221
+ else
222
+ debug_msg(string.format("IADS - SAM GROUP to spawn %s not found in mission", groupNameToSpawn))
223
+ end
224
+ if (type(site.pointDefenses) == "string") then
225
+ local pdGroupNameToSpawn = string.format("%s", site.pointDefenses)
226
+ if (GROUP:FindByName(pdGroupNameToSpawn) ~= nil) then
227
+ local spawnGroup = SPAWN:New(pdGroupNameToSpawn)
228
+ debug_msg(string.format("IADS - SPAWN SAM-PointDefense : %s", pdGroupNameToSpawn))
229
+ local pdSamGroupsSpawned = spawnGroup:Spawn():OptionAlarmStateRed()
230
+ --if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then
231
+ -- attachPdSiteToSkynet(site, pdSamGroupsSpawned:GetName(), samGroupsSpawned[siteIndex]:GetName(), IADSObjectIndex, nodeConfig.connection)
232
+ --end
233
+ else
234
+ debug_msg(string.format("IADS - SAM-PointDefense GROUP to spawn %s not found in mission", pdGroupNameToSpawn))
235
+ end
236
+ elseif (type(site.pointDefenses) == "table") then
237
+ local pdSamGroupsSpawned = {}
238
+ for pdindex, pdSamGroup in ipairs(site.pointDefenses) do
239
+ local pdGroupNameToSpawn = string.format("%s", pdSamGroup)
240
+ if (GROUP:FindByName(pdGroupNameToSpawn) ~= nil) then
241
+ local spawnGroup = SPAWN:New(pdGroupNameToSpawn)
242
+ debug_msg(string.format("IADS - SPAWN SAM-PointDefense : %s", pdGroupNameToSpawn))
243
+ pdSamGroupsSpawned[pdindex] = spawnGroup:Spawn():OptionAlarmStateRed()
244
+ --if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then
245
+ -- attachPdSiteToSkynet(site, pdSamGroupsSpawned[pdindex]:GetName(), samGroupsSpawned[siteIndex]:GetName(), IADSObjectIndex, nodeConfig.connection)
246
+ --end
247
+ else
248
+ debug_msg(string.format("IADS - SAM-PointDefense GROUP to spawn %s not found in mission", pdGroupNameToSpawn))
249
+ end
250
+ end
251
+ end
252
+ end
253
+ end
254
+ end
255
+ IADSArray[IADSObjectIndex].spawned[difficulty] = true
256
+ if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then
257
+ local showStatusOption = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings().IADSStatus
258
+ local showContactsOption = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings().contacts
259
+ deactivateSkynet(
260
+ {iadsConfig, IADSObjectIndex,parentMenu}
261
+ )
262
+ activateSkynet(
263
+ {iadsConfig, IADSObjectIndex,parentMenu}
264
+ )
265
+ skynetUpdateDisplay({ IADSObjectIndex,'contacts',showContactsOption })
266
+ skynetUpdateDisplay({ IADSObjectIndex,'IADSStatus',showStatusOption })
267
+ end
268
+ debug_msg(string.format("IADS - Spawn IADS : %s-[%s] DONE", iadsName, difficulty))
269
+ manageIADSNetworkMenu(parentMenu,iadsConfig,IADSObjectIndex)
270
+ MESSAGE:NewType(string.format("IADS - IADS Units %s-[%s] in place", iadsName, difficulty), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition)
271
+ end
272
+
273
+ function deleteIADSNetwork(param)
274
+ local iadsConfig = param[1]
275
+ local IADSObjectIndex = param[2]
276
+ local networkRootMenu = param[3]
277
+ local iadsName = iadsConfig.name
278
+ local nodesConfig = iadsConfig.nodes
279
+ local skynetIADSObject = IADSArray[IADSObjectIndex].IADSObject
280
+ local difficultyArray = {"easy","medium","hard","extreme"}
281
+
282
+ if (skynetIADSObject ~= nil) then
283
+ deactivateSkynet({ iadsConfig, IADSObjectIndex, networkRootMenu })
284
+ end
285
+ for index, difficulty in ipairs(difficultyArray) do
286
+ param[4] = difficulty
287
+ deleteIADSUnits(param)
288
+ end
289
+ IADSArray[IADSObjectIndex].IADSNetworkRunning = false
290
+ MESSAGE:NewType(string.format("IADS - Remove IADS : %s", iadsName), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition)
291
+ manageIADSNetworkMenu(networkRootMenu, iadsConfig, IADSObjectIndex)
292
+ end
293
+
294
+ function deactivateSkynet(param)
295
+ local iadsConfig = param[1]
296
+ local IADSObjectIndex = param[2]
297
+ local parentMenu = param[3]
298
+
299
+ IADSArray[IADSObjectIndex].IADSObject:deactivate()
300
+ IADSArray[IADSObjectIndex].IADSNetworkRunning = false
301
+
302
+ manageIADSNetworkMenu(parentMenu, iadsConfig, IADSObjectIndex)
303
+ MESSAGE:NewType(string.format("IADS - Skynet of %s is desactivated", iadsConfig.name), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition)
304
+ end
305
+
306
+ function skynetUpdateDisplay(param)
307
+ local IADSObjectIndex = param[1]
308
+ local option = param[2]
309
+ local value = param[3]
310
+
311
+ IADSArray[IADSObjectIndex].IADSObject.updateDisplay({
312
+ option = option,
313
+ self = IADSArray[IADSObjectIndex].IADSObject,
314
+ value = value
315
+ })
316
+ end
317
+
318
+ function activateGCI(param)
319
+ local iadsConfig = param[1]
320
+ local IADSObjectIndex = param[2]
321
+ local parentMenu = param[3]
322
+ debug_msg(string.format("IADS - GCI activation for %s", iadsConfig.name))
323
+
324
+ DetectionSetGroup = SET_GROUP:New()
325
+ IADSArray[IADSObjectIndex].IADSObject:addMooseSetGroup(DetectionSetGroup)
326
+ Detection = DETECTION_AREAS:New( DetectionSetGroup, 30000 )
327
+ A2ADispatcher = AI_A2A_DISPATCHER:New( Detection )
328
+ A2ADispatcher:SetEngageRadius() -- 100000 is the default value.
329
+ if (iadsConfig.gci_engage_radius) then
330
+ A2ADispatcher:SetGciRadius(iadsConfig.gci_engage_radius)
331
+ else
332
+ A2ADispatcher:SetGciRadius()
333
+ end
334
+ CCCPBorderZone = ZONE_POLYGON:New( iadsConfig.gci_border , GROUP:FindByName( iadsConfig.gci_border ) )
335
+ A2ADispatcher:SetBorderZone( CCCPBorderZone )
336
+
337
+ A2ADispatcher:SetDefaultTakeoffFromRunway()
338
+ A2ADispatcher:SetDefaultLandingAtRunway()
339
+
340
+ for index, gci_group in ipairs(iadsConfig.gci) do
341
+ gci_group_name = string.format("GCI_%s", gci_group.airport)
342
+ debug_msg(string.format("IADS - GCI - Group %s", gci_group_name))
343
+ A2ADispatcher:SetSquadron( gci_group_name, gci_group.airport, gci_group.templatePrefixes, gci_group.numberOfAircraftAvailable )
344
+ A2ADispatcher:SetSquadronGci( gci_group_name, 1000, 3000 )
345
+ end
346
+ MESSAGE:NewType(string.format("IADS - GCI of %s is activated", iadsConfig.name), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition)
347
+ end
348
+
349
+ function activateSkynet(param)
350
+ local iadsConfig = param[1]
351
+ local IADSObjectIndex = param[2]
352
+ local parentMenu = param[3]
353
+ local difficultyArray = {"easy","medium","hard","extreme"}
354
+ debug_msg(string.format("IADS - Skynet activation for %s", iadsConfig.name))
355
+ -- create an instance of the IADS
356
+ IADSArray[IADSObjectIndex].IADSObject = SkynetIADS:create(iadsConfig.name)
357
+
358
+ ---debug settings remove from here on if you do not wan't any output on what the IADS is doing by default
359
+ local iadsDebug = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings()
360
+ iadsDebug.IADSStatus = DEBUG_MSG
361
+ iadsDebug.radarWentDark = DEBUG_MSG
362
+ iadsDebug.contacts = DEBUG_MSG
363
+ iadsDebug.radarWentLive = DEBUG_MSG
364
+ iadsDebug.noWorkingCommmandCenter = DEBUG_MSG
365
+ iadsDebug.ewRadarNoConnection = DEBUG_MSG
366
+ iadsDebug.samNoConnection = DEBUG_MSG
367
+ iadsDebug.jammerProbability = DEBUG_MSG
368
+ iadsDebug.addedEWRadar = DEBUG_MSG
369
+ iadsDebug.hasNoPower = DEBUG_MSG
370
+ iadsDebug.harmDefence = DEBUG_MSG
371
+ iadsDebug.samSiteStatusEnvOutput = DEBUG_MSG
372
+ iadsDebug.earlyWarningRadarStatusEnvOutput = DEBUG_MSG
373
+ iadsDebug.commandCenterStatusEnvOutput = DEBUG_MSG
374
+ ---end remove debug ---
375
+
376
+ -- add a command center:
377
+ for index, headQuarter in ipairs(iadsConfig.headQuarter) do
378
+ local commandCenter = StaticObject.getByName(headQuarter)
379
+ IADSArray[IADSObjectIndex].IADSObject:addCommandCenter(commandCenter)
380
+ end
381
+
382
+ for index, node in ipairs(iadsConfig.nodes) do
383
+ local connectionName = ""
384
+ if (type(node.connection) == "string") then
385
+ connectionName = node.connection
386
+ else
387
+ connectionName = node.connection.name
388
+ end
389
+ debug_msg(string.format("IADS - Connection Node %s", connectionName))
390
+ local connectionNode = StaticObject.getByName(connectionName)
391
+ for index, ewr in ipairs(node.ewrs) do
392
+ if (ewr ~= nil and connectionNode ~= nil) then
393
+ debug_msg(string.format("IADS - EWR Unit name in config file : %s", ewr))
394
+ local set_ewr_units = SET_UNIT:New():FilterPrefixes(ewr):FilterOnce()
395
+ set_ewr_units:ForEachUnit(function(ewr_alive)
396
+ if ewr_alive:IsAlive() then
397
+ debug_msg(string.format("IADS - Alive EWR Unit name found %s", ewr_alive:Name()))
398
+ IADSArray[IADSObjectIndex].IADSObject:addEarlyWarningRadar(ewr_alive:Name())
399
+ IADSArray[IADSObjectIndex].IADSObject:getEarlyWarningRadarByUnitName(ewr_alive:Name()):addConnectionNode(connectionNode)
400
+ end
401
+ end)
402
+ end
403
+ end
404
+ for indexdiff, difficulty in ipairs(difficultyArray) do
405
+ if IADSArray[IADSObjectIndex].spawned[difficulty] then
406
+ for siteIndex, site in ipairs(node.sites[difficulty]) do
407
+ if (site ~= nil and connectionNode ~= nil) then
408
+ if (type(site) == "string") then
409
+ debug_msg(string.format("IADS - Sam Group name in config file : %s", site))
410
+ local set_group_alive = SET_GROUP:New():FilterPrefixes(site):FilterOnce()
411
+ set_group_alive:ForEachGroupAlive(function(group_alive)
412
+ debug_msg(string.format("IADS - Alive Sam Group found %s", group_alive:GetName()))
413
+ attachSAMSiteToSkynet(site, group_alive:GetName(), IADSObjectIndex, connectionName)
414
+ end)
415
+ elseif (type(site) == "table") then
416
+ debug_msg(string.format("IADS - Sam Group name in config file : %s", site.sam))
417
+ local set_group_alive = SET_GROUP:New():FilterPrefixes(site.sam):FilterOnce()
418
+ set_group_alive:ForEachGroupAlive(function(samGroupAlive)
419
+ debug_msg(string.format("IADS - Alive Sam Group found %s", samGroupAlive:GetName()))
420
+ attachSAMSiteToSkynet(site, samGroupAlive:GetName(), IADSObjectIndex, connectionName)
421
+ if (type(site.pointDefenses) == "string") then
422
+ local set_pdgroup_alive = SET_GROUP:New():FilterPrefixes(site.pointDefenses):FilterOnce()
423
+ set_pdgroup_alive:ForEachGroupAlive(function(pdGroupAlive)
424
+ debug_msg(string.format("IADS - Alive Point Defense Sam Group found %s", pdGroupAlive:GetName()))
425
+ attachPdSiteToSkynet(site,pdGroupAlive:GetName(), samGroupAlive:GetName(), IADSObjectIndex, connectionName)
426
+ end)
427
+ elseif (type(site.pointDefenses) == "table") then
428
+ for pdIndex, pdSamGroupName in ipairs(site.pointDefenses) do
429
+ debug_msg(string.format("IADS - Point Defense Sam Group name in config file : %s", pdSamGroupName))
430
+ local set_pdgroup_alive = SET_GROUP:New():FilterPrefixes(pdSamGroupName):FilterOnce()
431
+ set_pdgroup_alive:ForEachGroupAlive(function(pdGroupAlive)
432
+ debug_msg(string.format("IADS - Alive Point Defense Sam Group found %s", pdGroupAlive:GetName()))
433
+ attachPdSiteToSkynet(site,pdGroupAlive:GetName(), samGroupAlive:GetName(), IADSObjectIndex, connectionName)
434
+ end)
435
+ end
436
+ end
437
+ end)
438
+ end
439
+ end
440
+ end
441
+ end
442
+ end
443
+ end
444
+
445
+ -- activate the radio menu to toggle IADS Status output
446
+ --if (iadsConfig.radioMenu) then
447
+ -- debug_msg(string.format("IADS - Add radio menu %s", iadsConfig.name))
448
+ -- IADSArray[IADSObjectIndex].IADSObject:addRadioMenu()
449
+ --end
450
+
451
+ -- activate the IADS
452
+ IADSArray[IADSObjectIndex].IADSObject:activate()
453
+ IADSArray[IADSObjectIndex].IADSNetworkRunning = true
454
+
455
+ manageIADSNetworkMenu(parentMenu, iadsConfig, IADSObjectIndex)
456
+ MESSAGE:NewType(string.format("Skynet of %s activate in 60 secondes", iadsConfig.name), MESSAGE.Type.Information):ToCoalition(iadsConfig.benefit_coalition)
457
+ end
458
+
459
+ function deleteIADSUnits(param)
460
+ local iadsConfig = param[1]
461
+ local IADSObjectIndex = param[2]
462
+ local parentMenu = param[3]
463
+ local difficulty = param[4]
464
+ local iadsName = iadsConfig.name
465
+ local nodesConfig = iadsConfig.nodes
466
+ local difficultyArray = {"easy","medium","hard","extreme"}
467
+ local difficultiesAlreadySpawned = 0
468
+ for indexdiff, currentdifficulty in ipairs(difficultyArray) do
469
+ if (IADSArray[IADSObjectIndex].spawned[currentdifficulty]) then
470
+ difficultiesAlreadySpawned = difficultiesAlreadySpawned + 1
471
+ end
472
+ end
473
+
474
+ for index, nodeConfig in ipairs(nodesConfig) do
475
+ local connection = nodeConfig.connection
476
+ destroyStatic(connection)
477
+ local ewrList = nodeConfig.ewrs
478
+ if (difficultiesAlreadySpawned <= 1) then
479
+ for index, ewrGroup in ipairs(ewrList) do
480
+ local groupNameToDelete = string.format("%s", ewrGroup)
481
+ destroyGroup(groupNameToDelete)
482
+ end
483
+ end
484
+ local sitesList = nodeConfig.sites[difficulty]
485
+ for siteindex, site in ipairs(sitesList) do
486
+ if (type(site) == "string") then
487
+ local groupNameToDelete = string.format("%s", site)
488
+ destroyGroup(groupNameToDelete)
489
+ elseif (type(site) == "table") then
490
+ local groupNameToDelete = string.format("%s", site.sam)
491
+ destroyGroup(groupNameToDelete)
492
+ end
493
+ if (type( site.staticsToSpawn) == "table") then
494
+ destroyStatics(site.staticsToSpawn, site.sam)
495
+ end
496
+ if (type(site.pointDefenses) == "string") then
497
+ local groupNameToDelete = string.format("%s", site.pointDefenses)
498
+ destroyGroup(groupNameToDelete)
499
+ elseif (type(site.pointDefenses) == "table") then
500
+ for pdIndex, pdSamGroupName in ipairs(site.pointDefenses) do
501
+ local groupNameToDelete = string.format("%s", pdSamGroupName)
502
+ destroyGroup(groupNameToDelete)
503
+ end
504
+ end
505
+ end
506
+ end
507
+ IADSArray[IADSObjectIndex].spawned[difficulty] = false
508
+ if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then
509
+ local showStatusOption = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings().IADSStatus
510
+ local showContactsOption = IADSArray[IADSObjectIndex].IADSObject:getDebugSettings().contacts
511
+ deactivateSkynet(
512
+ {iadsConfig, IADSObjectIndex,parentMenu}
513
+ )
514
+ activateSkynet(
515
+ {iadsConfig, IADSObjectIndex,parentMenu}
516
+ )
517
+ skynetUpdateDisplay({ IADSObjectIndex,'contacts',showContactsOption })
518
+ skynetUpdateDisplay({ IADSObjectIndex,'IADSStatus',showStatusOption })
519
+ end
520
+ manageIADSNetworkMenu(parentMenu,iadsConfig,IADSObjectIndex)
521
+ end
522
+
523
+ function manageIADSNetworkMenu(networkRootMenu, iadsconfig, IADSObjectIndex)
524
+ local difficultyArray = {"easy","medium","hard","extreme"}
525
+ local anyDifficultySpawned = false
526
+ local skynetIADSObject = IADSArray[IADSObjectIndex].IADSObject
527
+ for index, difficulty in ipairs(difficultyArray) do
528
+ anyDifficultySpawned = anyDifficultySpawned or IADSArray[IADSObjectIndex].spawned[difficulty]
529
+ end
530
+ networkRootMenu:RemoveSubMenus()
531
+ if (anyDifficultySpawned) then
532
+ --Il y a au moins 1 groupe de difficulté spawné : on affiche les menus skynet Ad-Hoc
533
+ local CommandIADSDetroy = MENU_MISSION_COMMAND:New(
534
+ "[Whole IADS Network] Delete",
535
+ networkRootMenu,
536
+ deleteIADSNetwork,
537
+ { iadsconfig, IADSObjectIndex, networkRootMenu }
538
+ )
539
+ if (IADSArray[IADSObjectIndex].IADSNetworkRunning) then
540
+ --Le reseau tourne déjà, on affiche le menu de desactivation du reseau et les menus de troubleshooting
541
+ local CommandIADSShowStatus = MENU_MISSION_COMMAND:New(
542
+ "Show IADS Status",
543
+ networkRootMenu,
544
+ skynetUpdateDisplay,
545
+ { IADSObjectIndex, 'IADSStatus', true }
546
+ )
547
+ local CommandIADSHideStatus = MENU_MISSION_COMMAND:New(
548
+ "Hide IADS Status",
549
+ networkRootMenu,
550
+ skynetUpdateDisplay,
551
+ { IADSObjectIndex, 'IADSStatus', false }
552
+ )
553
+ local CommandIADSShowContacts = MENU_MISSION_COMMAND:New(
554
+ "Show contacts",
555
+ networkRootMenu,
556
+ skynetUpdateDisplay,
557
+ { IADSObjectIndex, 'contacts', true }
558
+ )
559
+ local CommandIADSHideContacts = MENU_MISSION_COMMAND:New(
560
+ "Hide contacts",
561
+ networkRootMenu,
562
+ skynetUpdateDisplay,
563
+ { IADSObjectIndex, 'contacts', false }
564
+ )
565
+ local CommandIADSDisable = MENU_MISSION_COMMAND:New(
566
+ "Disable Skynet",
567
+ networkRootMenu,
568
+ deactivateSkynet,
569
+ { iadsconfig, IADSObjectIndex, networkRootMenu }
570
+ )
571
+ --TODO: A tweaker pour que les objets skynets seront basés sur la coalition et non sur la mission globale
572
+ if (type(iadsconfig.gci) == "table") then
573
+ local CommandGCIActivate = MENU_MISSION_COMMAND:New(
574
+ "GCI Activation",
575
+ networkRootMenu,
576
+ activateGCI,
577
+ { iadsconfig, IADSObjectIndex, networkRootMenu }
578
+ )
579
+ end
580
+ else
581
+ --On affiche le menu d activation skynet
582
+ local CommandIADSActivate = MENU_MISSION_COMMAND:New("Skynet Activation",
583
+ networkRootMenu, activateSkynet, { iadsconfig, IADSObjectIndex, networkRootMenu })
584
+ end
585
+ end
586
+ for index, difficulty in ipairs(difficultyArray) do
587
+ if IADSArray[IADSObjectIndex].spawned[difficulty] then
588
+ local CommandIADSDetroyEasy = MENU_MISSION_COMMAND:New(
589
+ "[" .. difficulty .. "] Delete",
590
+ networkRootMenu,
591
+ deleteIADSUnits,
592
+ { iadsconfig, IADSObjectIndex, networkRootMenu, difficulty }
593
+ )
594
+ else
595
+ local isThereSomethingToSpawn = false
596
+ for indexnodes, nodeconfig in ipairs(iadsconfig.nodes) do
597
+ local tbl_json_txt = net.lua2json(nodeconfig.sites[difficulty])
598
+ --debug_msg(string.format('IADS: network=%s node=%s difficulty=%s sites config=%s', iadsconfig.name, nodeconfig.connection, difficulty, tbl_json_txt))
599
+ local difficultySiteNumberToSpawn = 0
600
+ for indexsite, siteconfig in ipairs(nodeconfig.sites[difficulty]) do
601
+ difficultySiteNumberToSpawn = indexsite
602
+ if indexsite >= 1 then
603
+ isThereSomethingToSpawn = true
604
+ end
605
+ end
606
+ if (type(nodeconfig.connection) == "string") then
607
+ debug_msg(string.format('IADS - network=%s node=%s difficulty=%s sites number=%d', iadsconfig.name,
608
+ nodeconfig.connection, difficulty, difficultySiteNumberToSpawn))
609
+ else
610
+ debug_msg(string.format('IADS - network=%s node=%s difficulty=%s sites number=%d', iadsconfig.name,
611
+ nodeconfig.connection.name, difficulty, difficultySiteNumberToSpawn))
612
+ end
613
+ end
614
+ if isThereSomethingToSpawn then
615
+ local RadioCommandAddDifficulty = MENU_MISSION_COMMAND:New(
616
+ "[" .. difficulty .. "] Spawn",
617
+ networkRootMenu,
618
+ SpawnIADSDelayed,
619
+ { networkRootMenu, iadsconfig, IADSObjectIndex, spawnStandardDelay, difficulty}
620
+ )
621
+ end
622
+ end
623
+ end
624
+ end
625
+
626
+ function addExtraSamTypeDB()
627
+ samTypesDB['FPS-117'] = {
628
+ ['type'] = 'ewr',
629
+ ['searchRadar'] = {
630
+ ['FPS-117'] = {
631
+ ['name'] = {
632
+ ['NATO'] = 'Seek Igloo',
633
+ },
634
+ },
635
+ },
636
+ ['harm_detection_chance'] = 60
637
+ }
638
+ samTypesDB['FPS-117 Dome'] = {
639
+ ['type'] = 'ewr',
640
+ ['searchRadar'] = {
641
+ ['FPS-117 Dome'] = {
642
+ ['name'] = {
643
+ ['NATO'] = 'Seek Igloo',
644
+ },
645
+ },
646
+ },
647
+ ['harm_detection_chance'] = 60
648
+ }
649
+ samTypesDB['EWR P-37 BAR LOCK'] = {
650
+ ['type'] = 'ewr',
651
+ ['searchRadar'] = {
652
+ ['EWR P-37 BAR LOCK'] = {
653
+ ['name'] = {
654
+ ['NATO'] = 'Bar lock',
655
+ },
656
+ },
657
+ },
658
+
659
+ ['harm_detection_chance'] = 60
660
+ }
661
+ samTypesDB['EWR 55G6U NEBO-U'] = {
662
+ ['type'] = 'ewr',
663
+ ['searchRadar'] = {
664
+ ['EWR 55G6U NEBO-U'] = {
665
+ ['name'] = {
666
+ ['NATO'] = 'Nebo-U',
667
+ },
668
+ },
669
+ },
670
+
671
+ ['harm_detection_chance'] = 65
672
+ }
673
+ samTypesDB['EWR 1L119 Nebo-SVU'] = {
674
+ ['type'] = 'ewr',
675
+ ['searchRadar'] = {
676
+ ['EWR 1L119 Nebo-SVU'] = {
677
+ ['name'] = {
678
+ ['NATO'] = 'Nebo-SVU',
679
+ },
680
+ },
681
+ },
682
+
683
+ ['harm_detection_chance'] = 75
684
+ }
685
+ samTypesDB['EWR Generic radar tower'] = {
686
+ ['type'] = 'ewr',
687
+ ['searchRadar'] = {
688
+ ['EWR Generic radar tower'] = {
689
+ ['name'] = {
690
+ ['NATO'] = 'EWR Generic radar tower',
691
+ },
692
+ },
693
+ },
694
+ ['harm_detection_chance'] = 60
695
+ }
696
+
697
+ end
698
+
699
+ IADSArray = {}
700
+ compteur = 0
701
+ mainRadioMenuForSkynet = MENU_MISSION:New("Skynet-IADS", nil )
702
+ addExtraSamTypeDB()
703
+ for index, skynetconfig in ipairs(SkynetConfig) do
704
+ if ( skynetconfig.enable ) then
705
+ compteur = compteur + 1
706
+ env.info('Ajout menu radio pour IADS Skynet : '.. skynetconfig.name..'...')
707
+ IADSArray[compteur] = {
708
+ customconfig = skynetconfig,
709
+ IADSObject = nil,
710
+ spawned = {
711
+ easy = false,
712
+ medium = false,
713
+ hard = false,
714
+ extreme = false,
715
+ },
716
+ IADSNetworkRunning = false,
717
+ radioMenuForSkynet = MENU_MISSION:New(skynetconfig.name , mainRadioMenuForSkynet)
718
+ }
719
+ manageIADSNetworkMenu(IADSArray[compteur].radioMenuForSkynet, skynetconfig, compteur)
720
+ end
721
+ end