- Improved CAPTUREZONE for FLIGHTGROUP
This commit is contained in:
Frank 2023-06-08 19:51:09 +02:00
parent f45a22fe78
commit 1b6648996c
5 changed files with 100 additions and 18 deletions

View File

@ -68,7 +68,7 @@ ARMYGROUP = {
--- Army Group version.
-- @field #string version
ARMYGROUP.version="1.0.0"
ARMYGROUP.version="1.0.1"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
@ -1028,10 +1028,10 @@ function ARMYGROUP:onbeforeUpdateRoute(From, Event, To, n, N, Speed, Formation)
local task=self:GetTaskByID(self.taskcurrent)
if task then
if task.dcstask.id=="PatrolZone" then
if task.dcstask.id==AUFTRAG.SpecialTask.PATROLZONE then
-- For patrol zone, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: PatrolZone")
elseif task.dcstask.id=="ReconMission" then
elseif task.dcstask.id==AUFTRAG.SpecialTask.RECON then
-- For recon missions, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: ReconMission")
elseif task.dcstask.id==AUFTRAG.SpecialTask.RELOCATECOHORT then

View File

@ -216,7 +216,7 @@ FLIGHTGROUP.Players={}
--- FLIGHTGROUP class version.
-- @field #string version
FLIGHTGROUP.version="1.0.0"
FLIGHTGROUP.version="1.0.1"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
@ -1004,6 +1004,17 @@ function FLIGHTGROUP:Status()
self:_SandwitchDCSTask(DCSTask, Task, false, 1)
end
elseif mission.type==AUFTRAG.Type.CAPTUREZONE then
-- Get task.
local Task=mission:GetGroupWaypointTask(self)
-- Update task: Engage or get new zone.
if mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.EXECUTING or mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.STARTED then
self:_UpdateTask(Task, mission)
end
end
end
@ -2240,13 +2251,16 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n, N)
local task=self:GetTaskByID(self.taskcurrent)
if task then
if task.dcstask.id=="PatrolZone" then
if task.dcstask.id==AUFTRAG.SpecialTask.PATROLZONE then
-- For patrol zone, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: PatrolZone")
elseif task.dcstask.id=="ReconMission" then
elseif task.dcstask.id==AUFTRAG.SpecialTask.CAPTUREZONE then
-- For patrol zone, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: CaptureZone")
elseif task.dcstask.id==AUFTRAG.SpecialTask.RECON then
-- For recon missions, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: ReconMission")
elseif task.dcstask.id=="Hover" then
elseif task.dcstask.id==AUFTRAG.SpecialTask.HOVER then
-- For recon missions, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: Hover")
elseif task.dcstask.id==AUFTRAG.SpecialTask.RELOCATECOHORT then

View File

@ -90,7 +90,7 @@ NAVYGROUP = {
--- NavyGroup version.
-- @field #string version
NAVYGROUP.version="1.0.0"
NAVYGROUP.version="1.0.1"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
@ -783,6 +783,28 @@ function NAVYGROUP:Status(From, Event, To)
end
end
end
-- Get current mission (if any).
local mission=self:GetMissionCurrent()
-- If mission, check if DCS task needs to be updated.
if mission and mission.updateDCSTask then
if mission.type==AUFTRAG.Type.CAPTUREZONE then
-- Get task.
local Task=mission:GetGroupWaypointTask(self)
-- Update task: Engage or get new zone.
if mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.EXECUTING or mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.STARTED then
self:_UpdateTask(Task, mission)
end
end
end
else
-- Check damage of elements and group.
@ -1065,10 +1087,10 @@ function NAVYGROUP:onbeforeUpdateRoute(From, Event, To, n, Speed, Depth)
local task=self:GetTaskByID(self.taskcurrent)
if task then
if task.dcstask.id=="PatrolZone" then
if task.dcstask.id==AUFTRAG.SpecialTask.PATROLZONE then
-- For patrol zone, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: PatrolZone")
elseif task.dcstask.id=="ReconMission" then
elseif task.dcstask.id==AUFTRAG.SpecialTask.RECON then
-- For recon missions, we need to allow the update as we insert new waypoints.
self:T2(self.lid.."Allowing update route for Task: ReconMission")
elseif task.dcstask.id==AUFTRAG.SpecialTask.RELOCATECOHORT then

View File

@ -4576,8 +4576,18 @@ function OPSGROUP:_UpdateTask(Task, Mission)
self:EngageTarget(targetgroup)
else
-- Debug info.
self:T(self.lid..string.format("Zone %s not captured but no target group could be found. Should be captured in the next zone evaluation.", zoneCurr:GetName()))
if self:IsFlightgroup() then
-- Debug info.
self:T(self.lid..string.format("Zone %s not captured but no target group could be found ==> TaskDone as FLIGHTGROUPS cannot capture zones", zoneCurr:GetName()))
-- Task done.
self:TaskDone(Task)
else
-- Debug info.
self:T(self.lid..string.format("Zone %s not captured but no target group could be found. Should be captured in the next zone evaluation.", zoneCurr:GetName()))
end
end
else
@ -4882,12 +4892,37 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task)
-- Remove mission waypoints.
self:T(self.lid.."Remove mission waypoints")
self:_RemoveMissionWaypoints(Mission, false)
self:T(self.lid.."Task done ==> Route to mission for next opszone")
self:MissionStart(Mission)
self:_RemoveMissionWaypoints(Mission, false)
return
if self:IsFlightgroup() then
-- A flight cannot capture so we assume done.
-- local opszone=Mission:GetTargetData() --Ops.OpsZone#OPSZONE
--
-- if opszone then
--
-- local mycoalition=self:GetCoalition()
--
-- if mycoalition~=opszone:GetOwner() then
-- local nenemy=0
-- if mycoalition==coalition.side.BLUE then
-- nenemy=opszone.Nred
-- else
-- nenemy=opszone.Nblu
-- end
--
-- end
--
-- end
else
self:T(self.lid.."Task done ==> Route to mission for next opszone")
self:MissionStart(Mission)
return
end
end
-- Get egress waypoint uid.

View File

@ -32,6 +32,7 @@
-- @field #number Nred Number of red units in the zone.
-- @field #number Nblu Number of blue units in the zone.
-- @field #number Nnut Number of neutral units in the zone.
-- @field #table Ncoal Number of units in zone for each coalition.
-- @field #number Tred Threat level of red units in the zone.
-- @field #number Tblu Threat level of blue units in the zone.
-- @field #number Tnut Threat level of neutral units in the zone.
@ -70,6 +71,7 @@ OPSZONE = {
Nred = 0,
Nblu = 0,
Nnut = 0,
Ncoal = {},
Tred = 0,
Tblu = 0,
Tnut = 0,
@ -116,7 +118,7 @@ OPSZONE.version="0.6.0"
--- Create a new OPSZONE class object.
-- @param #OPSZONE self
-- @param Core.Zone#ZONE Zone The zone. Needs to be a ZONE\_RADIUS (round) zone. Can be passed as ZONE\_AIRBASE or simply as the name of the airbase.
-- @param Core.Zone#ZONE Zone The zone. Can be passed as ZONE\_RADIUS, ZONE_POLYGON, ZONE\_AIRBASE or simply as the name of the airbase.
-- @param #number CoalitionOwner Initial owner of the coaliton. Default `coalition.side.NEUTRAL`.
-- @return #OPSZONE self
-- @usage
@ -193,6 +195,10 @@ function OPSZONE:New(Zone, CoalitionOwner)
-- Contested.
self.isContested=false
self.Ncoal[coalition.side.BLUE]=0
self.Ncoal[coalition.side.RED]=0
self.Ncoal[coalition.side.NEUTRAL]=0
-- We take the airbase coalition.
if self.airbase then
self.ownerCurrent=self.airbase:GetCoalition()
@ -1197,6 +1203,11 @@ function OPSZONE:Scan()
self.Nblu=Nblu
self.Nnut=Nnut
self.Ncoal[coalition.side.BLUE]=Nblu
self.Ncoal[coalition.side.RED]=Nred
self.Ncoal[coalition.side.NEUTRAL]=Nnut
self.Tblu=Tblu
self.Tred=Tred
self.Tnut=Tnut