Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Applevangelist committed Aug 18, 2024
2 parents 4bd36a4 + ad7dba6 commit 928c20c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
26 changes: 21 additions & 5 deletions Moose Development/Moose/Ops/Chief.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
-- @field Ops.Commander#COMMANDER commander Commander of assigned legions.
-- @field #number Nsuccess Number of successful missions.
-- @field #number Nfailure Number of failed mission.
-- @field #table assetNumbers Asset numbers. Each entry is a table of data type `#CHIEF.AssetNumber`.
-- @extends Ops.Intel#INTEL

--- *In preparing for battle I have always found that plans are useless, but planning is indispensable* -- Dwight D Eisenhower
Expand Down Expand Up @@ -331,7 +332,7 @@ CHIEF.Strategy = {

--- CHIEF class version.
-- @field #string version
CHIEF.version="0.6.0"
CHIEF.version="0.6.1"

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
Expand Down Expand Up @@ -1284,8 +1285,10 @@ end
--
-- Empty:
--
-- * `AUFTRAG.Type.ONGURAD` with Nmin=1 and Nmax=1 assets, Attribute=`GROUP.Attribute.GROUND_TANK`.
-- * `AUFTRAG.Type.ONGURAD` with Nmin=0 and Nmax=1 assets, Attribute=`GROUP.Attribute.GROUND_TANK`.
-- * `AUFTRAG.Type.ONGURAD` with Nmin=0 and Nmax=1 assets, Attribute=`GROUP.Attribute.GROUND_IFV`.
-- * `AUFTRAG.Type.ONGUARD` with Nmin=1 and Nmax=3 assets, Attribute=`GROUP.Attribute.GROUND_INFANTRY`.
-- * `AUFTRAG.Type.OPSTRANSPORT` with Nmin=0 and Nmax=1 assets, Attribute=`GROUP.Attribute.AIR_TRANSPORTHELO` or `GROUP.Attribute.GROUND_APC`. This asset is used to transport the infantry groups.
--
-- Resources can be created with the @{#CHIEF.CreateResource} and @{#CHIEF.AddToResource} functions.
--
Expand Down Expand Up @@ -3033,10 +3036,13 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource)
end

-- Recruite infantry assets.
self:T(self.lid..string.format("Recruiting assets for zone %s", StratZone.opszone:GetName()))
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
Expand All @@ -3052,9 +3058,12 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource)
local TargetCoord = TargetZone:GetCoordinate()

-- First check if we need a transportation.
local transport=nil
local transport=nil --Ops.OpsTransport#OPSTRANSPORT
local Ntransports=0
if Resource.carrierNmin and Resource.carrierNmax and Resource.carrierNmax>0 then

self:T(self.lid..string.format("Recruiting carrier assets: Nmin=%s, Nmax=%s", tostring(Resource.carrierNmin), tostring(Resource.carrierNmax)))

-- Filter only those assets that shall be transported.
local cargoassets=CHIEF._FilterAssets(assets, Resource.Categories, Resource.Attributes, Resource.Properties)

Expand All @@ -3064,6 +3073,10 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource)
recruited, transport=LEGION.AssignAssetsForTransport(self.commander, self.commander.legions, cargoassets,
Resource.carrierNmin, Resource.carrierNmax, TargetZone, nil, Resource.carrierCategories, Resource.carrierAttributes, Resource.carrierProperties)

Ntransports=transport~=nil and #transport.assets or 0

self:T(self.lid..string.format("Recruited %d transport carrier assets success=%s", Ntransports, tostring(recruited)))

end

end
Expand All @@ -3076,7 +3089,7 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource)
return false
end

-- Debug messgage.
-- Debug message
self:T2(self.lid..string.format("Recruited %d assets for mission %s", #assets, MissionType))


Expand Down Expand Up @@ -3224,10 +3237,13 @@ function CHIEF:RecruitAssetsForZone(StratZone, Resource)
-- Attach mission to ops zone.
StratZone.opszone:_AddMission(self.coalition, MissionType, mission)

mission:SetName(string.format("Stratzone %s-%d", StratZone.opszone:GetName(), mission.auftragsnummer))

-- Attach mission to resource.
Resource.mission=mission

if transport then
-- Check if transport assets could be allocated. If carrier Nmin=0 and 0 assets could be allocated, transport would still be created but not usefull obviously
if transport and Ntransports>0 then
-- Attach OPS transport to mission.
mission.opstransport=transport
-- Set ops zone to transport.
Expand Down
14 changes: 12 additions & 2 deletions Moose Development/Moose/Ops/Legion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,8 @@ function LEGION._CohortCan(Cohort, MissionType, Categories, Attributes, Properti
local RangeMax = RangeMax or 0
local InRange=(RangeMax and math.max(RangeMax, Rmax) or Rmax) >= TargetDistance

--env.info(string.format("Range TargetDist=%.1f Rmax=%.1f RangeMax=%.1f InRange=%s", TargetDistance, Rmax, RangeMax, tostring(InRange)))

return InRange
end

Expand Down Expand Up @@ -2684,7 +2686,7 @@ function LEGION._CohortCan(Cohort, MissionType, Categories, Attributes, Properti
else
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of category", Cohort.name))
return false
end
end

if can then
can=CheckAttribute(Cohort)
Expand Down Expand Up @@ -2740,7 +2742,7 @@ function LEGION._CohortCan(Cohort, MissionType, Categories, Attributes, Properti
else
Cohort:T(Cohort.lid..string.format("Cohort %s cannot because of max weight", Cohort.name))
return false
end
end

return nil
end
Expand Down Expand Up @@ -2784,6 +2786,8 @@ function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt,

-- Check if cohort can do the mission.
local can=LEGION._CohortCan(cohort, MissionTypeRecruit, Categories, Attributes, Properties, WeaponTypes, TargetVec2, RangeMax, RefuelSystem, CargoWeight, MaxWeight)

--env.info(string.format("RecruitCohortAssets %s Cohort=%s can=%s", MissionTypeRecruit, cohort:GetName(), tostring(can)))

-- Check OnDuty, capable, in range and refueling type (if TANKER).
if can then
Expand All @@ -2800,6 +2804,12 @@ function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt,

end

-- Break if no assets could be found
if #Assets==0 then
env.info(string.format("LEGION.RecruitCohortAssets: No assets could be recruited for mission type %s [Nmin=%s, Nmax=%s]", MissionTypeRecruit, tostring(NreqMin), tostring(NreqMax)))
return false, {}, {}
end

-- Now we have a long list with assets.
LEGION._OptimizeAssetSelection(Assets, MissionTypeOpt, TargetVec2, false, TotalWeight)

Expand Down

0 comments on commit 928c20c

Please sign in to comment.