@jtff/miztemplate-lib 3.10.14 → 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
package/lua/src/150-awacs.lua
CHANGED
|
@@ -1,497 +1,595 @@
|
|
|
1
1
|
-- *****************************************************************************
|
|
2
2
|
-- ** Awacs **
|
|
3
3
|
-- *********************************************************
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
4
|
+
|
|
5
|
+
-- region AwacsConfigFunctions
|
|
6
|
+
|
|
7
|
+
-- @type AwacsCallsignConfig
|
|
8
|
+
-- @field #string alias Alias for the AWACS.
|
|
9
|
+
-- @field #number name CallSign name for the AWACS.
|
|
10
|
+
-- @field #number number CallSign number (1-7) for the AWACS.
|
|
11
|
+
|
|
12
|
+
--- Parse an Awacs Callsign config Object.
|
|
13
|
+
-- @param #JsonObject config Config object to parse
|
|
14
|
+
-- @param #string parser_name Parser name ("AIRBASE", "AIRBOSS", etc...).
|
|
15
|
+
-- @return #AwacsCallsignConfig awacsCallsignConfigJson Parsed CallSign object
|
|
16
|
+
function ParseAwacsCallsignConfigJson(config, parser_name)
|
|
17
|
+
local awacsCallsignConfigJson = {}
|
|
18
|
+
local default_number = 1
|
|
19
|
+
-- **************************************************************************
|
|
20
|
+
-- name
|
|
21
|
+
-- **************************************************************************
|
|
22
|
+
if type(config.name) == "number" then
|
|
23
|
+
if table.count_value(CALLSIGN.AWACS, config.name) > 0 then
|
|
24
|
+
awacsCallsignConfigJson.name = config.name
|
|
25
|
+
else
|
|
26
|
+
Jtff_log.error("Awacs Callsign name is not a valid CallSign name, skipping awacs configuration",
|
|
27
|
+
parser_name)
|
|
28
|
+
return {}
|
|
29
|
+
end
|
|
30
|
+
else
|
|
31
|
+
Jtff_log.error("Awacs Callsign name is not valid, skipping awacs configuration", parser_name)
|
|
32
|
+
return {}
|
|
33
|
+
end
|
|
34
|
+
-- **************************************************************************
|
|
35
|
+
-- alias
|
|
36
|
+
-- **************************************************************************
|
|
37
|
+
if type(config.alias) == "string" then
|
|
38
|
+
awacsCallsignConfigJson.alias = config.alias
|
|
39
|
+
else
|
|
40
|
+
Jtff_log.warn("Awacs Callsign alias is not a string, defaulting to Awacs name", parser_name)
|
|
41
|
+
awacsCallsignConfigJson.alias = awacsCallsignConfigJson.name
|
|
42
|
+
end
|
|
43
|
+
-- **************************************************************************
|
|
44
|
+
-- number
|
|
45
|
+
-- **************************************************************************
|
|
46
|
+
if type(config.number) == "number" then
|
|
47
|
+
if config.number >= 1 and config.number <= 7 then
|
|
48
|
+
awacsCallsignConfigJson.number = config.number
|
|
26
49
|
else
|
|
27
|
-
|
|
50
|
+
Jtff_log.warn(
|
|
51
|
+
string.format("Awacs Callsign number is not a valid number (1-7), defaulting number to %d", default_number),
|
|
52
|
+
parser_name)
|
|
53
|
+
awacsCallsignConfigJson.number = default_number
|
|
54
|
+
end
|
|
55
|
+
else
|
|
56
|
+
Jtff_log.warn(string.format("Awacs Callsign number is not a number, defaulting number to %d", default_number),
|
|
57
|
+
parser_name)
|
|
58
|
+
awacsCallsignConfigJson.number = default_number
|
|
59
|
+
end
|
|
60
|
+
return awacsCallsignConfigJson
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
-- @type AwacsConfig
|
|
64
|
+
-- @field #boolean enable Enable awacs creation.
|
|
65
|
+
-- @field #string type Awacs type.
|
|
66
|
+
-- @field #string airbaseName Airbase name.
|
|
67
|
+
-- @field #boolean autospawn Autospawn Awacs.
|
|
68
|
+
-- @field #RacetrackConfig racetrack Racetrack configuration.
|
|
69
|
+
-- @field #number nbEscort Number of escort aircraft.
|
|
70
|
+
-- @field #number missionmaxduration Maximum mission duration in minutes.
|
|
71
|
+
-- @field #tacanConfig tacan TACAN configuration.
|
|
72
|
+
-- @field #radioConfig radio Radio configuration.
|
|
73
|
+
-- @field #number fuelLowThreshold Fuel low threshold in %.
|
|
74
|
+
-- @field #AwacsCallsignConfig callsign Callsign configuration.
|
|
28
75
|
|
|
76
|
+
--- Parse Awacs config Object.
|
|
77
|
+
-- @param #JsonObject config Config object to parse
|
|
78
|
+
-- @return #AwacsConfig awacsConfigJson Parsed AwacsConfig object
|
|
79
|
+
function ParseAwacsConfigJson(config)
|
|
80
|
+
local json = require('Scripts/json')
|
|
81
|
+
local parser_name = "AWACS"
|
|
82
|
+
local default_autospawn = false
|
|
83
|
+
local default_nbEscort = 1
|
|
84
|
+
local default_missionmaxduration = 240
|
|
85
|
+
local default_fuelLowThreshold = 30
|
|
86
|
+
|
|
87
|
+
-- **************************************************************************
|
|
88
|
+
-- enable
|
|
89
|
+
-- **************************************************************************
|
|
90
|
+
local awacsConfigJson = {
|
|
91
|
+
enable = config.enable or false,
|
|
92
|
+
}
|
|
93
|
+
-- **************************************************************************
|
|
94
|
+
-- type
|
|
95
|
+
-- **************************************************************************
|
|
96
|
+
if type(config.type) == "string" then
|
|
97
|
+
awacsConfigJson.type = config.type
|
|
98
|
+
else
|
|
99
|
+
Jtff_log.error("Awacs type is not a string, skipping awacs configuration", parser_name)
|
|
100
|
+
config.enable = false
|
|
101
|
+
return config
|
|
102
|
+
end
|
|
103
|
+
-- **************************************************************************
|
|
104
|
+
-- airbaseName
|
|
105
|
+
-- **************************************************************************
|
|
106
|
+
if type(config.airbaseName) == "string" then
|
|
107
|
+
if type(AIRBASE:FindByName(config.airbaseName)) == 'nil' then
|
|
108
|
+
Jtff_log.error(
|
|
109
|
+
string.format(
|
|
110
|
+
"Airbase %s not found, skipping awacs configuration",
|
|
111
|
+
config.airbaseName
|
|
112
|
+
),
|
|
113
|
+
parser_name
|
|
114
|
+
)
|
|
115
|
+
config.enable = false
|
|
116
|
+
return config
|
|
117
|
+
else
|
|
118
|
+
awacsConfigJson.airbaseName = config.airbaseName
|
|
29
119
|
end
|
|
30
|
-
|
|
31
|
-
|
|
120
|
+
else
|
|
121
|
+
Jtff_log.error("Airbase warehouse is not a string", parser_name)
|
|
122
|
+
config.enable = false
|
|
123
|
+
return config
|
|
124
|
+
end
|
|
125
|
+
-- **************************************************************************
|
|
126
|
+
-- autospawn
|
|
127
|
+
-- **************************************************************************
|
|
128
|
+
if type(config.autospawn) == "boolean" then
|
|
129
|
+
awacsConfigJson.autospawn = config.autospawn
|
|
130
|
+
else
|
|
131
|
+
Jtff_log.warn("Awacs %s autospawn not defined : defaulting", parser_name)
|
|
132
|
+
awacsConfigJson.autospawn = default_autospawn
|
|
133
|
+
end
|
|
134
|
+
-- **************************************************************************
|
|
135
|
+
-- racetrack
|
|
136
|
+
-- **************************************************************************
|
|
137
|
+
if type(config.racetrack) == "table" then
|
|
138
|
+
awacsConfigJson.racetrack = ParseRacetrackConfigJson(config.racetrack, parser_name)
|
|
139
|
+
if next(awacsConfigJson.racetrack) == nil then
|
|
140
|
+
Jtff_log.error("Awacs racetrack is not a valid Racetrack object, skipping awacs configuration", parser_name)
|
|
141
|
+
config.enable = false
|
|
142
|
+
return config
|
|
32
143
|
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
144
|
+
else
|
|
145
|
+
Jtff_log.error("Awacs racetrack is not a table, skipping awacs configuration", parser_name)
|
|
146
|
+
config.enable = false
|
|
147
|
+
return config
|
|
148
|
+
end
|
|
149
|
+
-- **************************************************************************
|
|
150
|
+
-- nbEscort
|
|
151
|
+
-- **************************************************************************
|
|
152
|
+
if type(config.nbEscort) == "number" then
|
|
153
|
+
awacsConfigJson.nbEscort = config.nbEscort
|
|
154
|
+
else
|
|
155
|
+
Jtff_log.warn(string.format("Awacs nbEscort is not a number, defaulting to %d", default_nbEscort), parser_name)
|
|
156
|
+
awacsConfigJson.nbEscort = default_nbEscort
|
|
157
|
+
end
|
|
158
|
+
-- **************************************************************************
|
|
159
|
+
-- missionmaxduration
|
|
160
|
+
-- **************************************************************************
|
|
161
|
+
if type(config.missionmaxduration) == "number" then
|
|
162
|
+
awacsConfigJson.missionmaxduration = config.missionmaxduration
|
|
163
|
+
else
|
|
164
|
+
Jtff_log.warn(
|
|
165
|
+
string.format("Awacs missionmaxduration is not a number, defaulting to %d", default_missionmaxduration),
|
|
166
|
+
parser_name)
|
|
167
|
+
awacsConfigJson.missionmaxduration = default_missionmaxduration
|
|
168
|
+
end
|
|
169
|
+
-- **************************************************************************
|
|
170
|
+
-- tacan
|
|
171
|
+
-- **************************************************************************
|
|
172
|
+
if type(config.tacan) == "table" then
|
|
173
|
+
awacsConfigJson.tacan = ParseTacanConfigJson(config.tacan, parser_name)
|
|
174
|
+
else
|
|
175
|
+
Jtff_log.error("Awacs tacan is not a table, skiping TACAN awacs configuration", parser_name)
|
|
176
|
+
awacsConfigJson.tacan = {}
|
|
177
|
+
end
|
|
178
|
+
-- **************************************************************************
|
|
179
|
+
-- radio
|
|
180
|
+
-- **************************************************************************
|
|
181
|
+
if type(config.radio) == "table" then
|
|
182
|
+
awacsConfigJson.radio = ParseRadioConfigJson(config.radio, parser_name)
|
|
183
|
+
if next(awacsConfigJson.radio) == nil then
|
|
184
|
+
Jtff_log.error("Awacs radio is not a valid Radio object, skipping awacs configuration", parser_name)
|
|
185
|
+
config.enable = false
|
|
186
|
+
return config
|
|
187
|
+
end
|
|
188
|
+
else
|
|
189
|
+
Jtff_log.error("Awacs radio is not a table, skipping awacs configuration", parser_name)
|
|
190
|
+
config.enable = false
|
|
191
|
+
return config
|
|
192
|
+
end
|
|
193
|
+
-- **************************************************************************
|
|
194
|
+
-- fuelLowThreshold
|
|
195
|
+
-- **************************************************************************
|
|
196
|
+
if type(config.fuelLowThreshold) == "number" then
|
|
197
|
+
awacsConfigJson.fuelLowThreshold = config.fuelLowThreshold
|
|
198
|
+
else
|
|
199
|
+
Jtff_log.warn(
|
|
200
|
+
string.format("Awacs fuelLowThreshold is not a number, defaulting to %d %%", default_fuelLowThreshold),
|
|
201
|
+
parser_name)
|
|
202
|
+
awacsConfigJson.fuelLowThreshold = default_fuelLowThreshold
|
|
203
|
+
end
|
|
204
|
+
-- **************************************************************************
|
|
205
|
+
-- callsign
|
|
206
|
+
-- **************************************************************************
|
|
207
|
+
if type(config.callsign) == "table" then
|
|
208
|
+
awacsConfigJson.callsign = ParseAwacsCallsignConfigJson(config.callsign, parser_name)
|
|
209
|
+
if next(awacsConfigJson.callsign) == nil then
|
|
210
|
+
Jtff_log.error("Awacs callsign is not a valid Callsign object, skipping awacs configuration", parser_name)
|
|
211
|
+
config.enable = false
|
|
212
|
+
return config
|
|
213
|
+
end
|
|
214
|
+
else
|
|
215
|
+
Jtff_log.error("Awacs callsign is not a table, skipping awacs configuration", parser_name)
|
|
216
|
+
config.enable = false
|
|
217
|
+
return config
|
|
218
|
+
end
|
|
219
|
+
Jtff_log.debug(
|
|
220
|
+
string.format(
|
|
221
|
+
"parsed Awacs config for %s Awacs, resulting config :\n%s",
|
|
222
|
+
config.type or "",
|
|
223
|
+
json:encode(
|
|
224
|
+
awacsConfigJson,
|
|
225
|
+
{ indent = true }
|
|
226
|
+
)
|
|
227
|
+
),
|
|
228
|
+
parser_name
|
|
229
|
+
)
|
|
230
|
+
return awacsConfigJson
|
|
231
|
+
end
|
|
232
|
+
-- endregion AwacsConfigFunctions
|
|
233
|
+
|
|
234
|
+
-- region AwacsFunctions
|
|
235
|
+
|
|
236
|
+
--- Generate an Awacs mission object.
|
|
237
|
+
-- @param #AwacsConfig awacsconfig Awacs configuration object.
|
|
238
|
+
-- @param #boolean manageEscort Manage escort mission creation.
|
|
239
|
+
-- @return #AUFTRAG awacsmission AWACS mission object, #AIRWING airwing Airwing object.
|
|
240
|
+
function GenerateAwacsMission(awacsconfig, manageEscort)
|
|
241
|
+
local generateEscortMission = false
|
|
242
|
+
if manageEscort == true then
|
|
243
|
+
generateEscortMission = true
|
|
244
|
+
end
|
|
245
|
+
local airwing = FindAirwingByAirbaseName(awacsconfig.airbaseName)
|
|
246
|
+
local awacsmission = nil
|
|
247
|
+
if airwing == nil then
|
|
248
|
+
Jtff_log.error(
|
|
249
|
+
string.format(
|
|
250
|
+
"Airwing not found for Airbase %s, skipping awacs mission generation",
|
|
251
|
+
awacsconfig.airbaseName
|
|
252
|
+
),
|
|
253
|
+
"AWACS"
|
|
254
|
+
)
|
|
255
|
+
return nil,nil
|
|
256
|
+
else
|
|
257
|
+
local function isAnchorCoordValid(MGRSString, autospawn)
|
|
258
|
+
if autospawn == true then
|
|
259
|
+
return true
|
|
55
260
|
end
|
|
56
|
-
if
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
261
|
+
if #(UTILS.Split(MGRSString," ")) ~= 5 then
|
|
262
|
+
return false
|
|
263
|
+
end
|
|
264
|
+
return true
|
|
265
|
+
end
|
|
266
|
+
local orbitCoord = {x=0, y=0, z=0}
|
|
267
|
+
if (isAnchorCoordValid(awacsconfig.racetrack.coordinate, awacsconfig.autospawn) == true) then
|
|
268
|
+
orbitCoord = COORDINATE:NewFromMGRSString(awacsconfig.racetrack.coordinate)
|
|
269
|
+
else
|
|
270
|
+
orbitCoord = AIRBASE:FindByName(awacsconfig.airbaseName):GetCoordinate()
|
|
271
|
+
end
|
|
272
|
+
awacsmission = AUFTRAG:NewAWACS(
|
|
273
|
+
orbitCoord,
|
|
274
|
+
awacsconfig.racetrack.fl * 100,
|
|
275
|
+
awacsconfig.racetrack.speed,
|
|
276
|
+
awacsconfig.racetrack.heading,
|
|
277
|
+
awacsconfig.racetrack.leg
|
|
278
|
+
) or {}
|
|
279
|
+
awacsmission:SetDuration(awacsconfig.missionmaxduration*60)
|
|
280
|
+
awacsmission:SetReturnToLegion(true)
|
|
281
|
+
awacsmission:SetRequiredAssets(1)
|
|
282
|
+
awacsmission:SetName(
|
|
283
|
+
string.format(
|
|
284
|
+
"Awacs-%s",
|
|
285
|
+
awacsconfig.type
|
|
286
|
+
)
|
|
287
|
+
)
|
|
288
|
+
awacsmission:SetRadio(
|
|
289
|
+
awacsconfig.radio.freq,
|
|
290
|
+
awacsconfig.radio.modulation
|
|
291
|
+
)
|
|
292
|
+
if next(awacsconfig.tacan) ~= nil then
|
|
293
|
+
awacsmission:SetTACAN(
|
|
294
|
+
awacsconfig.tacan.channel,
|
|
295
|
+
awacsconfig.tacan.morse,
|
|
296
|
+
nil,
|
|
297
|
+
awacsconfig.tacan.band
|
|
298
|
+
)
|
|
299
|
+
end
|
|
300
|
+
awacsmission:SetEPLRS(true)
|
|
301
|
+
awacsmission:SetEmission(false)
|
|
302
|
+
awacsmission:SetVerbosity(JTFF_verbosity_levels[JTFF_LOGLEVEL])
|
|
303
|
+
awacsmission.additionalData = {
|
|
304
|
+
minEscort = awacsconfig.nbEscort,
|
|
305
|
+
maxEscort = awacsconfig.nbEscort,
|
|
306
|
+
awacsType = awacsconfig.type,
|
|
307
|
+
awacsDuration = awacsconfig.missionmaxduration,
|
|
308
|
+
callsign = awacsconfig.callsign,
|
|
309
|
+
awacsTacan = awacsconfig.tacan,
|
|
310
|
+
awacsRadio = awacsconfig.radio,
|
|
311
|
+
awacsRacetrack = awacsconfig.racetrack,
|
|
312
|
+
awacsFuelLowThreshold = awacsconfig.fuelLowThreshold,
|
|
313
|
+
}
|
|
314
|
+
function awacsmission:OnAfterScheduled(From, Event, To)
|
|
315
|
+
local awacsOpsGroup = self:GetOpsGroups()[1]
|
|
316
|
+
local airwing = awacsOpsGroup:GetAirwing()
|
|
317
|
+
awacsOpsGroup:SwitchCallsign(
|
|
318
|
+
self.additionalData.callsign.name,
|
|
319
|
+
self.additionalData.callsign.number
|
|
320
|
+
)
|
|
321
|
+
awacsOpsGroup:SetFuelLowThreshold(self.additionalData.awacsFuelLowThreshold)
|
|
322
|
+
awacsOpsGroup:SetFuelCriticalThreshold(self.additionalData.awacsFuelLowThreshold-10)
|
|
323
|
+
awacsOpsGroup:SetFuelLowRefuel(true)
|
|
324
|
+
awacsOpsGroup:SetFuelLowRTB(false)
|
|
325
|
+
awacsOpsGroup:SetFuelCriticalRTB(true)
|
|
326
|
+
if (Jtff_map_marker[awacsOpsGroup:GetName()]) then
|
|
327
|
+
COORDINATE:RemoveMark(Jtff_map_marker[awacsOpsGroup:GetName()])
|
|
65
328
|
end
|
|
66
|
-
if
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
329
|
+
if(next(self.additionalData.awacsTacan) ~= nil) then
|
|
330
|
+
Jtff_map_marker[awacsOpsGroup:GetName()] = COORDINATE:NewFromMGRSString(self.additionalData.awacsRacetrack.coordinate):MarkToCoalition(
|
|
331
|
+
string.format(
|
|
332
|
+
'OnDemand Awacs %s - TCN %i\nFL %i at %i knots\nFreq %.2f MHz\nOn station for %i minutes\nRacetrack : %i ° for %i nm',
|
|
333
|
+
self.additionalData.awacsType,
|
|
334
|
+
self.additionalData.awacsTacan.channel,
|
|
335
|
+
UTILS.Round(self.additionalData.awacsRacetrack.fl , 0),
|
|
336
|
+
self.additionalData.awacsRacetrack.speed,
|
|
337
|
+
self.additionalData.awacsRadio.freq,
|
|
338
|
+
self.additionalData.awacsDuration,
|
|
339
|
+
self.additionalData.awacsRacetrack.heading,
|
|
340
|
+
self.additionalData.awacsRacetrack.leg
|
|
341
|
+
),
|
|
342
|
+
awacsOpsGroup:GetCoalition(),
|
|
343
|
+
true,
|
|
344
|
+
'OnDemand Awacs %s is Activated'
|
|
73
345
|
)
|
|
74
346
|
else
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
347
|
+
Jtff_map_marker[awacsOpsGroup:GetName()] = COORDINATE:NewFromMGRSString(self.additionalData.awacsRacetrack.coordinate):MarkToCoalition(
|
|
348
|
+
string.format(
|
|
349
|
+
'OnDemand Awacs %s\nFL %i at %i knots\nFreq %.2f MHz\nOn station for %i minutes\nRacetrack : %i ° for %i nm',
|
|
350
|
+
self.additionalData.awacsType,
|
|
351
|
+
UTILS.Round(self.additionalData.awacsRacetrack.fl , 0),
|
|
352
|
+
self.additionalData.awacsRacetrack.speed,
|
|
353
|
+
self.additionalData.awacsRadio.freq,
|
|
354
|
+
self.additionalData.awacsDuration,
|
|
355
|
+
self.additionalData.awacsRacetrack.heading,
|
|
356
|
+
self.additionalData.awacsRacetrack.leg
|
|
357
|
+
),
|
|
358
|
+
awacsOpsGroup:GetCoalition(),
|
|
359
|
+
true,
|
|
360
|
+
'OnDemand Awacs %s is Activated'
|
|
81
361
|
)
|
|
82
362
|
end
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if self.customconfig.escortgroupname then
|
|
86
|
-
jtff_log.info('RTB: '..self.tanker.GroupName..'...',"AWACS")
|
|
87
|
-
if self.escortGroupObject:IsAirborne(false) == true then
|
|
88
|
-
jtff_log.info('escort RTB : '.. self.escortGroupObject.GroupName..' Tanker : '..self.tanker.GroupName..'...',"AWACS")
|
|
89
|
-
self.escortGroupObject:RouteRTB(airbase)
|
|
90
|
-
else
|
|
91
|
-
--self.escortGroupObject:Destroy(nil, 5)
|
|
92
|
-
end
|
|
363
|
+
function awacsOpsGroup:OnBeforeRTB(From, Event, To, Airbase, speed, holdspeed)
|
|
364
|
+
COORDINATE:RemoveMark(Jtff_map_marker[self:GetName()])
|
|
93
365
|
end
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if self.customconfig.escortgroupname then
|
|
97
|
-
jtff_log.info(event.target' Killed !! Sending escort Home',"AWACS")
|
|
98
|
-
self.escortGroupObject:RouteRTB(AIRBASE:FindByName(self.customconfig.baseUnit))
|
|
366
|
+
function awacsOpsGroup:OnAfterDead(From, Event, To)
|
|
367
|
+
COORDINATE:RemoveMark(Jtff_map_marker[self:GetName()])
|
|
99
368
|
end
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
369
|
+
function awacsOpsGroup:OnAfterElementDestroyed(From, Event, To, Element)
|
|
370
|
+
COORDINATE:RemoveMark(Jtff_map_marker[self:GetName()])
|
|
371
|
+
end
|
|
372
|
+
if self.additionalData.maxEscort > 0 and generateEscortMission == true then
|
|
373
|
+
local escortMission = AUFTRAG:NewESCORT(
|
|
374
|
+
awacsOpsGroup,
|
|
375
|
+
{x=250, y=100, z=400},
|
|
376
|
+
35,
|
|
377
|
+
{'Air'}
|
|
378
|
+
)
|
|
379
|
+
escortMission:SetReturnToLegion(true)
|
|
380
|
+
escortMission:SetRequiredAssets(self.additionalData.minEscort, self.additionalData.maxEscort)
|
|
381
|
+
escortMission:SetReinforce(3)
|
|
382
|
+
escortMission:SetName(string.format("Escort-Awacs-%s", self.additionalData.awacsType))
|
|
383
|
+
escortMission:SetEPLRS(true)
|
|
384
|
+
escortMission:SetEmission(true)
|
|
385
|
+
escortMission:SetVerbosity(JTFF_verbosity_levels[JTFF_LOGLEVEL])
|
|
386
|
+
escortMission:SetFormation(ENUMS.Formation.FixedWing.EchelonRight.Close)
|
|
387
|
+
escortMission:SetMissionAltitude(20000)
|
|
388
|
+
escortMission:SetMissionWaypointRandomization(UTILS.NMToMeters(20))
|
|
389
|
+
escortMission:SetProhibitAfterburnerExecutePhase()
|
|
390
|
+
escortMission:SetTime(
|
|
391
|
+
300,
|
|
392
|
+
( self.additionalData.awacsDuration * 60 ) + 1200
|
|
393
|
+
)
|
|
394
|
+
function escortMission:OnAfterScheduled(From, Event, To)
|
|
395
|
+
for _, opsGroup in ipairs(self:GetOpsGroups()) do
|
|
396
|
+
opsGroup:SetFuelLowThreshold(30)
|
|
397
|
+
opsGroup:SetFuelCriticalThreshold(20)
|
|
398
|
+
opsGroup:SetFuelLowRefuel(true)
|
|
399
|
+
opsGroup:SetFuelLowRTB(false)
|
|
400
|
+
opsGroup:SetFuelCriticalRTB(true)
|
|
401
|
+
opsGroup:SetJettisonEmptyTanks(false)
|
|
402
|
+
opsGroup:SetJettisonWeapons(false)
|
|
403
|
+
end
|
|
107
404
|
end
|
|
405
|
+
airwing:AddMission(escortMission)
|
|
108
406
|
end
|
|
109
407
|
end
|
|
110
|
-
|
|
111
|
-
AwacsArray[compteur]:Start()
|
|
408
|
+
return awacsmission,airwing
|
|
112
409
|
end
|
|
113
410
|
end
|
|
114
411
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
412
|
+
--- Trigger an Awacs mission.
|
|
413
|
+
-- @param #table objAwacs AWACS object.
|
|
414
|
+
function TriggerAwacsMission(objAwacs)
|
|
415
|
+
objAwacs.airwing:AddMission(objAwacs.mission)
|
|
416
|
+
Jtff_log.info(
|
|
417
|
+
string.format(
|
|
418
|
+
'Awacs %s triggered',
|
|
419
|
+
objAwacs.customconfig.type
|
|
420
|
+
),
|
|
421
|
+
"AWACS"
|
|
422
|
+
)
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
-- endregion AwacsFunctions
|
|
426
|
+
|
|
427
|
+
AwacsArray = {}
|
|
428
|
+
MenuCoalitionAwacs = {}
|
|
429
|
+
for _k, _coalition in pairs(coalition.side) do
|
|
430
|
+
MenuCoalitionAwacs[UTILS.GetCoalitionName(_coalition)] = MENU_COALITION:New(_coalition, "Awacs", MenuCoalition[UTILS.GetCoalitionName(_coalition)])
|
|
431
|
+
end
|
|
432
|
+
local compteur = #AwacsArray
|
|
433
|
+
|
|
434
|
+
for index, _currentAwacsConfigObject in ipairs(AwacsConfig) do
|
|
435
|
+
local awacsconfig = ParseAwacsConfigJson(_currentAwacsConfigObject)
|
|
436
|
+
if awacsconfig.enable == true then
|
|
437
|
+
compteur = compteur + 1
|
|
438
|
+
Jtff_log.info(
|
|
439
|
+
string.format(
|
|
440
|
+
'configuration AWACS %s: ',
|
|
441
|
+
awacsconfig.type
|
|
442
|
+
),
|
|
443
|
+
"AWACS"
|
|
444
|
+
)
|
|
445
|
+
local awacsmission, airwing = GenerateAwacsMission(awacsconfig, true)
|
|
446
|
+
if awacsmission == nil or airwing == nil then
|
|
447
|
+
Jtff_log.error(
|
|
448
|
+
string.format(
|
|
449
|
+
"Airwing not found for Airbase %s, skipping Awacs Registration",
|
|
450
|
+
awacsconfig.airbaseName
|
|
451
|
+
),
|
|
452
|
+
"AWACS"
|
|
453
|
+
)
|
|
454
|
+
else
|
|
455
|
+
AwacsArray[compteur] = {
|
|
456
|
+
customconfig = awacsconfig,
|
|
457
|
+
mission = awacsmission,
|
|
458
|
+
airwing = airwing,
|
|
459
|
+
}
|
|
460
|
+
if awacsconfig.autospawn == true then
|
|
461
|
+
Jtff_log.info(
|
|
462
|
+
string.format(
|
|
463
|
+
'autospawn Awacs %s',
|
|
464
|
+
awacsconfig.type
|
|
465
|
+
),
|
|
466
|
+
"AWACS"
|
|
467
|
+
)
|
|
468
|
+
TriggerAwacsMission(AwacsArray[compteur])
|
|
469
|
+
-- AwacsArray[compteur].airwing:AddMission(TanAwacsArraykersArray[compteur].mission)
|
|
470
|
+
else
|
|
471
|
+
Jtff_log.info(
|
|
472
|
+
string.format(
|
|
473
|
+
'OnDemand Awacs %s Registering',
|
|
474
|
+
awacsconfig.type
|
|
475
|
+
),
|
|
476
|
+
"AWACS"
|
|
477
|
+
)
|
|
478
|
+
end
|
|
479
|
+
end
|
|
480
|
+
end
|
|
118
481
|
end
|
|
119
482
|
|
|
120
483
|
-- *****************************************************************************
|
|
121
484
|
-- ** OnDemand Awacs **
|
|
122
485
|
-- *********************************************************
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
486
|
+
function TriggerOnDemandAwacs(type, askedDuration, askedFL, askedSpeed, askedAnchorCoord, askedOrbitHeading,askedOrbitLeg)
|
|
487
|
+
if (AwacsConfig) then
|
|
488
|
+
for index, objAwacs in ipairs(AwacsArray) do
|
|
489
|
+
if (objAwacs.customconfig.type == type) then
|
|
490
|
+
Jtff_log.debug(
|
|
491
|
+
string.format(
|
|
492
|
+
'OnDemandAwacs : Found type %s Awacs !',
|
|
493
|
+
type
|
|
494
|
+
),
|
|
495
|
+
"AWACS"
|
|
496
|
+
)
|
|
497
|
+
if (askedAnchorCoord) then
|
|
498
|
+
objAwacs.customconfig.racetrack.coordinate = askedAnchorCoord:ToStringMGRS()
|
|
131
499
|
end
|
|
132
500
|
if (askedFL and askedFL > 0) then
|
|
133
|
-
|
|
501
|
+
objAwacs.customconfig.racetrack.fl = askedFL
|
|
502
|
+
end
|
|
503
|
+
if (askedSpeed and askedSpeed > 0) then
|
|
504
|
+
objAwacs.customconfig.racetrack.speed = askedSpeed
|
|
134
505
|
end
|
|
135
|
-
if (
|
|
136
|
-
|
|
506
|
+
if (askedDuration ~= nil and askedDuration ~= 0) then
|
|
507
|
+
objAwacs.customconfig.missionmaxduration = askedDuration
|
|
137
508
|
end
|
|
138
509
|
if (askedOrbitHeading) then
|
|
139
|
-
if (askedOrbitLeg
|
|
510
|
+
if (askedOrbitLeg) then
|
|
140
511
|
--heading et Leg demandés
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
length = askedOrbitLeg,
|
|
144
|
-
}
|
|
512
|
+
objAwacs.customconfig.racetrack.heading = askedOrbitHeading % 360
|
|
513
|
+
objAwacs.customconfig.racetrack.leg = math.max(10, askedOrbitLeg)
|
|
145
514
|
else
|
|
146
515
|
--heading demandé et leg non demandé
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
OnDemandAwacs.orbit = {
|
|
150
|
-
heading = askedOrbitHeading % 360,
|
|
151
|
-
length = 30,
|
|
152
|
-
}
|
|
153
|
-
else
|
|
154
|
-
OnDemandAwacs.orbit = {
|
|
155
|
-
heading = askedOrbitHeading % 360,
|
|
156
|
-
length = math.max(5, OnDemandAwacs.orbit.length),
|
|
157
|
-
}
|
|
158
|
-
end
|
|
159
|
-
else
|
|
160
|
-
OnDemandAwacs.orbit = {
|
|
161
|
-
heading = askedOrbitHeading % 360,
|
|
162
|
-
length = 30,
|
|
163
|
-
}
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
else
|
|
167
|
-
--pas de heading demandé
|
|
168
|
-
if (OnDemandAwacs.orbit ) then
|
|
169
|
-
if (not(OnDemandAwacs.orbit.heading)) then
|
|
170
|
-
OnDemandAwacs.orbit.heading = 90
|
|
171
|
-
end
|
|
172
|
-
if (not(OnDemandAwacs.orbit.length)) then
|
|
173
|
-
OnDemandAwacs.orbit.length = 30
|
|
174
|
-
else
|
|
175
|
-
OnDemandAwacs.orbit.length = math.max(5, OnDemandAwacs.orbit.length)
|
|
176
|
-
end
|
|
177
|
-
else
|
|
178
|
-
OnDemandAwacs.orbit = {
|
|
179
|
-
heading = 90,
|
|
180
|
-
length = 30,
|
|
181
|
-
}
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
local set_group_awacs = SET_GROUP:New()
|
|
185
|
-
:FilterActive()
|
|
186
|
-
:FilterPrefixes(OnDemandAwacs.groupName)
|
|
187
|
-
:FilterCategories("plane")
|
|
188
|
-
:FilterOnce()
|
|
189
|
-
local aliveAwacsGroupList = set_group_awacs:GetSetObjects()
|
|
190
|
-
|
|
191
|
-
local is_awacs_spawned = false
|
|
192
|
-
jtff_log.debug(string.format('Looking for a Group corresponding to template %s', string.format("%s-%s", OnDemandAwacs.groupName, OnDemandAwacs.type)),"AWACS")
|
|
193
|
-
for current_index, current_group in ipairs(aliveAwacsGroupList) do
|
|
194
|
-
if (
|
|
195
|
-
(not(is_awacs_spawned)) and
|
|
196
|
-
(string.find(
|
|
197
|
-
current_group.GroupName,
|
|
198
|
-
string.format("%s-%s", OnDemandAwacs.groupName, OnDemandAwacs.type),
|
|
199
|
-
1,
|
|
200
|
-
true
|
|
201
|
-
) ~= nil)
|
|
202
|
-
) then
|
|
203
|
-
jtff_log.info(string.format('Found %s corresponding to template %s', current_group.GroupName, string.format("%s-%s", OnDemandAwacs.groupName, OnDemandAwacs.type)),"AWACS")
|
|
204
|
-
is_awacs_spawned = true
|
|
205
|
-
AwacsGroup = current_group
|
|
516
|
+
objAwacs.customconfig.racetrack.heading = askedOrbitHeading % 360
|
|
517
|
+
objAwacs.customconfig.racetrack.leg = 30
|
|
206
518
|
end
|
|
207
519
|
end
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
jtff_log.info(string.format('OnDemandAwacs already in air : rerouting %s', OnDemandAwacs.groupName),"AWACS")
|
|
218
|
-
AwacsGroup:ClearTasks()
|
|
219
|
-
table.insert(
|
|
220
|
-
AwacsRoute,
|
|
221
|
-
askedAnchorCoord
|
|
222
|
-
:SetAltitude(UTILS.FeetToMeters(OnDemandAwacs.altitude))
|
|
223
|
-
:WaypointAirTurningPoint(
|
|
224
|
-
nil,
|
|
225
|
-
UTILS.KnotsToKmph(OnDemandAwacs.speed),
|
|
226
|
-
{
|
|
227
|
-
{
|
|
228
|
-
id = 'AWACS',
|
|
229
|
-
params = {
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
id = 'ControlledTask',
|
|
234
|
-
params = {
|
|
235
|
-
task =
|
|
236
|
-
{
|
|
237
|
-
id = 'Orbit',
|
|
238
|
-
params = {
|
|
239
|
-
pattern = AI.Task.OrbitPattern.RACE_TRACK,
|
|
240
|
-
speed = UTILS.KnotsToMps(OnDemandAwacs.speed),
|
|
241
|
-
altitude = UTILS.FeetToMeters(OnDemandAwacs.altitude)
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
stopCondition = {
|
|
245
|
-
duration = askedDuration * 60
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
"Awacs Start"
|
|
251
|
-
)
|
|
252
|
-
)
|
|
253
|
-
table.insert(
|
|
254
|
-
AwacsRoute,
|
|
255
|
-
askedAnchorCoord
|
|
256
|
-
:Translate(UTILS.NMToMeters(OnDemandAwacs.orbit.length), OnDemandAwacs.orbit.heading, true, false)
|
|
257
|
-
:SetAltitude(UTILS.FeetToMeters(OnDemandAwacs.altitude))
|
|
258
|
-
:WaypointAirTurningPoint(
|
|
259
|
-
nil,
|
|
260
|
-
UTILS.KnotsToKmph(OnDemandAwacs.speed),
|
|
261
|
-
{
|
|
262
|
-
{
|
|
263
|
-
id = 'AWACS',
|
|
264
|
-
params = {
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
"Orbit End"
|
|
269
|
-
)
|
|
270
|
-
)
|
|
271
|
-
table.insert(
|
|
272
|
-
AwacsRoute,
|
|
273
|
-
RTBAirbase
|
|
274
|
-
:GetCoordinate()
|
|
275
|
-
:WaypointAirLanding(
|
|
276
|
-
UTILS.KnotsToKmph(OnDemandAwacs.speed),
|
|
277
|
-
RTBAirbase
|
|
278
|
-
)
|
|
279
|
-
)
|
|
280
|
-
else
|
|
281
|
-
jtff_log.info(string.format('OnDemandAwacs Spawning %s', OnDemandAwacs.groupName),"AWACS")
|
|
282
|
-
local SpawnAwacs = SPAWN:NewWithAlias(
|
|
283
|
-
OnDemandAwacs.groupName,
|
|
284
|
-
string.format("%s-%s", OnDemandAwacs.groupName, OnDemandAwacs.type)
|
|
520
|
+
local oldMission = objAwacs.airwing:GetMissionByID(objAwacs.mission.auftragsnummer)
|
|
521
|
+
if oldMission then
|
|
522
|
+
Jtff_log.info(
|
|
523
|
+
string.format(
|
|
524
|
+
'Mission %s already registered to Airwing %s, rerouting now',
|
|
525
|
+
objAwacs.mission:GetName(),
|
|
526
|
+
objAwacs.airwing:GetName()
|
|
527
|
+
),
|
|
528
|
+
"AWACS"
|
|
285
529
|
)
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
AIRBASE:FindByName(OnDemandAwacs.baseUnit),
|
|
296
|
-
SPAWN.Takeoff.Hot,
|
|
297
|
-
nil,
|
|
298
|
-
OnDemandAwacs.terminalType
|
|
299
|
-
)
|
|
300
|
-
table.insert(AwacsRoute,
|
|
301
|
-
AIRBASE
|
|
302
|
-
:FindByName(OnDemandAwacs.baseUnit)
|
|
303
|
-
:GetCoordinate()
|
|
304
|
-
:WaypointAirTakeOffParkingHot()
|
|
305
|
-
)
|
|
306
|
-
else
|
|
307
|
-
AwacsGroup = SpawnAwacs:SpawnFromCoordinate(
|
|
308
|
-
askedAnchorCoord
|
|
309
|
-
:GetRandomCoordinateInRadius(
|
|
310
|
-
UTILS.NMToMeters(30),
|
|
311
|
-
UTILS.NMToMeters(20)
|
|
312
|
-
)
|
|
313
|
-
:SetAltitude(
|
|
314
|
-
UTILS.FeetToMeters(OnDemandAwacs.altitude)
|
|
315
|
-
)
|
|
316
|
-
)
|
|
317
|
-
end
|
|
318
|
-
AwacsGroup.customconfig = OnDemandAwacs
|
|
319
|
-
AwacsGroup.spawnAbsTime = timer.getAbsTime()
|
|
320
|
-
AwacsGroup.missionmaxduration = askedDuration
|
|
321
|
-
table.insert(AwacsRoute,
|
|
322
|
-
askedAnchorCoord
|
|
323
|
-
:SetAltitude(UTILS.FeetToMeters(OnDemandAwacs.altitude))
|
|
324
|
-
:WaypointAirTurningPoint(
|
|
325
|
-
nil,
|
|
326
|
-
UTILS.KnotsToKmph(OnDemandAwacs.speed),
|
|
327
|
-
{
|
|
328
|
-
{
|
|
329
|
-
id = 'AWACS',
|
|
330
|
-
params = {
|
|
331
|
-
}
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
id = 'ControlledTask',
|
|
335
|
-
params = {
|
|
336
|
-
task =
|
|
337
|
-
{
|
|
338
|
-
id = 'Orbit',
|
|
339
|
-
params = {
|
|
340
|
-
pattern = AI.Task.OrbitPattern.RACE_TRACK,
|
|
341
|
-
speed = UTILS.KnotsToMps(OnDemandAwacs.speed),
|
|
342
|
-
altitude = UTILS.FeetToMeters(OnDemandAwacs.altitude)
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
stopCondition = {
|
|
346
|
-
duration = askedDuration * 60
|
|
347
|
-
}
|
|
348
|
-
},
|
|
349
|
-
},
|
|
350
|
-
},
|
|
351
|
-
"Awacs Start"
|
|
352
|
-
)
|
|
530
|
+
local objOpsGroup = objAwacs.mission:GetOpsGroups()[1]
|
|
531
|
+
Jtff_log.debug(
|
|
532
|
+
string.format(
|
|
533
|
+
'OpsGroup executing previous mission %s ID=%d is %s',
|
|
534
|
+
oldMission:GetName(),
|
|
535
|
+
oldMission.auftragsnummer,
|
|
536
|
+
objOpsGroup:GetName()
|
|
537
|
+
),
|
|
538
|
+
"AWACS"
|
|
353
539
|
)
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
:
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
id = 'AWACS',
|
|
364
|
-
params = {
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
},
|
|
368
|
-
"Orbit End"
|
|
369
|
-
)
|
|
540
|
+
objAwacs.mission, objAwacs.airwing = GenerateAwacsMission(objAwacs.customconfig, false)
|
|
541
|
+
Jtff_log.debug(
|
|
542
|
+
string.format(
|
|
543
|
+
'Next Mission generated %s ID=%d for airwing %s',
|
|
544
|
+
objAwacs.mission:GetName(),
|
|
545
|
+
objAwacs.mission.auftragsnummer,
|
|
546
|
+
objAwacs.airwing:GetName()
|
|
547
|
+
),
|
|
548
|
+
"AWACS"
|
|
370
549
|
)
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
:
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
)
|
|
550
|
+
objOpsGroup:AddMission(objAwacs.mission)
|
|
551
|
+
Jtff_log.debug(
|
|
552
|
+
string.format(
|
|
553
|
+
'Added next Mission %s generated ID=%d to group %s : %d mission(s) active(s)',
|
|
554
|
+
objAwacs.mission:GetName(),
|
|
555
|
+
objAwacs.mission.auftragsnummer,
|
|
556
|
+
objOpsGroup:GetName(),
|
|
557
|
+
#(objOpsGroup.missionqueue)
|
|
558
|
+
),
|
|
559
|
+
"AWACS"
|
|
380
560
|
)
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
AwacsGroup.beacon:ActivateTACAN(OnDemandAwacs.tacan.channel, "Y", OnDemandAwacs.tacan.morse, true)
|
|
387
|
-
end
|
|
388
|
-
if (OnDemandAwacs.callsign) then
|
|
389
|
-
AwacsGroup:CommandSetCallsign(OnDemandAwacs.callsign.name, OnDemandAwacs.callsign.number, 2)
|
|
390
|
-
end
|
|
391
|
-
if OnDemandAwacs.escortgroupname then
|
|
392
|
-
AwacsGroup.escortSpawnObject = SPAWN:NewWithAlias(OnDemandAwacs.escortgroupname,'escort-'.. OnDemandAwacs.groupName)
|
|
393
|
-
:InitRepeatOnEngineShutDown()
|
|
394
|
-
:InitSkill("Excellent")
|
|
395
|
-
:OnSpawnGroup(function(SpawnGroup)
|
|
396
|
-
taskGroupEscort({AwacsGroup, SpawnGroup})
|
|
397
|
-
end)
|
|
398
|
-
AwacsGroup.escortGroupObject = spawnRecoveryTankerEscort(AwacsGroup.escortSpawnObject,OnDemandAwacs)
|
|
399
|
-
if OnDemandAwacs.missionmaxduration then
|
|
400
|
-
AwacsGroup.escortGroupObject:ScheduleOnce(OnDemandAwacs.missionmaxduration*60,
|
|
401
|
-
function(SpawnGroup, airBaseName)
|
|
402
|
-
--trigger.action.outText('RTB schedule trigger Tanker-escort group : '..(SpawnGroup.GroupName)..' airbase'..(airBaseName)..'...', 45)
|
|
403
|
-
SpawnGroup:RouteRTB(AIRBASE:FindByName(airBaseName))
|
|
404
|
-
end,
|
|
405
|
-
AwacsGroup.escortGroupObject,
|
|
406
|
-
OnDemandAwacs.baseUnit
|
|
407
|
-
)
|
|
408
|
-
--trigger.action.outText('Tanker-escort configured to RTB in : '..(OnDemandAwacs.missionmaxduration)..' minutes max...', 45)
|
|
409
|
-
end
|
|
410
|
-
end
|
|
411
|
-
if (map_marker[AwacsGroup:GetName()]) then
|
|
412
|
-
COORDINATE:RemoveMark(map_marker[AwacsGroup:GetName()])
|
|
413
|
-
end
|
|
414
|
-
if (OnDemandAwacs.tacan) then
|
|
415
|
-
map_marker[AwacsGroup:GetName()] = askedAnchorCoord:MarkToCoalition(
|
|
561
|
+
-- objAwacs.airwing:AddMission(objAwacs.mission)
|
|
562
|
+
objAwacs.mission:AssignLegion(objAwacs.airwing)
|
|
563
|
+
table.insert(objAwacs.airwing.missionqueue, objAwacs.mission)
|
|
564
|
+
oldMission:SetTime(nil, 5)
|
|
565
|
+
Jtff_log.debug(
|
|
416
566
|
string.format(
|
|
417
|
-
'
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
OnDemandAwacs.freq,
|
|
423
|
-
askedDuration,
|
|
424
|
-
OnDemandAwacs.orbit.heading,
|
|
425
|
-
OnDemandAwacs.orbit.length
|
|
567
|
+
'Stopped old Mission %s (ID=%d) from group %s : %d mission(s) active(s)',
|
|
568
|
+
oldMission:GetName(),
|
|
569
|
+
oldMission.auftragsnummer,
|
|
570
|
+
objOpsGroup:GetName(),
|
|
571
|
+
#(objOpsGroup.missionqueue)
|
|
426
572
|
),
|
|
427
|
-
|
|
428
|
-
true,
|
|
429
|
-
'OnDemand Awacs %s is Activated'
|
|
573
|
+
"AWACS"
|
|
430
574
|
)
|
|
431
575
|
else
|
|
432
|
-
|
|
576
|
+
Jtff_log.info(
|
|
433
577
|
string.format(
|
|
434
|
-
'
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
OnDemandAwacs.speed,
|
|
438
|
-
OnDemandAwacs.freq,
|
|
439
|
-
askedDuration,
|
|
440
|
-
OnDemandAwacs.orbit.heading,
|
|
441
|
-
OnDemandAwacs.orbit.length
|
|
578
|
+
'Mission %s not registered to Airwing %s, spawning now',
|
|
579
|
+
objAwacs.mission:GetName(),
|
|
580
|
+
objAwacs.airwing:GetName()
|
|
442
581
|
),
|
|
443
|
-
|
|
444
|
-
true,
|
|
445
|
-
'OnDemand Awacs %s is Activated'
|
|
582
|
+
"AWACS"
|
|
446
583
|
)
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
AwacsGroup:HandleEvent(EVENTS.Crash)
|
|
450
|
-
AwacsGroup:HandleEvent(EVENTS.Dead)
|
|
451
|
-
function AwacsGroup:OnEventLand(EventData)
|
|
452
|
-
COORDINATE:RemoveMark(map_marker[self:GetName()])
|
|
453
|
-
if self.customconfig.escortgroupname then
|
|
454
|
-
jtff_log.info('RTB: '..self.GroupName..'...',"AWACS")
|
|
455
|
-
if self.escortGroupObject:IsAirborne(false) == true then
|
|
456
|
-
jtff_log.info('escort RTB : '.. self.escortGroupObject.GroupName..' AWACS : '..self.GroupName..'...',"AWACS")
|
|
457
|
-
self.escortGroupObject:RouteRTB()
|
|
458
|
-
else
|
|
459
|
-
--self.escortGroupObject:Destroy(nil, 5)
|
|
460
|
-
end
|
|
461
|
-
end
|
|
462
|
-
end
|
|
463
|
-
function AwacsGroup:OnEventCrash(EventData)
|
|
464
|
-
COORDINATE:RemoveMark(map_marker[self:GetName()])
|
|
465
|
-
if self.customconfig.escortgroupname then
|
|
466
|
-
jtff_log.info('RTB: '..self.GroupName..'...',"AWACS")
|
|
467
|
-
if self.escortGroupObject:IsAirborne(false) == true then
|
|
468
|
-
jtff_log.info('escort RTB : '.. self.escortGroupObject.GroupName..' AWACS : '..self.GroupName..'...',"AWACS")
|
|
469
|
-
self.escortGroupObject:RouteRTB()
|
|
470
|
-
else
|
|
471
|
-
--self.escortGroupObject:Destroy(nil, 5)
|
|
472
|
-
end
|
|
473
|
-
end
|
|
474
|
-
end
|
|
475
|
-
function AwacsGroup:OnEventDead(EventData)
|
|
476
|
-
COORDINATE:RemoveMark(map_marker[self:GetName()])
|
|
477
|
-
if self.customconfig.escortgroupname then
|
|
478
|
-
jtff_log.info('RTB: '..self.GroupName..'...',"AWACS")
|
|
479
|
-
if self.escortGroupObject:IsAirborne(false) == true then
|
|
480
|
-
jtff_log.info('escort RTB : '.. self.escortGroupObject.GroupName..' AWACS : '..self.GroupName..'...',"AWACS")
|
|
481
|
-
self.escortGroupObject:RouteRTB()
|
|
482
|
-
else
|
|
483
|
-
--self.escortGroupObject:Destroy(nil, 5)
|
|
484
|
-
end
|
|
485
|
-
end
|
|
584
|
+
objAwacs.mission, objAwacs.airwing = GenerateAwacsMission(objAwacs.customconfig, true)
|
|
585
|
+
objAwacs.airwing:AddMission(objAwacs.mission)
|
|
486
586
|
end
|
|
487
587
|
end
|
|
488
588
|
end
|
|
489
589
|
end
|
|
490
|
-
return AwacsGroup;
|
|
491
590
|
end
|
|
492
591
|
|
|
493
592
|
--local RestrToCoal = nil
|
|
494
|
-
awacsOnDemandArray = {}
|
|
495
593
|
local AwacsMarkHandler = {}
|
|
496
594
|
|
|
497
595
|
|
|
@@ -565,7 +663,7 @@ function AwacsMarkHandler:onEvent(event)
|
|
|
565
663
|
else
|
|
566
664
|
cmd = full
|
|
567
665
|
end
|
|
568
|
-
if
|
|
666
|
+
if Log_levels[JTFF_LOGLEVEL] <= Log_levels['debug'] then
|
|
569
667
|
trigger.action.outText("Full Text = " .. full, 10)
|
|
570
668
|
trigger.action.outText("Command = " .. cmd, 10)
|
|
571
669
|
if param1 ~= nil then trigger.action.outText("type = " .. param1, 10) end
|
|
@@ -577,10 +675,10 @@ function AwacsMarkHandler:onEvent(event)
|
|
|
577
675
|
end
|
|
578
676
|
|
|
579
677
|
if string.find(cmd, "awacs") then
|
|
580
|
-
if
|
|
678
|
+
if Log_levels[JTFF_LOGLEVEL] <= Log_levels['debug'] then
|
|
581
679
|
trigger.action.outText("DEBUG: On Demand Awacs Started!", 10)
|
|
582
680
|
end
|
|
583
|
-
|
|
681
|
+
TriggerOnDemandAwacs(
|
|
584
682
|
param1,
|
|
585
683
|
tonumber(param2),
|
|
586
684
|
tonumber(param3),
|
|
@@ -590,9 +688,7 @@ function AwacsMarkHandler:onEvent(event)
|
|
|
590
688
|
tonumber(param6)
|
|
591
689
|
)
|
|
592
690
|
end
|
|
593
|
-
--end
|
|
594
691
|
end
|
|
595
|
-
|
|
596
692
|
end
|
|
597
693
|
|
|
598
694
|
world.addEventHandler(AwacsMarkHandler)
|