mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
commit
725efc3e70
@ -2771,7 +2771,10 @@ function AUFTRAG:SetRepeatOnSuccess(Nrepeat)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- **[LEGION, COMMANDER, CHIEF]** Set that mission assets get reinforced if their number drops below Nmin.
|
--- **[LEGION, COMMANDER, CHIEF]** Set that mission assets get reinforced if their number drops below the minimum number of required assets of the mission (*c.f.* SetRequiredAssets() function).
|
||||||
|
--
|
||||||
|
-- **Note** that reinforcement groups are only recruited from the legion (airwing, brigade, fleet) the mission was assigned to. If the legion does not have any more of these assets,
|
||||||
|
-- no reinforcement can take place, even if the mission is submitted to a COMMANDER or CHIEF.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param #number Nreinforce Number of max asset groups used to reinforce.
|
-- @param #number Nreinforce Number of max asset groups used to reinforce.
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
@ -4029,7 +4032,7 @@ function AUFTRAG:onafterStatus(From, Event, To)
|
|||||||
self:T(self.lid.."No targets left cancelling mission!")
|
self:T(self.lid.."No targets left cancelling mission!")
|
||||||
self:Cancel()
|
self:Cancel()
|
||||||
|
|
||||||
elseif self:IsExecuting() and ((not self.reinforce) or (self.reinforce==0 and Nassigned<=0)) then
|
elseif self:IsExecuting() and self:_IsNotReinforcing() then
|
||||||
|
|
||||||
-- env.info("Mission Done:")
|
-- env.info("Mission Done:")
|
||||||
-- env.info(string.format("Nreinforce= %d", self.reinforce or 0))
|
-- env.info(string.format("Nreinforce= %d", self.reinforce or 0))
|
||||||
@ -4575,7 +4578,7 @@ function AUFTRAG:CheckGroupsDone()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Check if there is still reinforcement to be expected.
|
-- Check if there is still reinforcement to be expected.
|
||||||
if self:IsExecuting() and self.reinforce and (self.reinforce>0 or self.Nassigned-self.Ndead>0) then
|
if self:IsExecuting() and self:_IsReinforcing() then
|
||||||
self:T2(self.lid..string.format("CheckGroupsDone: Mission is still in state %s [FSM=%s] and reinfoce=%d. Mission NOT DONE!", self.status, self:GetState(), self.reinforce))
|
self:T2(self.lid..string.format("CheckGroupsDone: Mission is still in state %s [FSM=%s] and reinfoce=%d. Mission NOT DONE!", self.status, self:GetState(), self.reinforce))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -4736,10 +4739,12 @@ function AUFTRAG:onafterAssetDead(From, Event, To, Asset)
|
|||||||
-- Number of groups alive.
|
-- Number of groups alive.
|
||||||
local N=self:CountOpsGroups()
|
local N=self:CountOpsGroups()
|
||||||
|
|
||||||
self:T(self.lid..string.format("Asset %s dead! Number of ops groups remaining %d", tostring(Asset.spawngroupname), N))
|
local notreinforcing=self:_IsNotReinforcing()
|
||||||
|
|
||||||
|
self:T(self.lid..string.format("Asset %s dead! Number of ops groups remaining %d (reinforcing=%s)", tostring(Asset.spawngroupname), N, tostring(not notreinforcing)))
|
||||||
|
|
||||||
-- All assets dead?
|
-- All assets dead?
|
||||||
if N==0 and (self.reinforce==nil or self.reinforce==0) then
|
if N==0 and notreinforcing then
|
||||||
|
|
||||||
if self:IsNotOver() then
|
if self:IsNotOver() then
|
||||||
|
|
||||||
@ -5374,12 +5379,20 @@ function AUFTRAG:AddAsset(Asset)
|
|||||||
-- Add to table.
|
-- Add to table.
|
||||||
self.assets=self.assets or {}
|
self.assets=self.assets or {}
|
||||||
|
|
||||||
-- Add to table.
|
-- Get asset if it was already added.
|
||||||
table.insert(self.assets, Asset)
|
local asset=self:GetAssetByName(Asset.spawngroupname)
|
||||||
|
|
||||||
self.Nassigned=self.Nassigned or 0
|
-- Only add an asset is not already in.
|
||||||
|
if not asset then
|
||||||
|
|
||||||
self.Nassigned=self.Nassigned+1
|
-- Add to table.
|
||||||
|
table.insert(self.assets, Asset)
|
||||||
|
|
||||||
|
self.Nassigned=self.Nassigned or 0
|
||||||
|
|
||||||
|
self.Nassigned=self.Nassigned+1
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -5658,6 +5671,31 @@ function AUFTRAG:_SetRequestID(Legion, RequestID)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if reinforcement is done.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #boolean If `true`, reinforcing is over.
|
||||||
|
function AUFTRAG:_IsNotReinforcing()
|
||||||
|
|
||||||
|
-- Number of assigned assets that are still alive.
|
||||||
|
local Nassigned=self.Nassigned and self.Nassigned-self.Ndead or 0
|
||||||
|
|
||||||
|
-- Not reinforcing?
|
||||||
|
local notreinforcing=((not self.reinforce) or (self.reinforce==0 and Nassigned<=0))
|
||||||
|
|
||||||
|
return notreinforcing
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if reinforcement is still ongoing.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #boolean If `true`, reinforcing is ongoing.
|
||||||
|
function AUFTRAG:_IsReinforcing()
|
||||||
|
|
||||||
|
local reinforcing=not self:_IsNotReinforcing()
|
||||||
|
|
||||||
|
return reinforcing
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Update mission F10 map marker.
|
--- Update mission F10 map marker.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
|
|||||||
@ -1003,6 +1003,7 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission, Assets)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Add asset to mission.
|
||||||
Mission:AddAsset(asset)
|
Mission:AddAsset(asset)
|
||||||
|
|
||||||
-- Trigger event.
|
-- Trigger event.
|
||||||
@ -1054,6 +1055,7 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission, Assets)
|
|||||||
asset.takeoffType=COORDINATE.WaypointType.TakeOffParking
|
asset.takeoffType=COORDINATE.WaypointType.TakeOffParking
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Add asset to mission.
|
||||||
Mission:AddAsset(asset)
|
Mission:AddAsset(asset)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user