diff --git a/Moose Development/Moose/Ops/ArmyGroup.lua b/Moose Development/Moose/Ops/ArmyGroup.lua index edd3fc94a..fef3e35f0 100644 --- a/Moose Development/Moose/Ops/ArmyGroup.lua +++ b/Moose Development/Moose/Ops/ArmyGroup.lua @@ -1415,12 +1415,14 @@ function ARMYGROUP:onafterOutOfAmmo(From, Event, To) -- Second, check if we want to retreat once out of ammo. if self.retreatOnOutOfAmmo then + self:T(self.lid.."Retreat on out of ammo") self:__Retreat(-1) return end - -- Third, check if we want to RTZ once out of ammo. - if self.rtzOnOutOfAmmo then + -- Third, check if we want to RTZ once out of ammo (unless we have a rearming mission in the queue). + if self.rtzOnOutOfAmmo and not self:IsMissionTypeInQueue(AUFTRAG.Type.REARMING) then + self:T(self.lid.."RTZ on out of ammo") self:__RTZ(-1) end @@ -1536,6 +1538,7 @@ end -- @param Core.Zone#ZONE Zone The zone to return to. -- @param #number Formation Formation of the group. function ARMYGROUP:onbeforeRTZ(From, Event, To, Zone, Formation) + self:T2(self.lid.."onbeforeRTZ") -- Zone. local zone=Zone or self.homezone @@ -1563,6 +1566,7 @@ end -- @param Core.Zone#ZONE Zone The zone to return to. -- @param #number Formation Formation of the group. function ARMYGROUP:onafterRTZ(From, Event, To, Zone, Formation) + self:T2(self.lid.."onafterRTZ") -- Zone. local zone=Zone or self.homezone diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 7d29d2a91..64dc71582 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -4898,6 +4898,22 @@ function OPSGROUP:RemoveMission(Mission) return self end +--- Cancel all missions in mission queue. +-- @param #OPSGROUP self +function OPSGROUP:CancelAllMissions() + self:T(self.lid.."Cancelling ALL missions!") + + -- Cancel all missions. + for _,_mission in pairs(self.missionqueue) do + local mission=_mission --Ops.Auftrag#AUFTRAG + if mission:IsNotOver() then + self:T(self.lid.."Cancelling mission "..tostring(mission:GetName())) + self:MissionCancel(mission) + end + end + +end + --- Count remaining missons. -- @param #OPSGROUP self -- @return #number Number of missions to be done. @@ -5083,6 +5099,24 @@ function OPSGROUP:IsMissionInQueue(Mission) return false end +--- Check if a given mission type is already in the queue. +-- @param #OPSGROUP self +-- @param #string MissionType MissionType Type of mission. +-- @return #boolean If `true`, the mission type is in the queue. +function OPSGROUP:IsMissionTypeInQueue(MissionType) + + for _,_mission in pairs(self.missionqueue) do + local mission=_mission --Ops.Auftrag#AUFTRAG + + if mission:GetType()==MissionType then + return true + end + + end + + return false +end + --- Get mission by its task id. -- @param #OPSGROUP self -- @param #number taskid The id of the (waypoint) task of the mission. @@ -7536,21 +7570,6 @@ function OPSGROUP:onbeforeDead(From, Event, To) end end ---- Cancel all missions in mission queue. --- @param #OPSGROUP self -function OPSGROUP:CancelAllMissions() - - -- Cancel all missions. - for _,_mission in pairs(self.missionqueue) do - local mission=_mission --Ops.Auftrag#AUFTRAG - if mission:IsNotOver() then - self:T(self.lid.."Cancelling mission "..tostring(mission:GetName())) - self:MissionCancel(mission) - end - end - -end - --- On after "Dead" event. -- @param #OPSGROUP self -- @param #string From From state. @@ -10171,8 +10190,10 @@ function OPSGROUP:_CheckGroupDone(delay) self:T(self.lid..string.format("Passed final WP, adinfinitum=FALSE, LEGION set ==> RTZ")) if self.isArmygroup then + self:T2(self.lid.."RTZ to legion spawn zone") self:RTZ(self.legion.spawnzone) elseif self.isNavygroup then + self:T2(self.lid.."RTZ to legion port zone") self:RTZ(self.legion.portzone) end @@ -10255,6 +10276,7 @@ function OPSGROUP:_CheckStuck() if self:IsEngaging() then self:__Disengage(1) elseif self:IsReturning() then + self:T2(self.lid.."RTZ because of stuck") self:__RTZ(1) else self:__Cruise(1) @@ -10274,6 +10296,7 @@ function OPSGROUP:_CheckStuck() else -- Give cruise command again. if self:IsReturning() then + self:T2(self.lid.."RTZ because of stuck") self:__RTZ(1) else self:__Cruise(1)