diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index 93239b913..f420a770e 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -6671,7 +6671,13 @@ function WAREHOUSE:_OnEventCrashOrDead(EventData) self:Destroyed() end if self.airbase and self.airbasename and self.airbasename==EventData.IniUnitName then - self:RunwayDestroyed() + if self:IsRunwayOperational() then + -- Trigger RunwayDestroyed event (only if it is not destroyed already) + self:RunwayDestroyed() + else + -- Reset the time stamp. + self.runwaydestroyed=timer.getAbsTime() + end end end diff --git a/Moose Development/Moose/Ops/ArmyGroup.lua b/Moose Development/Moose/Ops/ArmyGroup.lua index 57ed7b84d..1bbad51e8 100644 --- a/Moose Development/Moose/Ops/ArmyGroup.lua +++ b/Moose Development/Moose/Ops/ArmyGroup.lua @@ -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 diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 52dcc4f5d..befae86f3 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -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 diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 640815a2a..1da630eb6 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -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 diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 5b49bf0e4..e780835fd 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -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. @@ -12090,6 +12125,8 @@ end -- @return #OPSGROUP self function OPSGROUP:SetDefaultCallsign(CallsignName, CallsignNumber) + self:T(self.lid..string.format("Setting Default callsing %s-%s", tostring(CallsignName), tostring(CallsignNumber))) + self.callsignDefault={} --#OPSGROUP.Callsign self.callsignDefault.NumberSquad=CallsignName self.callsignDefault.NumberGroup=CallsignNumber or 1 diff --git a/Moose Development/Moose/Ops/OpsZone.lua b/Moose Development/Moose/Ops/OpsZone.lua index d7b134adf..63287cbf2 100644 --- a/Moose Development/Moose/Ops/OpsZone.lua +++ b/Moose Development/Moose/Ops/OpsZone.lua @@ -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