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
@ -726,6 +726,7 @@ function AUFTRAG:New(Type)
|
|||||||
self:AddTransition(AUFTRAG.Status.SCHEDULED, "Started", AUFTRAG.Status.STARTED) -- First asset has started the mission.
|
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(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.
|
self:AddTransition("*", "Done", AUFTRAG.Status.DONE) -- All assets have reported that mission is done.
|
||||||
|
|
||||||
self:AddTransition("*", "Cancel", AUFTRAG.Status.CANCELLED) -- Command to cancel the mission.
|
self:AddTransition("*", "Cancel", AUFTRAG.Status.CANCELLED) -- Command to cancel the mission.
|
||||||
|
|||||||
@ -2991,7 +2991,11 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Recruite infantry assets.
|
-- 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
|
if recruited then
|
||||||
|
|
||||||
|
|||||||
@ -1686,8 +1686,15 @@ function COMMANDER:RecruitAssetsForMission(Mission)
|
|||||||
|
|
||||||
if Mission.NcarriersMin then
|
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.
|
-- 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.
|
-- Filter cohorts that can actually perform transport missions.
|
||||||
local transportcohorts={}
|
local transportcohorts={}
|
||||||
@ -1707,8 +1714,15 @@ function COMMANDER:RecruitAssetsForMission(Mission)
|
|||||||
self:T(self.lid..string.format("Largest cargo bay available=%.1f", MaxWeight))
|
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.
|
-- 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.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Found %d cohort candidates for mission", #Cohorts))
|
self:T(self.lid..string.format("Found %d cohort candidates for mission", #Cohorts))
|
||||||
|
|||||||
@ -2276,6 +2276,10 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n, N)
|
|||||||
table.insert(wp, self.waypoints[i])
|
table.insert(wp, self.waypoints[i])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if wp[2] then
|
||||||
|
self.speedWp=wp[2].speed
|
||||||
|
end
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
local hb=self.homebase and self.homebase:GetName() or "unknown"
|
local hb=self.homebase and self.homebase:GetName() or "unknown"
|
||||||
local db=self.destbase and self.destbase:GetName() or "unknown"
|
local db=self.destbase and self.destbase:GetName() or "unknown"
|
||||||
|
|||||||
@ -670,16 +670,15 @@ function LEGION:CheckMissionQueue()
|
|||||||
local reinforce=false
|
local reinforce=false
|
||||||
if mission:IsExecuting() and mission.reinforce and mission.reinforce>0 then
|
if mission:IsExecuting() and mission.reinforce and mission.reinforce>0 then
|
||||||
|
|
||||||
|
-- Number of current opsgroups.
|
||||||
local N=mission:CountOpsGroups()
|
local N=mission:CountOpsGroups()
|
||||||
|
|
||||||
local Nmin, Nmax=mission:GetRequiredAssets()
|
if N<mission.NassetsMin then
|
||||||
|
|
||||||
if N<Nmin then
|
|
||||||
reinforce=true
|
reinforce=true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
mission:CountOpsGroups()
|
self:I(self.lid..string.format("Checking Reinforcement N=%d, Nmin=%d ==> Reinforce=%s", N, mission.NassetsMin, tostring(reinforce)))
|
||||||
|
end
|
||||||
|
|
||||||
-- Firstly, check if mission is due?
|
-- Firstly, check if mission is due?
|
||||||
if (mission:IsQueued(self) or reinforce) and mission:IsReadyToGo() and (mission.importance==nil or mission.importance<=vip) then
|
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
|
if recruited then
|
||||||
|
|
||||||
-- Reserve assets and add to mission.
|
-- Reserve assets and add to mission.
|
||||||
for _,_asset in pairs(assets) do
|
mission:_AddAssets(assets)
|
||||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
|
||||||
mission:AddAsset(asset)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Recruit asset for escorting recruited mission assets.
|
-- Recruit asset for escorting recruited mission assets.
|
||||||
local EscortAvail=self:RecruitAssetsForEscort(mission, assets)
|
local EscortAvail=self:RecruitAssetsForEscort(mission, assets)
|
||||||
@ -728,6 +724,12 @@ function LEGION:CheckMissionQueue()
|
|||||||
-- Got a mission.
|
-- Got a mission.
|
||||||
self:MissionRequest(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
|
return true
|
||||||
else
|
else
|
||||||
-- Recruited assets but no requested escort available. Unrecruit assets!
|
-- Recruited assets but no requested escort available. Unrecruit assets!
|
||||||
@ -2039,7 +2041,7 @@ function LEGION:CountAssetsOnMission(MissionTypes, Cohort)
|
|||||||
return Np+Nq, Np, Nq
|
return Np+Nq, Np, Nq
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Count assets on mission.
|
--- Get assets on mission.
|
||||||
-- @param #LEGION self
|
-- @param #LEGION self
|
||||||
-- @param #table MissionTypes Types on mission to be checked. Default all.
|
-- @param #table MissionTypes Types on mission to be checked. Default all.
|
||||||
-- @return #table Assets on pending requests.
|
-- @return #table Assets on pending requests.
|
||||||
@ -2159,8 +2161,15 @@ function LEGION:RecruitAssetsForMission(Mission)
|
|||||||
|
|
||||||
if Mission.NcarriersMin then
|
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.
|
-- 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.
|
-- Filter cohorts that can actually perform transport missions.
|
||||||
local transportcohorts={}
|
local transportcohorts={}
|
||||||
@ -2180,8 +2189,16 @@ function LEGION:RecruitAssetsForMission(Mission)
|
|||||||
self:T(self.lid..string.format("Largest cargo bay available=%.1f", MaxWeight))
|
self:T(self.lid..string.format("Largest cargo bay available=%.1f", MaxWeight))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local legions={self}
|
||||||
|
local cohorts=self.cohorts
|
||||||
|
if Mission.specialLegions or Mission.specialCohorts then
|
||||||
|
legions=Mission.specialLegions
|
||||||
|
cohorts=Mission.specialCohorts
|
||||||
|
end
|
||||||
|
|
||||||
-- Get cohorts.
|
-- 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.
|
-- Recuit assets.
|
||||||
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, Mission.type, Mission.alert5MissionType, NreqMin, NreqMax, TargetVec2, Payloads,
|
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.
|
-- Add cohorts of legion.
|
||||||
for _,_cohort in pairs(legion.cohorts) do
|
for _,_cohort in pairs(legion.cohorts) do
|
||||||
local cohort=_cohort --Ops.Cohort#COHORT
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
|
|
||||||
if (CheckOperation(cohort.legion) or CheckOperation(cohort)) and not UTILS.IsInTable(cohorts, cohort, "name") then
|
if (CheckOperation(cohort.legion) or CheckOperation(cohort)) and not UTILS.IsInTable(cohorts, cohort, "name") then
|
||||||
table.insert(cohorts, cohort)
|
table.insert(cohorts, cohort)
|
||||||
end
|
end
|
||||||
@ -2361,7 +2377,6 @@ function LEGION._GetCohorts(Legions, Cohorts, Operation, OpsQueue)
|
|||||||
-- Add special cohorts.
|
-- Add special cohorts.
|
||||||
for _,_cohort in pairs(Cohorts or {}) do
|
for _,_cohort in pairs(Cohorts or {}) do
|
||||||
local cohort=_cohort --Ops.Cohort#COHORT
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
|
|
||||||
if CheckOperation(cohort) and not UTILS.IsInTable(cohorts, cohort, "name") then
|
if CheckOperation(cohort) and not UTILS.IsInTable(cohorts, cohort, "name") then
|
||||||
table.insert(cohorts, cohort)
|
table.insert(cohorts, cohort)
|
||||||
end
|
end
|
||||||
@ -2505,7 +2520,7 @@ function LEGION._CohortCan(Cohort, MissionType, Categories, Attributes, Properti
|
|||||||
local function CheckMaxWeight(_cohort)
|
local function CheckMaxWeight(_cohort)
|
||||||
local cohort=_cohort --Ops.Cohort#COHORT
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
if MaxWeight~=nil then
|
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
|
return cohort.weightAsset<=MaxWeight
|
||||||
else
|
else
|
||||||
return true
|
return true
|
||||||
@ -2519,7 +2534,7 @@ function LEGION._CohortCan(Cohort, MissionType, Categories, Attributes, Properti
|
|||||||
if can then
|
if can then
|
||||||
can=CheckCategory(Cohort)
|
can=CheckCategory(Cohort)
|
||||||
else
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2530,65 +2545,63 @@ function LEGION._CohortCan(Cohort, MissionType, Categories, Attributes, Properti
|
|||||||
can=Cohort:IsOnDuty()
|
can=Cohort:IsOnDuty()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
env.info(string.format("Cohort %s cannot because of category", Cohort.name))
|
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of category", Cohort.name))
|
||||||
BASE:I(Categories)
|
|
||||||
BASE:I(Cohort.category)
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if can then
|
if can then
|
||||||
can=CheckAttribute(Cohort)
|
can=CheckAttribute(Cohort)
|
||||||
else
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if can then
|
if can then
|
||||||
can=CheckProperty(Cohort)
|
can=CheckProperty(Cohort)
|
||||||
else
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if can then
|
if can then
|
||||||
can=CheckWeapon(Cohort)
|
can=CheckWeapon(Cohort)
|
||||||
else
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if can then
|
if can then
|
||||||
can=CheckRange(Cohort)
|
can=CheckRange(Cohort)
|
||||||
else
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if can then
|
if can then
|
||||||
can=CheckRefueling(Cohort)
|
can=CheckRefueling(Cohort)
|
||||||
else
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if can then
|
if can then
|
||||||
can=CheckCargoWeight(Cohort)
|
can=CheckCargoWeight(Cohort)
|
||||||
else
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if can then
|
if can then
|
||||||
can=CheckMaxWeight(Cohort)
|
can=CheckMaxWeight(Cohort)
|
||||||
else
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if can then
|
if can then
|
||||||
return true
|
return true
|
||||||
else
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -6335,6 +6335,12 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set expected speed.
|
||||||
|
local wpnext=self:GetWaypointNext()
|
||||||
|
if wpnext then
|
||||||
|
self.speedWp=wpnext.speed
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set tasks at this waypoint
|
--- Set tasks at this waypoint
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user