mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
This commit is contained in:
parent
334af52ddf
commit
d53f01232d
@ -720,11 +720,12 @@ function AUFTRAG:New(Type)
|
||||
self:AddTransition(AUFTRAG.Status.PLANNED, "Queued", AUFTRAG.Status.QUEUED) -- Mission is in queue of a LEGION.
|
||||
self:AddTransition(AUFTRAG.Status.QUEUED, "Requested", AUFTRAG.Status.REQUESTED) -- Mission assets have been requested from the warehouse.
|
||||
self:AddTransition(AUFTRAG.Status.REQUESTED, "Scheduled", AUFTRAG.Status.SCHEDULED) -- Mission added to the first ops group queue.
|
||||
|
||||
|
||||
self:AddTransition(AUFTRAG.Status.PLANNED, "Scheduled", AUFTRAG.Status.SCHEDULED) -- From planned directly to scheduled.
|
||||
|
||||
self:AddTransition(AUFTRAG.Status.SCHEDULED, "Started", AUFTRAG.Status.STARTED) -- First asset has started the mission.
|
||||
self:AddTransition(AUFTRAG.Status.STARTED, "Executing", AUFTRAG.Status.EXECUTING) -- First asset is executing the mission.
|
||||
|
||||
|
||||
self:AddTransition("*", "Done", AUFTRAG.Status.DONE) -- All assets have reported that mission is done.
|
||||
|
||||
|
||||
@ -2991,7 +2991,11 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource)
|
||||
end
|
||||
|
||||
-- Recruite infantry assets.
|
||||
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, MissionType, nil, NassetsMin, NassetsMax, TargetVec2, nil, RangeMax, nil, nil, nil, Categories, Attributes, Properties)
|
||||
self:T(self.lid.."Missiontype="..MissionType)
|
||||
self:T({categories=Categories})
|
||||
self:T({attributes=Attributes})
|
||||
self:T({properties=Properties})
|
||||
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, MissionType, nil, NassetsMin, NassetsMax, TargetVec2, nil, RangeMax, nil, nil, nil, nil, Categories, Attributes, Properties)
|
||||
|
||||
if recruited then
|
||||
|
||||
|
||||
@ -1686,8 +1686,15 @@ function COMMANDER:RecruitAssetsForMission(Mission)
|
||||
|
||||
if Mission.NcarriersMin then
|
||||
|
||||
local legions=self.legions
|
||||
local cohorts=nil
|
||||
if Mission.transportLegions or Mission.transportCohorts then
|
||||
legions=Mission.transportLegions
|
||||
cohorts=Mission.transportCohorts
|
||||
end
|
||||
|
||||
-- Get transport cohorts.
|
||||
local Cohorts=LEGION._GetCohorts(Mission.transportLegions or self.legions, Mission.transportCohorts)
|
||||
local Cohorts=LEGION._GetCohorts(legions, cohorts)
|
||||
|
||||
-- Filter cohorts that can actually perform transport missions.
|
||||
local transportcohorts={}
|
||||
@ -1705,10 +1712,17 @@ function COMMANDER:RecruitAssetsForMission(Mission)
|
||||
end
|
||||
|
||||
self:T(self.lid..string.format("Largest cargo bay available=%.1f", MaxWeight))
|
||||
end
|
||||
end
|
||||
|
||||
local legions=self.legions
|
||||
local cohorts=nil
|
||||
if Mission.specialLegions or Mission.specialCohorts then
|
||||
legions=Mission.specialLegions
|
||||
cohorts=Mission.specialCohorts
|
||||
end
|
||||
|
||||
-- Get cohorts.
|
||||
local Cohorts=LEGION._GetCohorts(Mission.specialLegions or self.legions, Mission.specialCohorts, Mission.operation, self.opsqueue)
|
||||
local Cohorts=LEGION._GetCohorts(legions, cohorts, Mission.operation, self.opsqueue)
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Found %d cohort candidates for mission", #Cohorts))
|
||||
|
||||
@ -2275,6 +2275,10 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n, N)
|
||||
for i=n, N do
|
||||
table.insert(wp, self.waypoints[i])
|
||||
end
|
||||
|
||||
if wp[2] then
|
||||
self.speedWp=wp[2].speed
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
local hb=self.homebase and self.homebase:GetName() or "unknown"
|
||||
|
||||
@ -670,16 +670,15 @@ function LEGION:CheckMissionQueue()
|
||||
local reinforce=false
|
||||
if mission:IsExecuting() and mission.reinforce and mission.reinforce>0 then
|
||||
|
||||
-- Number of current opsgroups.
|
||||
local N=mission:CountOpsGroups()
|
||||
|
||||
local Nmin, Nmax=mission:GetRequiredAssets()
|
||||
|
||||
if N<Nmin then
|
||||
if N<mission.NassetsMin then
|
||||
reinforce=true
|
||||
end
|
||||
end
|
||||
|
||||
self:I(self.lid..string.format("Checking Reinforcement N=%d, Nmin=%d ==> Reinforce=%s", N, mission.NassetsMin, tostring(reinforce)))
|
||||
end
|
||||
|
||||
mission:CountOpsGroups()
|
||||
|
||||
-- Firstly, check if mission is due?
|
||||
if (mission:IsQueued(self) or reinforce) and mission:IsReadyToGo() and (mission.importance==nil or mission.importance<=vip) then
|
||||
@ -691,10 +690,7 @@ function LEGION:CheckMissionQueue()
|
||||
if recruited then
|
||||
|
||||
-- Reserve assets and add to mission.
|
||||
for _,_asset in pairs(assets) do
|
||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||
mission:AddAsset(asset)
|
||||
end
|
||||
mission:_AddAssets(assets)
|
||||
|
||||
-- Recruit asset for escorting recruited mission assets.
|
||||
local EscortAvail=self:RecruitAssetsForEscort(mission, assets)
|
||||
@ -728,10 +724,16 @@ function LEGION:CheckMissionQueue()
|
||||
-- Got a mission.
|
||||
self:MissionRequest(mission)
|
||||
|
||||
-- Reduce number of reinforcements.
|
||||
if reinforce then
|
||||
mission.reinforce=mission.reinforce-#assets
|
||||
self:I(self.lid..string.format("Reinforced with N=%d Nreinforce=%d", #assets, mission.reinforce))
|
||||
end
|
||||
|
||||
return true
|
||||
else
|
||||
-- Recruited assets but no requested escort available. Unrecruit assets!
|
||||
LEGION.UnRecruitAssets(assets, mission)
|
||||
LEGION.UnRecruitAssets(assets, mission)
|
||||
end
|
||||
|
||||
end -- recruited mission assets
|
||||
@ -2039,7 +2041,7 @@ function LEGION:CountAssetsOnMission(MissionTypes, Cohort)
|
||||
return Np+Nq, Np, Nq
|
||||
end
|
||||
|
||||
--- Count assets on mission.
|
||||
--- Get assets on mission.
|
||||
-- @param #LEGION self
|
||||
-- @param #table MissionTypes Types on mission to be checked. Default all.
|
||||
-- @return #table Assets on pending requests.
|
||||
@ -2159,8 +2161,15 @@ function LEGION:RecruitAssetsForMission(Mission)
|
||||
|
||||
if Mission.NcarriersMin then
|
||||
|
||||
local legions={self}
|
||||
local cohorts=self.cohorts
|
||||
if Mission.transportLegions or Mission.transportCohorts then
|
||||
legions=Mission.transportLegions
|
||||
cohorts=Mission.transportCohorts
|
||||
end
|
||||
|
||||
-- Get transport cohorts.
|
||||
local Cohorts=LEGION._GetCohorts(Mission.transportLegions or {self}, Mission.transportCohorts or self.cohorts)
|
||||
local Cohorts=LEGION._GetCohorts(legions, cohorts)
|
||||
|
||||
-- Filter cohorts that can actually perform transport missions.
|
||||
local transportcohorts={}
|
||||
@ -2179,9 +2188,17 @@ function LEGION:RecruitAssetsForMission(Mission)
|
||||
|
||||
self:T(self.lid..string.format("Largest cargo bay available=%.1f", MaxWeight))
|
||||
end
|
||||
|
||||
|
||||
local legions={self}
|
||||
local cohorts=self.cohorts
|
||||
if Mission.specialLegions or Mission.specialCohorts then
|
||||
legions=Mission.specialLegions
|
||||
cohorts=Mission.specialCohorts
|
||||
end
|
||||
|
||||
-- Get cohorts.
|
||||
local Cohorts=LEGION._GetCohorts(Mission.specialLegions or {self}, Mission.specialCohorts or self.cohorts, Operation, OpsQueue)
|
||||
local Cohorts=LEGION._GetCohorts(legions, cohorts, Operation, OpsQueue)
|
||||
|
||||
-- Recuit assets.
|
||||
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, Mission.type, Mission.alert5MissionType, NreqMin, NreqMax, TargetVec2, Payloads,
|
||||
@ -2349,7 +2366,6 @@ function LEGION._GetCohorts(Legions, Cohorts, Operation, OpsQueue)
|
||||
-- Add cohorts of legion.
|
||||
for _,_cohort in pairs(legion.cohorts) do
|
||||
local cohort=_cohort --Ops.Cohort#COHORT
|
||||
|
||||
if (CheckOperation(cohort.legion) or CheckOperation(cohort)) and not UTILS.IsInTable(cohorts, cohort, "name") then
|
||||
table.insert(cohorts, cohort)
|
||||
end
|
||||
@ -2361,7 +2377,6 @@ function LEGION._GetCohorts(Legions, Cohorts, Operation, OpsQueue)
|
||||
-- Add special cohorts.
|
||||
for _,_cohort in pairs(Cohorts or {}) do
|
||||
local cohort=_cohort --Ops.Cohort#COHORT
|
||||
|
||||
if CheckOperation(cohort) and not UTILS.IsInTable(cohorts, cohort, "name") then
|
||||
table.insert(cohorts, cohort)
|
||||
end
|
||||
@ -2505,7 +2520,7 @@ function LEGION._CohortCan(Cohort, MissionType, Categories, Attributes, Properti
|
||||
local function CheckMaxWeight(_cohort)
|
||||
local cohort=_cohort --Ops.Cohort#COHORT
|
||||
if MaxWeight~=nil then
|
||||
cohort:I(string.format("Cohort weight=%.1f | max weight=%.1f", cohort.weightAsset, MaxWeight))
|
||||
cohort:T(string.format("Cohort weight=%.1f | max weight=%.1f", cohort.weightAsset, MaxWeight))
|
||||
return cohort.weightAsset<=MaxWeight
|
||||
else
|
||||
return true
|
||||
@ -2519,7 +2534,7 @@ function LEGION._CohortCan(Cohort, MissionType, Categories, Attributes, Properti
|
||||
if can then
|
||||
can=CheckCategory(Cohort)
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of mission types", Cohort.name))
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of mission types", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
@ -2530,65 +2545,63 @@ function LEGION._CohortCan(Cohort, MissionType, Categories, Attributes, Properti
|
||||
can=Cohort:IsOnDuty()
|
||||
end
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of category", Cohort.name))
|
||||
BASE:I(Categories)
|
||||
BASE:I(Cohort.category)
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of category", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
if can then
|
||||
can=CheckAttribute(Cohort)
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of readyiness", Cohort.name))
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of readyiness", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
if can then
|
||||
can=CheckProperty(Cohort)
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of attribute", Cohort.name))
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of attribute", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
if can then
|
||||
can=CheckWeapon(Cohort)
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of property", Cohort.name))
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of property", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
if can then
|
||||
can=CheckRange(Cohort)
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of weapon type", Cohort.name))
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of weapon type", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
if can then
|
||||
can=CheckRefueling(Cohort)
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of range", Cohort.name))
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of range", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
if can then
|
||||
can=CheckCargoWeight(Cohort)
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of refueling system", Cohort.name))
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of refueling system", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
if can then
|
||||
can=CheckMaxWeight(Cohort)
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of cargo weight", Cohort.name))
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of cargo weight", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
if can then
|
||||
return true
|
||||
else
|
||||
env.info(string.format("Cohort %s cannot because of max weight", Cohort.name))
|
||||
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of max weight", Cohort.name))
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
@ -6334,6 +6334,12 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
||||
self:T(self.lid..text)
|
||||
|
||||
end
|
||||
|
||||
-- Set expected speed.
|
||||
local wpnext=self:GetWaypointNext()
|
||||
if wpnext then
|
||||
self.speedWp=wpnext.speed
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user