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