mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OPS Escort
- Refined functions to recruit escort assets.
This commit is contained in:
parent
73940fffc6
commit
7148bd1d42
@ -815,7 +815,7 @@ function AIRWING:onafterStatus(From, Event, To)
|
|||||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
|
|
||||||
local prio=string.format("%d/%s", mission.prio, tostring(mission.importance)) ; if mission.urgent then prio=prio.." (!)" end
|
local prio=string.format("%d/%s", mission.prio, tostring(mission.importance)) ; if mission.urgent then prio=prio.." (!)" end
|
||||||
local assets=string.format("%d/%d", mission:CountOpsGroups(), mission.nassets)
|
local assets=string.format("%d/%d", mission:CountOpsGroups(), mission:GetNumberOfRequiredAssets())
|
||||||
local target=string.format("%d/%d Damage=%.1f", mission:CountMissionTargets(), mission:GetTargetInitialNumber(), mission:GetTargetDamage())
|
local target=string.format("%d/%d Damage=%.1f", mission:CountMissionTargets(), mission:GetTargetInitialNumber(), mission:GetTargetDamage())
|
||||||
local mystatus=mission:GetLegionStatus(self)
|
local mystatus=mission:GetLegionStatus(self)
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
-- @field #string lid Class id string for output to DCS log file.
|
-- @field #string lid Class id string for output to DCS log file.
|
||||||
-- @field #number auftragsnummer Auftragsnummer.
|
-- @field #number auftragsnummer Auftragsnummer.
|
||||||
-- @field #string type Mission type.
|
-- @field #string type Mission type.
|
||||||
|
-- @field #table categories Mission categories.
|
||||||
-- @field #string status Mission status.
|
-- @field #string status Mission status.
|
||||||
-- @field #table legions Assigned legions.
|
-- @field #table legions Assigned legions.
|
||||||
-- @field #table statusLegion Mission status of all assigned LEGIONs.
|
-- @field #table statusLegion Mission status of all assigned LEGIONs.
|
||||||
@ -95,15 +96,23 @@
|
|||||||
-- @field #number artyRadius Radius in meters.
|
-- @field #number artyRadius Radius in meters.
|
||||||
-- @field #number artyShots Number of shots fired.
|
-- @field #number artyShots Number of shots fired.
|
||||||
--
|
--
|
||||||
|
-- @field #string alert5MissionType Alert 5 mission type. This is the mission type, the alerted assets will be able to carry out.
|
||||||
|
--
|
||||||
-- @field Ops.Chief#CHIEF chief The CHIEF managing this mission.
|
-- @field Ops.Chief#CHIEF chief The CHIEF managing this mission.
|
||||||
-- @field Ops.Commander#COMMANDER commander The COMMANDER managing this mission.
|
-- @field Ops.Commander#COMMANDER commander The COMMANDER managing this mission.
|
||||||
-- @field #table assets Warehouse assets assigned for this mission.
|
-- @field #table assets Warehouse assets assigned for this mission.
|
||||||
-- @field #number nassets Number of required warehouse assets.
|
-- @field #number NassetsMin Min. number of required warehouse assets.
|
||||||
-- @field #table Nassets Number of required warehouse assets for each assigned legion.
|
-- @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 #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.
|
||||||
-- @field #table requestID The ID of the queued warehouse request. Necessary to cancel the request if the mission was cancelled before the request is processed.
|
-- @field #table requestID The ID of the queued warehouse request. Necessary to cancel the request if the mission was cancelled before the request is processed.
|
||||||
|
-- @field #table specialLegions User specified legions assigned for this mission. Only these will be considered for the job!
|
||||||
|
-- @field #table specialCohorts User specified cohorts assigned for this mission. Only these will be considered for the job!
|
||||||
-- @field #table squadrons User specified airwing squadrons assigned for this mission. Only these will be considered for the job!
|
-- @field #table squadrons User specified airwing squadrons assigned for this mission. Only these will be considered for the job!
|
||||||
-- @field #table payloads User specified airwing payloads for this mission. Only these will be considered for the job!
|
-- @field #table payloads User specified airwing payloads for this mission. Only these will be considered for the job!
|
||||||
-- @field #table mylegions User specified legions for this mission. Only these will be considered for the job!
|
|
||||||
-- @field Ops.AirWing#AIRWING.PatrolData patroldata Patrol data.
|
-- @field Ops.AirWing#AIRWING.PatrolData patroldata Patrol data.
|
||||||
--
|
--
|
||||||
-- @field #string missionTask Mission task. See `ENUMS.MissionTask`.
|
-- @field #string missionTask Mission task. See `ENUMS.MissionTask`.
|
||||||
@ -244,9 +253,11 @@
|
|||||||
--
|
--
|
||||||
-- An arty mission can be created with the @{#AUFTRAG.NewARTY}() function.
|
-- An arty mission can be created with the @{#AUFTRAG.NewARTY}() function.
|
||||||
--
|
--
|
||||||
|
--
|
||||||
-- # Options and Parameters
|
-- # Options and Parameters
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
--
|
||||||
-- # Assigning Missions
|
-- # Assigning Missions
|
||||||
--
|
--
|
||||||
-- An AUFTRAG can be assigned to groups, airwings or wingcommanders
|
-- An AUFTRAG can be assigned to groups, airwings or wingcommanders
|
||||||
@ -261,13 +272,19 @@
|
|||||||
--
|
--
|
||||||
-- Assigning an AUFTRAG to a navy groups is done via the @{Ops.NavyGroup#NAVYGROUP.AddMission} function. See NAVYGROUP docs for details.
|
-- Assigning an AUFTRAG to a navy groups is done via the @{Ops.NavyGroup#NAVYGROUP.AddMission} function. See NAVYGROUP docs for details.
|
||||||
--
|
--
|
||||||
-- ## Airwing Level
|
-- ## Legion Level
|
||||||
--
|
--
|
||||||
-- Adding an AUFTRAG to an airwing is done via the @{Ops.AirWing#AIRWING.AddMission} function. See AIRWING docs for further details.
|
-- Adding an AUFTRAG to an airwing is done via the @{Ops.AirWing#AIRWING.AddMission} function. See AIRWING docs for further details.
|
||||||
|
-- Similarly, an AUFTRAG can be added to a brigade via the @{Ops.Brigade#BRIGADE.AddMission} function
|
||||||
--
|
--
|
||||||
-- ## Wing Commander Level
|
-- ## Commander Level
|
||||||
|
--
|
||||||
|
-- Assigning an AUFTRAG to acommander is done via the @{Ops.Commander#COMMANDER.AddMission} function. See COMMADER docs for details.
|
||||||
|
--
|
||||||
|
-- ## Chief Level
|
||||||
|
--
|
||||||
|
-- Assigning an AUFTRAG to a wing commander is done via the @{Ops.Chief#CHIEF.AddMission} function. See CHIEF docs for details.
|
||||||
--
|
--
|
||||||
-- Assigning an AUFTRAG to a wing commander is done via the @{Ops.WingCommander#WINGCOMMANDER.AddMission} function. See WINGCOMMADER docs for details.
|
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- # Events
|
-- # Events
|
||||||
@ -289,7 +306,8 @@ AUFTRAG = {
|
|||||||
statusLegion = {},
|
statusLegion = {},
|
||||||
requestID = {},
|
requestID = {},
|
||||||
assets = {},
|
assets = {},
|
||||||
Nassets = {},
|
NassetsLegMin = {},
|
||||||
|
NassetsLegMax = {},
|
||||||
missionFraction = 0.5,
|
missionFraction = 0.5,
|
||||||
enrouteTasks = {},
|
enrouteTasks = {},
|
||||||
marker = nil,
|
marker = nil,
|
||||||
@ -444,6 +462,22 @@ AUFTRAG.TargetType={
|
|||||||
SETUNIT="SetUnit",
|
SETUNIT="SetUnit",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Mission category.
|
||||||
|
-- @type AUFTRAG.Category
|
||||||
|
-- @field #string AIRCRAFT Airplanes and helicopters.
|
||||||
|
-- @field #string AIRPLANE Airplanes.
|
||||||
|
-- @field #string HELICOPTER Helicopter.
|
||||||
|
-- @field #string GROUND Ground troops.
|
||||||
|
-- @field #string NAVAL Naval grous.
|
||||||
|
AUFTRAG.Category={
|
||||||
|
ALL="All",
|
||||||
|
AIRCRAFT="Aircraft",
|
||||||
|
AIRPLANE="Airplane",
|
||||||
|
HELICOPTER="Helicopter",
|
||||||
|
GROUND="Ground",
|
||||||
|
NAVAL="Naval",
|
||||||
|
}
|
||||||
|
|
||||||
--- Target data.
|
--- Target data.
|
||||||
-- @type AUFTRAG.TargetData
|
-- @type AUFTRAG.TargetData
|
||||||
-- @field Wrapper.Positionable#POSITIONABLE Target Target Object.
|
-- @field Wrapper.Positionable#POSITIONABLE Target Target Object.
|
||||||
@ -483,7 +517,7 @@ AUFTRAG.TargetType={
|
|||||||
|
|
||||||
--- AUFTRAG class version.
|
--- AUFTRAG class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AUFTRAG.version="0.8.0"
|
AUFTRAG.version="0.8.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -493,6 +527,7 @@ AUFTRAG.version="0.8.0"
|
|||||||
-- TODO: Mission success options damaged, destroyed.
|
-- TODO: Mission success options damaged, destroyed.
|
||||||
-- TODO: F10 marker to create new missions.
|
-- TODO: F10 marker to create new missions.
|
||||||
-- TODO: Add recovery tanker mission for boat ops.
|
-- TODO: Add recovery tanker mission for boat ops.
|
||||||
|
-- DONE: Added auftrag category.
|
||||||
-- DONE: Missions can be assigned to multiple legions.
|
-- DONE: Missions can be assigned to multiple legions.
|
||||||
-- DONE: Option to assign a specific payload for the mission (requires an AIRWING).
|
-- DONE: Option to assign a specific payload for the mission (requires an AIRWING).
|
||||||
-- NOPE: Clone mission. How? Deepcopy? ==> Create a new auftrag.
|
-- NOPE: Clone mission. How? Deepcopy? ==> Create a new auftrag.
|
||||||
@ -621,6 +656,8 @@ function AUFTRAG:NewANTISHIP(Target, Altitude)
|
|||||||
mission.optionROE=ENUMS.ROE.OpenFire
|
mission.optionROE=ENUMS.ROE.OpenFire
|
||||||
mission.optionROT=ENUMS.ROT.EvadeFire
|
mission.optionROT=ENUMS.ROT.EvadeFire
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -663,6 +700,8 @@ function AUFTRAG:NewORBIT(Coordinate, Altitude, Speed, Heading, Leg)
|
|||||||
mission.optionROE=ENUMS.ROE.ReturnFire
|
mission.optionROE=ENUMS.ROE.ReturnFire
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -722,6 +761,8 @@ function AUFTRAG:NewGCICAP(Coordinate, Altitude, Speed, Heading, Leg)
|
|||||||
mission.missionTask=ENUMS.MissionTask.INTERCEPT
|
mission.missionTask=ENUMS.MissionTask.INTERCEPT
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -751,6 +792,8 @@ function AUFTRAG:NewTANKER(Coordinate, Altitude, Speed, Heading, Leg, RefuelSyst
|
|||||||
mission.optionROE=ENUMS.ROE.WeaponHold
|
mission.optionROE=ENUMS.ROE.WeaponHold
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -779,6 +822,8 @@ function AUFTRAG:NewAWACS(Coordinate, Altitude, Speed, Heading, Leg)
|
|||||||
mission.optionROE=ENUMS.ROE.WeaponHold
|
mission.optionROE=ENUMS.ROE.WeaponHold
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -802,6 +847,8 @@ function AUFTRAG:NewINTERCEPT(Target)
|
|||||||
mission.optionROE=ENUMS.ROE.OpenFire
|
mission.optionROE=ENUMS.ROE.OpenFire
|
||||||
mission.optionROT=ENUMS.ROT.EvadeFire
|
mission.optionROT=ENUMS.ROT.EvadeFire
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -842,6 +889,8 @@ function AUFTRAG:NewCAP(ZoneCAP, Altitude, Speed, Coordinate, Heading, Leg, Targ
|
|||||||
mission.optionROE=ENUMS.ROE.OpenFire
|
mission.optionROE=ENUMS.ROE.OpenFire
|
||||||
mission.optionROT=ENUMS.ROT.EvadeFire
|
mission.optionROT=ENUMS.ROT.EvadeFire
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -882,6 +931,8 @@ function AUFTRAG:NewCAS(ZoneCAS, Altitude, Speed, Coordinate, Heading, Leg, Targ
|
|||||||
mission.optionROE=ENUMS.ROE.OpenFire
|
mission.optionROE=ENUMS.ROE.OpenFire
|
||||||
mission.optionROT=ENUMS.ROT.EvadeFire
|
mission.optionROT=ENUMS.ROT.EvadeFire
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -916,6 +967,8 @@ function AUFTRAG:NewFACA(Target, Designation, DataLink, Frequency, Modulation)
|
|||||||
mission.optionROE=ENUMS.ROE.ReturnFire
|
mission.optionROE=ENUMS.ROE.ReturnFire
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -945,6 +998,8 @@ function AUFTRAG:NewBAI(Target, Altitude)
|
|||||||
mission.optionROE=ENUMS.ROE.OpenFire
|
mission.optionROE=ENUMS.ROE.OpenFire
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -974,6 +1029,8 @@ function AUFTRAG:NewSEAD(Target, Altitude)
|
|||||||
mission.optionROT=ENUMS.ROT.EvadeFire
|
mission.optionROT=ENUMS.ROT.EvadeFire
|
||||||
--mission.optionROT=ENUMS.ROT.AllowAbortMission
|
--mission.optionROT=ENUMS.ROT.AllowAbortMission
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1002,6 +1059,8 @@ function AUFTRAG:NewSTRIKE(Target, Altitude)
|
|||||||
mission.optionROE=ENUMS.ROE.OpenFire
|
mission.optionROE=ENUMS.ROE.OpenFire
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1033,6 +1092,8 @@ function AUFTRAG:NewBOMBING(Target, Altitude)
|
|||||||
-- Evaluate result after 5 min. We might need time until the bombs have dropped and targets have been detroyed.
|
-- Evaluate result after 5 min. We might need time until the bombs have dropped and targets have been detroyed.
|
||||||
mission.dTevaluate=5*60
|
mission.dTevaluate=5*60
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
-- Get DCS task.
|
-- Get DCS task.
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
@ -1069,6 +1130,8 @@ function AUFTRAG:NewBOMBRUNWAY(Airdrome, Altitude)
|
|||||||
-- Evaluate result after 5 min.
|
-- Evaluate result after 5 min.
|
||||||
mission.dTevaluate=5*60
|
mission.dTevaluate=5*60
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
-- Get DCS task.
|
-- Get DCS task.
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
@ -1105,6 +1168,8 @@ function AUFTRAG:NewBOMBCARPET(Target, Altitude, CarpetLength)
|
|||||||
-- Evaluate result after 5 min.
|
-- Evaluate result after 5 min.
|
||||||
mission.dTevaluate=5*60
|
mission.dTevaluate=5*60
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
-- Get DCS task.
|
-- Get DCS task.
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
@ -1123,7 +1188,13 @@ function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetT
|
|||||||
|
|
||||||
local mission=AUFTRAG:New(AUFTRAG.Type.ESCORT)
|
local mission=AUFTRAG:New(AUFTRAG.Type.ESCORT)
|
||||||
|
|
||||||
|
-- If only a string is passed we set a variable and check later if the group exists.
|
||||||
|
if type(EscortGroup)=="string" then
|
||||||
|
mission.escortGroupName=EscortGroup
|
||||||
|
mission:_TargetFromObject()
|
||||||
|
else
|
||||||
mission:_TargetFromObject(EscortGroup)
|
mission:_TargetFromObject(EscortGroup)
|
||||||
|
end
|
||||||
|
|
||||||
-- DCS task parameters:
|
-- DCS task parameters:
|
||||||
mission.escortVec3=OffsetVector or {x=-100, y=0, z=200}
|
mission.escortVec3=OffsetVector or {x=-100, y=0, z=200}
|
||||||
@ -1137,6 +1208,8 @@ function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetT
|
|||||||
mission.optionROE=ENUMS.ROE.OpenFire -- TODO: what's the best ROE here? Make dependent on ESCORT or FOLLOW!
|
mission.optionROE=ENUMS.ROE.OpenFire -- TODO: what's the best ROE here? Make dependent on ESCORT or FOLLOW!
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1158,13 +1231,15 @@ function AUFTRAG:NewRESCUEHELO(Carrier)
|
|||||||
mission.optionROE=ENUMS.ROE.WeaponHold
|
mission.optionROE=ENUMS.ROE.WeaponHold
|
||||||
mission.optionROT=ENUMS.ROT.NoReaction
|
mission.optionROT=ENUMS.ROT.NoReaction
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.HELICOPTER}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- **[AIR ROTARY]** Create a TROOP TRANSPORT mission.
|
--- **[AIR ROTARY, GROUND]** Create a TROOP TRANSPORT mission.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param Core.Set#SET_GROUP TransportGroupSet The set group(s) to be transported.
|
-- @param Core.Set#SET_GROUP TransportGroupSet The set group(s) to be transported.
|
||||||
-- @param Core.Point#COORDINATE DropoffCoordinate Coordinate where the helo will land drop off the the troops.
|
-- @param Core.Point#COORDINATE DropoffCoordinate Coordinate where the helo will land drop off the the troops.
|
||||||
@ -1197,6 +1272,8 @@ function AUFTRAG:NewTROOPTRANSPORT(TransportGroupSet, DropoffCoordinate, PickupC
|
|||||||
mission.optionROE=ENUMS.ROE.ReturnFire
|
mission.optionROE=ENUMS.ROE.ReturnFire
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.HELICOPTER, AUFTRAG.Category.GROUND}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1231,6 +1308,8 @@ function AUFTRAG:NewOPSTRANSPORT(CargoGroupSet, PickupZone, DeployZone)
|
|||||||
mission.optionROE=ENUMS.ROE.ReturnFire
|
mission.optionROE=ENUMS.ROE.ReturnFire
|
||||||
mission.optionROT=ENUMS.ROT.PassiveDefense
|
mission.optionROT=ENUMS.ROT.PassiveDefense
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.ALL}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1262,6 +1341,8 @@ function AUFTRAG:NewARTY(Target, Nshots, Radius)
|
|||||||
-- Evaluate after 8 min.
|
-- Evaluate after 8 min.
|
||||||
mission.dTevaluate=8*60
|
mission.dTevaluate=8*60
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.GROUND}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1292,6 +1373,8 @@ function AUFTRAG:NewPATROLZONE(Zone, Speed, Altitude)
|
|||||||
mission.missionSpeed=Speed and UTILS.KnotsToKmph(Speed) or nil
|
mission.missionSpeed=Speed and UTILS.KnotsToKmph(Speed) or nil
|
||||||
mission.missionAltitude=Altitude and UTILS.FeetToMeters(Altitude) or nil
|
mission.missionAltitude=Altitude and UTILS.FeetToMeters(Altitude) or nil
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.ALL}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1319,6 +1402,8 @@ function AUFTRAG:NewRECON(ZoneSet, Speed, Altitude, Adinfinitum, Randomly)
|
|||||||
mission.missionSpeed=Speed and UTILS.KnotsToKmph(Speed) or nil
|
mission.missionSpeed=Speed and UTILS.KnotsToKmph(Speed) or nil
|
||||||
mission.missionAltitude=Altitude and UTILS.FeetToMeters(Altitude) or UTILS.FeetToMeters(2000)
|
mission.missionAltitude=Altitude and UTILS.FeetToMeters(Altitude) or UTILS.FeetToMeters(2000)
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.ALL}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
mission.DCStask.params.adinfitum=Adinfinitum
|
mission.DCStask.params.adinfitum=Adinfinitum
|
||||||
mission.DCStask.params.randomly=Randomly
|
mission.DCStask.params.randomly=Randomly
|
||||||
@ -1341,6 +1426,8 @@ function AUFTRAG:NewAMMOSUPPLY(Zone)
|
|||||||
|
|
||||||
mission.missionFraction=0.9
|
mission.missionFraction=0.9
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.GROUND}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1361,6 +1448,8 @@ function AUFTRAG:NewFUELSUPPLY(Zone)
|
|||||||
|
|
||||||
mission.missionFraction=0.9
|
mission.missionFraction=0.9
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.GROUND}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1384,6 +1473,8 @@ function AUFTRAG:NewALERT5(MissionType)
|
|||||||
|
|
||||||
mission.missionFraction=1.0
|
mission.missionFraction=1.0
|
||||||
|
|
||||||
|
mission.categories={AUFTRAG.Category.AIRCRAFT}
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
return mission
|
return mission
|
||||||
@ -1686,28 +1777,58 @@ function AUFTRAG:SetRepeatOnSuccess(Nrepeat)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Define how many assets are required to do the job. Only valid if the mission is handled by a LEGION (AIRWING, BRIGADE, ...) or higher level.
|
--- 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 #AUFTRAG self
|
||||||
-- @param #number Nassets Number of asset groups. Default 1.
|
-- @param #number NassetsMin Minimum number of asset groups. Default 1.
|
||||||
|
-- @param #number NassetsMax Maximum Number of asset groups. Default is same as `NassetsMin`.
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:SetRequiredAssets(Nassets)
|
function AUFTRAG:SetRequiredAssets(NassetsMin, NassetsMax)
|
||||||
self.nassets=Nassets or 1
|
|
||||||
|
self.NassetsMin=NassetsMin or 1
|
||||||
|
|
||||||
|
self.NassetsMax=NassetsMax or self.NassetsMin
|
||||||
|
|
||||||
|
-- Ensure that max is at least equal to min.
|
||||||
|
if self.NassetsMax<self.NassetsMin then
|
||||||
|
self.NassetsMax=self.NassetsMin
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get number of required assets.
|
--- Get number of required assets.
|
||||||
-- @param #AUFTRAG self
|
-- @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.
|
-- @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 Number of required assets.
|
-- @return #number Min. number of required assets.
|
||||||
|
-- @return #number Max. number of required assets.
|
||||||
function AUFTRAG:GetRequiredAssets(Legion)
|
function AUFTRAG:GetRequiredAssets(Legion)
|
||||||
|
|
||||||
local N=self.nassets
|
--local N=self.nassets
|
||||||
|
|
||||||
if Legion and self.Nassets[Legion.alias] then
|
--if Legion and self.Nassets[Legion.alias] then
|
||||||
N=self.Nassets[Legion.alias]
|
-- N=self.Nassets[Legion.alias]
|
||||||
|
--end
|
||||||
|
|
||||||
|
return self.NassetsMin, self.NassetsMax
|
||||||
end
|
end
|
||||||
|
|
||||||
return N
|
--- 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 NescortMin Minimum number of asset groups. Default 1.
|
||||||
|
-- @param #number NescortMax Maximum Number of asset groups. Default is same as `NassetsMin`.
|
||||||
|
-- @return #AUFTRAG self
|
||||||
|
function AUFTRAG:SetRequiredEscorts(NescortMin, NescortMax)
|
||||||
|
|
||||||
|
self.NescortMin=NescortMin or 1
|
||||||
|
|
||||||
|
self.NescortMax=NescortMax or self.NescortMin
|
||||||
|
|
||||||
|
-- Ensure that max is at least equal to min.
|
||||||
|
if self.NescortMax<self.NescortMin then
|
||||||
|
self.NescortMax=self.NescortMin
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set mission name.
|
--- Set mission name.
|
||||||
@ -2039,7 +2160,7 @@ end
|
|||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @return #number Numer of required assets.
|
-- @return #number Numer of required assets.
|
||||||
function AUFTRAG:GetNumberOfRequiredAssets()
|
function AUFTRAG:GetNumberOfRequiredAssets()
|
||||||
return self.nassets
|
return self.Nassets or self.NassetsMin
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get mission priority.
|
--- Get mission priority.
|
||||||
@ -2167,6 +2288,8 @@ function AUFTRAG:_AssignCohort(Cohort)
|
|||||||
self.squadrons=self.squadrons or {}
|
self.squadrons=self.squadrons or {}
|
||||||
|
|
||||||
self:T3(self.lid..string.format("Assigning cohort %s", tostring(Cohort.name)))
|
self:T3(self.lid..string.format("Assigning cohort %s", tostring(Cohort.name)))
|
||||||
|
|
||||||
|
-- Add cohort to table.
|
||||||
table.insert(self.squadrons, Cohort)
|
table.insert(self.squadrons, Cohort)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -2338,6 +2461,67 @@ function AUFTRAG:IsNotOver()
|
|||||||
return not self:IsOver()
|
return not self:IsOver()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if mission is for aircarft (airplanes and/or helicopters).
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #boolean If `true`, mission is for aircraft.
|
||||||
|
function AUFTRAG:IsAircraft()
|
||||||
|
for _,category in pairs(self.categories) do
|
||||||
|
if category==AUFTRAG.Category.AIRCRAFT or category==AUFTRAG.Category.AIRPLANE or category==AUFTRAG.Category.HELICOPTER then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if mission is for airplanes.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #boolean If `true`, mission is for airplanes.
|
||||||
|
function AUFTRAG:IsAirplane()
|
||||||
|
for _,category in pairs(self.categories) do
|
||||||
|
if category==AUFTRAG.Category.AIRPLANE then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if mission is for helicopters.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #boolean If `true`, mission is for helicopters.
|
||||||
|
function AUFTRAG:IsHelicopters()
|
||||||
|
for _,category in pairs(self.categories) do
|
||||||
|
if category==AUFTRAG.Category.HELICOPTER then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if mission is for ground units.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #boolean If `true`, mission is for ground units.
|
||||||
|
function AUFTRAG:IsGround()
|
||||||
|
for _,category in pairs(self.categories) do
|
||||||
|
if category==AUFTRAG.Category.GROUND then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if mission is for naval units.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #boolean If `true`, mission is for naval units.
|
||||||
|
function AUFTRAG:IsNaval()
|
||||||
|
for _,category in pairs(self.categories) do
|
||||||
|
if category==AUFTRAG.Category.NAVAL then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if mission is ready to be started.
|
--- Check if mission is ready to be started.
|
||||||
-- * Mission start time passed.
|
-- * Mission start time passed.
|
||||||
-- * Mission stop time did not pass already.
|
-- * Mission stop time did not pass already.
|
||||||
@ -2496,6 +2680,26 @@ function AUFTRAG:onafterStatus(From, Event, To)
|
|||||||
-- Current abs. mission time.
|
-- Current abs. mission time.
|
||||||
local Tnow=timer.getAbsTime()
|
local Tnow=timer.getAbsTime()
|
||||||
|
|
||||||
|
-- ESCORT: Check if only the group NAME of an escort had been specified.
|
||||||
|
if self.escortGroupName then
|
||||||
|
-- Try to find the group.
|
||||||
|
local group=GROUP:FindByName(self.escortGroupName)
|
||||||
|
if group and group:IsAlive() then
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("ESCORT group %s is now alive. Updating DCS task and adding group to TARGET", tostring(self.escortGroupName)))
|
||||||
|
|
||||||
|
-- Add TARGET object.
|
||||||
|
self.engageTarget:AddObject(group)
|
||||||
|
|
||||||
|
-- Update DCS task with the known group ID.
|
||||||
|
self.DCStask=self:GetDCSMissionTask()
|
||||||
|
|
||||||
|
-- Set value to nil so we do not do this again in the next cycle.
|
||||||
|
self.escortGroupName=nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Number of alive mission targets.
|
-- Number of alive mission targets.
|
||||||
local Ntargets=self:CountMissionTargets()
|
local Ntargets=self:CountMissionTargets()
|
||||||
local Ntargets0=self:GetTargetInitialNumber()
|
local Ntargets0=self:GetTargetInitialNumber()
|
||||||
@ -3337,7 +3541,7 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function AUFTRAG:onbeforeRepeat(From, Event, To)
|
function AUFTRAG:onbeforeRepeat(From, Event, To)
|
||||||
|
|
||||||
if not (self.chief or self.commander or #self.legions==0) then
|
if not (self.chief or self.commander or #self.legions>0) then
|
||||||
self:E(self.lid.."ERROR: Mission can only be repeated by a CHIEF, COMMANDER or LEGION! Stopping AUFTRAG")
|
self:E(self.lid.."ERROR: Mission can only be repeated by a CHIEF, COMMANDER or LEGION! Stopping AUFTRAG")
|
||||||
self:Stop()
|
self:Stop()
|
||||||
return false
|
return false
|
||||||
@ -3498,7 +3702,7 @@ function AUFTRAG:_TargetFromObject(Object)
|
|||||||
|
|
||||||
if not self.engageTarget then
|
if not self.engageTarget then
|
||||||
|
|
||||||
if Object:IsInstanceOf("TARGET") then
|
if Object and Object:IsInstanceOf("TARGET") then
|
||||||
|
|
||||||
self.engageTarget=Object
|
self.engageTarget=Object
|
||||||
|
|
||||||
@ -3848,7 +4052,7 @@ function AUFTRAG:UpdateMarker()
|
|||||||
local text=string.format("%s %s: %s", self.name, self.type:upper(), self.status:upper())
|
local text=string.format("%s %s: %s", self.name, self.type:upper(), self.status:upper())
|
||||||
text=text..string.format("\n%s", self:GetTargetName())
|
text=text..string.format("\n%s", self:GetTargetName())
|
||||||
text=text..string.format("\nTargets %d/%d, Life Points=%d/%d", self:CountMissionTargets(), self:GetTargetInitialNumber(), self:GetTargetLife(), self:GetTargetInitialLife())
|
text=text..string.format("\nTargets %d/%d, Life Points=%d/%d", self:CountMissionTargets(), self:GetTargetInitialNumber(), self:GetTargetLife(), self:GetTargetInitialLife())
|
||||||
text=text..string.format("\nFlights %d/%d", self:CountOpsGroups(), self.nassets)
|
text=text..string.format("\nOpsGroups %d/%d", self:CountOpsGroups(), self.nassets)
|
||||||
|
|
||||||
if not self.marker then
|
if not self.marker then
|
||||||
|
|
||||||
|
|||||||
@ -694,6 +694,12 @@ function COMMANDER:CheckMissionQueue()
|
|||||||
mission:AddAsset(asset)
|
mission:AddAsset(asset)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Recruit asset for escorting recruited mission assets.
|
||||||
|
local EscortAvail=self:RecruitAssetsForEscort(mission, assets)
|
||||||
|
|
||||||
|
|
||||||
|
if EscortAvail then
|
||||||
|
|
||||||
-- Assign mission to legion(s).
|
-- Assign mission to legion(s).
|
||||||
for _,_legion in pairs(legions) do
|
for _,_legion in pairs(legions) do
|
||||||
local legion=_legion --Ops.Legion#LEGION
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
@ -706,6 +712,11 @@ function COMMANDER:CheckMissionQueue()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
-- Recruited assets but no requested escort available. Unrecruit assets!
|
||||||
|
LEGION.UnRecruitAssets(assets, mission)
|
||||||
|
end
|
||||||
|
|
||||||
-- Only ONE mission is assigned.
|
-- Only ONE mission is assigned.
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -745,8 +756,7 @@ function COMMANDER:RecruitAssetsForMission(Mission)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Number of required assets.
|
-- Number of required assets.
|
||||||
local NreqMin=Mission:GetRequiredAssets()
|
local NreqMin, NreqMax=Mission:GetRequiredAssets()
|
||||||
local NreqMax=NreqMin
|
|
||||||
|
|
||||||
-- Target position.
|
-- Target position.
|
||||||
local TargetVec2=Mission:GetTargetVec2()
|
local TargetVec2=Mission:GetTargetVec2()
|
||||||
@ -760,6 +770,111 @@ function COMMANDER:RecruitAssetsForMission(Mission)
|
|||||||
return recruited, assets, legions
|
return recruited, assets, legions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Recruit assets performing an escort mission for a given asset.
|
||||||
|
-- @param #COMMANDER self
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
-- @param #table Assets Table of assets.
|
||||||
|
-- @return #boolean If `true`, enough assets could be recruited or no escort was required in the first place.
|
||||||
|
function COMMANDER:RecruitAssetsForEscort(Mission, Assets)
|
||||||
|
|
||||||
|
-- Cohorts.
|
||||||
|
local Cohorts=Mission.squadrons
|
||||||
|
if not Cohorts then
|
||||||
|
Cohorts={}
|
||||||
|
for _,_legion in pairs(Mission.mylegions or self.legions) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
-- Loops over cohorts.
|
||||||
|
for _,_cohort in pairs(legion.cohorts) do
|
||||||
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
|
table.insert(Cohorts, cohort)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Is an escort requested in the first place?
|
||||||
|
if Mission.NescortMin and Mission.NescortMax and (Mission.NescortMin>0 or Mission.NescortMax>0) then
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("Reqested escort for mission %s [%s]. Required assets=%d-%d", Mission:GetName(), Mission:GetType(), Mission.NescortMin,Mission.NescortMax))
|
||||||
|
|
||||||
|
-- Escorts for each asset.
|
||||||
|
local Escorts={}
|
||||||
|
|
||||||
|
local EscortAvail=true
|
||||||
|
for _,_asset in pairs(Assets) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
|
-- Recruit escort asset for the mission asset.
|
||||||
|
local Erecruited, eassets, elegions=LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.ESCORT, nil, Mission.NescortMin, Mission.NescortMax)
|
||||||
|
|
||||||
|
if Erecruited then
|
||||||
|
Escorts[asset.spawngroupname]={EscortLegions=elegions, EscortAssets=eassets}
|
||||||
|
else
|
||||||
|
-- Could not find escort for this asset ==> Escort not possible ==> Break the loop.
|
||||||
|
EscortAvail=false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ALL escorts could be recruited.
|
||||||
|
if EscortAvail then
|
||||||
|
|
||||||
|
local N=0
|
||||||
|
for groupname,value in pairs(Escorts) do
|
||||||
|
|
||||||
|
local Elegions=value.EscortLegions
|
||||||
|
local Eassets=value.EscortAssets
|
||||||
|
|
||||||
|
for _,_legion in pairs(Elegions) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
|
||||||
|
-- Create and ESCORT mission for this asset.
|
||||||
|
local escort=AUFTRAG:NewESCORT(groupname)
|
||||||
|
|
||||||
|
-- Reserve assts and add to mission.
|
||||||
|
for _,_asset in pairs(Eassets) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
asset.isReserved=true
|
||||||
|
escort:AddAsset(asset)
|
||||||
|
N=N+1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add mission.
|
||||||
|
legion:AddMission(escort)
|
||||||
|
|
||||||
|
-- Request mission.
|
||||||
|
legion:MissionRequest(escort)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("Recruited %d escort assets for mission %s [%s]", N, Mission:GetName(), Mission:GetType()))
|
||||||
|
|
||||||
|
-- Yup!
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("Could not get at least one escort for mission %s [%s]! Unrecruit all recruited assets", Mission:GetName(), Mission:GetType()))
|
||||||
|
|
||||||
|
-- Could not get at least one escort. Unrecruit all recruited ones.
|
||||||
|
for groupname,value in pairs(Escorts) do
|
||||||
|
local Eassets=value.EscortAssets
|
||||||
|
LEGION.UnRecruitAssets(Eassets)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- No,no!
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
-- No escort required.
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Transport Functions
|
-- Transport Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -476,15 +476,28 @@ function LEGION:_GetNextMission()
|
|||||||
|
|
||||||
-- Did we find enough assets?
|
-- Did we find enough assets?
|
||||||
if recruited then
|
if recruited then
|
||||||
|
|
||||||
|
-- Reserve assets and add to mission.
|
||||||
for _,_asset in pairs(assets) do
|
for _,_asset in pairs(assets) do
|
||||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
asset.isReserved=true
|
asset.isReserved=true
|
||||||
mission:AddAsset(asset)
|
mission:AddAsset(asset)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Recruit asset for escorting recruited mission assets.
|
||||||
|
local EscortAvail=self:RecruitAssetsForEscort(mission, assets)
|
||||||
|
|
||||||
|
-- Is escort required and available?
|
||||||
|
if EscortAvail then
|
||||||
|
-- Got a missin.
|
||||||
return mission
|
return mission
|
||||||
|
else
|
||||||
|
-- Recruited assets but no requested escort available. Unrecruit assets!
|
||||||
|
LEGION.UnRecruitAssets(assets, mission)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end -- recruited mission assets
|
||||||
|
|
||||||
end -- mission due?
|
end -- mission due?
|
||||||
end -- mission loop
|
end -- mission loop
|
||||||
|
|
||||||
@ -1627,8 +1640,7 @@ end
|
|||||||
function LEGION:RecruitAssetsForMission(Mission)
|
function LEGION:RecruitAssetsForMission(Mission)
|
||||||
|
|
||||||
-- Get required assets.
|
-- Get required assets.
|
||||||
local NreqMin=Mission:GetRequiredAssets()
|
local NreqMin, NreqMax=Mission:GetRequiredAssets()
|
||||||
local NreqMax=NreqMin
|
|
||||||
|
|
||||||
-- Target position vector.
|
-- Target position vector.
|
||||||
local TargetVec2=Mission:GetTargetVec2()
|
local TargetVec2=Mission:GetTargetVec2()
|
||||||
@ -1686,6 +1698,97 @@ function LEGION:RecruitAssetsForTransport(Transport)
|
|||||||
return recruited, assets, legions
|
return recruited, assets, legions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Recruit assets performing an escort mission for a given asset.
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
-- @param #table Assets Table of assets.
|
||||||
|
-- @return #boolean If `true`, enough assets could be recruited or no escort was required in the first place.
|
||||||
|
function LEGION:RecruitAssetsForEscort(Mission, Assets)
|
||||||
|
|
||||||
|
-- Is an escort requested in the first place?
|
||||||
|
if Mission.NescortMin and Mission.NescortMax and (Mission.NescortMin>0 or Mission.NescortMax>0) then
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("Reqested escort for mission %s [%s]. Required assets=%d-%d", Mission:GetName(), Mission:GetType(), Mission.NescortMin,Mission.NescortMax))
|
||||||
|
|
||||||
|
-- Escorts for each asset.
|
||||||
|
local Escorts={}
|
||||||
|
|
||||||
|
local EscortAvail=true
|
||||||
|
for _,_asset in pairs(Assets) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
|
-- Recruit escort asset for the mission asset.
|
||||||
|
local Erecruited, eassets, elegions=LEGION.RecruitCohortAssets(self.cohorts, AUFTRAG.Type.ESCORT, nil, Mission.NescortMin, Mission.NescortMax)
|
||||||
|
|
||||||
|
if Erecruited then
|
||||||
|
Escorts[asset.spawngroupname]={EscortLegions=elegions, EscortAssets=eassets}
|
||||||
|
else
|
||||||
|
-- Could not find escort for this asset ==> Escort not possible ==> Break the loop.
|
||||||
|
EscortAvail=false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ALL escorts could be recruited.
|
||||||
|
if EscortAvail then
|
||||||
|
|
||||||
|
local N=0
|
||||||
|
for groupname,value in pairs(Escorts) do
|
||||||
|
|
||||||
|
local Elegions=value.EscortLegions
|
||||||
|
local Eassets=value.EscortAssets
|
||||||
|
|
||||||
|
for _,_legion in pairs(Elegions) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
|
||||||
|
-- Create and ESCORT mission for this asset.
|
||||||
|
local escort=AUFTRAG:NewESCORT(groupname)
|
||||||
|
|
||||||
|
-- Reserve assts and add to mission.
|
||||||
|
for _,_asset in pairs(Eassets) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
asset.isReserved=true
|
||||||
|
escort:AddAsset(asset)
|
||||||
|
N=N+1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add mission.
|
||||||
|
legion:AddMission(escort)
|
||||||
|
|
||||||
|
-- Request mission.
|
||||||
|
legion:MissionRequest(escort)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("Recruited %d escort assets for mission %s [%s]", N, Mission:GetName(), Mission:GetType()))
|
||||||
|
|
||||||
|
-- Yup!
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:I(self.lid..string.format("Could not get at least one escort for mission %s [%s]! Unrecruit all recruited assets", Mission:GetName(), Mission:GetType()))
|
||||||
|
|
||||||
|
-- Could not get at least one escort. Unrecruit all recruited ones.
|
||||||
|
for groupname,value in pairs(Escorts) do
|
||||||
|
local Eassets=value.EscortAssets
|
||||||
|
LEGION.UnRecruitAssets(Eassets)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- No,no!
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
-- No escort required.
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Recruiting and Optimization Functions
|
-- Recruiting and Optimization Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -1827,6 +1930,30 @@ function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt,
|
|||||||
return false, {}, {}
|
return false, {}, {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Unrecruit assets. Set `isReserved` to false, return payload to airwing and (optionally) remove from assigned mission.
|
||||||
|
-- @param #table Assets List of assets.
|
||||||
|
-- @param Ops.Auftrag#AUFTRAG Mission (Optional) The mission from which the assets will be deleted.
|
||||||
|
function LEGION.UnRecruitAssets(Assets, Mission)
|
||||||
|
|
||||||
|
-- Return payloads of assets.
|
||||||
|
for i=1,#Assets do
|
||||||
|
local asset=Assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
-- Not reserved any more.
|
||||||
|
asset.isReserved=false
|
||||||
|
-- Return payload.
|
||||||
|
if asset.legion:IsAirwing() and not asset.spawned then
|
||||||
|
asset.legion:T2(asset.legion.lid..string.format("Returning payload from asset %s", asset.spawngroupname))
|
||||||
|
asset.legion:ReturnPayloadFromAsset(asset)
|
||||||
|
end
|
||||||
|
-- Remove from mission.
|
||||||
|
if Mission then
|
||||||
|
Mission:DelAsset(asset)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Calculate the mission score of an asset.
|
--- Calculate the mission score of an asset.
|
||||||
-- @param Functional.Warehouse#WAREHOUSE.Assetitem asset Asset
|
-- @param Functional.Warehouse#WAREHOUSE.Assetitem asset Asset
|
||||||
|
|||||||
@ -3763,9 +3763,6 @@ function OPSGROUP:_GetNextMission()
|
|||||||
end
|
end
|
||||||
table.sort(self.missionqueue, _sort)
|
table.sort(self.missionqueue, _sort)
|
||||||
|
|
||||||
-- Current time.
|
|
||||||
local time=timer.getAbsTime()
|
|
||||||
|
|
||||||
-- Look for first mission that is SCHEDULED.
|
-- Look for first mission that is SCHEDULED.
|
||||||
local vip=math.huge
|
local vip=math.huge
|
||||||
for _,_mission in pairs(self.missionqueue) do
|
for _,_mission in pairs(self.missionqueue) do
|
||||||
@ -3795,8 +3792,22 @@ function OPSGROUP:_GetNextMission()
|
|||||||
-- TODO: One could think of opsgroup specific start conditions. A legion also checks if "ready" but it can be other criteria for the group to actually start the mission.
|
-- TODO: One could think of opsgroup specific start conditions. A legion also checks if "ready" but it can be other criteria for the group to actually start the mission.
|
||||||
-- Good example is the above transport. The legion should start the mission but the group should only start after the transport is finished.
|
-- Good example is the above transport. The legion should start the mission but the group should only start after the transport is finished.
|
||||||
|
|
||||||
|
-- Escort mission. Check that escorted group is alive.
|
||||||
|
local isEscort=true
|
||||||
|
if mission.type==AUFTRAG.Type.ESCORT then
|
||||||
|
local target=mission:GetTargetData()
|
||||||
|
if not target:IsAlive() then
|
||||||
|
isEscort=false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local isScheduled=mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.SCHEDULED
|
||||||
|
local isReadyToGo=(mission:IsReadyToGo() or self.legion)
|
||||||
|
local isImportant=(mission.importance==nil or mission.importance<=vip)
|
||||||
|
local isTransport=transport
|
||||||
|
|
||||||
-- Check necessary conditions.
|
-- Check necessary conditions.
|
||||||
if mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.SCHEDULED and (mission:IsReadyToGo() or self.legion) and (mission.importance==nil or mission.importance<=vip) and transport then
|
if isScheduled and isReadyToGo and isImportant and isTransport and isEscort then
|
||||||
return mission
|
return mission
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -130,13 +130,14 @@ _TARGETID=0
|
|||||||
|
|
||||||
--- TARGET class version.
|
--- TARGET class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
TARGET.version="0.5.1"
|
TARGET.version="0.5.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- TODO: Add pseudo functions.
|
-- TODO: Add pseudo functions.
|
||||||
|
-- DONE: Initial object can be nil.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Constructor
|
-- Constructor
|
||||||
@ -157,29 +158,19 @@ function TARGET:New(TargetObject)
|
|||||||
-- Set UID.
|
-- Set UID.
|
||||||
self.uid=_TARGETID
|
self.uid=_TARGETID
|
||||||
|
|
||||||
|
if TargetObject then
|
||||||
|
|
||||||
-- Add object.
|
-- Add object.
|
||||||
self:AddObject(TargetObject)
|
self:AddObject(TargetObject)
|
||||||
|
|
||||||
-- Get first target.
|
|
||||||
local Target=self.targets[1] --#TARGET.Object
|
|
||||||
|
|
||||||
if not Target then
|
|
||||||
self:E("ERROR: No valid TARGET!")
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Defaults.
|
-- Defaults.
|
||||||
self:SetPriority()
|
self:SetPriority()
|
||||||
self:SetImportance()
|
self:SetImportance()
|
||||||
|
|
||||||
-- Target Name.
|
|
||||||
self.name=self:GetTargetName(Target)
|
|
||||||
|
|
||||||
-- Target category.
|
|
||||||
self.category=self:GetTargetCategory(Target)
|
|
||||||
|
|
||||||
-- Log ID.
|
-- Log ID.
|
||||||
self.lid=string.format("TARGET #%03d [%s] | ", _TARGETID, tostring(self.category))
|
self.lid=string.format("TARGET #%03d | ", _TARGETID)
|
||||||
|
|
||||||
-- Start state.
|
-- Start state.
|
||||||
self:SetStartState("Stopped")
|
self:SetStartState("Stopped")
|
||||||
@ -317,8 +308,15 @@ end
|
|||||||
-- @param #TARGET self
|
-- @param #TARGET self
|
||||||
-- @return #boolean If true, target is alive.
|
-- @return #boolean If true, target is alive.
|
||||||
function TARGET:IsAlive()
|
function TARGET:IsAlive()
|
||||||
local is=self:Is("Alive")
|
|
||||||
return is
|
for _,_target in pairs(self.targets) do
|
||||||
|
local target=_target --Ops.Target#TARGET.Object
|
||||||
|
if target.Status==TARGET.ObjectStatus.ALIVE then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if TARGET is destroyed.
|
--- Check if TARGET is destroyed.
|
||||||
@ -757,6 +755,13 @@ function TARGET:_AddObject(Object)
|
|||||||
|
|
||||||
table.insert(self.targets, target)
|
table.insert(self.targets, target)
|
||||||
|
|
||||||
|
if self.name==nil then
|
||||||
|
self.name=self:GetTargetName(target)
|
||||||
|
end
|
||||||
|
if self.category==nil then
|
||||||
|
self.category=self:GetTargetCategory(target)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -1051,7 +1056,7 @@ end
|
|||||||
-- @param #TARGET self
|
-- @param #TARGET self
|
||||||
-- @return #string Name of the target usually the first object.
|
-- @return #string Name of the target usually the first object.
|
||||||
function TARGET:GetName()
|
function TARGET:GetName()
|
||||||
return self.name
|
return self.name or "Unknown"
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get 2D vector.
|
--- Get 2D vector.
|
||||||
|
|||||||
@ -1407,7 +1407,7 @@ function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, E
|
|||||||
DCSTask = {
|
DCSTask = {
|
||||||
id = 'Escort',
|
id = 'Escort',
|
||||||
params = {
|
params = {
|
||||||
groupId = FollowControllable:GetID(),
|
groupId = FollowControllable and FollowControllable:GetID() or nil,
|
||||||
pos = Vec3,
|
pos = Vec3,
|
||||||
lastWptIndexFlag = LastWaypointIndex and true or false,
|
lastWptIndexFlag = LastWaypointIndex and true or false,
|
||||||
lastWptIndex = LastWaypointIndex,
|
lastWptIndex = LastWaypointIndex,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user