- Added resource.carrierProperties for LEGION.AssignAssetsForTransport
- Ensure table for carrier categories, attributes and properties
This commit is contained in:
Frank 2022-11-08 20:29:51 +01:00
parent 254d43fef1
commit 0e78be86e4
2 changed files with 12 additions and 8 deletions

View File

@ -188,6 +188,7 @@
-- --- Create a resource list of mission types and required assets for the case that the zone is OCCUPIED. -- --- Create a resource list of mission types and required assets for the case that the zone is OCCUPIED.
-- -- -- --
-- -- Here, we create an enhanced CAS mission and employ at least on and at most two asset groups. -- -- Here, we create an enhanced CAS mission and employ at least on and at most two asset groups.
-- -- NOTE that two objects are returned, the resource list (ResourceOccupied) and the first resource of that list (resourceCAS).
-- local ResourceOccupied, resourceCAS=myChief:CreateResource(AUFTRAG.Type.CASENHANCED, 1, 2) -- local ResourceOccupied, resourceCAS=myChief:CreateResource(AUFTRAG.Type.CASENHANCED, 1, 2)
-- -- We also add ARTY missions with at least one and at most two assets. We additionally require these to be MLRS groups (and not howitzers). -- -- We also add ARTY missions with at least one and at most two assets. We additionally require these to be MLRS groups (and not howitzers).
-- myChief:AddToResource(ResourceOccupied, AUFTRAG.Type.ARTY, 1, 2, nil, "MLRS") -- myChief:AddToResource(ResourceOccupied, AUFTRAG.Type.ARTY, 1, 2, nil, "MLRS")
@ -197,7 +198,7 @@
-- myChief:AddToResource(ResourceOccupied, AUFTRAG.Type.BOMBCARPET, 1, 2) -- myChief:AddToResource(ResourceOccupied, AUFTRAG.Type.BOMBCARPET, 1, 2)
-- --
-- --- Create a resource list of mission types and required assets for the case that the zone is EMPTY. -- --- Create a resource list of mission types and required assets for the case that the zone is EMPTY.
-- -- -- -- NOTE that two objects are returned, the resource list (ResourceEmpty) and the first resource of that list (resourceInf).
-- -- Here, we create an ONGUARD mission and employ at least on and at most five infantry assets. -- -- Here, we create an ONGUARD mission and employ at least on and at most five infantry assets.
-- local ResourceEmpty, resourceInf=myChief:CreateResource(AUFTRAG.Type.ONGUARD, 1, 5, GROUP.Attribute.GROUND_INFANTRY) -- local ResourceEmpty, resourceInf=myChief:CreateResource(AUFTRAG.Type.ONGUARD, 1, 5, GROUP.Attribute.GROUND_INFANTRY)
-- -- Additionally, we send up to three tank groups. -- -- Additionally, we send up to three tank groups.
@ -329,7 +330,7 @@ CHIEF.Strategy = {
--- CHIEF class version. --- CHIEF class version.
-- @field #string version -- @field #string version
CHIEF.version="0.5.2" CHIEF.version="0.5.3"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -822,9 +823,9 @@ function CHIEF:AddTransportToResource(Resource, Nmin, Nmax, CarrierAttributes, C
Resource.carrierNmin=Nmin or 1 Resource.carrierNmin=Nmin or 1
Resource.carrierNmax=Nmax or Nmin Resource.carrierNmax=Nmax or Nmin
Resource.carrierCategories=CarrierCategories Resource.carrierCategories=UTILS.EnsureTable(CarrierCategories, true)
Resource.carrierAttributes=CarrierAttributes Resource.carrierAttributes=UTILS.EnsureTable(CarrierAttributes, true)
Resource.carrierProperties=CarrierProperties Resource.carrierProperties=UTILS.EnsureTable(CarrierProperties, true)
return self return self
end end
@ -2971,7 +2972,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource)
-- Recruit transport carrier assets. -- Recruit transport carrier assets.
recruited, transport=LEGION.AssignAssetsForTransport(self.commander, self.commander.legions, cargoassets, recruited, transport=LEGION.AssignAssetsForTransport(self.commander, self.commander.legions, cargoassets,
Resource.carrierNmin, Resource.carrierNmax, TargetZone, nil, Resource.carrierCategories, Resource.carrierAttributes) Resource.carrierNmin, Resource.carrierNmax, TargetZone, nil, Resource.carrierCategories, Resource.carrierAttributes, Resource.carrierProperties)
end end

View File

@ -2649,7 +2649,7 @@ function LEGION:AssignAssetsForTransport(Legions, CargoAssets, NcarriersMin, Nca
-- Is an escort requested in the first place? -- Is an escort requested in the first place?
if NcarriersMin and NcarriersMax and (NcarriersMin>0 or NcarriersMax>0) then if NcarriersMin and NcarriersMax and (NcarriersMin>0 or NcarriersMax>0) then
-- Cohorts. -- Cohorts.
local Cohorts={} local Cohorts={}
for _,_legion in pairs(Legions) do for _,_legion in pairs(Legions) do
@ -2688,7 +2688,7 @@ function LEGION:AssignAssetsForTransport(Legions, CargoAssets, NcarriersMin, Nca
LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.OPSTRANSPORT, nil, NcarriersMin, NcarriersMax, TargetVec2, nil, nil, nil, CargoWeight, TotalWeight, Categories, Attributes, Properties) LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.OPSTRANSPORT, nil, NcarriersMin, NcarriersMax, TargetVec2, nil, nil, nil, CargoWeight, TotalWeight, Categories, Attributes, Properties)
if TransportAvail then if TransportAvail then
-- Create and OPSTRANSPORT assignment. -- Create and OPSTRANSPORT assignment.
local Transport=OPSTRANSPORT:New(nil, nil, DeployZone) local Transport=OPSTRANSPORT:New(nil, nil, DeployZone)
if DisembarkZone then if DisembarkZone then
@ -2735,6 +2735,9 @@ function LEGION:AssignAssetsForTransport(Legions, CargoAssets, NcarriersMin, Nca
-- Got transport. -- Got transport.
return true, Transport return true, Transport
else else
-- Debug info.
self:T(self.lid..string.format("Transport assets could not be allocated ==> Unrecruiting assets"))
-- Uncrecruit transport assets. -- Uncrecruit transport assets.
LEGION.UnRecruitAssets(CarrierAssets) LEGION.UnRecruitAssets(CarrierAssets)
return false, nil return false, nil