@jtff/miztemplate-lib 3.7.6 → 3.7.8

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.
@@ -434,12 +434,24 @@ function deleteSubRangeUnits(param)
434
434
  local subRangeConfig = param[3]
435
435
  local radioCommandSubRange = param[4]
436
436
  local blnMute = param[5]
437
- for i = 1, #groupsToSpawn do
438
- destroyGroup(groupsToSpawn[i])
439
- end
440
-
441
437
  local subRangeName = subRangeConfig.name
442
438
  local staticsToDelete = subRangeConfig.staticsToSpawn
439
+ if (subRangeConfig.groupsToSpawn ~= nil) then
440
+ for i = 1, #groupsToSpawn do
441
+ destroyGroup(groupsToSpawn[i])
442
+ end
443
+ else
444
+ jtff_log.warn(string.format("No Groups in %s", subRangeName), "RANGE")
445
+ end
446
+ if (subRangeConfig.randomGroupsToSpawn ~= nil) then
447
+ local groupsToDestroy = subRangeConfig.randomGroupsToSpawn
448
+ for i = 1, #groupsToDestroy do
449
+ destroyGroup(subRangeConfig.randomGroupsToSpawn[i])
450
+ end
451
+ else
452
+ jtff_log.warn(string.format("No random*W Groups in %s", subRangeName), "RANGE")
453
+ end
454
+
443
455
  if (staticsToDelete ~= nil)then
444
456
  destroyStatics(staticsToDelete, subRangeName)
445
457
  else
@@ -715,8 +727,8 @@ end
715
727
  function markGroupOnMap(param)
716
728
  local groupsToSpawn = param[1]
717
729
  local side = param[2]
718
- for i = 2, #groupsToSpawn do
719
- local group_name = string.format("%s", groupsToSpawn[i])
730
+ for index = 1, #groupsToSpawn do
731
+ local group_name = string.format("%s", groupsToSpawn[index])
720
732
  jtff_log.info(string.format("Mark on map all groups with name prefix %s", group_name),"MARK")
721
733
  local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
722
734
  dcs_groups:ForEachGroupAlive(function(group_alive)
@@ -844,6 +856,8 @@ function SpawnRanges(param)
844
856
  local subRangeConfig = param[3]
845
857
  local subRangeName = subRangeConfig.name
846
858
  local groupsToSpawn = subRangeConfig.groupsToSpawn
859
+ local randomGroupsToSpawn = subRangeConfig.randomGroupsToSpawn
860
+ local nbRandomGroupsToSpawn = subRangeConfig.nbRandomGroupsToSpawn or 1
847
861
  local staticsToSpawn = subRangeConfig.staticsToSpawn
848
862
  local holdFire = subRangeConfig.holdFire
849
863
  local engageAirWeapons = subRangeConfig.engageAirWeapons
@@ -851,7 +865,7 @@ function SpawnRanges(param)
851
865
  local redAlert = subRangeConfig.redAlert
852
866
 
853
867
  jtff_log.info(string.format("SpawnRanges : Range %s - Targets %s", rangeName, subRangeName),"RANGE")
854
- if (staticsToSpawn ~= nil)then
868
+ if (staticsToSpawn ~= nil) then
855
869
  for index, staticToSpawn in ipairs(staticsToSpawn) do
856
870
  local spawnStatic = nil
857
871
  if (staticToSpawn.name ~= nil) then
@@ -910,46 +924,107 @@ function SpawnRanges(param)
910
924
  jtff_log.warn(string.format("No static in %s", subRangeName),"RANGE")
911
925
  end
912
926
 
913
- for i = 1, #groupsToSpawn do
914
- local groupNameToSpawn = string.format("%s", groupsToSpawn[i])
915
- if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
916
- local spawnGroup = SPAWN:New(groupNameToSpawn)
917
- jtff_log.info(string.format("SPAWN %s", groupNameToSpawn), "RANGE")
918
- local groupSpawning
919
- if (subRangeConfig.spawnZone) then
920
- groupSpawning = spawnGroup:SpawnInZone(ZONE:New(subRangeConfig.spawnZone),true)
921
- else
922
- groupSpawning = spawnGroup:Spawn()
927
+ if (randomGroupsToSpawn ~= nil) then
928
+ local availableRandomGroupsList = randomGroupsToSpawn
929
+ nbRandomGroupsToSpawn = math.min(nbRandomGroupsToSpawn,#availableRandomGroupsList)
930
+ --math.randomseed(os.time())
931
+ for i = 1, nbRandomGroupsToSpawn do
932
+ local randomIndex = math.random(1, #availableRandomGroupsList)
933
+ local groupNameToSpawn = string.format("%s", availableRandomGroupsList[randomIndex])
934
+ local finalList = {}
935
+ for index, value in ipairs(availableRandomGroupsList) do
936
+ if index ~= randomIndex then
937
+ table.insert(finalList, value)
938
+ end
923
939
  end
924
- if (holdFire) then
925
- groupSpawning:OptionROEHoldFire()
940
+ availableRandomGroupsList = finalList
941
+
942
+ if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
943
+ local spawnGroup = SPAWN:New(groupNameToSpawn)
944
+ jtff_log.info(string.format("SPAWN %s", groupNameToSpawn), "RANGE")
945
+ local groupSpawning
946
+ if (subRangeConfig.spawnZone) then
947
+ groupSpawning = spawnGroup:SpawnInZone(ZONE:New(subRangeConfig.spawnZone),true)
948
+ else
949
+ groupSpawning = spawnGroup:Spawn()
950
+ end
951
+ markGroupOnMap({{groupNameToSpawn}, rangeConfig.benefit_coalition})
952
+ if (holdFire) then
953
+ groupSpawning:OptionROEHoldFire()
954
+ else
955
+ groupSpawning:OptionROEOpenFire()
956
+ end
957
+ if (engageAirWeapons) then
958
+ groupSpawning:SetOption(AI.Option.Ground.id.ENGAGE_AIR_WEAPONS, true)
959
+ end
960
+ if (activateAI == true or activateAI == false) then
961
+ groupSpawning:SetAIOnOff(activateAI)
962
+ end
963
+ if (redAlert == true or redAlert == false) then
964
+ if (redAlert == true) then
965
+ groupSpawning:OptionAlarmStateRed()
966
+ else
967
+ groupSpawning:OptionAlarmStateGreen()
968
+ end
969
+ else
970
+ groupSpawning:OptionAlarmStateAuto()
971
+ end
972
+ if (string.find(groupNameToSpawn, "SAM") ~= nil) then
973
+ sead:UpdateSet(groupNameToSpawn)
974
+ jtff_log.info(string.format("SEAD for %s", groupNameToSpawn),"RANGE")
975
+ end
926
976
  else
927
- groupSpawning:OptionROEOpenFire()
977
+ jtff_log.error(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn),"RANGE")
928
978
  end
929
- if (engageAirWeapons) then
930
- groupSpawning:SetOption(AI.Option.Ground.id.ENGAGE_AIR_WEAPONS, true)
931
- end
932
- if (activateAI == true or activateAI == false) then
933
- groupSpawning:SetAIOnOff(activateAI)
934
- end
935
- if (redAlert == true or redAlert == false) then
936
- if (redAlert == true) then
937
- groupSpawning:OptionAlarmStateRed()
979
+ end
980
+ end
981
+
982
+ if (groupsToSpawn ~= nil) then
983
+ for i = 1, #groupsToSpawn do
984
+ local groupNameToSpawn = string.format("%s", groupsToSpawn[i])
985
+ if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
986
+ local spawnGroup = SPAWN:New(groupNameToSpawn)
987
+ jtff_log.info(string.format("SPAWN %s", groupNameToSpawn), "RANGE")
988
+ local groupSpawning
989
+ if (subRangeConfig.spawnZone) then
990
+ groupSpawning = spawnGroup:SpawnInZone(ZONE:New(subRangeConfig.spawnZone),true)
991
+ else
992
+ groupSpawning = spawnGroup:Spawn()
993
+ end
994
+ if (holdFire) then
995
+ groupSpawning:OptionROEHoldFire()
996
+ else
997
+ groupSpawning:OptionROEOpenFire()
998
+ end
999
+ if (engageAirWeapons) then
1000
+ groupSpawning:SetOption(AI.Option.Ground.id.ENGAGE_AIR_WEAPONS, true)
1001
+ end
1002
+ if (activateAI == true or activateAI == false) then
1003
+ groupSpawning:SetAIOnOff(activateAI)
1004
+ end
1005
+ if (redAlert == true or redAlert == false) then
1006
+ if (redAlert == true) then
1007
+ groupSpawning:OptionAlarmStateRed()
1008
+ else
1009
+ groupSpawning:OptionAlarmStateGreen()
1010
+ end
938
1011
  else
939
- groupSpawning:OptionAlarmStateGreen()
1012
+ groupSpawning:OptionAlarmStateAuto()
1013
+ end
1014
+ if (string.find(groupNameToSpawn, "SAM") ~= nil) then
1015
+ sead:UpdateSet(groupNameToSpawn)
1016
+ jtff_log.info(string.format("SEAD for %s", groupNameToSpawn),"RANGE")
940
1017
  end
941
1018
  else
942
- groupSpawning:OptionAlarmStateAuto()
943
- end
944
- if (string.find(groupNameToSpawn, "SAM") ~= nil) then
945
- sead:UpdateSet(groupNameToSpawn)
946
- jtff_log.info(string.format("SEAD for %s", groupNameToSpawn),"RANGE")
1019
+ jtff_log.error(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn),"RANGE")
947
1020
  end
948
- else
949
- jtff_log.error(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn),"RANGE")
950
1021
  end
1022
+ markGroupOnMap({groupsToSpawn, rangeConfig.benefit_coalition})
1023
+ else
1024
+ jtff_log.warn(string.format("No GROUP to spawn in subRange %s settings !",subRangeName),"RANGE")
951
1025
  end
952
1026
 
1027
+
953
1028
  radioCommandSubRange:RemoveSubMenus()
954
1029
  local CommandZoneDetroy = MENU_COALITION_COMMAND:New(rangeConfig.benefit_coalition, "Delete", radioCommandSubRange,
955
1030
  deleteSubRangeUnits, {groupsToSpawn, rangeConfig, subRangeConfig, radioCommandSubRange, true})
@@ -982,7 +1057,6 @@ function SpawnRanges(param)
982
1057
  radioCommandSubRange, giveListOfUnitsAliveInGroup, {groupsToSpawn, rangeConfig.benefit_coalition, 5})
983
1058
  MESSAGE:NewType(string.format("Units in range %s(%s) in place", rangeName, subRangeName), MESSAGE.Type.Information)
984
1059
  :ToCoalition(rangeConfig.benefit_coalition)
985
- markGroupOnMap({groupsToSpawn, rangeConfig.benefit_coalition})
986
1060
  end
987
1061
 
988
1062
  function SpawnFacRangesDelay(param)
@@ -99,20 +99,27 @@ function getCaseTypeFromWeather(CVNCoordinates, recovery_start, recovery_stop)
99
99
  end
100
100
  local weather = env.mission.weather
101
101
  local clouds = weather.clouds
102
- -- local static = weather.atmosphere_type == 0
102
+ local static = weather.atmosphere_type == 0
103
103
  local visibility = weather.visibility.distance
104
- -- local turbulence = weather.groundTurbulence
104
+ local turbulence = weather.groundTurbulence
105
105
  local dust = nil
106
106
  if weather.enable_dust == true then
107
107
  dust = weather.dust_density
108
+ else
109
+ dust = 0
108
110
  end
109
111
  local fog = nil
110
112
  if weather.enable_fog == true then
111
113
  fog = weather.fog
114
+ else
115
+ fog = {
116
+ thickness = 0,
117
+ visibility = 0,
118
+ }
112
119
  end
113
120
 
114
- -- jtff_log.trace(string.format("visibility : %i | cloud : base %i density %i | fog %i,%i | dust %i", visibility, clouds.base, clouds.density, fog.thickness, fog.visibility, dust),"AIRBOSS")
115
- local minVisibility = visibility
121
+ jtff_log.info(string.format("visibility : %i | cloud : base %i density %i | fog %i,%i | dust %i | precpt: %i", visibility, clouds.base, clouds.density, fog.thickness, fog.visibility, dust, clouds.iprecptns),"AIRBOSS")
122
+ local minVisibility = (clouds.iprecptns >= 2) and math.floor(visibility/2) or visibility
116
123
  if (weather.enable_fog and fog.thickness > 0) then
117
124
  minVisibility = math.min(minVisibility,fog.visibility)
118
125
  end
@@ -137,23 +144,28 @@ function getCaseTypeFromWeather(CVNCoordinates, recovery_start, recovery_stop)
137
144
  end
138
145
  end
139
146
 
140
- function startRecoveryOnDemand(objAirboss)
141
- local effectiveeventcase = getCaseTypeFromWeather(
142
- objAirboss:GetCoordinate(),
143
- UTILS.Round(timer.getAbsTime() + 5 *60,0),
144
- UTILS.Round(timer.getAbsTime() + ((objAirboss.customconfig.recoveryops.ondemand.recovery_duration_minutes or 30) * 60),0)
145
- )
146
- if effectiveeventcase == 1 then
147
- objAirboss:MessageToMarshal('Good visibility : Case I', objAirboss.customconfig.alias, "", 45, false, 0)
148
- objAirboss:SetMaxSectionSize(4)
149
- elseif effectiveeventcase == 2 then
150
- objAirboss:MessageToMarshal('Bad visibility in altitude : Case II', objAirboss.customconfig.alias, "", 45, false, 0)
151
- objAirboss:SetMaxSectionSize(2)
152
- elseif effectiveeventcase == 3 then
153
- objAirboss:MessageToMarshal('Bad visibility : Case III', objAirboss.customconfig.alias, "", 45, false, 0)
154
- objAirboss:SetMaxSectionSize(1)
147
+ function startRecoveryOnDemand(objAirboss, forced_eventcase)
148
+ local effectiveeventcase
149
+ if (forced_eventcase) then
150
+ effectiveeventcase = forced_eventcase
155
151
  else
156
- objAirboss:SetMaxSectionSize(1)
152
+ effectiveeventcase = getCaseTypeFromWeather(
153
+ objAirboss:GetCoordinate(),
154
+ UTILS.Round(timer.getAbsTime() + 5 *60,0),
155
+ UTILS.Round(timer.getAbsTime() + ((objAirboss.customconfig.recoveryops.ondemand.recovery_duration_minutes or 30) * 60),0)
156
+ )
157
+ if effectiveeventcase == 1 then
158
+ objAirboss:MessageToMarshal('Good visibility : Case I', objAirboss.customconfig.alias, "", 45, false, 0)
159
+ objAirboss:SetMaxSectionSize(4)
160
+ elseif effectiveeventcase == 2 then
161
+ objAirboss:MessageToMarshal('Bad visibility in altitude : Case II', objAirboss.customconfig.alias, "", 45, false, 0)
162
+ objAirboss:SetMaxSectionSize(2)
163
+ elseif effectiveeventcase == 3 then
164
+ objAirboss:MessageToMarshal('Bad visibility : Case III', objAirboss.customconfig.alias, "", 45, false, 0)
165
+ objAirboss:SetMaxSectionSize(1)
166
+ else
167
+ objAirboss:SetMaxSectionSize(1)
168
+ end
157
169
  end
158
170
  objAirboss:AddRecoveryWindow(
159
171
  UTILS.SecondsToClock(timer.getAbsTime() + 10 * 60, false, false),
@@ -481,7 +493,7 @@ function flexDeck3SpawnLayout(objAirboss)
481
493
  ["type"] = "EA_6B",
482
494
  },
483
495
  {
484
- ["livery_id"] = "vfa-87",
496
+ ["livery_id"] = "JTFF VFA-83 Line",
485
497
  ["category"] = "Planes",
486
498
  ["offsets"] =
487
499
  {
@@ -613,7 +625,7 @@ function flexDeck7SpawnLayout(objAirboss)
613
625
  spawnDeckLayout_Zone(objAirboss, "Point", pointLayout)
614
626
  local cat1Layout = {
615
627
  {
616
- ["livery_id"] = "VFA-87",
628
+ ["livery_id"] = "JTFF VFA-83 Line",
617
629
  ["category"] = "Planes",
618
630
  ["offsets"] =
619
631
  {
@@ -624,7 +636,7 @@ function flexDeck7SpawnLayout(objAirboss)
624
636
  ["type"] = "FA-18C_hornet",
625
637
  },
626
638
  {
627
- ["livery_id"] = "VFA-87",
639
+ ["livery_id"] = "JTFF VFA-83 Line",
628
640
  ["category"] = "Planes",
629
641
  ["offsets"] =
630
642
  {
@@ -635,7 +647,7 @@ function flexDeck7SpawnLayout(objAirboss)
635
647
  ["type"] = "FA-18C_hornet",
636
648
  },
637
649
  {
638
- ["livery_id"] = "VFA-87",
650
+ ["livery_id"] = "JTFF VFA-83 Line",
639
651
  ["category"] = "Planes",
640
652
  ["offsets"] =
641
653
  {
@@ -740,7 +752,7 @@ function flexDeck7SpawnLayout(objAirboss)
740
752
  ["type"] = "FA-18C_hornet",
741
753
  },
742
754
  {
743
- ["livery_id"] = "VFA-87",
755
+ ["livery_id"] = "JTFF VFA-83 Line",
744
756
  ["category"] = "Planes",
745
757
  ["offsets"] =
746
758
  {
@@ -1014,6 +1026,13 @@ function launchDeck1SpawnLayout(objAirboss)
1014
1026
  spawnDeckLayout_Zone(objAirboss, "Stern", sternLayout)
1015
1027
  end
1016
1028
 
1029
+ function resetAirbossDeck(objAirboss, delay)
1030
+ local delay_second = delay or 5
1031
+ jtff_log.info(string.format("reset all Deck Operations, closing the Deck on %s in %i seconds",objAirboss.customconfig.alias, delay_second),"AIRBOSS")
1032
+ objAirboss:CloseCurrentRecoveryWindow(delay_second)
1033
+ objAirboss:DeleteAllRecoveryWindows(delay_second+1)
1034
+ end
1035
+
1017
1036
  AIRBOSSArray = {}
1018
1037
  compteur = 0
1019
1038
  MenuCoalitionCSGCommandsBlue = MENU_COALITION:New(coalition.side.BLUE, "CSG Commands", MenuCoalitionBlue)
@@ -1126,7 +1145,38 @@ for index, airbossconfig in ipairs(AirBossConfig) do
1126
1145
  startRecoveryOnDemand,
1127
1146
  objAirboss
1128
1147
  )
1148
+ MENU_COALITION_COMMAND:New(
1149
+ airbossconfig.coalition,
1150
+ "OnDemand Recovery Forced Case 1: will start turning in 5 minutes",
1151
+ objAirboss.menuObject,
1152
+ startRecoveryOnDemand,
1153
+ objAirboss,
1154
+ 1
1155
+ )
1156
+ MENU_COALITION_COMMAND:New(
1157
+ airbossconfig.coalition,
1158
+ "OnDemand Recovery Forced Case 2: will start turning in 5 minutes",
1159
+ objAirboss.menuObject,
1160
+ startRecoveryOnDemand,
1161
+ objAirboss,
1162
+ 2
1163
+ )
1164
+ MENU_COALITION_COMMAND:New(
1165
+ airbossconfig.coalition,
1166
+ "OnDemand Recovery Forced Case 3: will start turning in 5 minutes",
1167
+ objAirboss.menuObject,
1168
+ startRecoveryOnDemand,
1169
+ objAirboss,
1170
+ 3
1171
+ )
1129
1172
  end
1173
+ MENU_COALITION_COMMAND:New(
1174
+ airbossconfig.coalition,
1175
+ "Recovery : close the deck and reset Airboss",
1176
+ objAirboss.menuObject,
1177
+ resetAirbossDeck,
1178
+ objAirboss
1179
+ )
1130
1180
  objAirboss:SetTACAN(airbossconfig.tacan.channel, airbossconfig.tacan.mode, airbossconfig.tacan.morse)
1131
1181
  objAirboss:SetICLS(airbossconfig.icls.channel, airbossconfig.icls.morse)
1132
1182
  if (airbossconfig.infinitepatrol) then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jtff/miztemplate-lib",
3
- "version": "3.7.6",
3
+ "version": "3.7.8",
4
4
  "description": "JTFF mission template library",
5
5
  "main": "index.js",
6
6
  "files": [