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