- Improved recovery of retreated groups
This commit is contained in:
Frank 2022-03-11 22:35:57 +01:00
parent 2d0b4d6ae5
commit 520eb4cd1d
2 changed files with 31 additions and 2 deletions

View File

@ -115,6 +115,7 @@ function ARMYGROUP:New(group)
self:AddTransition("*", "Cruise", "Cruising") -- Cruise along the given route of waypoints. self:AddTransition("*", "Cruise", "Cruising") -- Cruise along the given route of waypoints.
self:AddTransition("*", "RTZ", "Returning") -- Group is returning to (home) zone. self:AddTransition("*", "RTZ", "Returning") -- Group is returning to (home) zone.
self:AddTransition("Holding", "Returned", "Returned") -- Group is returned to (home) zone, e.g. when unloaded from carrier.
self:AddTransition("Returning", "Returned", "Returned") -- Group is returned to (home) zone. self:AddTransition("Returning", "Returned", "Returned") -- Group is returned to (home) zone.
self:AddTransition("*", "Detour", "OnDetour") -- Make a detour to a coordinate and resume route afterwards. self:AddTransition("*", "Detour", "OnDetour") -- Make a detour to a coordinate and resume route afterwards.
@ -1352,6 +1353,9 @@ function ARMYGROUP:onafterRetreat(From, Event, To, Zone, Formation)
-- Set if we want to resume route after reaching the detour waypoint. -- Set if we want to resume route after reaching the detour waypoint.
wp.detour=0 wp.detour=0
-- Cancel all missions.
self:CancelAllMissions()
end end
--- On after "Retreated" event. --- On after "Retreated" event.

View File

@ -6125,6 +6125,19 @@ function OPSGROUP:onbeforeDead(From, Event, To)
end end
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
self:T(self.lid.."Cancelling mission "..tostring(mission:GetName()))
self:MissionCancel(mission)
end
end
--- On after "Dead" event. --- On after "Dead" event.
-- @param #OPSGROUP self -- @param #OPSGROUP self
-- @param #string From From state. -- @param #string From From state.
@ -8055,6 +8068,12 @@ end
-- @param #OPSGROUP OpsGroupCargo Cargo OPSGROUP that was unloaded from a carrier. -- @param #OPSGROUP OpsGroupCargo Cargo OPSGROUP that was unloaded from a carrier.
function OPSGROUP:onafterUnloaded(From, Event, To, OpsGroupCargo) function OPSGROUP:onafterUnloaded(From, Event, To, OpsGroupCargo)
self:T(self.lid..string.format("Unloaded OPSGROUP %s", OpsGroupCargo:GetName())) self:T(self.lid..string.format("Unloaded OPSGROUP %s", OpsGroupCargo:GetName()))
if OpsGroupCargo.legion and OpsGroupCargo:IsInZone(OpsGroupCargo.legion.spawnzone) then
self:T(self.lid..string.format("Unloaded group %s returned to legion", OpsGroupCargo:GetName()))
OpsGroupCargo:Returned()
end
end end
@ -8592,18 +8611,24 @@ function OPSGROUP:_CheckGroupDone(delay)
return return
end end
-- Group is returning -- Group is returning.
if self:IsReturning() then if self:IsReturning() then
self:T(self.lid.."Returning! Group NOT done...") self:T(self.lid.."Returning! Group NOT done...")
return return
end end
-- Group is returning -- Group is rearming.
if self:IsRearming() then if self:IsRearming() then
self:T(self.lid.."Rearming! Group NOT done...") self:T(self.lid.."Rearming! Group NOT done...")
return return
end end
-- Group is retreating.
if self:IsRetreating() then
self:T(self.lid.."Retreating! Group NOT done...")
return
end
-- Group is waiting. We deny all updates. -- Group is waiting. We deny all updates.
if self:IsWaiting() then if self:IsWaiting() then
-- If group is waiting, we assume that is the way it is meant to be. -- If group is waiting, we assume that is the way it is meant to be.