@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.
@@ -1,273 +1,324 @@
1
- -- *****************************************************************************
2
- -- ** Interception Training **
3
- -- *********************************************************
4
- function clearIntercept(param)
5
- local objInterceptIndex = param[1]
6
- local objIntercept = InterceptArray[objInterceptIndex]
7
- jtff_log.debug(string.format("objIntercept.objSpawn is %s", net.lua2json(objIntercept.objSpawn)),"INTERCEPT")
8
- local GroupPlane, Index = objIntercept.objSpawn:GetFirstAliveGroup()
9
- while GroupPlane ~= nil do
10
- GroupPlane:ScheduleStop()
11
- GroupPlane:Destroy(true,0)
12
- GroupPlane, Index = objIntercept.objSpawn:GetNextAliveGroup( Index )
13
- end
14
- collectgarbage()
15
- end
1
+ -- region InterceptConfigFunctions
16
2
 
17
- function interceptDefendFicghter(targetGroup)
18
- targetGroup:OptionROEWeaponFree()
19
- targetGroup:OptionROTVertical()
20
- targetGroup:OptionRTBBingoFuel(true)
21
- targetGroup:OptionRestrictBurner(false)
22
- targetGroup:EnableEmission(true)
23
- targetGroup:OptionAlarmStateRed()
24
- targetGroup:OptionECM_DetectedLockByRadar()
25
- targetGroup:CommandEPLRS(true)
26
- end
3
+ -- @type InterceptConfig
4
+ -- @field #string name Name of the intercept scenario.
5
+ -- @field #boolean enable Enable the intercept scenario.
6
+ -- @field #coalition.side benefitCoalition Benefit coalition.
7
+ -- @field #JTFF_INTERCEPT.Type type Type of intercept.
8
+ -- @field #string skill Skill of the intercept.
9
+ -- @field #string[] templates Templates of the intercept (string or table of strings).
27
10
 
28
- function interceptDefendFastBomber(targetGroup)
29
- targetGroup:OptionRestrictBurner(false)
30
- local targetDestinationCoord = targetGroup:GetCoordinate():Translate(
31
- UTILS.NMToMeters(150),
32
- targetGroup:GetHeading(),
33
- true,
34
- false
35
- ):SetAltitude(UTILS.FeetToMeters(55000), true)
36
- targetGroup:Route(
37
- {
38
- targetDestinationCoord:WaypointAirTurningPoint(
39
- COORDINATE.WaypointAltType.BARO,
40
- UTILS.KnotsToKmph(5000),
41
- nil,
42
- "End interception"
43
- ),
44
- targetDestinationCoord:GetClosestAirbase(
45
- targetGroup:GetCategory(),
46
- targetGroup:GetCoalition()
47
- ):GetCoordinate():WaypointAirLanding(
48
- UTILS.KnotsToKmph(250),
49
- targetDestinationCoord:GetClosestAirbase(
50
- targetGroup:GetCategory(),
51
- targetGroup:GetCoalition()
52
- )
53
- )
54
- }
55
- )
11
+ --- Parse a RAT config Object.
12
+ -- @param #JsonObject config Config object to parse
13
+ -- @return #InterceptConfig interceptConfigJson Parsed INTERCEPT config object
14
+ function ParseInterceptConfigJson(config)
15
+ local json = require('Scripts/json')
16
+ local parser_name = "INTERCEPT"
17
+ -- **************************************************************************
18
+ -- enable
19
+ -- **************************************************************************
20
+ local interceptConfigJson = {}
21
+ if config.enable == true then
22
+ interceptConfigJson = config
23
+ else
24
+ interceptConfigJson = {
25
+ enable = false,
26
+ }
27
+ end
28
+ Jtff_log.debug(
29
+ string.format(
30
+ "parsed INTERCEPT config for %s, resulting config :\n%s",
31
+ config.name or "",
32
+ json:encode(
33
+ interceptConfigJson,
34
+ { indent = true }
35
+ )
36
+ ),
37
+ parser_name
38
+ )
39
+ return interceptConfigJson
56
40
  end
57
41
 
58
- function interceptDetection(param)
59
- local objIntercept = param[1]
60
- jtff_log.debug(string.format("objIntercept.interceptDetectionZone is %s", net.lua2json(objIntercept.interceptDetectionZone)),"INTERCEPT")
61
- --jtff_log.debug(string.format("interceptorUnitName is %s", net.lua2json(interceptorUnitName)),"INTERCEPT")
62
- if ( objIntercept.bubbleInvaded == false ) then
63
- jtff_log.trace(string.format("%s has not yet been intercepted", objIntercept.interceptTarget:GetName()),"INTERCEPT")
64
- --jtff_log.debug(string.format("interceptDetectionZone is %s", net.lua2json(interceptDetectionZone)),"INTERCEPT")
65
- if (SET_CLIENT:New():FilterZones({objIntercept.interceptDetectionZone}):FilterOnce():CountAlive() > 0) then
66
- objIntercept.bubbleInvaded = true
67
- jtff_log.info(string.format("%s has been intercepted", objIntercept.interceptTarget:GetName()),"INTERCEPT")
68
- if (objIntercept.knowIsIntercepted == false) then
69
- if (math.random(1,100) >= 75) then
70
- local delay = math.random(15,120)
71
- jtff_log.info(string.format("%s has detected it has been intercepted : he will react accordingly in %i seconds !", objIntercept.interceptTarget:GetName(), delay),"INTERCEPT")
72
- objIntercept.knowIsIntercepted = true
73
- if objIntercept.customconfig.type == 'fastbomber' then
74
- SCHEDULER:New(
75
- objIntercept.interceptTarget,
76
- interceptDefendFastBomber,
77
- {},
78
- delay
79
- )
80
- elseif objIntercept.customconfig.type == 'fighter' then
81
- SCHEDULER:New(
82
- objIntercept.interceptTarget,
83
- interceptDefendFicghter,
84
- {},
85
- delay
86
- )
87
- end
88
- else
89
- jtff_log.info(string.format("%s has not detected soon enough it has been intercepted", objIntercept.interceptTarget:GetName()),"INTERCEPT")
90
- end
91
- end
92
- end
93
- end
94
- end
42
+ -- endregion InterceptConfigFunctions
43
+
44
+ -- region InterceptFunctions
95
45
 
96
- function StartInterceptTraining(param)
97
- local fighterUnitName = param[1]
98
- local objInterceptIndex = param[2]
99
- jtff_log.debug(string.format("fighterUnitName is %s", fighterUnitName),"INTERCEPT")
100
- jtff_log.debug(string.format("objInterceptIndex is %i", objInterceptIndex),"INTERCEPT")
101
- local minTA = param[3]
102
- local maxTA = param[4]
103
- local fighterUnit = UNIT:FindByName(fighterUnitName)
104
- jtff_log.debug(string.format("fighterUnit is %s", net.lua2json(fighterUnit)),"INTERCEPT")
105
- local fighterGroup = fighterUnit:GetGroup()
106
- local fighterCoord = fighterUnit:GetCoordinate()
107
- jtff_log.debug(string.format("fighterCoord is x=%d y=%d z=%d", fighterCoord.x, fighterCoord.y, fighterCoord.z),"INTERCEPT")
108
- local fighterHeading = fighterUnit:GetHeading()
109
- jtff_log.debug(string.format("fighterHeading is %i", fighterHeading),"INTERCEPT")
110
- local fighterAltitude = fighterUnit:GetAltitude(false)
111
- local deltaAltMax = nil
112
- local targetGroup = nil
113
- local targetRange = nil
114
- local targetGroundSpeed = 450
115
- local targetAngle = math.mod(minTA + math.random(0,maxTA-minTA),360)
116
- if (math.abs(math.mod(targetAngle,180)) > 50) then
117
- targetRange = 40
118
- deltaAltMax = 7000
119
- elseif (math.abs(math.mod(targetAngle,180)) > 20) then
120
- targetRange = 60
121
- deltaAltMax = 10000
122
- else
123
- targetRange = 90
124
- deltaAltMax = 15000
46
+ function clearIntercept(param)
47
+ local objInterceptIndex = param[1]
48
+ local objIntercept = InterceptArray[objInterceptIndex]
49
+ Jtff_log.debug(string.format("objIntercept.objSpawn is %s", net.lua2json(objIntercept.objSpawn)),"INTERCEPT")
50
+ local GroupPlane, Index = objIntercept.objSpawn:GetFirstAliveGroup()
51
+ while GroupPlane ~= nil do
52
+ GroupPlane:ScheduleStop()
53
+ GroupPlane:Destroy(true,0)
54
+ GroupPlane, Index = objIntercept.objSpawn:GetNextAliveGroup( Index )
55
+ end
56
+ collectgarbage()
125
57
  end
126
- jtff_log.info(string.format("Launching exercise TargetAngle %i degrees", targetAngle),"INTERCEPT")
127
- jtff_log.debug(string.format("Index is : %i", objInterceptIndex),"INTERCEPT")
128
- local targetSpawnObj = InterceptArray[objInterceptIndex].objSpawn
129
- local targetCoord = COORDINATE:NewFromVec3(
130
- {
131
- x = fighterCoord.x + math.floor(UTILS.NMToMeters(targetRange) * math.cos(math.rad(fighterHeading))),
132
- y = math.max(
133
- math.min(
134
- math.random(
135
- fighterCoord.y - UTILS.FeetToMeters(deltaAltMax),
136
- fighterCoord.y + UTILS.FeetToMeters(deltaAltMax)
137
- ),
138
- UTILS.FeetToMeters(32000)
139
- ),
140
- UTILS.FeetToMeters(8000)
141
- ),
142
- z = fighterCoord.z + math.floor(UTILS.NMToMeters(targetRange) * math.sin(math.rad(fighterHeading))),
143
- }
144
- )
145
- jtff_log.info(string.format("Spawning target based on %s with TargetAngle of %i degrees", targetSpawnObj.SpawnTemplatePrefix, targetAngle),"INTERCEPT")
146
- targetGroup = targetSpawnObj:InitHeading(math.mod(fighterHeading + 180 + targetAngle,360)):SpawnFromVec3(targetCoord:GetVec3())
147
- targetGroup:OptionROE(ENUMS.ROE.WeaponHold)
148
- targetGroup:OptionROT(ENUMS.ROT.NoReaction)
149
- targetGroup:OptionRTBBingoFuel(true)
150
- targetGroup:OptionRestrictBurner(false)
151
- targetGroup:EnableEmission(false)
152
- targetGroup:OptionAlarmStateGreen()
153
- targetGroup:OptionECM_Never()
154
- targetGroup:CommandEPLRS(true)
155
- InterceptArray[objInterceptIndex].interceptTarget = targetGroup
156
- InterceptArray[objInterceptIndex].knowIsIntercepted = false
157
- InterceptArray[objInterceptIndex].bubbleInvaded = false
158
- local targetDetectionRange = 1.5
159
- --targetDetectionRange = 70
160
- InterceptArray[objInterceptIndex].interceptDetectionZone = ZONE_GROUP:New(
161
- "intercept-" .. targetGroup:GetName(),
162
- targetGroup,
163
- UTILS.NMToMeters(targetDetectionRange)
164
- )
165
- InterceptArray[objInterceptIndex].interceptTarget:ScheduleRepeat(
166
- 0,
167
- 5,
168
- nil,
169
- nil,
170
- interceptDetection,
171
- {
172
- InterceptArray[objInterceptIndex]
173
- }
174
- )
175
- local targetDestinationCoord = targetGroup:GetCoordinate():Translate(
176
- UTILS.NMToMeters(200),
177
- math.mod(fighterHeading+180+ targetAngle,360),
178
- true,
179
- false
180
- )
181
- jtff_log.debug(string.format("targetDestinationCoord is %s", targetDestinationCoord:ToStringMGRS()),"INTERCEPT")
182
- local targetDestinationAirbase = targetDestinationCoord:GetClosestAirbase(
183
- targetGroup:GetCategory(),
184
- targetGroup:GetCoalition()
185
- )
186
- if type(targetDestinationAirbase) == 'nil' then
187
- targetDestinationAirbase = targetDestinationCoord:GetClosestAirbase(
188
- targetGroup:GetCategory(),
189
- coalition.side.NEUTRAL
190
- )
191
- jtff_log.info(string.format("no airbase in target coalition, choosing neutral coalition Airbase %s", targetDestinationAirbase:GetName()),"INTERCEPT")
58
+
59
+ function interceptDefendFicghter(targetGroup)
60
+ targetGroup:OptionROEWeaponFree()
61
+ targetGroup:OptionROTVertical()
62
+ targetGroup:OptionRTBBingoFuel(true)
63
+ targetGroup:OptionRestrictBurner(false)
64
+ targetGroup:EnableEmission(true)
65
+ targetGroup:OptionAlarmStateRed()
66
+ targetGroup:OptionECM_DetectedLockByRadar()
67
+ targetGroup:CommandEPLRS(true)
192
68
  end
193
- jtff_log.debug(string.format("targetDestinationAirbase is %s", targetDestinationAirbase:GetName()),"INTERCEPT")
194
- local targetRoute = {}
195
- targetRoute[1] = targetDestinationCoord:WaypointAirTurningPoint(
196
- COORDINATE.WaypointAltType.BARO,
197
- UTILS.KnotsToKmph(targetGroundSpeed),
198
- nil,
199
- "End interception"
200
- )
201
- targetRoute[2] = targetDestinationAirbase:GetCoordinate():WaypointAirLanding(
202
- UTILS.KnotsToKmph(targetGroundSpeed),
203
- targetDestinationAirbase
204
- )
205
- targetGroup:Route(targetRoute)
206
- return targetGroup
207
- end
69
+
70
+ function interceptDefendFastBomber(targetGroup)
71
+ targetGroup:OptionRestrictBurner(false)
72
+ local targetDestinationCoord = targetGroup:GetCoordinate():Translate(
73
+ UTILS.NMToMeters(150),
74
+ targetGroup:GetHeading(),
75
+ true,
76
+ false
77
+ ):SetAltitude(UTILS.FeetToMeters(55000), true)
78
+ targetGroup:Route(
79
+ {
80
+ targetDestinationCoord:WaypointAirTurningPoint(
81
+ COORDINATE.WaypointAltType.BARO,
82
+ UTILS.KnotsToKmph(5000),
83
+ nil,
84
+ "End interception"
85
+ ),
86
+ targetDestinationCoord:GetClosestAirbase(
87
+ targetGroup:GetCategory(),
88
+ targetGroup:GetCoalition()
89
+ ):GetCoordinate():WaypointAirLanding(
90
+ UTILS.KnotsToKmph(250),
91
+ targetDestinationCoord:GetClosestAirbase(
92
+ targetGroup:GetCategory(),
93
+ targetGroup:GetCoalition()
94
+ )
95
+ )
96
+ }
97
+ )
98
+ end
99
+
100
+ function interceptDetection(param)
101
+ local objIntercept = param[1]
102
+ Jtff_log.debug(string.format("objIntercept.interceptDetectionZone is %s", net.lua2json(objIntercept.interceptDetectionZone)),"INTERCEPT")
103
+ --Jtff_log.debug(string.format("interceptorUnitName is %s", net.lua2json(interceptorUnitName)),"INTERCEPT")
104
+ if ( objIntercept.bubbleInvaded == false ) then
105
+ Jtff_log.trace(string.format("%s has not yet been intercepted", objIntercept.interceptTarget:GetName()),"INTERCEPT")
106
+ --Jtff_log.debug(string.format("interceptDetectionZone is %s", net.lua2json(interceptDetectionZone)),"INTERCEPT")
107
+ if (SET_CLIENT:New():FilterZones({objIntercept.interceptDetectionZone}):FilterOnce():CountAlive() > 0) then
108
+ objIntercept.bubbleInvaded = true
109
+ Jtff_log.info(string.format("%s has been intercepted", objIntercept.interceptTarget:GetName()),"INTERCEPT")
110
+ if (objIntercept.knowIsIntercepted == false) then
111
+ if (math.random(1,100) >= 75) then
112
+ local delay = math.random(15,120)
113
+ Jtff_log.info(string.format("%s has detected it has been intercepted : he will react accordingly in %i seconds !", objIntercept.interceptTarget:GetName(), delay),"INTERCEPT")
114
+ objIntercept.knowIsIntercepted = true
115
+ if objIntercept.customconfig.type == 'fastbomber' then
116
+ SCHEDULER:New(
117
+ objIntercept.interceptTarget,
118
+ interceptDefendFastBomber,
119
+ {},
120
+ delay
121
+ )
122
+ elseif objIntercept.customconfig.type == 'fighter' then
123
+ SCHEDULER:New(
124
+ objIntercept.interceptTarget,
125
+ interceptDefendFicghter,
126
+ {},
127
+ delay
128
+ )
129
+ end
130
+ else
131
+ Jtff_log.info(string.format("%s has not detected soon enough it has been intercepted", objIntercept.interceptTarget:GetName()),"INTERCEPT")
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+
138
+ function StartInterceptTraining(param)
139
+ local fighterUnitName = param[1]
140
+ local objInterceptIndex = param[2]
141
+ Jtff_log.debug(string.format("fighterUnitName is %s", fighterUnitName),"INTERCEPT")
142
+ Jtff_log.debug(string.format("objInterceptIndex is %i", objInterceptIndex),"INTERCEPT")
143
+ local minTA = param[3]
144
+ local maxTA = param[4]
145
+ local fighterUnit = UNIT:FindByName(fighterUnitName)
146
+ Jtff_log.debug(string.format("fighterUnit is %s", net.lua2json(fighterUnit)),"INTERCEPT")
147
+ local fighterGroup = fighterUnit:GetGroup()
148
+ local fighterCoord = fighterUnit:GetCoordinate()
149
+ Jtff_log.debug(string.format("fighterCoord is x=%d y=%d z=%d", fighterCoord.x, fighterCoord.y, fighterCoord.z),"INTERCEPT")
150
+ local fighterHeading = fighterUnit:GetHeading()
151
+ Jtff_log.debug(string.format("fighterHeading is %i", fighterHeading),"INTERCEPT")
152
+ local fighterAltitude = fighterUnit:GetAltitude(false)
153
+ local deltaAltMax = nil
154
+ local targetGroup = nil
155
+ local targetRange = nil
156
+ local targetGroundSpeed = 450
157
+ local targetAngle = math.mod(minTA + math.random(0,maxTA-minTA),360)
158
+ if (math.abs(math.mod(targetAngle,180)) > 50) then
159
+ targetRange = 40
160
+ deltaAltMax = 7000
161
+ elseif (math.abs(math.mod(targetAngle,180)) > 20) then
162
+ targetRange = 60
163
+ deltaAltMax = 10000
164
+ else
165
+ targetRange = 90
166
+ deltaAltMax = 15000
167
+ end
168
+ Jtff_log.info(string.format("Launching exercise TargetAngle %i degrees", targetAngle),"INTERCEPT")
169
+ Jtff_log.debug(string.format("Index is : %i", objInterceptIndex),"INTERCEPT")
170
+ local targetSpawnObj = InterceptArray[objInterceptIndex].objSpawn
171
+ local targetCoord = COORDINATE:NewFromVec3(
172
+ {
173
+ x = fighterCoord.x + math.floor(UTILS.NMToMeters(targetRange) * math.cos(math.rad(fighterHeading))),
174
+ y = math.max(
175
+ math.min(
176
+ math.random(
177
+ fighterCoord.y - UTILS.FeetToMeters(deltaAltMax),
178
+ fighterCoord.y + UTILS.FeetToMeters(deltaAltMax)
179
+ ),
180
+ UTILS.FeetToMeters(32000)
181
+ ),
182
+ UTILS.FeetToMeters(8000)
183
+ ),
184
+ z = fighterCoord.z + math.floor(UTILS.NMToMeters(targetRange) * math.sin(math.rad(fighterHeading))),
185
+ }
186
+ )
187
+ Jtff_log.info(string.format("Spawning target based on %s with TargetAngle of %i degrees", targetSpawnObj.SpawnTemplatePrefix, targetAngle),"INTERCEPT")
188
+ targetGroup = targetSpawnObj:InitHeading(math.mod(fighterHeading + 180 + targetAngle,360)):SpawnFromVec3(targetCoord:GetVec3())
189
+ targetGroup:OptionROE(ENUMS.ROE.WeaponHold)
190
+ targetGroup:OptionROT(ENUMS.ROT.NoReaction)
191
+ targetGroup:OptionRTBBingoFuel(true)
192
+ targetGroup:OptionRestrictBurner(false)
193
+ targetGroup:EnableEmission(false)
194
+ targetGroup:OptionAlarmStateGreen()
195
+ targetGroup:OptionECM_Never()
196
+ targetGroup:CommandEPLRS(true)
197
+ InterceptArray[objInterceptIndex].interceptTarget = targetGroup
198
+ InterceptArray[objInterceptIndex].knowIsIntercepted = false
199
+ InterceptArray[objInterceptIndex].bubbleInvaded = false
200
+ local targetDetectionRange = 1.5
201
+ --targetDetectionRange = 70
202
+ InterceptArray[objInterceptIndex].interceptDetectionZone = ZONE_GROUP:New(
203
+ "intercept-" .. targetGroup:GetName(),
204
+ targetGroup,
205
+ UTILS.NMToMeters(targetDetectionRange)
206
+ )
207
+ InterceptArray[objInterceptIndex].interceptTarget:ScheduleRepeat(
208
+ 0,
209
+ 5,
210
+ nil,
211
+ nil,
212
+ interceptDetection,
213
+ {
214
+ InterceptArray[objInterceptIndex]
215
+ }
216
+ )
217
+ local targetDestinationCoord = targetGroup:GetCoordinate():Translate(
218
+ UTILS.NMToMeters(200),
219
+ math.mod(fighterHeading+180+ targetAngle,360),
220
+ true,
221
+ false
222
+ )
223
+ Jtff_log.debug(string.format("targetDestinationCoord is %s", targetDestinationCoord:ToStringMGRS()),"INTERCEPT")
224
+ local targetDestinationAirbase = targetDestinationCoord:GetClosestAirbase(
225
+ targetGroup:GetCategory(),
226
+ targetGroup:GetCoalition()
227
+ )
228
+ if type(targetDestinationAirbase) == 'nil' then
229
+ targetDestinationAirbase = targetDestinationCoord:GetClosestAirbase(
230
+ targetGroup:GetCategory(),
231
+ coalition.side.NEUTRAL
232
+ )
233
+ Jtff_log.info(string.format("no airbase in target coalition, choosing neutral coalition Airbase %s", targetDestinationAirbase:GetName()),"INTERCEPT")
234
+ end
235
+ Jtff_log.debug(string.format("targetDestinationAirbase is %s", targetDestinationAirbase:GetName()),"INTERCEPT")
236
+ local targetRoute = {}
237
+ targetRoute[1] = targetDestinationCoord:WaypointAirTurningPoint(
238
+ COORDINATE.WaypointAltType.BARO,
239
+ UTILS.KnotsToKmph(targetGroundSpeed),
240
+ nil,
241
+ "End interception"
242
+ )
243
+ targetRoute[2] = targetDestinationAirbase:GetCoordinate():WaypointAirLanding(
244
+ UTILS.KnotsToKmph(targetGroundSpeed),
245
+ targetDestinationAirbase
246
+ )
247
+ targetGroup:Route(targetRoute)
248
+ return targetGroup
249
+ end
250
+
251
+ -- endregion InterceptFunctions
252
+
253
+ -- *****************************************************************************
254
+ -- ** Interception Training **
255
+ -- *********************************************************
256
+
208
257
 
209
258
  InterceptArray = {}
210
- compteur = 0
211
- MenuCoalitionInterceptBlue = MENU_COALITION:New(coalition.side.BLUE, "Intercept Training", MenuCoalitionBlue)
212
- MenuCoalitionInterceptRed = MENU_COALITION:New(coalition.side.RED, "Intercept Training", MenuCoalitionRed)
213
- for index, intconfig in ipairs(InterceptConfig) do
214
- if intconfig.enable == true then
215
- jtff_log.info(string.format("Enable %s with %s behavior", intconfig.name, intconfig.type),"INTERCEPT")
216
- compteur = compteur +1
217
- local objIntercept = {
218
- customconfig = {},
219
- objSpawn = nil,
220
- menus = {},
221
- menu_finex = {},
222
- knowIsIntercepted = false,
223
- bubbleInvaded = false,
224
- }
225
- objIntercept.objSpawn = SPAWN:New(intconfig.templates[1])
226
- :InitSkill(intconfig.skill)
227
- :InitRandomizeTemplatePrefixes(intconfig.templates)
228
- if (intconfig.type == 'civil') then
229
- objIntercept.menus[coalition.side.BLUE] = MENU_COALITION:New(coalition.side.BLUE, intconfig.name, MenuCoalitionInterceptBlue)
230
- objIntercept.menu_finex[coalition.side.BLUE] = MENU_COALITION_COMMAND:New(
231
- coalition.side.BLUE,
232
- "Knock it off, FinEx !!",
233
- objIntercept.menus[coalition.side.BLUE],
234
- clearIntercept,
235
- {
236
- compteur
237
- }
238
- )
239
- objIntercept.menus[coalition.side.RED] = MENU_COALITION:New(coalition.side.RED, intconfig.name, MenuCoalitionInterceptRed)
240
- objIntercept.menu_finex[coalition.side.RED] = MENU_COALITION_COMMAND:New(
241
- coalition.side.RED,
242
- "Knock it off, FinEx !!",
243
- objIntercept.menus[coalition.side.RED],
244
- clearIntercept,
245
- {
246
- compteur
247
- }
248
- )
249
- else
250
- if (intconfig.benefitCoalition == coalition.side.BLUE) then
251
- objIntercept.menus[intconfig.benefitCoalition] = MENU_COALITION:New(intconfig.benefitCoalition, intconfig.name, MenuCoalitionInterceptBlue)
252
- else
253
- objIntercept.menus[intconfig.benefitCoalition] = MENU_COALITION:New(intconfig.benefitCoalition, intconfig.name, MenuCoalitionInterceptRed)
254
- end
255
- objIntercept.menu_finex[intconfig.benefitCoalition] = MENU_COALITION_COMMAND:New(
256
- intconfig.benefitCoalition,
257
- "Knock it off, FinEx !!",
258
- objIntercept.menus[intconfig.benefitCoalition],
259
- clearIntercept,
260
- {
261
- compteur
262
- }
263
- )
264
- end
265
- objIntercept.customconfig = intconfig
266
- InterceptArray[compteur] = objIntercept
267
- end
259
+ local compteur = #InterceptArray
260
+
261
+ MenuCoalitionIntercept = {}
262
+ for _k, _coalition in pairs(coalition.side) do
263
+ MenuCoalitionIntercept[UTILS.GetCoalitionName(_coalition)] = MENU_COALITION:New(_coalition, "Intercept Training", MenuCoalition[UTILS.GetCoalitionName(_coalition)])
264
+ end
265
+
266
+ for index, currentInterceptConfigObject in ipairs(InterceptConfig) do
267
+ local intconfig = ParseInterceptConfigJson(currentInterceptConfigObject)
268
+ if intconfig.enable == true then
269
+ Jtff_log.info(
270
+ string.format(
271
+ "Enable %s with %s behavior",
272
+ intconfig.name,
273
+ intconfig.type
274
+ ),
275
+ "INTERCEPT"
276
+ )
277
+ compteur = compteur +1
278
+ local objIntercept = {
279
+ customconfig = {},
280
+ objSpawn = nil,
281
+ menus = {},
282
+ menu_finex = {},
283
+ knowIsIntercepted = false,
284
+ bubbleInvaded = false,
285
+ }
286
+ objIntercept.objSpawn = SPAWN:New(intconfig.templates[1])
287
+ :InitSkill(intconfig.skill)
288
+ :InitRandomizeTemplatePrefixes(intconfig.templates)
289
+ if (intconfig.type == JTFF_INTERCEPT.Type.Civilian) then
290
+ for _k, _coalition in pairs(coalition.side) do
291
+ objIntercept.menus[_coalition] = MENU_COALITION:New(_coalition, intconfig.name, MenuCoalitionIntercept[UTILS.GetCoalitionName(_coalition)])
292
+ objIntercept.menu_finex[_coalition] = MENU_COALITION_COMMAND:New(
293
+ _coalition,
294
+ "Knock it off, FinEx !!",
295
+ objIntercept.menus[_coalition],
296
+ clearIntercept,
297
+ {
298
+ compteur
299
+ }
300
+ )
301
+ end
302
+ else
303
+ objIntercept.menus[intconfig.benefitCoalition] = MENU_COALITION:New(intconfig.benefitCoalition, intconfig.name, MenuCoalitionIntercept[UTILS.GetCoalitionName(intconfig.benefitCoalition)])
304
+ objIntercept.menu_finex[intconfig.benefitCoalition] = MENU_COALITION_COMMAND:New(
305
+ intconfig.benefitCoalition,
306
+ "Knock it off, FinEx !!",
307
+ objIntercept.menus[intconfig.benefitCoalition],
308
+ clearIntercept,
309
+ {
310
+ compteur
311
+ }
312
+ )
313
+ end
314
+ objIntercept.customconfig = intconfig
315
+ InterceptArray[compteur] = objIntercept
316
+ end
268
317
  end
269
318
 
270
- if compteur == 0 then
271
- MenuCoalitionInterceptBlue:Remove()
272
- MenuCoalitionInterceptRed:Remove()
319
+ if #InterceptArray == 0 then
320
+ for _k, _coalition in pairs(coalition.side) do
321
+ MenuCoalitionIntercept[UTILS.GetCoalitionName(_coalition)]:Remove()
322
+ end
323
+ MenuCoalitionIntercept = {}
273
324
  end
@@ -4,8 +4,8 @@
4
4
 
5
5
  CTLDArray = {}
6
6
  compteur = 0
7
- mainRadioMenuForLogisticsBlue = MENU_COALITION:New( coalition.side.BLUE , "Logistics", MenuCoalitionBlue )
8
- mainRadioMenuForLogisticsRed = MENU_COALITION:New( coalition.side.RED , "Logistics", MenuCoalitionRed )
7
+ mainRadioMenuForLogisticsBlue = MENU_COALITION:New( coalition.side.BLUE , "Logistics", MenuCoalition[coalition.side.BLUE] )
8
+ mainRadioMenuForLogisticsRed = MENU_COALITION:New( coalition.side.RED , "Logistics", MenuCoalition[coalition.side.RED] )
9
9
  for index, ctldconfig in ipairs(CTLDConfig) do
10
10
  if ctldconfig.enable == true then
11
11
  compteur = compteur + 1