From 313f99d09d18d60d8ce4df2c8e683841132c2011 Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 6 May 2022 21:50:23 +0200 Subject: [PATCH] OPS **AUFTRAG** - Added option to specify mission type for escorts, *e.g.* `AUFTRAG.Type.SEAD` **LEGION** and **COMMANDER** - Improved handling of SEAD escorts. --- Moose Development/Moose/Ops/Auftrag.lua | 57 ++++++++++++++--------- Moose Development/Moose/Ops/Commander.lua | 4 +- Moose Development/Moose/Ops/Legion.lua | 34 ++++++++++---- 3 files changed, 61 insertions(+), 34 deletions(-) diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index 77503da0e..430a032b0 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -119,6 +119,9 @@ -- @field #number NassetsMax Max. number of required warehouse assets. -- @field #number NescortMin Min. number of required escort assets for each group the mission is assigned to. -- @field #number NescortMax Max. number of required escort assets for each group the mission is assigned to. +-- @field #string escortMissionType Escort mission type. +-- @field #table escortTargetTypes Target types that will be engaged. +-- @field #number escortEngageRange Engage range in nautical miles (NM). -- @field #number Nassets Number of requested warehouse assets. -- @field #table NassetsLegMin Number of required warehouse assets for each assigned legion. -- @field #table NassetsLegMax Number of required warehouse assets for each assigned legion. @@ -610,7 +613,7 @@ AUFTRAG.Category={ --- AUFTRAG class version. -- @field #string version -AUFTRAG.version="0.9.5" +AUFTRAG.version="0.9.6" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -1404,7 +1407,6 @@ function AUFTRAG:NewSEAD(Target, Altitude) mission.missionFraction=0.2 mission.optionROE=ENUMS.ROE.OpenFire mission.optionROT=ENUMS.ROT.EvadeFire - --mission.optionROT=ENUMS.ROT.AllowAbortMission mission.categories={AUFTRAG.Category.AIRCRAFT} @@ -1558,7 +1560,7 @@ end -- @param #AUFTRAG self -- @param Wrapper.Group#GROUP EscortGroup The group to escort. -- @param DCS#Vec3 OffsetVector A table with x, y and z components specifying the offset of the flight to the escorted group. Default {x=-100, y=0, z=200} for z=200 meters to the right, same alitude (y=0), x=-100 meters behind. --- @param #number EngageMaxDistance Max engage distance of targets in nautical miles. Default auto (*nil*). +-- @param #number EngageMaxDistance Max engage distance of targets in nautical miles. Default auto 32 NM. -- @param #table TargetTypes Types of targets to engage automatically. Default is {"Air"}, i.e. all enemy airborne units. Use an empty set {} for a simple "FOLLOW" mission. -- @return #AUFTRAG self function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetTypes) @@ -1575,7 +1577,7 @@ function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetT -- DCS task parameters: mission.escortVec3=OffsetVector or {x=-100, y=0, z=200} - mission.engageMaxDistance=EngageMaxDistance and UTILS.NMToMeters(EngageMaxDistance) or nil + mission.engageMaxDistance=EngageMaxDistance and UTILS.NMToMeters(EngageMaxDistance) or UTILS.NMToMeters(32) mission.engageTargetTypes=TargetTypes or {"Air"} -- Mission options: @@ -2445,7 +2447,7 @@ function AUFTRAG:SetPriority(Prio, Urgent, Importance) return self end ---- Set how many times the mission is repeated. Only valid if the mission is handled by a LEGION (AIRWING, BRIGADE, ...) or higher level. +--- **[LEGION, COMMANDER, CHIEF]** Set how many times the mission is repeated. Only valid if the mission is handled by a LEGION (AIRWING, BRIGADE, FLEET) or higher level. -- @param #AUFTRAG self -- @param #number Nrepeat Number of repeats. Default 0. -- @return #AUFTRAG self @@ -2454,7 +2456,7 @@ function AUFTRAG:SetRepeat(Nrepeat) return self end ---- Set how many times the mission is repeated if it fails. Only valid if the mission is handled by a LEGION (AIRWING, BRIGADE, ...) or higher level. +--- **[LEGION, COMMANDER, CHIEF]** Set how many times the mission is repeated if it fails. Only valid if the mission is handled by a LEGION (AIRWING, BRIGADE, FLEET) or higher level. -- @param #AUFTRAG self -- @param #number Nrepeat Number of repeats. Default 0. -- @return #AUFTRAG self @@ -2463,7 +2465,7 @@ function AUFTRAG:SetRepeatOnFailure(Nrepeat) return self end ---- Set how many times the mission is repeated if it was successful. Only valid if the mission is handled by a LEGION (AIRWING, BRIGADE, ...) or higher level. +--- **[LEGION, COMMANDER, CHIEF]** Set how many times the mission is repeated if it was successful. Only valid if the mission is handled by a LEGION (AIRWING, BRIGADE, FLEET) or higher level. -- @param #AUFTRAG self -- @param #number Nrepeat Number of repeats. Default 0. -- @return #AUFTRAG self @@ -2472,7 +2474,7 @@ function AUFTRAG:SetRepeatOnSuccess(Nrepeat) return self end ---- Define how many assets are required to do the job. Only used if the mission is handled by a **LEGION** (AIRWING, BRIGADE, ...) or higher level. +--- **[LEGION, COMMANDER, CHIEF]** Define how many assets are required to do the job. Only used if the mission is handled by a **LEGION** (AIRWING, BRIGADE, ...) or higher level. -- @param #AUFTRAG self -- @param #number NassetsMin Minimum number of asset groups. Default 1. -- @param #number NassetsMax Maximum Number of asset groups. Default is same as `NassetsMin`. @@ -2491,7 +2493,7 @@ function AUFTRAG:SetRequiredAssets(NassetsMin, NassetsMax) return self end ---- Get number of required assets. +--- **[LEGION, COMMANDER, CHIEF]** Get number of required assets. -- @param #AUFTRAG self -- @param Ops.Legion#Legion Legion (Optional) Only get the required assets for a specific legion. If required assets for this legion are not defined, the total number is returned. -- @return #number Min. number of required assets. @@ -2507,21 +2509,30 @@ function AUFTRAG:GetRequiredAssets(Legion) return self.NassetsMin, self.NassetsMax end ---- Define how many assets are required to do the job. Only used if the mission is handled by a **LEGION** (AIRWING, BRIGADE, ...) or higher level. +--- **[LEGION, COMMANDER, CHIEF]** Define how many assets are required that escort the mission assets. +-- Only used if the mission is handled by a **LEGION** (AIRWING, BRIGADE, FLEET) or higher level. -- @param #AUFTRAG self -- @param #number NescortMin Minimum number of asset groups. Default 1. -- @param #number NescortMax Maximum Number of asset groups. Default is same as `NassetsMin`. +-- @param #string MissionType Mission type assets will be optimized for and payload selected, *e.g.* `AUFTRAG.Type.SEAD`. Default nil. +-- @param #table TargetTypes Target Types that will be engaged by the escort group(s). Default `{"Air"}` for aircraft and `{"Ground Units"}` for helos. Set, *e.g.*, `{"Air Defence"}` for SEAD. +-- @param #number EngageRange Max range in nautical miles that the escort group(s) will engage enemies. Default 32 NM (60 km). -- @return #AUFTRAG self -function AUFTRAG:SetRequiredEscorts(NescortMin, NescortMax) +function AUFTRAG:SetRequiredEscorts(NescortMin, NescortMax, MissionType, TargetTypes, EngageRange) + -- Set number of escort assets. self.NescortMin=NescortMin or 1 - self.NescortMax=NescortMax or self.NescortMin -- Ensure that max is at least equal to min. if self.NescortMax0 or NescortMax>0) then @@ -2493,17 +2496,19 @@ function LEGION:AssignAssetsForEscort(Cohorts, Assets, NescortMin, NescortMax) -- We want airplanes for airplanes and helos for everything else. local Categories={Group.Category.HELICOPTER} - local TargetTypes={"Ground Units"} + local targetTypes={"Ground Units"} if asset.category==Group.Category.AIRPLANE then Categories={Group.Category.AIRPLANE} - TargetTypes={"Air"} + targetTypes={"Air"} end + TargetTypes=TargetTypes or targetTypes + -- Recruit escort asset for the mission asset. - local Erecruited, eassets, elegions=LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.ESCORT, nil, NescortMin, NescortMax, TargetVec2, nil, nil, nil, nil, nil, Categories) + local Erecruited, eassets, elegions=LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.ESCORT, MissionType, NescortMin, NescortMax, TargetVec2, nil, nil, nil, nil, nil, Categories) if Erecruited then - Escorts[asset.spawngroupname]={EscortLegions=elegions, EscortAssets=eassets, ecategory=asset.category, TargetTypes=TargetTypes} + Escorts[asset.spawngroupname]={EscortLegions=elegions, EscortAssets=eassets, ecategory=asset.category} else -- Could not find escort for this asset ==> Escort not possible ==> Break the loop. EscortAvail=false @@ -2526,15 +2531,26 @@ function LEGION:AssignAssetsForEscort(Cohorts, Assets, NescortMin, NescortMax) local OffsetVector=nil --DCS#Vec3 if ecategory==Group.Category.GROUND then - -- Overhead + -- Overhead at 1000 ft. OffsetVector={} OffsetVector.x=0 OffsetVector.y=UTILS.FeetToMeters(1000) OffsetVector.z=0 + elseif MissionType==AUFTRAG.Type.SEAD then + -- Overhead slightly higher and right. + OffsetVector={} + OffsetVector.x=-100 + OffsetVector.y= 500 + OffsetVector.z= 500 end -- Create and ESCORT mission for this asset. - local escort=AUFTRAG:NewESCORT(groupname, OffsetVector, nil, value.TargetTypes) + local escort=AUFTRAG:NewESCORT(groupname, OffsetVector, EngageRange, TargetTypes) + + -- For a SEAD mission, we also adjust the mission task. + if MissionType==AUFTRAG.Type.SEAD then + escort.missionTask=ENUMS.MissionTask.SEAD + end -- Reserve assts and add to mission. for _,_asset in pairs(Eassets) do