@jtff/miztemplate-lib 3.10.13 → 4.0.0
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.
- package/lua/lib/HoundElint.lua +11423 -11415
- package/lua/lib/Moose_.lua +26495 -35921
- package/lua/src/010-root_menus.lua +4 -3
- package/lua/src/020-mission_functions.lua +807 -217
- package/lua/src/110-set_clients.lua +53 -43
- package/lua/src/115-airbases.lua +191 -0
- package/lua/src/120-tankers.lua +577 -461
- package/lua/src/130-airboss.lua +1982 -440
- package/lua/src/150-awacs.lua +541 -445
- package/lua/src/160-atis.lua +136 -73
- package/lua/src/170-cap_zone_training.lua +176 -73
- package/lua/src/172-cap_zone_war.lua +383 -226
- package/lua/src/173-fox_zone_training.lua +142 -67
- package/lua/src/174-qra-scenario.lua +417 -362
- package/lua/src/176-random_air_traffic.lua +101 -12
- package/lua/src/178-training-intercept.lua +312 -261
- package/lua/src/180-logistics.lua +2 -2
- package/lua/src/190-ranges.lua +104 -37
- package/lua/src/191-sams.lua +4 -4
- package/lua/src/193-training_ranges.lua +2 -2
- package/lua/src/195-reaper-ondemand.lua +29 -29
- package/lua/src/196-fac_ranges.lua +2 -2
- package/lua/src/197-elint-ondemand.lua +53 -53
- package/lua/src/199-skynet.lua +55 -55
- package/package.json +1 -1
- package/scripts/inject-scripts.js +3 -31
- package/lua/src/135-pedro.lua +0 -21
- package/lua/src/140-beacons.lua +0 -19
|
@@ -2,42 +2,46 @@
|
|
|
2
2
|
-- * Mission functions *
|
|
3
3
|
-- *****************************************************************************
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
--
|
|
7
6
|
-- Generic Spawn object functions
|
|
8
7
|
--
|
|
9
8
|
env.info('JTFF-SHAREDLIB: shared library loading...')
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
{ name = "trace", color = "\27[34m", },
|
|
13
|
-
{ name = "debug", color = "\27[36m", },
|
|
14
|
-
{ name = "info", color = "\27[32m", },
|
|
15
|
-
{ name = "warn", color = "\27[33m", },
|
|
16
|
-
{ name = "error", color = "\27[31m", },
|
|
17
|
-
{ name = "fatal", color = "\27[35m", },
|
|
10
|
+
Log_modes = {
|
|
11
|
+
{ name = "trace", color = "\27[34m", verbosity = 10},
|
|
12
|
+
{ name = "debug", color = "\27[36m", verbosity = 5},
|
|
13
|
+
{ name = "info", color = "\27[32m", verbosity = 1},
|
|
14
|
+
{ name = "warn", color = "\27[33m", verbosity = 0},
|
|
15
|
+
{ name = "error", color = "\27[31m", verbosity = 0},
|
|
16
|
+
{ name = "fatal", color = "\27[35m", verbosity = 0},
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
for i, v in ipairs(
|
|
21
|
-
|
|
18
|
+
Log_levels = {}
|
|
19
|
+
for i, v in ipairs(Log_modes) do
|
|
20
|
+
Log_levels[v.name] = i
|
|
22
21
|
end
|
|
23
22
|
JTFF_LOGLEVEL = 'info'
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
for
|
|
24
|
+
JTFF_verbosity_levels = {}
|
|
25
|
+
for i, v in ipairs(Log_modes) do
|
|
26
|
+
JTFF_verbosity_levels[v.name] = v.verbosity
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Jtff_log = {}
|
|
30
|
+
for index, mode in ipairs(Log_modes) do
|
|
27
31
|
local nameupper = mode.name:upper()
|
|
28
|
-
|
|
32
|
+
Jtff_log[mode.name] = function(message, category)
|
|
29
33
|
-- Return early if we're below the log level
|
|
30
|
-
if index <
|
|
34
|
+
if index < Log_levels[JTFF_LOGLEVEL] then
|
|
31
35
|
return
|
|
32
36
|
end
|
|
33
37
|
env.info(string.format("[JTFF-%s]--%s-- %s", mode.name, category, message))
|
|
34
38
|
end
|
|
35
39
|
end
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
Use_jtff_sound_mod = false
|
|
38
42
|
|
|
39
43
|
if (not(FunkmanConfig)) then
|
|
40
|
-
|
|
44
|
+
Jtff_log.error(string.format("Local Funkman Bot config not specified ! Initializing empty values for Funkman"), "Initialization")
|
|
41
45
|
FunkmanConfig = {
|
|
42
46
|
ip= "127.0.0.1",
|
|
43
47
|
port = 10042,
|
|
@@ -45,7 +49,7 @@ if (not(FunkmanConfig)) then
|
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
if (not(SRSConfig)) then
|
|
48
|
-
|
|
52
|
+
Jtff_log.error(string.format("Local SRS config not specified ! Initializing empty values for SRS"), "Initialization")
|
|
49
53
|
SRSConfig= {
|
|
50
54
|
port = 5002,
|
|
51
55
|
path = "C:/Program Files/DCS-SimpleRadio-Standalone/ExternalAudio",
|
|
@@ -53,10 +57,10 @@ if (not(SRSConfig)) then
|
|
|
53
57
|
}
|
|
54
58
|
end
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
SpawnStandardDelay = 15
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
Jtff_sead = SEAD:New({})
|
|
63
|
+
Jtff_map_marker = {}
|
|
60
64
|
|
|
61
65
|
AAMAxRange = {
|
|
62
66
|
MAX_RANGE = 0,
|
|
@@ -70,21 +74,22 @@ if (pcall(
|
|
|
70
74
|
function ()
|
|
71
75
|
dofile(lfs.writedir() .. 'Scripts/net/DCSServerBot/DCSServerBot.lua')
|
|
72
76
|
end)) then
|
|
73
|
-
|
|
77
|
+
Jtff_log.debug(string.format("DCSServerBot present on server ! Including NetLibrary..."), "Initialization")
|
|
78
|
+
Jtff_dcsbot = dcsbot
|
|
74
79
|
else
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
Jtff_log.error(string.format("DCSServerBot NOT present on server ! Preventing use of it..."), "Initialization")
|
|
81
|
+
Jtff_dcsbot = nil
|
|
77
82
|
end
|
|
78
83
|
|
|
79
|
-
function
|
|
80
|
-
status = not BASE:GetState(group, "isImmortal")
|
|
81
|
-
|
|
84
|
+
function SwitchGroupImmortalStatus(group)
|
|
85
|
+
local status = not BASE:GetState(group, "isImmortal")
|
|
86
|
+
Jtff_log.info(string.format("switch group %s to immortal status %s", group:GetName(), tostring(status)), "GENERAL")
|
|
82
87
|
group:SetCommandImmortal(status)
|
|
83
88
|
BASE:SetState(group, "isImmortal", status)
|
|
84
89
|
MESSAGE:NewType("Immortal status of your group : " .. tostring(status) , MESSAGE.Type.Update):ToGroup(group)
|
|
85
90
|
end
|
|
86
91
|
|
|
87
|
-
function
|
|
92
|
+
function SwitchGroupAirbossSubtitlesStatus(group)
|
|
88
93
|
for index, airbossObject in ipairs(AIRBOSSArray) do
|
|
89
94
|
for playerindex, player in ipairs(group:GetPlayerUnits()) do
|
|
90
95
|
airbossObject:_SubtitlesOnOff(player:Name())
|
|
@@ -92,7 +97,7 @@ function switchGroupAirbossSubtitlesStatus(group)
|
|
|
92
97
|
end
|
|
93
98
|
end
|
|
94
99
|
|
|
95
|
-
function
|
|
100
|
+
function Give_bra_of_air_group(param)
|
|
96
101
|
local target_group = param[1]
|
|
97
102
|
local client_group = param[2]
|
|
98
103
|
local settings = param[3]
|
|
@@ -104,7 +109,7 @@ function give_bra_of_air_group(param)
|
|
|
104
109
|
)
|
|
105
110
|
end
|
|
106
111
|
|
|
107
|
-
function
|
|
112
|
+
function Give_heading_speed(param)
|
|
108
113
|
local target_group = param[1]
|
|
109
114
|
local settings = param[2]
|
|
110
115
|
local heading_target = target_group:GetHeading()
|
|
@@ -124,16 +129,18 @@ function give_heading_speed(param)
|
|
|
124
129
|
)
|
|
125
130
|
end
|
|
126
131
|
|
|
127
|
-
function
|
|
132
|
+
function TankerStatusMessage(tanker, PlayerUnit, PlayerGroup)
|
|
128
133
|
local client = CLIENT:Find(PlayerUnit:GetDCSObject())
|
|
129
134
|
local setting = _DATABASE:GetPlayerSettings(client:GetPlayerName())
|
|
130
135
|
|
|
131
|
-
local tankerrefuelsystemName = "
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
local tankerrefuelsystemName = "PROBE_AND_DROGUE"
|
|
137
|
+
|
|
138
|
+
local isrefuelable, playerrefuelsystem=PlayerUnit:IsRefuelable()
|
|
139
|
+
if ((playerrefuelsystem or 0) == 0) and isrefuelable then
|
|
140
|
+
tankerrefuelsystemName = "BOOM_AND_RECEPTACLE"
|
|
134
141
|
end
|
|
135
|
-
local braa_message =
|
|
136
|
-
local aspect_message =
|
|
142
|
+
local braa_message = Give_bra_of_air_group({tanker:GetGroup(), PlayerGroup, setting})
|
|
143
|
+
local aspect_message = Give_heading_speed({tanker:GetGroup(), setting})
|
|
137
144
|
local fuelState = string.format("%s Lbs", tanker:GetTemplateFuel() * 2.205)
|
|
138
145
|
if setting:IsMetric() then
|
|
139
146
|
fuelState = string.format("%s Kg", tanker:GetTemplateFuel())
|
|
@@ -142,35 +149,20 @@ function tankerStatusMessage(tanker, PlayerUnit, PlayerGroup)
|
|
|
142
149
|
local timeInTheAir = 0
|
|
143
150
|
local timeLeftInTheAir = 0
|
|
144
151
|
local timeLeftString = "Time left : "
|
|
145
|
-
local groupName = tanker:
|
|
146
|
-
for index, value in pairs(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
timeLeftInTheAir = value.customconfig.missionmaxduration * 60 - timeInTheAir
|
|
151
|
-
if (UTILS.SecondsToClock(timeLeftInTheAir, true) ~= nil) then
|
|
152
|
-
timeLeftString = timeLeftString .. UTILS.SecondsToClock(timeLeftInTheAir, true)
|
|
153
|
-
end
|
|
154
|
-
jtff_log.debug(string.format("%s found in %s, time in the air : %i sec, time left %i sec",
|
|
155
|
-
value.tanker.GroupName, groupName, timeInTheAir, timeLeftInTheAir), "TANKER")
|
|
156
|
-
else
|
|
157
|
-
jtff_log.warn(string.format("%s not found in %s", value.tanker.GroupName, groupName),"TANKER")
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
for index, value in pairs(tankersOnDemandArray) do
|
|
162
|
-
if( value ~= nil) then
|
|
163
|
-
jtff_log.info(string.format("%s spawned in tankersOnDemandArray", value:GetName()),"TANKER")
|
|
164
|
-
if (string.find(groupName, value:GetName(), 1, true) ~= nil) then
|
|
152
|
+
local groupName = tanker:GetCallsign()
|
|
153
|
+
for index, value in pairs(TankersArray or {}) do
|
|
154
|
+
if( type(value) ~= 'nil') then
|
|
155
|
+
Jtff_log.info(string.format("%s-%d-1 is in TankersArray", value.customconfig.callsign.name, value.customconfig.callsign.number),"TANKER")
|
|
156
|
+
if (string.find(groupName, string.format("%s-%d", value.customconfig.callsign.name, value.customconfig.callsign.number), 1, true) ~= nil) then
|
|
165
157
|
timeInTheAir = timer.getAbsTime() - value.spawnAbsTime
|
|
166
158
|
timeLeftInTheAir = value.missionmaxduration * 60 - timeInTheAir
|
|
167
159
|
if (UTILS.SecondsToClock(timeLeftInTheAir, true) ~= nil) then
|
|
168
160
|
timeLeftString = timeLeftString .. UTILS.SecondsToClock(timeLeftInTheAir, true)
|
|
169
161
|
end
|
|
170
|
-
|
|
162
|
+
Jtff_log.debug(string.format("%s found in %s, time in the air : %i sec, time left %i sec",
|
|
171
163
|
value:GetName(), groupName, timeInTheAir, timeLeftInTheAir),"TANKER")
|
|
172
164
|
else
|
|
173
|
-
|
|
165
|
+
Jtff_log.warn(string.format("%s not found in %s", value:GetName(), groupName),"TANKER")
|
|
174
166
|
end
|
|
175
167
|
end
|
|
176
168
|
end
|
|
@@ -181,7 +173,7 @@ function tankerStatusMessage(tanker, PlayerUnit, PlayerGroup)
|
|
|
181
173
|
MESSAGE:NewType(message, MESSAGE.Type.Overview):ToGroup(PlayerGroup)
|
|
182
174
|
end
|
|
183
175
|
|
|
184
|
-
function
|
|
176
|
+
function GetNearestTankerfromPlayerUnit(PlayerUnit, Radius)
|
|
185
177
|
Radius=UTILS.NMToMeters(Radius or 50)
|
|
186
178
|
|
|
187
179
|
local isrefuelable, playerrefuelsystem=PlayerUnit:IsRefuelable()
|
|
@@ -212,14 +204,14 @@ function getNearestTankerfromPlayerUnit(PlayerUnit, Radius)
|
|
|
212
204
|
return nil
|
|
213
205
|
end
|
|
214
206
|
|
|
215
|
-
function
|
|
216
|
-
local tanker =
|
|
207
|
+
function FindNearestTanker(PlayerUnit, PlayerGroup, Radius)
|
|
208
|
+
local tanker = GetNearestTankerfromPlayerUnit(PlayerUnit)
|
|
217
209
|
if (type(tanker) ~= "nil") then
|
|
218
|
-
|
|
210
|
+
TankerStatusMessage(tanker, PlayerUnit, PlayerGroup)
|
|
219
211
|
end
|
|
220
212
|
end
|
|
221
213
|
|
|
222
|
-
function
|
|
214
|
+
function FindAllTanker(PlayerUnit, PlayerGroup, Radius)
|
|
223
215
|
|
|
224
216
|
Radius=UTILS.NMToMeters(Radius or 50)
|
|
225
217
|
|
|
@@ -239,7 +231,7 @@ function findAllTanker(PlayerUnit, PlayerGroup, Radius)
|
|
|
239
231
|
coalition == unit:GetCoalition() and
|
|
240
232
|
unit:IsAlive() then
|
|
241
233
|
tanker=unit
|
|
242
|
-
|
|
234
|
+
TankerStatusMessage(tanker, PlayerUnit, PlayerGroup)
|
|
243
235
|
end
|
|
244
236
|
end
|
|
245
237
|
end
|
|
@@ -247,7 +239,7 @@ function findAllTanker(PlayerUnit, PlayerGroup, Radius)
|
|
|
247
239
|
end
|
|
248
240
|
|
|
249
241
|
function NearestTankerInfo(param)
|
|
250
|
-
|
|
242
|
+
FindNearestTanker(
|
|
251
243
|
param[1],
|
|
252
244
|
param[2],
|
|
253
245
|
200
|
|
@@ -255,10 +247,10 @@ function NearestTankerInfo(param)
|
|
|
255
247
|
end
|
|
256
248
|
|
|
257
249
|
function AllTankersInfo(param)
|
|
258
|
-
|
|
250
|
+
FindAllTanker(param[1],param[2], 200)
|
|
259
251
|
end
|
|
260
252
|
|
|
261
|
-
function
|
|
253
|
+
function TaskTankerEscort(param)
|
|
262
254
|
local recoveryTankerObject = param[1]
|
|
263
255
|
local EscortGroup = param[2]
|
|
264
256
|
EscortGroup:OptionAlarmStateRed()
|
|
@@ -295,10 +287,10 @@ function taskTankerEscort(param)
|
|
|
295
287
|
)
|
|
296
288
|
}
|
|
297
289
|
)
|
|
298
|
-
|
|
290
|
+
Jtff_log.info('Escort group spawned : '.. EscortGroup.GroupName..'. Escorting '..recoveryTankerObject.tanker.GroupName,"TANKER")
|
|
299
291
|
end
|
|
300
292
|
|
|
301
|
-
function
|
|
293
|
+
function TaskGroupEscort(param)
|
|
302
294
|
local GroupToEscortObject = param[1]
|
|
303
295
|
local EscortingGroup = param[2]
|
|
304
296
|
EscortingGroup:OptionAlarmStateRed()
|
|
@@ -335,10 +327,10 @@ function taskGroupEscort(param)
|
|
|
335
327
|
)
|
|
336
328
|
}
|
|
337
329
|
)
|
|
338
|
-
|
|
330
|
+
Jtff_log.info('Escort group spawned : '.. EscortingGroup.GroupName..'. Escorting '.. GroupToEscortObject.GroupName,"GENERAL")
|
|
339
331
|
end
|
|
340
332
|
|
|
341
|
-
function
|
|
333
|
+
function SpawnRecoveryTankerEscort(escortSpawnObject,customconfig)
|
|
342
334
|
if (customconfig.airspawn) then
|
|
343
335
|
return escortSpawnObject
|
|
344
336
|
:SpawnFromCoordinate(UNIT:FindByName(customconfig.baseUnit):GetCoordinate():SetAltitude(UTILS.FeetToMeters(customconfig.altitude)))
|
|
@@ -352,7 +344,7 @@ function LeaveRecovery(objAirboss)
|
|
|
352
344
|
local shipID = UNIT:FindByName(objAirboss.carrier:Name()):GetDCSObject():getID()
|
|
353
345
|
end
|
|
354
346
|
|
|
355
|
-
function
|
|
347
|
+
function ResetRecoveryTanker(recoveryTankerObject)
|
|
356
348
|
recoveryTankerObject:SetRespawnOnOff(true)
|
|
357
349
|
recoveryTankerObject.tanker:Destroy()
|
|
358
350
|
recoveryTankerObject:SetRespawnOnOff(recoveryTankerObject.customconfig.autorespawn)
|
|
@@ -362,37 +354,28 @@ function resetRecoveryTanker(recoveryTankerObject)
|
|
|
362
354
|
end
|
|
363
355
|
end
|
|
364
356
|
|
|
365
|
-
function
|
|
366
|
-
local GroupPlane, Index = objSpawn:GetFirstAliveGroup()
|
|
367
|
-
while GroupPlane ~= nil do
|
|
368
|
-
-- Do actions with the GroupPlane object.
|
|
369
|
-
GroupPlane:Destroy(true)
|
|
370
|
-
GroupPlane, Index = objSpawn:GetNextAliveGroup( Index )
|
|
371
|
-
end
|
|
372
|
-
end
|
|
373
|
-
|
|
374
|
-
function getMaxThreatUnit(setUnits)
|
|
357
|
+
function GetMaxThreatUnit(setUnits)
|
|
375
358
|
local setUnitsSorted = SET_UNIT:New()
|
|
376
359
|
setUnits:ForEachUnitPerThreatLevel(10, 0, function(unit)
|
|
377
360
|
setUnitsSorted:AddUnit(unit)
|
|
378
361
|
end)
|
|
379
|
-
|
|
362
|
+
Jtff_log.debug(string.format("Max priority unit : %s", setUnitsSorted:GetFirst():GetName()), "GENERAL")
|
|
380
363
|
return setUnitsSorted:GetFirst()
|
|
381
364
|
end
|
|
382
365
|
|
|
383
|
-
function
|
|
366
|
+
function DestroyGroup(group_name)
|
|
384
367
|
local set_group_alive = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
|
|
385
368
|
set_group_alive:ForEachGroupAlive(
|
|
386
369
|
function(group_alive)
|
|
387
|
-
|
|
388
|
-
if (
|
|
389
|
-
COORDINATE:RemoveMark(
|
|
370
|
+
Jtff_log.info(string.format("Group %s just removed", group_alive:GetName()),"GENERAL")
|
|
371
|
+
if (Jtff_map_marker[group_alive:GetName()]) then
|
|
372
|
+
COORDINATE:RemoveMark(Jtff_map_marker[group_alive:GetName()])
|
|
390
373
|
end
|
|
391
374
|
group_alive:Destroy()
|
|
392
375
|
end )
|
|
393
376
|
end
|
|
394
377
|
|
|
395
|
-
function
|
|
378
|
+
function DestroyStatic(staticToDelete, subRangeName, index)
|
|
396
379
|
if (staticToDelete.name ~= nil) then
|
|
397
380
|
local staticNameToDelete = string.format("%s", staticToDelete.name)
|
|
398
381
|
if (subRangeName ~= nil and index ~= nil) then
|
|
@@ -400,28 +383,28 @@ function destroyStatic(staticToDelete, subRangeName, index)
|
|
|
400
383
|
end
|
|
401
384
|
local staticUnitToDelete = STATIC:FindByName(staticNameToDelete, false)
|
|
402
385
|
if (staticUnitToDelete ~= nil) then
|
|
403
|
-
|
|
386
|
+
Jtff_log.info(string.format("Delete static %s", staticUnitToDelete:GetDCSObject():getName()),"GENERAL")
|
|
404
387
|
staticUnitToDelete:Destroy()
|
|
405
388
|
end
|
|
406
389
|
elseif (staticToDelete.type ~= nil and staticToDelete.category ~= nil and index ~= nil) then
|
|
407
390
|
local staticNameToDelete = string.format("%s_%s_%i", subRangeName, staticToDelete.type, index)
|
|
408
391
|
local staticUnitToDelete = STATIC:FindByName(staticNameToDelete, false)
|
|
409
392
|
if (staticUnitToDelete ~= nil) then
|
|
410
|
-
|
|
393
|
+
Jtff_log.info(string.format("Delete Static %s", staticUnitToDelete:GetDCSObject():getName()),"GENERAL")
|
|
411
394
|
staticUnitToDelete:Destroy()
|
|
412
395
|
end
|
|
413
396
|
else
|
|
414
|
-
|
|
397
|
+
Jtff_log.error(string.format("Static to delete has no name or type!"), "GENERAL")
|
|
415
398
|
end
|
|
416
399
|
end
|
|
417
400
|
|
|
418
|
-
function
|
|
401
|
+
function DestroyStatics(staticsToDelete, subRangeName)
|
|
419
402
|
for index, staticToDelete in ipairs(staticsToDelete) do
|
|
420
|
-
|
|
403
|
+
DestroyStatic(staticToDelete, subRangeName, index)
|
|
421
404
|
end
|
|
422
405
|
end
|
|
423
406
|
|
|
424
|
-
function
|
|
407
|
+
function DeleteSubRangeUnits(param)
|
|
425
408
|
--parameters :
|
|
426
409
|
-- 1 : groups to be destroyed
|
|
427
410
|
-- 2 : Root range config Object
|
|
@@ -437,43 +420,43 @@ function deleteSubRangeUnits(param)
|
|
|
437
420
|
local staticsToDelete = subRangeConfig.staticsToSpawn
|
|
438
421
|
if (subRangeConfig.groupsToSpawn ~= nil) then
|
|
439
422
|
for i = 1, #groupsToSpawn do
|
|
440
|
-
|
|
423
|
+
DestroyGroup(groupsToSpawn[i])
|
|
441
424
|
end
|
|
442
425
|
else
|
|
443
|
-
|
|
426
|
+
Jtff_log.warn(string.format("No Groups in %s", subRangeName), "RANGE")
|
|
444
427
|
end
|
|
445
428
|
if (subRangeConfig.randomGroupsToSpawn ~= nil) then
|
|
446
429
|
local groupsToDestroy = subRangeConfig.randomGroupsToSpawn
|
|
447
430
|
for i = 1, #groupsToDestroy do
|
|
448
|
-
|
|
431
|
+
DestroyGroup(subRangeConfig.randomGroupsToSpawn[i])
|
|
449
432
|
end
|
|
450
433
|
else
|
|
451
|
-
|
|
434
|
+
Jtff_log.warn(string.format("No random*W Groups in %s", subRangeName), "RANGE")
|
|
452
435
|
end
|
|
453
436
|
|
|
454
437
|
if (staticsToDelete ~= nil)then
|
|
455
|
-
|
|
438
|
+
DestroyStatics(staticsToDelete, subRangeName)
|
|
456
439
|
else
|
|
457
|
-
|
|
440
|
+
Jtff_log.warn(string.format("No static in %s", subRangeName), "RANGE")
|
|
458
441
|
end
|
|
459
442
|
|
|
460
443
|
MESSAGE:NewType(string.format("Remove the site : %s-%s", rangeConfig.name, subRangeConfig.name),
|
|
461
444
|
MESSAGE.Type.Information):ToBlue()
|
|
462
445
|
if (not(blnMute)) then
|
|
463
|
-
|
|
446
|
+
Sound2Bip:ToAll()
|
|
464
447
|
end
|
|
465
448
|
if radioCommandSubRange then
|
|
466
449
|
radioCommandSubRange:RemoveSubMenus()
|
|
467
|
-
|
|
450
|
+
AddSubRangeRadioMenus(radioCommandSubRange, rangeConfig, subRangeConfig)
|
|
468
451
|
end
|
|
469
452
|
end
|
|
470
453
|
|
|
471
|
-
function
|
|
454
|
+
function DeleteWholeRangeUnits(param)
|
|
472
455
|
local rangeConfig = param[1]
|
|
473
456
|
local rangeCoalitionMenu = param[2]
|
|
474
457
|
rangeCoalitionMenu:RemoveSubMenus()
|
|
475
458
|
if (rangeConfig.subRange ~= nil ) then
|
|
476
|
-
|
|
459
|
+
Sound2Bip:ToAll()
|
|
477
460
|
MESSAGE:NewType(string.format("Removing the whole site : %s", rangeConfig.name),
|
|
478
461
|
MESSAGE.Type.Information):ToCoalition(rangeConfig.benefit_coalition)
|
|
479
462
|
for subIndex, subRangeConfig in ipairs(rangeConfig.subRange) do
|
|
@@ -481,38 +464,38 @@ function deleteWholeRangeUnits(param)
|
|
|
481
464
|
if (subRangeConfig.subsubRange ~= nil) then
|
|
482
465
|
for subsubIndex, subsubRangeConfig in ipairs(subRangeConfig.subsubRange) do
|
|
483
466
|
local radioMenuSubSubRange = MENU_COALITION:New(rangeConfig.benefit_coalition, subsubRangeConfig.name, radioMenuSubRange)
|
|
484
|
-
|
|
467
|
+
DeleteSubRangeUnits({
|
|
485
468
|
subsubRangeConfig.groupsToSpawn,
|
|
486
469
|
rangeConfig,
|
|
487
470
|
subsubRangeConfig,
|
|
488
471
|
nil,
|
|
489
472
|
true
|
|
490
473
|
})
|
|
491
|
-
|
|
474
|
+
AddSubRangeRadioMenus(radioMenuSubSubRange, rangeConfig, subsubRangeConfig)
|
|
492
475
|
end
|
|
493
476
|
else
|
|
494
|
-
|
|
477
|
+
DeleteSubRangeUnits({
|
|
495
478
|
subRangeConfig.groupsToSpawn,
|
|
496
479
|
rangeConfig,
|
|
497
480
|
subRangeConfig,
|
|
498
481
|
nil,
|
|
499
482
|
true
|
|
500
483
|
})
|
|
501
|
-
|
|
484
|
+
AddSubRangeRadioMenus(radioMenuSubRange, rangeConfig, subRangeConfig)
|
|
502
485
|
end
|
|
503
486
|
end
|
|
504
487
|
end
|
|
505
488
|
AddWholeRangeCoalitionCommandMenus(rangeCoalitionMenu, rangeConfig)
|
|
506
489
|
end
|
|
507
490
|
|
|
508
|
-
function
|
|
491
|
+
function SetROE(param)
|
|
509
492
|
local groupsToSpawn = param[1]
|
|
510
493
|
local ROEvalue = param[2]
|
|
511
494
|
for groupIndex = 1, #groupsToSpawn do
|
|
512
495
|
local group_name = string.format("%s", groupsToSpawn[groupIndex])
|
|
513
496
|
local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
|
|
514
497
|
dcs_groups:ForEachGroupAlive(function(group_alive)
|
|
515
|
-
|
|
498
|
+
Jtff_log.info(string.format("SET ROE of group %s at %i", group_alive:GetName(), ROEvalue), "GENERAL")
|
|
516
499
|
if (ROEvalue ~= ENUMS.ROE.WeaponHold) then
|
|
517
500
|
group_alive:SetAIOn()
|
|
518
501
|
end
|
|
@@ -521,7 +504,7 @@ function setROE(param)
|
|
|
521
504
|
end
|
|
522
505
|
end
|
|
523
506
|
|
|
524
|
-
function
|
|
507
|
+
function SetAlarmState(param)
|
|
525
508
|
local groupsToSpawn = param[1]
|
|
526
509
|
local AlarmStateValue = param[2]
|
|
527
510
|
for groupIndex = 1, #groupsToSpawn do
|
|
@@ -530,27 +513,27 @@ function setAlarmState(param)
|
|
|
530
513
|
dcs_groups:ForEachGroupAlive(function(group_alive)
|
|
531
514
|
group_alive:SetAIOn()
|
|
532
515
|
if AlarmStateValue == ENUMS.AlarmState.Auto then
|
|
533
|
-
|
|
516
|
+
Jtff_log.info(string.format("SET Alarm State of group %s at AUTO", group_alive:GetName()),"GENERAL")
|
|
534
517
|
group_alive:OptionAlarmStateAuto()
|
|
535
518
|
elseif AlarmStateValue == ENUMS.AlarmState.Green then
|
|
536
|
-
|
|
519
|
+
Jtff_log.info(string.format("SET Alarm State of group %s at Green", group_alive:GetName()),"GENERAL")
|
|
537
520
|
group_alive:OptionAlarmStateGreen()
|
|
538
521
|
elseif AlarmStateValue == ENUMS.AlarmState.Red then
|
|
539
|
-
|
|
522
|
+
Jtff_log.info(string.format("SET Alarm State of group %s at Red", group_alive:GetName()),"GENERAL")
|
|
540
523
|
group_alive:OptionAlarmStateRed()
|
|
541
524
|
end
|
|
542
525
|
end)
|
|
543
526
|
end
|
|
544
527
|
end
|
|
545
528
|
|
|
546
|
-
function
|
|
529
|
+
function SetEngageAirWeapons(param)
|
|
547
530
|
local groupsToSpawn = param[1]
|
|
548
531
|
local value = param[2]
|
|
549
532
|
for groupIndex = 1, #groupsToSpawn do
|
|
550
533
|
local group_name = string.format("%s", groupsToSpawn[groupIndex])
|
|
551
534
|
local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
|
|
552
535
|
dcs_groups:ForEachGroupAlive(function(group_alive)
|
|
553
|
-
|
|
536
|
+
Jtff_log.info(string.format("SET Engage Air Weapons of group %s at %s", group_alive:GetName(), tostring(value)),"GENERAL")
|
|
554
537
|
if (value) then
|
|
555
538
|
group_alive:SetAIOn()
|
|
556
539
|
end
|
|
@@ -559,14 +542,14 @@ function setEngageAirWeapons(param)
|
|
|
559
542
|
end
|
|
560
543
|
end
|
|
561
544
|
|
|
562
|
-
function
|
|
545
|
+
function SmokeOnSubRange(param)
|
|
563
546
|
local groupsToSpawn = param[1]
|
|
564
547
|
local displayToCoalition = param[2]
|
|
565
548
|
for groupIndex = 1, #groupsToSpawn do
|
|
566
549
|
local group_name = string.format("%s", groupsToSpawn[groupIndex])
|
|
567
550
|
local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
|
|
568
551
|
dcs_groups:ForEachGroupAlive(function(group_alive)
|
|
569
|
-
|
|
552
|
+
Jtff_log.info(string.format("Smoke on group %s", group_alive:GetName()),"GENERAL")
|
|
570
553
|
local list_units = group_alive:GetUnits()
|
|
571
554
|
local set_units_red = SET_UNIT:New()
|
|
572
555
|
local set_units_blue = SET_UNIT:New()
|
|
@@ -577,14 +560,14 @@ function smokeOnSubRange(param)
|
|
|
577
560
|
end
|
|
578
561
|
end
|
|
579
562
|
if (set_units_red:CountAlive() > 0) then
|
|
580
|
-
local unit_red_to_smoke =
|
|
563
|
+
local unit_red_to_smoke = GetMaxThreatUnit(set_units_red)
|
|
581
564
|
if (unit_red_to_smoke) then
|
|
582
565
|
unit_red_to_smoke:SmokeRed()
|
|
583
566
|
MESSAGE:NewType(string.format("[%s] Red smoke on : %s", group_alive:GetName(),
|
|
584
567
|
unit_red_to_smoke:GetTypeName()), MESSAGE.Type.Overview):ToCoalition(displayToCoalition)
|
|
585
568
|
end
|
|
586
569
|
elseif (set_units_blue:CountAlive() > 0) then
|
|
587
|
-
local unit_blue_to_smoke =
|
|
570
|
+
local unit_blue_to_smoke = GetMaxThreatUnit(set_units_blue)
|
|
588
571
|
if (unit_blue_to_smoke) then
|
|
589
572
|
unit_blue_to_smoke:SmokeBlue()
|
|
590
573
|
MESSAGE:NewType(string.format("[%s] Blue smoke on : %s", group_alive:GetName(),
|
|
@@ -595,78 +578,78 @@ function smokeOnSubRange(param)
|
|
|
595
578
|
end
|
|
596
579
|
end
|
|
597
580
|
|
|
598
|
-
function
|
|
581
|
+
function GiveToClientGroupCoordinates(param)
|
|
599
582
|
local groupsToSpawn = param[1]
|
|
600
583
|
for i = 1, #groupsToSpawn do
|
|
601
584
|
local group_name = string.format("%s", groupsToSpawn[i])
|
|
602
|
-
|
|
585
|
+
Jtff_log.debug(string.format("Coordinates of all groups with name prefix %s", group_name),"GENERAL")
|
|
603
586
|
local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
|
|
604
|
-
|
|
587
|
+
Set_AllClients:ForEachClient(function(client)
|
|
605
588
|
if (client:IsActive()) then
|
|
606
|
-
|
|
589
|
+
Jtff_log.debug(string.format("For Client %s ", client:GetName()),"GENERAL")
|
|
607
590
|
local coordinate_txt = ""
|
|
608
591
|
dcs_groups:ForEachGroupAlive(function(group_alive)
|
|
609
|
-
|
|
592
|
+
Jtff_log.debug(string.format("Coordinates of the group %s", group_alive:GetName()),"GENERAL")
|
|
610
593
|
local coordinate = group_alive:GetCoordinate()
|
|
611
594
|
local setting = _DATABASE:GetPlayerSettings(client:GetPlayerName())
|
|
612
595
|
local coordinate_string = ""
|
|
613
596
|
if (setting:IsA2G_LL_DDM()) then
|
|
614
597
|
coordinate_string = coordinate:ToStringLLDDM(setting)
|
|
615
|
-
|
|
598
|
+
Jtff_log.debug(string.format("%s IsA2G_LL_DDM", client:GetName()),"GENERAL")
|
|
616
599
|
elseif (setting:IsA2G_MGRS()) then
|
|
617
600
|
coordinate_string = coordinate:ToStringMGRS(setting)
|
|
618
|
-
|
|
601
|
+
Jtff_log.debug(string.format("%s IsA2G_MGRS", client:GetName()),"GENERAL")
|
|
619
602
|
elseif (setting:IsA2G_LL_DMS()) then
|
|
620
603
|
coordinate_string = coordinate:ToStringLLDMS(setting)
|
|
621
|
-
|
|
604
|
+
Jtff_log.debug(string.format("%s IsA2G_LL_DMS", client:GetName()),"GENERAL")
|
|
622
605
|
elseif (setting:IsA2G_BR()) then
|
|
623
606
|
coordinate_string = coordinate:ToStringBR(client:GetCoordinate(), setting)
|
|
624
|
-
|
|
607
|
+
Jtff_log.debug(string.format("%s IsA2G_BR", client:GetName()),"GENERAL")
|
|
625
608
|
end
|
|
626
|
-
|
|
609
|
+
Jtff_log.debug(string.format("coordinate_txt [%s] : %s", group_alive:GetName(), coordinate_string),"GENERAL")
|
|
627
610
|
coordinate_txt = string.format("%s[%s] : %s\n", coordinate_txt, group_alive:GetName(),
|
|
628
611
|
coordinate_string)
|
|
629
612
|
end)
|
|
630
|
-
|
|
613
|
+
Jtff_log.debug(string.format("Message to Client %s : %s", client:GetName(), coordinate_txt),"GENERAL")
|
|
631
614
|
MESSAGE:NewType(coordinate_txt, MESSAGE.Type.Detailed):ToClient(client)
|
|
632
615
|
end
|
|
633
616
|
end)
|
|
634
617
|
end
|
|
635
618
|
end
|
|
636
619
|
|
|
637
|
-
function
|
|
620
|
+
function GiveListOfGroupsAliveInRange(param)
|
|
638
621
|
local groupsToSpawn = param[1]
|
|
639
622
|
local rangeConfig = param[2]
|
|
640
623
|
local subRangeConfig = param[3]
|
|
641
|
-
|
|
624
|
+
Jtff_log.debug(string.format("List of groups in range %s-%s", rangeConfig.name, subRangeConfig.name),"RANGE")
|
|
642
625
|
local message = string.format("Targets groups in Range %s-%s :", rangeConfig.name, subRangeConfig.name)
|
|
643
626
|
for i = 1, #groupsToSpawn do
|
|
644
627
|
local group_name = string.format("%s", groupsToSpawn[i])
|
|
645
628
|
local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
|
|
646
629
|
dcs_groups:ForEachGroupAlive(function(group_alive)
|
|
647
|
-
|
|
630
|
+
Jtff_log.debug(string.format("group %s", group_alive:GetName()),"RANGE")
|
|
648
631
|
message = string.format("%s %s | ", message, group_alive:GetName());
|
|
649
632
|
end)
|
|
650
633
|
end
|
|
651
|
-
|
|
634
|
+
Set_AllClients:ForEachClient(function(client)
|
|
652
635
|
if (client:IsActive()) then
|
|
653
636
|
MESSAGE:NewType(message, MESSAGE.Type.Information):ToClient(client)
|
|
654
637
|
end
|
|
655
638
|
end)
|
|
656
639
|
end
|
|
657
640
|
|
|
658
|
-
function
|
|
641
|
+
function GiveListOfUnitsAliveInGroup(param)
|
|
659
642
|
local groupsToSpawn = param[1]
|
|
660
643
|
local side = param[2]
|
|
661
644
|
local number_to_display = param[3]
|
|
662
645
|
for i = 1, #groupsToSpawn do
|
|
663
646
|
local group_name = string.format("%s", groupsToSpawn[i])
|
|
664
|
-
|
|
647
|
+
Jtff_log.debug(string.format("List of units of all groups with name prefix %s", group_name),"GENERAL")
|
|
665
648
|
local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
|
|
666
649
|
dcs_groups:ForEachGroupAlive(function(group_alive)
|
|
667
|
-
|
|
650
|
+
Jtff_log.debug(string.format("List of units of the group %s", group_alive:GetName()),"GENERAL")
|
|
668
651
|
local info_unit_header = string.format("Units list of the group [%s]:", group_name)
|
|
669
|
-
|
|
652
|
+
Set_AllClients:ForEachClient(function(client)
|
|
670
653
|
if (client:IsActive()) then
|
|
671
654
|
MESSAGE:NewType(info_unit_header, MESSAGE.Type.Overview):ToClient(client)
|
|
672
655
|
end
|
|
@@ -677,7 +660,7 @@ function giveListOfUnitsAliveInGroup(param)
|
|
|
677
660
|
local unit_tmp = list_units[index]
|
|
678
661
|
if (unit_tmp:IsAlive() and unit_tmp:GetCoalition() ~= side) then
|
|
679
662
|
set_units:AddUnit(unit_tmp)
|
|
680
|
-
|
|
663
|
+
Jtff_log.debug(string.format("Type : %s", unit_tmp:GetTypeName()),"GENERAL")
|
|
681
664
|
end
|
|
682
665
|
end
|
|
683
666
|
local increment = 0;
|
|
@@ -689,7 +672,7 @@ function giveListOfUnitsAliveInGroup(param)
|
|
|
689
672
|
local unit_coordinate_for_client = ""
|
|
690
673
|
local unit_altitude_for_client = 0
|
|
691
674
|
local unit_altitude_for_client_unit = ""
|
|
692
|
-
|
|
675
|
+
Set_AllClients:ForEachClient(function(client)
|
|
693
676
|
if (client:IsActive()) then
|
|
694
677
|
local setting = _DATABASE:GetPlayerSettings(client:GetPlayerName())
|
|
695
678
|
unit_coordinate_for_client = ""
|
|
@@ -723,17 +706,17 @@ function giveListOfUnitsAliveInGroup(param)
|
|
|
723
706
|
end
|
|
724
707
|
end
|
|
725
708
|
|
|
726
|
-
function
|
|
709
|
+
function MarkGroupOnMap(param)
|
|
727
710
|
local groupsToSpawn = param[1]
|
|
728
711
|
local side = param[2]
|
|
729
712
|
for index = 1, #groupsToSpawn do
|
|
730
713
|
local group_name = string.format("%s", groupsToSpawn[index])
|
|
731
|
-
|
|
714
|
+
Jtff_log.info(string.format("Mark on map all groups with name prefix %s", group_name),"MARK")
|
|
732
715
|
local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
|
|
733
716
|
dcs_groups:ForEachGroupAlive(function(group_alive)
|
|
734
|
-
|
|
717
|
+
Jtff_log.info(string.format("Mark on map the group %s", group_alive:GetName()),"MARK")
|
|
735
718
|
local coordinate = group_alive:GetCoordinate()
|
|
736
|
-
|
|
719
|
+
Jtff_map_marker[group_alive:GetName()] = coordinate:MarkToCoalition(group_alive:GetName(), side)
|
|
737
720
|
end)
|
|
738
721
|
end
|
|
739
722
|
end
|
|
@@ -749,7 +732,7 @@ function SpawnRangesDelay(param)
|
|
|
749
732
|
-- 7 : boolean for message warning
|
|
750
733
|
local rangeConfig = param[2]
|
|
751
734
|
local subRangeConfig = param[3]
|
|
752
|
-
local delay = param[4] or
|
|
735
|
+
local delay = param[4] or SpawnStandardDelay
|
|
753
736
|
local myfunc = param[5]
|
|
754
737
|
local sound_warning = true
|
|
755
738
|
if (type(param[6]) ~= "nil") then
|
|
@@ -760,7 +743,7 @@ function SpawnRangesDelay(param)
|
|
|
760
743
|
message_warning = param[7]
|
|
761
744
|
end
|
|
762
745
|
if ( sound_warning ) then
|
|
763
|
-
|
|
746
|
+
Sound2Bip:ToAll()
|
|
764
747
|
end
|
|
765
748
|
if ( message_warning ) then
|
|
766
749
|
MESSAGE:NewType(string.format("Warning, Range Units %s(%s) will spawn in %d sec", rangeConfig.name, subRangeConfig.name, delay), MESSAGE.Type.Update):ToAll()
|
|
@@ -778,7 +761,7 @@ function SpawnWholeRangesDelay(param)
|
|
|
778
761
|
-- 6 : boolean for message warning
|
|
779
762
|
local parentRangeMenu = param[1]
|
|
780
763
|
local rangeConfig = param[2]
|
|
781
|
-
local delay = param[3] or
|
|
764
|
+
local delay = param[3] or SpawnStandardDelay
|
|
782
765
|
local myfunc = param[4]
|
|
783
766
|
local sound_warning = true
|
|
784
767
|
if (type(param[5]) ~= "nil") then
|
|
@@ -790,7 +773,7 @@ function SpawnWholeRangesDelay(param)
|
|
|
790
773
|
end
|
|
791
774
|
parentRangeMenu:RemoveSubMenus()
|
|
792
775
|
if (rangeConfig.subRange) then
|
|
793
|
-
|
|
776
|
+
Sound2Bip:ToAll()
|
|
794
777
|
for subIndex, subRangeConfig in ipairs(rangeConfig.subRange) do
|
|
795
778
|
local radioMenuSubRange = MENU_COALITION:New(
|
|
796
779
|
rangeConfig.benefit_coalition,
|
|
@@ -834,7 +817,7 @@ function SpawnWholeRangesDelay(param)
|
|
|
834
817
|
rangeConfig.benefit_coalition,
|
|
835
818
|
"Delete whole Range",
|
|
836
819
|
parentRangeMenu,
|
|
837
|
-
|
|
820
|
+
DeleteWholeRangeUnits,
|
|
838
821
|
{
|
|
839
822
|
rangeConfig,
|
|
840
823
|
parentRangeMenu
|
|
@@ -863,28 +846,28 @@ function SpawnRanges(param)
|
|
|
863
846
|
local activateAI = subRangeConfig.AI
|
|
864
847
|
local redAlert = subRangeConfig.redAlert
|
|
865
848
|
|
|
866
|
-
|
|
849
|
+
Jtff_log.info(string.format("SpawnRanges : Range %s - Targets %s", rangeName, subRangeName),"RANGE")
|
|
867
850
|
if (staticsToSpawn ~= nil) then
|
|
868
851
|
for index, staticToSpawn in ipairs(staticsToSpawn) do
|
|
869
|
-
local spawnStatic =
|
|
870
|
-
if (staticToSpawn.name ~= nil) then
|
|
852
|
+
local spawnStatic = {}
|
|
853
|
+
if (type(staticToSpawn.name) ~= 'nil') then
|
|
871
854
|
local staticNameToSpawn = string.format("%s", staticToSpawn.name)
|
|
872
|
-
spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn)
|
|
855
|
+
spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn) or {}
|
|
873
856
|
if (staticToSpawn.coalition ~= nil) then
|
|
874
857
|
if (staticToSpawn.coalition == coalition.side.BLUE) then
|
|
875
|
-
spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.CJTF_BLUE)
|
|
858
|
+
spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.CJTF_BLUE) or {}
|
|
876
859
|
elseif (staticToSpawn.coalition == coalition.side.RED) then
|
|
877
|
-
spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.CJTF_RED)
|
|
860
|
+
spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.CJTF_RED) or {}
|
|
878
861
|
else
|
|
879
|
-
spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.UN_PEACEKEEPERS)
|
|
862
|
+
spawnStatic = SPAWNSTATIC:NewFromStatic(staticNameToSpawn, country.id.UN_PEACEKEEPERS) or {}
|
|
880
863
|
end
|
|
881
864
|
end
|
|
882
865
|
local x = staticToSpawn.x
|
|
883
866
|
local y = staticToSpawn.y
|
|
884
867
|
local heading = staticToSpawn.heading
|
|
885
868
|
local name = string.format("%s_%s_%i", subRangeName, staticNameToSpawn,index)
|
|
886
|
-
local static = spawnStatic:
|
|
887
|
-
|
|
869
|
+
local static = spawnStatic:SpawnFromCoordinate( COORDINATE:NewFromVec2( x, y ), heading, name )
|
|
870
|
+
Jtff_log.info(string.format("Static to spawn %s at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()),"RANGE")
|
|
888
871
|
elseif (staticToSpawn.type ~= nil and staticToSpawn.category ~= nil) then
|
|
889
872
|
local staticTypeToSpawn = string.format("%s", staticToSpawn.type)
|
|
890
873
|
local staticCategoryToSpawn = string.format("%s", staticToSpawn.category)
|
|
@@ -892,16 +875,16 @@ function SpawnRanges(param)
|
|
|
892
875
|
local y = staticToSpawn.y
|
|
893
876
|
--spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn)
|
|
894
877
|
if (staticToSpawn.type == "big_smoke" and staticToSpawn.category == "Effects") then
|
|
895
|
-
local landAltitude =
|
|
878
|
+
local landAltitude = COORDINATE:NewFromVec2( {x=x, y=y} ):GetLandHeight()
|
|
896
879
|
trigger.action.effectSmokeBig({ x = x, y = landAltitude, z = y}, staticToSpawn.effectPreset or 1, staticToSpawn.effectTransparency or 1)
|
|
897
880
|
else
|
|
898
|
-
if (staticToSpawn.coalition ~= nil) then
|
|
881
|
+
if type(staticToSpawn.coalition ~= 'nil') then
|
|
899
882
|
if (staticToSpawn.coalition == coalition.side.BLUE) then
|
|
900
|
-
spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.CJTF_BLUE)
|
|
883
|
+
spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.CJTF_BLUE) or {}
|
|
901
884
|
elseif (staticToSpawn.coalition == coalition.side.RED) then
|
|
902
|
-
spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.CJTF_RED)
|
|
885
|
+
spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.CJTF_RED) or {}
|
|
903
886
|
else
|
|
904
|
-
spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.UN_PEACEKEEPERS)
|
|
887
|
+
spawnStatic = SPAWNSTATIC:NewFromType(staticTypeToSpawn, staticCategoryToSpawn, country.id.UN_PEACEKEEPERS) or {}
|
|
905
888
|
end
|
|
906
889
|
end
|
|
907
890
|
local heading = staticToSpawn.heading
|
|
@@ -912,15 +895,15 @@ function SpawnRanges(param)
|
|
|
912
895
|
if (staticToSpawn.dead ~= nil) then
|
|
913
896
|
spawnStatic:InitDead(staticToSpawn.dead)
|
|
914
897
|
end
|
|
915
|
-
local static = spawnStatic:
|
|
916
|
-
|
|
898
|
+
local static = spawnStatic:SpawnFromCoordinate( COORDINATE:NewFromVec2( {x=x, y=y} ), heading, name )
|
|
899
|
+
Jtff_log.info(string.format("Static type to spawn %s at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()),"RANGE")
|
|
917
900
|
end
|
|
918
901
|
else
|
|
919
|
-
|
|
902
|
+
Jtff_log.warn(string.format("Static to spawn has no name or type!"),"RANGE")
|
|
920
903
|
end
|
|
921
904
|
end
|
|
922
905
|
else
|
|
923
|
-
|
|
906
|
+
Jtff_log.warn(string.format("No static in %s", subRangeName),"RANGE")
|
|
924
907
|
end
|
|
925
908
|
|
|
926
909
|
if (randomGroupsToSpawn ~= nil) then
|
|
@@ -940,14 +923,14 @@ function SpawnRanges(param)
|
|
|
940
923
|
|
|
941
924
|
if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
|
|
942
925
|
local spawnGroup = SPAWN:New(groupNameToSpawn)
|
|
943
|
-
|
|
926
|
+
Jtff_log.info(string.format("SPAWN %s", groupNameToSpawn), "RANGE")
|
|
944
927
|
local groupSpawning
|
|
945
928
|
if (subRangeConfig.spawnZone) then
|
|
946
929
|
groupSpawning = spawnGroup:SpawnInZone(ZONE:New(subRangeConfig.spawnZone),true)
|
|
947
930
|
else
|
|
948
931
|
groupSpawning = spawnGroup:Spawn()
|
|
949
932
|
end
|
|
950
|
-
|
|
933
|
+
MarkGroupOnMap({{groupNameToSpawn}, rangeConfig.benefit_coalition})
|
|
951
934
|
if (holdFire) then
|
|
952
935
|
groupSpawning:OptionROEHoldFire()
|
|
953
936
|
else
|
|
@@ -969,11 +952,11 @@ function SpawnRanges(param)
|
|
|
969
952
|
groupSpawning:OptionAlarmStateAuto()
|
|
970
953
|
end
|
|
971
954
|
if (string.find(groupNameToSpawn, "SAM") ~= nil) then
|
|
972
|
-
|
|
973
|
-
|
|
955
|
+
Jtff_sead:UpdateSet(groupNameToSpawn)
|
|
956
|
+
Jtff_log.info(string.format("SEAD for %s", groupNameToSpawn),"RANGE")
|
|
974
957
|
end
|
|
975
958
|
else
|
|
976
|
-
|
|
959
|
+
Jtff_log.error(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn),"RANGE")
|
|
977
960
|
end
|
|
978
961
|
end
|
|
979
962
|
end
|
|
@@ -983,7 +966,7 @@ function SpawnRanges(param)
|
|
|
983
966
|
local groupNameToSpawn = string.format("%s", groupsToSpawn[i])
|
|
984
967
|
if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
|
|
985
968
|
local spawnGroup = SPAWN:New(groupNameToSpawn)
|
|
986
|
-
|
|
969
|
+
Jtff_log.info(string.format("SPAWN %s", groupNameToSpawn), "RANGE")
|
|
987
970
|
local groupSpawning
|
|
988
971
|
if (subRangeConfig.spawnZone) then
|
|
989
972
|
groupSpawning = spawnGroup:SpawnInZone(ZONE:New(subRangeConfig.spawnZone),true)
|
|
@@ -1011,49 +994,49 @@ function SpawnRanges(param)
|
|
|
1011
994
|
groupSpawning:OptionAlarmStateAuto()
|
|
1012
995
|
end
|
|
1013
996
|
if (string.find(groupNameToSpawn, "SAM") ~= nil) then
|
|
1014
|
-
|
|
1015
|
-
|
|
997
|
+
Jtff_sead:UpdateSet(groupNameToSpawn)
|
|
998
|
+
Jtff_log.info(string.format("SEAD for %s", groupNameToSpawn),"RANGE")
|
|
1016
999
|
end
|
|
1017
1000
|
else
|
|
1018
|
-
|
|
1001
|
+
Jtff_log.error(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn),"RANGE")
|
|
1019
1002
|
end
|
|
1020
1003
|
end
|
|
1021
|
-
|
|
1004
|
+
MarkGroupOnMap({groupsToSpawn, rangeConfig.benefit_coalition})
|
|
1022
1005
|
else
|
|
1023
|
-
|
|
1006
|
+
Jtff_log.warn(string.format("No GROUP to spawn in subRange %s settings !",subRangeName),"RANGE")
|
|
1024
1007
|
end
|
|
1025
1008
|
|
|
1026
1009
|
|
|
1027
1010
|
radioCommandSubRange:RemoveSubMenus()
|
|
1028
1011
|
local CommandZoneDetroy = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Delete", radioCommandSubRange,
|
|
1029
|
-
|
|
1012
|
+
DeleteSubRangeUnits, {groupsToSpawn, rangeConfig, subRangeConfig, radioCommandSubRange, true})
|
|
1030
1013
|
local ROE = MENU_COALITION:New(rangeConfig.benefit_coalition, "ROE", radioCommandSubRange)
|
|
1031
|
-
local ROEOpenFire = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Open Fire", ROE,
|
|
1014
|
+
local ROEOpenFire = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Open Fire", ROE, SetROE,
|
|
1032
1015
|
{groupsToSpawn, ENUMS.ROE.OpenFire})
|
|
1033
|
-
local ROEReturnFire = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Return Fire", ROE,
|
|
1016
|
+
local ROEReturnFire = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Return Fire", ROE, SetROE,
|
|
1034
1017
|
{groupsToSpawn, ENUMS.ROE.ReturnFire})
|
|
1035
|
-
local ROEHoldFire = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Hold Fire", ROE,
|
|
1018
|
+
local ROEHoldFire = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Hold Fire", ROE, SetROE,
|
|
1036
1019
|
{groupsToSpawn, ENUMS.ROE.WeaponHold})
|
|
1037
1020
|
local AlarmState = MENU_COALITION:New(rangeConfig.benefit_coalition, "Alarm State", radioCommandSubRange)
|
|
1038
|
-
local AlarmStateAuto = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Auto", AlarmState,
|
|
1021
|
+
local AlarmStateAuto = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Auto", AlarmState, SetAlarmState,
|
|
1039
1022
|
{groupsToSpawn, ENUMS.AlarmState.Auto})
|
|
1040
|
-
local AlarmStateGreen = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Green", AlarmState,
|
|
1023
|
+
local AlarmStateGreen = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Green", AlarmState, SetAlarmState,
|
|
1041
1024
|
{groupsToSpawn, ENUMS.AlarmState.Green})
|
|
1042
|
-
local AlarmStateRed = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Red", AlarmState,
|
|
1025
|
+
local AlarmStateRed = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Red", AlarmState, SetAlarmState,
|
|
1043
1026
|
{groupsToSpawn, ENUMS.AlarmState.Red})
|
|
1044
1027
|
local Engage_Air_Weapons = MENU_COALITION:New(rangeConfig.benefit_coalition, "Engage Air Weapons", radioCommandSubRange)
|
|
1045
|
-
local Engage_Air_Weapons_True = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "True", Engage_Air_Weapons,
|
|
1028
|
+
local Engage_Air_Weapons_True = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "True", Engage_Air_Weapons, SetEngageAirWeapons,
|
|
1046
1029
|
{groupsToSpawn, true})
|
|
1047
|
-
local Engage_Air_Weapons_False = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "False", Engage_Air_Weapons,
|
|
1030
|
+
local Engage_Air_Weapons_False = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "False", Engage_Air_Weapons, SetEngageAirWeapons,
|
|
1048
1031
|
{groupsToSpawn, false})
|
|
1049
1032
|
local CommandZoneFumigene = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Smoke", radioCommandSubRange,
|
|
1050
|
-
|
|
1033
|
+
SmokeOnSubRange, {groupsToSpawn, rangeConfig.benefit_coalition})
|
|
1051
1034
|
local CommandZoneCoord = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Coordinates",
|
|
1052
|
-
radioCommandSubRange,
|
|
1035
|
+
radioCommandSubRange, GiveToClientGroupCoordinates, {groupsToSpawn})
|
|
1053
1036
|
local CommandZoneListGroup = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "List Groups",
|
|
1054
|
-
radioCommandSubRange,
|
|
1037
|
+
radioCommandSubRange, GiveListOfGroupsAliveInRange, {groupsToSpawn, rangeConfig, subRangeConfig})
|
|
1055
1038
|
local CommandZoneList = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "List Units",
|
|
1056
|
-
radioCommandSubRange,
|
|
1039
|
+
radioCommandSubRange, GiveListOfUnitsAliveInGroup, {groupsToSpawn, rangeConfig.benefit_coalition, 5})
|
|
1057
1040
|
MESSAGE:NewType(string.format("Units in range %s(%s) in place", rangeName, subRangeName), MESSAGE.Type.Information)
|
|
1058
1041
|
:ToCoalition(rangeConfig.benefit_coalition)
|
|
1059
1042
|
end
|
|
@@ -1075,12 +1058,12 @@ function SpawnFacRanges(param)
|
|
|
1075
1058
|
local groupsToSpawn = facSubRangeConfig.groupsToSpawn
|
|
1076
1059
|
local staticsToSpawn = facSubRangeConfig.staticsToSpawn
|
|
1077
1060
|
|
|
1078
|
-
|
|
1061
|
+
Jtff_log.info(string.format("SpawnFacRanges : %s-%s", facRangeName, facSubRangeName),"RANGE")
|
|
1079
1062
|
for i = 1, #groupsToSpawn do
|
|
1080
1063
|
local groupNameToSpawn = string.format("%s", groupsToSpawn[i])
|
|
1081
1064
|
if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
|
|
1082
1065
|
local spawnGroup = SPAWN:New(groupNameToSpawn)
|
|
1083
|
-
|
|
1066
|
+
Jtff_log.info(string.format("SPAWN %s", groupNameToSpawn),"RANGE")
|
|
1084
1067
|
local groupSpawning
|
|
1085
1068
|
if (facSubRangeConfig.spawnZone) then
|
|
1086
1069
|
groupSpawning = spawnGroup:SpawnInZone(ZONE:New(facSubRangeConfig.spawnZone),true)
|
|
@@ -1089,27 +1072,27 @@ function SpawnFacRanges(param)
|
|
|
1089
1072
|
end
|
|
1090
1073
|
groupSpawning:SetCommandInvisible(true)
|
|
1091
1074
|
else
|
|
1092
|
-
|
|
1075
|
+
Jtff_log.warn(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn),"RANGE")
|
|
1093
1076
|
end
|
|
1094
1077
|
end
|
|
1095
1078
|
|
|
1096
1079
|
radioCommandSubRange:RemoveSubMenus()
|
|
1097
1080
|
local CommandZoneDetroy = MENU_COALITION_COMMAND:New(facRangeConfig.benefit_coalition, "Delete", radioCommandSubRange,
|
|
1098
|
-
|
|
1081
|
+
DeleteSubRangeUnits, { groupsToSpawn, facRangeConfig, facSubRangeConfig, radioCommandSubRange, true})
|
|
1099
1082
|
local CommandZoneFumigene = MENU_COALITION_COMMAND:New(facRangeConfig.benefit_coalition, "Smoke", radioCommandSubRange,
|
|
1100
|
-
|
|
1083
|
+
SmokeOnSubRange, { groupsToSpawn, facRangeConfig.benefit_coalition})
|
|
1101
1084
|
local CommandZoneCoord = MENU_COALITION_COMMAND:New(facRangeConfig.benefit_coalition, "Coordinates",
|
|
1102
|
-
radioCommandSubRange,
|
|
1085
|
+
radioCommandSubRange, GiveToClientGroupCoordinates, {groupsToSpawn})
|
|
1103
1086
|
local CommandZoneListGroup = MENU_COALITION_COMMAND:New(facRangeConfig.benefit_coalition, "List Groups",
|
|
1104
|
-
radioCommandSubRange,
|
|
1087
|
+
radioCommandSubRange, GiveListOfGroupsAliveInRange, { groupsToSpawn, facRangeConfig, facSubRangeConfig })
|
|
1105
1088
|
local CommandZoneList = MENU_COALITION_COMMAND:New(facRangeConfig.benefit_coalition, "List Units",
|
|
1106
|
-
radioCommandSubRange,
|
|
1089
|
+
radioCommandSubRange, GiveListOfUnitsAliveInGroup, { groupsToSpawn, facRangeConfig.benefit_coalition, 5})
|
|
1107
1090
|
MESSAGE:NewType(string.format("FAC in range %s(%s) in place", facRangeName, facSubRangeName), MESSAGE.Type.Information)
|
|
1108
1091
|
:ToBlue()
|
|
1109
|
-
|
|
1092
|
+
MarkGroupOnMap({ groupsToSpawn, facRangeConfig.benefit_coalition})
|
|
1110
1093
|
end
|
|
1111
1094
|
|
|
1112
|
-
function
|
|
1095
|
+
function AddSubRangeRadioMenus(radioCommandSubRange, rangeConfig, subRangeConfig)
|
|
1113
1096
|
local RadioCommandAdd = MENU_COALITION_COMMAND:New(
|
|
1114
1097
|
rangeConfig.benefit_coalition,
|
|
1115
1098
|
"Spawn",
|
|
@@ -1119,8 +1102,8 @@ function addSubRangeRadioMenus(radioCommandSubRange, rangeConfig, subRangeConfig
|
|
|
1119
1102
|
radioCommandSubRange,
|
|
1120
1103
|
rangeConfig,
|
|
1121
1104
|
subRangeConfig,
|
|
1122
|
-
|
|
1123
|
-
|
|
1105
|
+
SpawnStandardDelay,
|
|
1106
|
+
AddSubRangeRadioMenus
|
|
1124
1107
|
}
|
|
1125
1108
|
)
|
|
1126
1109
|
end
|
|
@@ -1134,7 +1117,7 @@ function AddWholeRangeCoalitionCommandMenus(radioCommandRange, rangeConfig)
|
|
|
1134
1117
|
{
|
|
1135
1118
|
radioCommandRange,
|
|
1136
1119
|
rangeConfig,
|
|
1137
|
-
|
|
1120
|
+
SpawnStandardDelay,
|
|
1138
1121
|
AddWholeRangeCoalitionCommandMenus
|
|
1139
1122
|
}
|
|
1140
1123
|
)
|
|
@@ -1142,7 +1125,7 @@ function AddWholeRangeCoalitionCommandMenus(radioCommandRange, rangeConfig)
|
|
|
1142
1125
|
rangeConfig.benefit_coalition,
|
|
1143
1126
|
"Delete whole Range",
|
|
1144
1127
|
radioCommandRange,
|
|
1145
|
-
|
|
1128
|
+
DeleteWholeRangeUnits,
|
|
1146
1129
|
{
|
|
1147
1130
|
rangeConfig,
|
|
1148
1131
|
radioCommandRange
|
|
@@ -1161,7 +1144,7 @@ function AddFacFunction(radioCommandSubRange, facRangeConfig, facSubRangeConfig)
|
|
|
1161
1144
|
radioCommandSubRange,
|
|
1162
1145
|
facRangeConfig,
|
|
1163
1146
|
facSubRangeConfig,
|
|
1164
|
-
|
|
1147
|
+
SpawnStandardDelay,
|
|
1165
1148
|
AddFacFunction
|
|
1166
1149
|
}
|
|
1167
1150
|
)
|
|
@@ -1175,10 +1158,10 @@ function GetTableLng(tbl)
|
|
|
1175
1158
|
return getN
|
|
1176
1159
|
end
|
|
1177
1160
|
|
|
1178
|
-
function
|
|
1161
|
+
function GetSoundFilesPrefix()
|
|
1179
1162
|
local strPrefix
|
|
1180
1163
|
local lfs = require("lfs")
|
|
1181
|
-
if (
|
|
1164
|
+
if (Use_jtff_sound_mod) then
|
|
1182
1165
|
strPrefix = lfs.writedir() .. 'Sounds/JTFF-Missions/'
|
|
1183
1166
|
else
|
|
1184
1167
|
strPrefix = ""
|
|
@@ -1186,7 +1169,7 @@ function getSoundFilesPrefix()
|
|
|
1186
1169
|
return strPrefix
|
|
1187
1170
|
end
|
|
1188
1171
|
|
|
1189
|
-
function
|
|
1172
|
+
function SpawnStaticListWithUnitLink(layoutData, namePrefix, unitID, countryID)
|
|
1190
1173
|
for index, layoutObject in pairs(layoutData) do
|
|
1191
1174
|
local staticToSpawn = {
|
|
1192
1175
|
["name"] = namePrefix .. "-" .. index,
|
|
@@ -1209,10 +1192,605 @@ function spawnStaticListWithUnitLink(layoutData, namePrefix, unitID, countryID)
|
|
|
1209
1192
|
end
|
|
1210
1193
|
|
|
1211
1194
|
function ClientIsOnGround(client)
|
|
1212
|
-
|
|
1195
|
+
Jtff_log.trace(string.format("Client %s is tested if alive and OnGround", client:GetPlayer() or ""),"QRA")
|
|
1213
1196
|
return UNIT:Find(client:GetDCSObject()):IsAlive() and not(UNIT:Find(client:GetDCSObject()):InAir(true))
|
|
1214
1197
|
end
|
|
1215
1198
|
|
|
1199
|
+
--- find a #AIRWING object by its AirbaseName.
|
|
1200
|
+
-- @param #string airbaseName Airbase name.
|
|
1201
|
+
-- @return #AIRWING _airbase Found AIRWING object.
|
|
1202
|
+
-- @return #nil nil if no AIRWING object found.
|
|
1203
|
+
function FindAirwingByAirbaseName(airbaseName)
|
|
1204
|
+
if type(UNIT:FindByName(airbaseName)) ~= 'nil' then
|
|
1205
|
+
if type(AIRBOSSArray) ~= 'table' then
|
|
1206
|
+
return nil
|
|
1207
|
+
end
|
|
1208
|
+
for _key,_airboss in pairs(AIRBOSSArray) do
|
|
1209
|
+
if (_airboss.customconfig.carriername == airbaseName) then
|
|
1210
|
+
return _airboss.airwing
|
|
1211
|
+
end
|
|
1212
|
+
end
|
|
1213
|
+
end
|
|
1214
|
+
if type(AirbasesArray) ~= 'table' then
|
|
1215
|
+
return nil
|
|
1216
|
+
end
|
|
1217
|
+
for _key,_airbase in pairs(AirbasesArray) do
|
|
1218
|
+
if (_airbase.customconfig.name == airbaseName) then
|
|
1219
|
+
return _airbase.airwing
|
|
1220
|
+
end
|
|
1221
|
+
end
|
|
1222
|
+
return nil
|
|
1223
|
+
end
|
|
1224
|
+
|
|
1225
|
+
--- find a #AIRBOSS object by its alias.
|
|
1226
|
+
-- @param #string airbossUnitName Airboss unit name.
|
|
1227
|
+
-- @return #AIRBOSS value Found Airboss object.
|
|
1228
|
+
-- @return #nil nil if no Airboss object found.
|
|
1229
|
+
function FindAirbossByUnitName(airbossUnitName)
|
|
1230
|
+
if type(AIRBOSSArray) ~= 'table' then
|
|
1231
|
+
return nil
|
|
1232
|
+
end
|
|
1233
|
+
for key,value in pairs(AIRBOSSArray) do
|
|
1234
|
+
if (value.customconfig.carriername == airbossUnitName) then
|
|
1235
|
+
return value
|
|
1236
|
+
end
|
|
1237
|
+
end
|
|
1238
|
+
return nil
|
|
1239
|
+
end
|
|
1240
|
+
|
|
1241
|
+
--- find a #AIRBOSS object by its alias.
|
|
1242
|
+
-- @param #string airbossAlias Airboss alias.
|
|
1243
|
+
-- @return #AIRBOSS Found Airboss object.
|
|
1244
|
+
-- @return #nil if no Airboss object found.
|
|
1245
|
+
function FindAirbossByAlias(airbossAlias)
|
|
1246
|
+
if type(AIRBOSSArray) ~= 'table' then
|
|
1247
|
+
return nil
|
|
1248
|
+
end
|
|
1249
|
+
for index,value in pairs(AIRBOSSArray) do
|
|
1250
|
+
if (value.customconfig.alias == airbossAlias) then
|
|
1251
|
+
return value
|
|
1252
|
+
end
|
|
1253
|
+
end
|
|
1254
|
+
return nil
|
|
1255
|
+
end
|
|
1256
|
+
|
|
1257
|
+
-- @type AirwingConfig
|
|
1258
|
+
-- @field #string name Airwing name.
|
|
1259
|
+
-- @field #SquadronConfig[] squadrons Squadrons for the airwing.
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
--- Parse an Airwing config Object.
|
|
1263
|
+
-- @param #JsonObject config Config object to parse
|
|
1264
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
1265
|
+
-- @return #AirwingConfig airwingConfigJson Parsed Airwing object
|
|
1266
|
+
function ParseAirwingConfigJson(config, parser_name)
|
|
1267
|
+
local airwingConfigJson = {}
|
|
1268
|
+
-- **************************************************************************
|
|
1269
|
+
-- name
|
|
1270
|
+
-- **************************************************************************
|
|
1271
|
+
if type(config.name) == "string" then
|
|
1272
|
+
airwingConfigJson.name = config.name
|
|
1273
|
+
else
|
|
1274
|
+
Jtff_log.error("Airwing name is not a string, skipping airwing configuration", parser_name)
|
|
1275
|
+
return {}
|
|
1276
|
+
end
|
|
1277
|
+
-- **************************************************************************
|
|
1278
|
+
-- squadrons
|
|
1279
|
+
-- **************************************************************************
|
|
1280
|
+
if type(config.squadrons) == "table" then
|
|
1281
|
+
airwingConfigJson.squadrons = {}
|
|
1282
|
+
for _, _squadconfig in ipairs(config.squadrons) do
|
|
1283
|
+
table.insert(
|
|
1284
|
+
airwingConfigJson.squadrons,
|
|
1285
|
+
ParseSquadronConfigJson(_squadconfig, parser_name)
|
|
1286
|
+
)
|
|
1287
|
+
end
|
|
1288
|
+
else
|
|
1289
|
+
Jtff_log.error("Airwing squadrons is not a table, skipping airwing configuration", "AIRWING")
|
|
1290
|
+
config.squadrons = {}
|
|
1291
|
+
return config
|
|
1292
|
+
end
|
|
1293
|
+
return airwingConfigJson
|
|
1294
|
+
end
|
|
1295
|
+
|
|
1296
|
+
-- @type RadioConfig
|
|
1297
|
+
-- @field #number freq Frequency for the radio.
|
|
1298
|
+
-- @field #number modulation Modulation for the radio.
|
|
1299
|
+
-- @field #number power Radio power in Watts
|
|
1300
|
+
|
|
1301
|
+
--- Parse an Radio config Object.
|
|
1302
|
+
-- @param #JsonObject config Config object to parse
|
|
1303
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
1304
|
+
-- @return #RadioConfig radioConfigJson Parsed Radio object
|
|
1305
|
+
function ParseRadioConfigJson(config, parser_name)
|
|
1306
|
+
local radioConfigJson = {}
|
|
1307
|
+
local default_freq = 251.000
|
|
1308
|
+
local default_power = 100
|
|
1309
|
+
local default_modulation = radio.modulation.AM
|
|
1310
|
+
-- **************************************************************************
|
|
1311
|
+
-- freq
|
|
1312
|
+
-- **************************************************************************
|
|
1313
|
+
radioConfigJson.freq = config.freq or default_freq
|
|
1314
|
+
-- **************************************************************************
|
|
1315
|
+
-- modulation
|
|
1316
|
+
-- **************************************************************************
|
|
1317
|
+
radioConfigJson.modulation = config.modulation or default_modulation
|
|
1318
|
+
-- **************************************************************************
|
|
1319
|
+
-- power
|
|
1320
|
+
-- **************************************************************************
|
|
1321
|
+
radioConfigJson.power = config.power or default_power
|
|
1322
|
+
return radioConfigJson
|
|
1323
|
+
end
|
|
1324
|
+
|
|
1325
|
+
-- @type tacanConfig
|
|
1326
|
+
-- @field #number channel Channel for the TACAN.
|
|
1327
|
+
-- @field #string morse Morse code for the TACAN.
|
|
1328
|
+
-- @field #string band Band for the TACAN.
|
|
1329
|
+
|
|
1330
|
+
--- Parse an TACAN config Object.
|
|
1331
|
+
-- @param #JsonObject config Config object to parse
|
|
1332
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
1333
|
+
-- @return #tacanConfig tacanConfigJson Parsed Radio object
|
|
1334
|
+
function ParseTacanConfigJson(config, parser_name)
|
|
1335
|
+
local tacanConfigJson = {}
|
|
1336
|
+
local default_channel = 100
|
|
1337
|
+
local default_morse = 'TEX'
|
|
1338
|
+
local default_band = 'Y'
|
|
1339
|
+
if type(config) == "table" then
|
|
1340
|
+
-- **********************************************************************
|
|
1341
|
+
-- channel
|
|
1342
|
+
-- **********************************************************************
|
|
1343
|
+
tacanConfigJson.channel = config.channel or default_channel
|
|
1344
|
+
-- **************************************************************************
|
|
1345
|
+
-- morse
|
|
1346
|
+
-- **************************************************************************
|
|
1347
|
+
tacanConfigJson.morse = config.morse or default_morse
|
|
1348
|
+
-- **************************************************************************
|
|
1349
|
+
-- band
|
|
1350
|
+
-- **************************************************************************
|
|
1351
|
+
tacanConfigJson.band = config.band or default_band
|
|
1352
|
+
else
|
|
1353
|
+
Jtff_log.error("TACAN config is not a table, skipping TACAN configuration", parser_name)
|
|
1354
|
+
return {}
|
|
1355
|
+
end
|
|
1356
|
+
return tacanConfigJson
|
|
1357
|
+
end
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
-- @type SquadronConfig
|
|
1361
|
+
-- @field #string name Squadron name.
|
|
1362
|
+
-- @field #number fuellowthreshold Low Fuel threshold in percent.
|
|
1363
|
+
-- @field #boolean lowfuelrtb Enable Low Fuel RTB.
|
|
1364
|
+
-- @field #number grouping Grouping for the squadron.
|
|
1365
|
+
-- @field #number modex Modex for the squadron.
|
|
1366
|
+
-- @field #RadioConfig radio Radio configuration for the squadron.
|
|
1367
|
+
-- @field #number skill Skill for the squadron.
|
|
1368
|
+
-- @field #number turnovertime Turnover time in seconds.
|
|
1369
|
+
-- @field #number repairtime Repair time in seconds.
|
|
1370
|
+
-- @field #string livery Livery for the squadron.
|
|
1371
|
+
-- @field #PayloadConfig[] payloads Templates for the squadron.
|
|
1372
|
+
-- @field #number nb_aircrafts Number of aircrafts in the squadron.
|
|
1373
|
+
|
|
1374
|
+
--- Parse an Squadron config Object.
|
|
1375
|
+
-- @param #JsonObject config Config object to parse
|
|
1376
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
1377
|
+
-- @return #SquadronConfig squadronConfigJson Parsed Squadron object
|
|
1378
|
+
function ParseSquadronConfigJson(config, parser_name)
|
|
1379
|
+
local squadronConfigJson = {}
|
|
1380
|
+
local default_nb_aircrafts = 6
|
|
1381
|
+
local default_fuellowthreshold = 25
|
|
1382
|
+
local default_lowfuelrtb = false
|
|
1383
|
+
local default_grouping = 1
|
|
1384
|
+
local default_modex = 400
|
|
1385
|
+
local default_radio = {freq = 251.000, modulation = radio.modulation.AM, power = 100}
|
|
1386
|
+
local default_skill = AI.Skill.GOOD
|
|
1387
|
+
local default_turnovertime = 10
|
|
1388
|
+
local default_repairtime = (default_turnovertime *2)
|
|
1389
|
+
local default_livery = ""
|
|
1390
|
+
-- **************************************************************************
|
|
1391
|
+
-- template
|
|
1392
|
+
-- **************************************************************************
|
|
1393
|
+
if type(config.template) == "string" then
|
|
1394
|
+
if type(GROUP:FindByName(config.template)) == 'nil' then
|
|
1395
|
+
Jtff_log.error(
|
|
1396
|
+
string.format(
|
|
1397
|
+
"Squadron template %s not found, skipping squadron template configuration",
|
|
1398
|
+
config.template
|
|
1399
|
+
),
|
|
1400
|
+
parser_name
|
|
1401
|
+
)
|
|
1402
|
+
return {}
|
|
1403
|
+
else
|
|
1404
|
+
squadronConfigJson.template = config.template
|
|
1405
|
+
end
|
|
1406
|
+
else
|
|
1407
|
+
Jtff_log.error("Squadron template is not a string, skipping squadron configuration", parser_name)
|
|
1408
|
+
return {}
|
|
1409
|
+
end
|
|
1410
|
+
-- **************************************************************************
|
|
1411
|
+
-- name
|
|
1412
|
+
-- **************************************************************************
|
|
1413
|
+
if type(config.name) == "string" then
|
|
1414
|
+
squadronConfigJson.name = config.name
|
|
1415
|
+
else
|
|
1416
|
+
Jtff_log.error("Squadron name is not a string, skipping squadron configuration", parser_name)
|
|
1417
|
+
return {}
|
|
1418
|
+
end
|
|
1419
|
+
-- **************************************************************************
|
|
1420
|
+
-- fuellowthreshold
|
|
1421
|
+
-- **************************************************************************
|
|
1422
|
+
squadronConfigJson.fuellowthreshold = config.fuellowthreshold or default_fuellowthreshold
|
|
1423
|
+
-- **************************************************************************
|
|
1424
|
+
-- lowfuelrtb
|
|
1425
|
+
-- **************************************************************************
|
|
1426
|
+
squadronConfigJson.lowfuelrtb = config.lowfuelrtb or default_lowfuelrtb
|
|
1427
|
+
-- **************************************************************************
|
|
1428
|
+
-- grouping
|
|
1429
|
+
-- **************************************************************************
|
|
1430
|
+
squadronConfigJson.grouping = config.grouping or default_grouping
|
|
1431
|
+
-- **************************************************************************
|
|
1432
|
+
-- modex
|
|
1433
|
+
-- **************************************************************************
|
|
1434
|
+
squadronConfigJson.modex = config.modex or default_modex
|
|
1435
|
+
-- **************************************************************************
|
|
1436
|
+
-- radio
|
|
1437
|
+
-- **************************************************************************
|
|
1438
|
+
if type(config.radio) == "table" then
|
|
1439
|
+
squadronConfigJson.radio = ParseRadioConfigJson(config.radio, parser_name)
|
|
1440
|
+
if next(squadronConfigJson.radio) == nil then
|
|
1441
|
+
Jtff_log.warn("Squadron radio is not a valid Radio object, skipping tanker configuration", parser_name)
|
|
1442
|
+
squadronConfigJson.radio = default_radio
|
|
1443
|
+
end
|
|
1444
|
+
else
|
|
1445
|
+
Jtff_log.warn(
|
|
1446
|
+
string.format(
|
|
1447
|
+
"Squadron %s radio config is not a table, apply default radio config",
|
|
1448
|
+
squadronConfigJson.name
|
|
1449
|
+
),
|
|
1450
|
+
parser_name
|
|
1451
|
+
)
|
|
1452
|
+
squadronConfigJson.radio = default_radio
|
|
1453
|
+
end
|
|
1454
|
+
-- **************************************************************************
|
|
1455
|
+
-- skill
|
|
1456
|
+
-- **************************************************************************
|
|
1457
|
+
squadronConfigJson.skill = config.skill or default_skill
|
|
1458
|
+
-- **************************************************************************
|
|
1459
|
+
-- turnovertime
|
|
1460
|
+
-- **************************************************************************
|
|
1461
|
+
squadronConfigJson.turnovertime = config.turnovertime or default_turnovertime
|
|
1462
|
+
-- **************************************************************************
|
|
1463
|
+
-- repairtime
|
|
1464
|
+
-- **************************************************************************
|
|
1465
|
+
squadronConfigJson.repairtime = config.repairtime or default_repairtime
|
|
1466
|
+
-- **************************************************************************
|
|
1467
|
+
-- livery
|
|
1468
|
+
-- **************************************************************************
|
|
1469
|
+
squadronConfigJson.livery = config.livery or default_livery
|
|
1470
|
+
-- **************************************************************************
|
|
1471
|
+
-- payloads
|
|
1472
|
+
-- **************************************************************************
|
|
1473
|
+
if type(config.payloads) == "table" then
|
|
1474
|
+
squadronConfigJson.payloads = {}
|
|
1475
|
+
for _, _payload in ipairs(config.payloads) do
|
|
1476
|
+
table.insert(
|
|
1477
|
+
squadronConfigJson.payloads,
|
|
1478
|
+
ParseSquadPayloadConfigJson(
|
|
1479
|
+
_payload,
|
|
1480
|
+
parser_name
|
|
1481
|
+
)
|
|
1482
|
+
)
|
|
1483
|
+
end
|
|
1484
|
+
if #(squadronConfigJson.payloads) == 0 then
|
|
1485
|
+
Jtff_log.error(
|
|
1486
|
+
string.format(
|
|
1487
|
+
"Squadron %s has no payloads, skipping squadron configuration",
|
|
1488
|
+
squadronConfigJson.name
|
|
1489
|
+
),
|
|
1490
|
+
parser_name
|
|
1491
|
+
)
|
|
1492
|
+
return {}
|
|
1493
|
+
end
|
|
1494
|
+
else
|
|
1495
|
+
Jtff_log.error("Airwing squadrons is not a table, skipping airwing configuration", "AIRWING")
|
|
1496
|
+
return {}
|
|
1497
|
+
end
|
|
1498
|
+
-- **************************************************************************
|
|
1499
|
+
-- nb_aircrafts
|
|
1500
|
+
-- **************************************************************************
|
|
1501
|
+
if type(config.nb_aircrafts) == "number" then
|
|
1502
|
+
squadronConfigJson.nb_aircrafts = config.nb_aircrafts
|
|
1503
|
+
else
|
|
1504
|
+
Jtff_log.warn(
|
|
1505
|
+
string.format(
|
|
1506
|
+
"Squadron %s nb_aircrafts is not a number, defaulting to %d",
|
|
1507
|
+
squadronConfigJson.name,
|
|
1508
|
+
default_nb_aircrafts
|
|
1509
|
+
),
|
|
1510
|
+
parser_name
|
|
1511
|
+
)
|
|
1512
|
+
squadronConfigJson.nb_aircrafts = default_nb_aircrafts
|
|
1513
|
+
end
|
|
1514
|
+
return squadronConfigJson
|
|
1515
|
+
end
|
|
1516
|
+
|
|
1517
|
+
-- @type PayloadRoleConfig
|
|
1518
|
+
-- @field #AUFTRAG.Type[] roles Roles for the payload.
|
|
1519
|
+
-- @field #number perf Performance for the payload (between 1 and 100).
|
|
1520
|
+
-- @field #number qty Quantity of the payload. (-1 is unlimited)
|
|
1521
|
+
|
|
1522
|
+
-- @type PayloadConfig
|
|
1523
|
+
-- @field #string name Payload name.
|
|
1524
|
+
-- @field #PayloadRoleConfig[] payloadconfigs Payload roles config for the payload.
|
|
1525
|
+
|
|
1526
|
+
--- Parse a PayloadConfig config Object.
|
|
1527
|
+
-- @param #JsonObject config Config object to parse
|
|
1528
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
1529
|
+
-- @return #PayloadConfig squadronPayloadConfigJson Parsed PayloadConfig object
|
|
1530
|
+
function ParsePayloadConfigJson(config, parser_name)
|
|
1531
|
+
local payloadConfigJson = {}
|
|
1532
|
+
local default_perf = 70
|
|
1533
|
+
local default_qty = 50
|
|
1534
|
+
-- **************************************************************************
|
|
1535
|
+
-- roles
|
|
1536
|
+
-- **************************************************************************
|
|
1537
|
+
if type(config.roles) == "table" then
|
|
1538
|
+
payloadConfigJson.roles = {}
|
|
1539
|
+
for _, _role in ipairs(config.roles) do
|
|
1540
|
+
table.insert(payloadConfigJson.roles, _role)
|
|
1541
|
+
end
|
|
1542
|
+
else
|
|
1543
|
+
Jtff_log.error("Payload roles is not a table, skipping payload configuration", parser_name)
|
|
1544
|
+
return {}
|
|
1545
|
+
end
|
|
1546
|
+
-- **************************************************************************
|
|
1547
|
+
-- perf
|
|
1548
|
+
-- **************************************************************************
|
|
1549
|
+
payloadConfigJson.perf = config.perf or default_perf
|
|
1550
|
+
-- **************************************************************************
|
|
1551
|
+
-- qty
|
|
1552
|
+
-- **************************************************************************
|
|
1553
|
+
payloadConfigJson.qty = config.qty or default_qty
|
|
1554
|
+
return payloadConfigJson
|
|
1555
|
+
|
|
1556
|
+
end
|
|
1557
|
+
|
|
1558
|
+
--- Parse an SquadronPayload config Object.
|
|
1559
|
+
-- @param #JsonObject config Config object to parse
|
|
1560
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
1561
|
+
-- @return #PayloadConfig squadronPayloadConfigJson Parsed PayloadConfig object
|
|
1562
|
+
function ParseSquadPayloadConfigJson(config, parser_name)
|
|
1563
|
+
local squadronPayloadConfigJson = {}
|
|
1564
|
+
-- **************************************************************************
|
|
1565
|
+
-- name
|
|
1566
|
+
-- **************************************************************************
|
|
1567
|
+
if type(config.name) == "string" then
|
|
1568
|
+
if type(GROUP:FindByName(config.name)) == 'nil' then
|
|
1569
|
+
Jtff_log.error(
|
|
1570
|
+
string.format(
|
|
1571
|
+
"SquadronPayload %s not found, skipping squadron payload configuration",
|
|
1572
|
+
config.name
|
|
1573
|
+
),
|
|
1574
|
+
parser_name
|
|
1575
|
+
)
|
|
1576
|
+
return {}
|
|
1577
|
+
else
|
|
1578
|
+
squadronPayloadConfigJson.name = config.name
|
|
1579
|
+
end
|
|
1580
|
+
else
|
|
1581
|
+
Jtff_log.error(
|
|
1582
|
+
"SquadronPayloadTemplate name is not a string, skipping squadron Payload configuration",
|
|
1583
|
+
parser_name
|
|
1584
|
+
)
|
|
1585
|
+
return {}
|
|
1586
|
+
end
|
|
1587
|
+
-- **************************************************************************
|
|
1588
|
+
-- payloadconfigs
|
|
1589
|
+
-- **************************************************************************
|
|
1590
|
+
if type(config.payloadconfigs) == "table" then
|
|
1591
|
+
squadronPayloadConfigJson.payloadconfigs = {}
|
|
1592
|
+
for _, _payloadconfig in ipairs(config.payloadconfigs) do
|
|
1593
|
+
if type(_payloadconfig) == "table" then
|
|
1594
|
+
table.insert(
|
|
1595
|
+
squadronPayloadConfigJson.payloadconfigs,
|
|
1596
|
+
ParsePayloadConfigJson(_payloadconfig, parser_name)
|
|
1597
|
+
)
|
|
1598
|
+
else
|
|
1599
|
+
Jtff_log.error(
|
|
1600
|
+
string.format(
|
|
1601
|
+
"SquadronPayload is not a valid PayloadRoleConfig object, skipping squadron payload configuration"
|
|
1602
|
+
),
|
|
1603
|
+
parser_name
|
|
1604
|
+
)
|
|
1605
|
+
return {}
|
|
1606
|
+
end
|
|
1607
|
+
end
|
|
1608
|
+
if #(squadronPayloadConfigJson.payloadconfigs) == 0 then
|
|
1609
|
+
Jtff_log.error(
|
|
1610
|
+
string.format(
|
|
1611
|
+
"SquadronPayload %s has no payloads, skipping squadron Payload configuration",
|
|
1612
|
+
squadronPayloadConfigJson.name
|
|
1613
|
+
),
|
|
1614
|
+
parser_name
|
|
1615
|
+
)
|
|
1616
|
+
return {}
|
|
1617
|
+
end
|
|
1618
|
+
else
|
|
1619
|
+
Jtff_log.error(
|
|
1620
|
+
string.format(
|
|
1621
|
+
"SquadronPayload %s payloadconfigs is not a table, skipping squadron Payload configuration",
|
|
1622
|
+
squadronPayloadConfigJson.name
|
|
1623
|
+
),
|
|
1624
|
+
parser_name
|
|
1625
|
+
)
|
|
1626
|
+
return {}
|
|
1627
|
+
end
|
|
1628
|
+
return squadronPayloadConfigJson
|
|
1629
|
+
end
|
|
1630
|
+
|
|
1631
|
+
-- @type RelativeRacetrackConfig
|
|
1632
|
+
-- @field #WRAPPER.Unit patternUnit Unit name to use for the pattern.
|
|
1633
|
+
-- @field #number front number of nm in the racetrack before the unit.
|
|
1634
|
+
-- @field #number back number of nm in the racetrack behind of the unit.
|
|
1635
|
+
-- @field #number fl Racetrack flight level.
|
|
1636
|
+
-- @field #number speed Racetrack speed in knots.
|
|
1637
|
+
|
|
1638
|
+
--- Parse an RelativeRacetrackConfig config Object.
|
|
1639
|
+
-- @param #JsonObject config Config object to parse
|
|
1640
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
1641
|
+
-- @return #RelativeRacetrackConfig racetrackConfigJson Parsed RacetrackConfig object
|
|
1642
|
+
function ParseRelativeRacetrackConfigJson(config, parser_name)
|
|
1643
|
+
local relativeRacetrackConfigJson = {}
|
|
1644
|
+
local default_front = 30
|
|
1645
|
+
local default_back = 30
|
|
1646
|
+
local default_fl = 080
|
|
1647
|
+
local default_speed = 320
|
|
1648
|
+
-- **************************************************************************
|
|
1649
|
+
-- patternUnit
|
|
1650
|
+
-- **************************************************************************
|
|
1651
|
+
if type(config.patternUnit) == "string" then
|
|
1652
|
+
if type(UNIT:FindByName(config.patternUnit)) == 'nil' then
|
|
1653
|
+
Jtff_log.error(
|
|
1654
|
+
string.format(
|
|
1655
|
+
"Racetrack patternUnit %s not found, skipping racetrack configuration",
|
|
1656
|
+
config.patternUnit
|
|
1657
|
+
),
|
|
1658
|
+
parser_name
|
|
1659
|
+
)
|
|
1660
|
+
return {}
|
|
1661
|
+
else
|
|
1662
|
+
relativeRacetrackConfigJson.patternUnit = UNIT:FindByName(config.patternUnit)
|
|
1663
|
+
end
|
|
1664
|
+
else
|
|
1665
|
+
Jtff_log.error(
|
|
1666
|
+
string.format(
|
|
1667
|
+
"Racetrack patternUnit %s is not a string, skipping racetrack configuration",
|
|
1668
|
+
config.patternUnit
|
|
1669
|
+
),
|
|
1670
|
+
parser_name
|
|
1671
|
+
)
|
|
1672
|
+
return {}
|
|
1673
|
+
end
|
|
1674
|
+
-- **************************************************************************
|
|
1675
|
+
-- front
|
|
1676
|
+
-- **************************************************************************
|
|
1677
|
+
relativeRacetrackConfigJson.front = config.front or default_front
|
|
1678
|
+
-- **************************************************************************
|
|
1679
|
+
-- back
|
|
1680
|
+
-- **************************************************************************
|
|
1681
|
+
relativeRacetrackConfigJson.back = config.back or default_back
|
|
1682
|
+
-- **************************************************************************
|
|
1683
|
+
-- fl
|
|
1684
|
+
-- **************************************************************************
|
|
1685
|
+
relativeRacetrackConfigJson.fl = config.fl or default_fl
|
|
1686
|
+
-- **************************************************************************
|
|
1687
|
+
-- speed
|
|
1688
|
+
-- **************************************************************************
|
|
1689
|
+
relativeRacetrackConfigJson.speed = config.speed or default_speed
|
|
1690
|
+
return relativeRacetrackConfigJson
|
|
1691
|
+
end
|
|
1692
|
+
|
|
1693
|
+
-- @type RacetrackConfig
|
|
1694
|
+
-- @field #string coordinate MGRS Racetrack coordinates.
|
|
1695
|
+
-- @field #number fl Racetrack flight level.
|
|
1696
|
+
-- @field #number speed Racetrack speed in knots.
|
|
1697
|
+
-- @field #number heading Racetrack heading in degrees.
|
|
1698
|
+
-- @field #number leg Racetrack leg in nm.
|
|
1699
|
+
|
|
1700
|
+
--- Parse an Racetrack config Object.
|
|
1701
|
+
-- @param #JsonObject config Config object to parse
|
|
1702
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
1703
|
+
-- @return #RacetrackConfig racetrackConfigJson Parsed RacetrackConfig object
|
|
1704
|
+
function ParseRacetrackConfigJson(config, parser_name)
|
|
1705
|
+
local racetrackConfigJson = {}
|
|
1706
|
+
local default_fl = 250
|
|
1707
|
+
local default_speed = 320
|
|
1708
|
+
local default_heading = 090
|
|
1709
|
+
local default_leg = 30
|
|
1710
|
+
-- **************************************************************************
|
|
1711
|
+
-- coordinate
|
|
1712
|
+
-- **************************************************************************
|
|
1713
|
+
if type(config.coordinate) == "string" then
|
|
1714
|
+
racetrackConfigJson.coordinate = config.coordinate
|
|
1715
|
+
else
|
|
1716
|
+
Jtff_log.error("Racetrack coordinates is not a table, skipping racetrack configuration", parser_name)
|
|
1717
|
+
return {}
|
|
1718
|
+
end
|
|
1719
|
+
-- **************************************************************************
|
|
1720
|
+
-- fl
|
|
1721
|
+
-- **************************************************************************
|
|
1722
|
+
racetrackConfigJson.fl = config.fl or default_fl
|
|
1723
|
+
-- **************************************************************************
|
|
1724
|
+
-- speed
|
|
1725
|
+
-- **************************************************************************
|
|
1726
|
+
racetrackConfigJson.speed = config.speed or default_speed
|
|
1727
|
+
-- **************************************************************************
|
|
1728
|
+
-- heading
|
|
1729
|
+
-- **************************************************************************
|
|
1730
|
+
racetrackConfigJson.heading = config.heading or default_heading
|
|
1731
|
+
-- **************************************************************************
|
|
1732
|
+
-- leg
|
|
1733
|
+
-- **************************************************************************
|
|
1734
|
+
racetrackConfigJson.leg = config.leg or default_leg
|
|
1735
|
+
return racetrackConfigJson
|
|
1736
|
+
end
|
|
1737
|
+
|
|
1738
|
+
-- @type AwacsCallsignConfig
|
|
1739
|
+
-- @field #string alias Alias for the awacs.
|
|
1740
|
+
-- @field #number name CallSign name for the awacs.
|
|
1741
|
+
-- @field #number number CallSign number (1-7) for the awacs.
|
|
1742
|
+
|
|
1743
|
+
--- Parse an Awacs Callsign config Object.
|
|
1744
|
+
-- @param #JsonObject config Config object to parse
|
|
1745
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
1746
|
+
-- @return #RescueHeloCallsignConfig rescueHeloCallsignConfigJson Parsed CallSign object
|
|
1747
|
+
function ParseAwacsCallsignConfigJson(config, parser_name)
|
|
1748
|
+
local awacsCallsignConfigJson = {}
|
|
1749
|
+
local default_number = 1
|
|
1750
|
+
-- **************************************************************************
|
|
1751
|
+
-- name
|
|
1752
|
+
-- **************************************************************************
|
|
1753
|
+
if type(config.name) == "number" then
|
|
1754
|
+
if table.count_value(CALLSIGN.AWACS, config.name) > 0 then
|
|
1755
|
+
awacsCallsignConfigJson.name = config.name
|
|
1756
|
+
else
|
|
1757
|
+
Jtff_log.warn("AWACS Callsign name is not a valid CallSign name, skipping AWACS configuration",
|
|
1758
|
+
parser_name)
|
|
1759
|
+
awacsCallsignConfigJson.name = CALLSIGN.AWACS.Darkstar
|
|
1760
|
+
end
|
|
1761
|
+
else
|
|
1762
|
+
Jtff_log.error("AWACS Callsign name is not valid, skipping AWACS configuration", parser_name)
|
|
1763
|
+
return {}
|
|
1764
|
+
end
|
|
1765
|
+
-- **************************************************************************
|
|
1766
|
+
-- alias
|
|
1767
|
+
-- **************************************************************************
|
|
1768
|
+
if type(config.alias) == "string" then
|
|
1769
|
+
awacsCallsignConfigJson.alias = config.alias
|
|
1770
|
+
else
|
|
1771
|
+
Jtff_log.warn("AWACS Callsign alias is not a string, defaulting to AWACS name", parser_name)
|
|
1772
|
+
awacsCallsignConfigJson.alias = "Ford"
|
|
1773
|
+
end
|
|
1774
|
+
-- **************************************************************************
|
|
1775
|
+
-- number
|
|
1776
|
+
-- **************************************************************************
|
|
1777
|
+
if type(config.number) == "number" then
|
|
1778
|
+
if config.number >= 1 and config.number <= 7 then
|
|
1779
|
+
awacsCallsignConfigJson.number = config.number
|
|
1780
|
+
else
|
|
1781
|
+
Jtff_log.warn(
|
|
1782
|
+
string.format("AWACS Callsign number is not a valid number (1-7), defaulting number to %d", default_number),
|
|
1783
|
+
parser_name)
|
|
1784
|
+
awacsCallsignConfigJson.number = default_number
|
|
1785
|
+
end
|
|
1786
|
+
else
|
|
1787
|
+
Jtff_log.warn(string.format("AWACS Callsign number is not a number, defaulting number to %d", default_number),
|
|
1788
|
+
parser_name)
|
|
1789
|
+
awacsCallsignConfigJson.number = default_number
|
|
1790
|
+
end
|
|
1791
|
+
return awacsCallsignConfigJson
|
|
1792
|
+
end
|
|
1793
|
+
|
|
1216
1794
|
-- @field #JTFF_QRA JTFF_QRA
|
|
1217
1795
|
JTFF_QRA = {
|
|
1218
1796
|
ClassName = "JTFF_QRA",
|
|
@@ -1226,13 +1804,25 @@ JTFF_QRA.Type = {
|
|
|
1226
1804
|
Alpha = "Alpha Scramble",
|
|
1227
1805
|
}
|
|
1228
1806
|
|
|
1807
|
+
-- @field JTFF_INTERCEPT JTFF_INTERCEPT
|
|
1808
|
+
JTFF_INTERCEPT = {
|
|
1809
|
+
ClassName = "JTFF_INTERCEPT",
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
-- @type JTFF_INTERCEPT.Type
|
|
1813
|
+
JTFF_INTERCEPT.Type = {
|
|
1814
|
+
Civilian = "civil",
|
|
1815
|
+
Fighter = "fighter",
|
|
1816
|
+
Vampire = "bomber",
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1229
1819
|
env.info('JTFF-SHAREDLIB: shared library loaded succesfully')
|
|
1230
1820
|
|
|
1231
|
-
|
|
1821
|
+
SoundFilesPrefix = GetSoundFilesPrefix()
|
|
1232
1822
|
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1823
|
+
Sound2Bip = USERSOUND:New( SoundFilesPrefix .. "Misc/2_Bips.ogg" )
|
|
1824
|
+
Sound1Bip = USERSOUND:New( SoundFilesPrefix .. "Misc/Bip.ogg" )
|
|
1825
|
+
SoundCrashWood = USERSOUND:New( SoundFilesPrefix .. "Misc/crash_wood.ogg" )
|
|
1826
|
+
SoundQRA = USERSOUND:New( SoundFilesPrefix .. "Misc/SCRAMBLE QRA.ogg" )
|
|
1237
1827
|
|
|
1238
|
-
|
|
1828
|
+
Sound1Bip:ToAll()
|