mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
- Improved OPSTRANSPORT for LEGION assets.
This commit is contained in:
parent
c5af279730
commit
d7dae1366d
@ -1867,6 +1867,7 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
else
|
else
|
||||||
self.isunit=true
|
self.isunit=true
|
||||||
if warehouse:IsShip() then
|
if warehouse:IsShip() then
|
||||||
|
env.info("FF warehouse is ship!")
|
||||||
self.isShip=true
|
self.isShip=true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1925,7 +1926,6 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
self:SetMarker(true)
|
self:SetMarker(true)
|
||||||
self:SetReportOff()
|
self:SetReportOff()
|
||||||
self:SetRunwayRepairtime()
|
self:SetRunwayRepairtime()
|
||||||
--self:SetVerbosityLevel(0)
|
|
||||||
|
|
||||||
-- Add warehouse to database.
|
-- Add warehouse to database.
|
||||||
_WAREHOUSEDB.Warehouses[self.uid]=self
|
_WAREHOUSEDB.Warehouses[self.uid]=self
|
||||||
@ -5829,7 +5829,7 @@ function WAREHOUSE:_SpawnAssetGroundNaval(alias, asset, request, spawnzone, late
|
|||||||
-- Late activation.
|
-- Late activation.
|
||||||
template.lateActivation=lateactivated
|
template.lateActivation=lateactivated
|
||||||
|
|
||||||
env.info("FF lateActivation="..tostring(template.lateActivation))
|
--env.info("FF lateActivation="..tostring(template.lateActivation))
|
||||||
|
|
||||||
template.route.points[1].x = coord.x
|
template.route.points[1].x = coord.x
|
||||||
template.route.points[1].y = coord.z
|
template.route.points[1].y = coord.z
|
||||||
|
|||||||
@ -1968,9 +1968,10 @@ end
|
|||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param Core.Zone#ZONE DeployZone Zone where assets are deployed.
|
-- @param Core.Zone#ZONE DeployZone Zone where assets are deployed.
|
||||||
-- @param Core.Zone#ZONE DisembarkZone Zone where assets are disembarked to.
|
-- @param Core.Zone#ZONE DisembarkZone Zone where assets are disembarked to.
|
||||||
-- @param Core.Set#SET_OPSGROUP Carriers Set of carriers. Can also be a single group. Can also be added via the AddTransportCarriers functions.
|
-- @param #number NcarriersMin Number of carriers *at least* required. Default 1.
|
||||||
|
-- @param #number NcarriersMax Number of carriers *at most* used for transportation. Default is same as `NcarriersMin`.
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:SetTransportForAssets(DeployZone, DisembarkZone, Carriers)
|
function AUFTRAG:SetTransportForAssets(DeployZone, DisembarkZone, NcarriersMin, NcarriersMax)
|
||||||
|
|
||||||
-- OPS transport from pickup to deploy zone.
|
-- OPS transport from pickup to deploy zone.
|
||||||
self.opstransport=OPSTRANSPORT:New(nil, nil, DeployZone)
|
self.opstransport=OPSTRANSPORT:New(nil, nil, DeployZone)
|
||||||
@ -1978,8 +1979,20 @@ function AUFTRAG:SetTransportForAssets(DeployZone, DisembarkZone, Carriers)
|
|||||||
if DisembarkZone then
|
if DisembarkZone then
|
||||||
self.opstransport:SetDisembarkZone(DisembarkZone)
|
self.opstransport:SetDisembarkZone(DisembarkZone)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Carriers then
|
-- Set required carriers.
|
||||||
|
self:SetRequiredCarriers(NcarriersMin, NcarriersMax)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add carriers for a transport of mission assets.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @param Core.Set#SET_OPSGROUP Carriers Set of carriers. Can also be a single group.
|
||||||
|
-- @return #AUFTRAG self
|
||||||
|
function AUFTRAG:AddTransportCarriers(Carriers)
|
||||||
|
|
||||||
|
if self.opstransport then
|
||||||
if Carriers:IsInstanceOf("SET_OPSGROUP") then
|
if Carriers:IsInstanceOf("SET_OPSGROUP") then
|
||||||
|
|
||||||
for _,_carrier in pairs(Carriers.Set) do
|
for _,_carrier in pairs(Carriers.Set) do
|
||||||
@ -1992,12 +2005,7 @@ function AUFTRAG:SetTransportForAssets(DeployZone, DisembarkZone, Carriers)
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set min/max number of carriers to be assigned.
|
|
||||||
self.opstransport.nCarriersMin=self.nCarriersMin
|
|
||||||
self.opstransport.nCarriersMax=self.nCarriersMax
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set number of required carrier groups if an OPSTRANSPORT assignment is required.
|
--- Set number of required carrier groups if an OPSTRANSPORT assignment is required.
|
||||||
@ -2347,9 +2355,11 @@ function AUFTRAG:AddOpsGroup(OpsGroup)
|
|||||||
if self.opstransport then
|
if self.opstransport then
|
||||||
for _,_tzc in pairs(self.opstransport.tzCombos) do
|
for _,_tzc in pairs(self.opstransport.tzCombos) do
|
||||||
local tzc=_tzc --Ops.OpsTransport#OPSTRANSPORT.TransportZoneCombo
|
local tzc=_tzc --Ops.OpsTransport#OPSTRANSPORT.TransportZoneCombo
|
||||||
if tzc.uid~=self.opstransport.tzcDefault.uid then
|
|
||||||
|
if tzc.assetsCargo and tzc.assetsCargo[OpsGroup:GetName()] then
|
||||||
self.opstransport:AddCargoGroups(OpsGroup, tzc)
|
self.opstransport:AddCargoGroups(OpsGroup, tzc)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2544,15 +2554,6 @@ function AUFTRAG:IsReadyToGo()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ops transport at
|
|
||||||
if self.opstransport then
|
|
||||||
if #self.legions>0 then
|
|
||||||
end
|
|
||||||
if self.opstransport:IsPlanned() or self.opstransport:IsQueued() or self.opstransport:IsRequested() then
|
|
||||||
--return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- All start conditions true?
|
-- All start conditions true?
|
||||||
local startme=self:EvalConditionsAll(self.conditionStart)
|
local startme=self:EvalConditionsAll(self.conditionStart)
|
||||||
|
|
||||||
|
|||||||
@ -52,6 +52,9 @@ BRIGADE.version="0.1.0"
|
|||||||
-- ToDo list
|
-- ToDo list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- TODO: Spawn when hosting warehouse is a ship or oil rig or gas platform.
|
||||||
|
-- TODO: Rearming zones.
|
||||||
|
-- TODO: Retreat zones.
|
||||||
-- DONE: Add weapon range.
|
-- DONE: Add weapon range.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -509,6 +509,23 @@ function CHIEF:AddStrateticZone(Zone)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add strategically important zone.
|
||||||
|
-- @param #CHIEF self
|
||||||
|
-- @param Ops.OpsZone#OPSZONE OpsZone OPS zone object.
|
||||||
|
-- @return #CHIEF self
|
||||||
|
function CHIEF:AddOpsZone(OpsZone)
|
||||||
|
|
||||||
|
-- Start ops zone.
|
||||||
|
if OpsZone:IsStopped() then
|
||||||
|
OpsZone:Start()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add to table.
|
||||||
|
table.insert(self.zonequeue, OpsZone)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set border zone set.
|
--- Set border zone set.
|
||||||
-- @param #CHIEF self
|
-- @param #CHIEF self
|
||||||
@ -663,27 +680,7 @@ function CHIEF:onafterStatus(From, Event, To)
|
|||||||
self:AddTarget(Target)
|
self:AddTarget(Target)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
|
||||||
local redalert=true
|
|
||||||
if self.borderzoneset:Count()>0 then
|
|
||||||
redalert=inred
|
|
||||||
end
|
|
||||||
|
|
||||||
if redalert and threat and not contact.target then
|
|
||||||
|
|
||||||
-- Create a new TARGET of the contact group.
|
|
||||||
local Target=TARGET:New(contact.group)
|
|
||||||
|
|
||||||
-- Set to contact.
|
|
||||||
contact.target=Target
|
|
||||||
|
|
||||||
-- Add target to queue.
|
|
||||||
self:AddTarget(Target)
|
|
||||||
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -706,6 +703,13 @@ function CHIEF:onafterStatus(From, Event, To)
|
|||||||
-- Check target queue and assign missions to new targets.
|
-- Check target queue and assign missions to new targets.
|
||||||
self:CheckTargetQueue()
|
self:CheckTargetQueue()
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Check Strategic Zone Queue
|
||||||
|
---
|
||||||
|
|
||||||
|
-- Check target queue and assign missions to new targets.
|
||||||
|
self:CheckOpsZoneQueue()
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Info General
|
-- Info General
|
||||||
---
|
---
|
||||||
@ -771,7 +775,24 @@ function CHIEF:onafterStatus(From, Event, To)
|
|||||||
text=text..string.format("\n[%d] %s (%s): status=%s, target=%s", i, mission.name, mission.type, mission.status, target)
|
text=text..string.format("\n[%d] %s (%s): status=%s, target=%s", i, mission.name, mission.type, mission.status, target)
|
||||||
end
|
end
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Info Strategic Zones
|
||||||
|
---
|
||||||
|
|
||||||
|
-- Loop over targets.
|
||||||
|
if self.verbose>=4 and #self.zonequeue>0 then
|
||||||
|
local text="Zone queue:"
|
||||||
|
for i,_opszone in pairs(self.zonequeue) do
|
||||||
|
local opszone=_opszone --Ops.OpsZone#OPSZONE
|
||||||
|
|
||||||
|
text=text..string.format("\n[%d] %s [%s]: owner=%d [%d]: Blue=%d, Red=%d, Neutral=%d", i, opszone.zone:GetName(), opszone:GetState(), opszone:GetOwner(), opszone:GetPreviousOwner(), opszone.Nblu, opszone.Nred, opszone.Nnut)
|
||||||
|
|
||||||
|
end
|
||||||
|
self:I(self.lid..text)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Info Assets
|
-- Info Assets
|
||||||
@ -1111,6 +1132,63 @@ function CHIEF:CheckTargetQueue()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Strategic Zone Functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
--- Check strategic zone queue.
|
||||||
|
-- @param #CHIEF self
|
||||||
|
function CHIEF:CheckOpsZoneQueue()
|
||||||
|
|
||||||
|
-- Number of zones.
|
||||||
|
local Nzones=#self.zonequeue
|
||||||
|
|
||||||
|
-- Treat special cases.
|
||||||
|
if Nzones==0 then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Sort results table wrt ?.
|
||||||
|
local function _sort(a, b)
|
||||||
|
local taskA=a --Ops.Target#TARGET
|
||||||
|
local taskB=b --Ops.Target#TARGET
|
||||||
|
return (taskA.prio<taskB.prio)
|
||||||
|
end
|
||||||
|
--table.sort(self.zonequeue, _sort)
|
||||||
|
|
||||||
|
-- Get the lowest importance value (lower means more important).
|
||||||
|
-- If a target with importance 1 exists, targets with importance 2 will not be assigned. Targets with no importance (nil) can still be selected.
|
||||||
|
local vip=math.huge
|
||||||
|
for _,_target in pairs(self.zonequeue) do
|
||||||
|
local target=_target --Ops.Target#TARGET
|
||||||
|
if target.importance and target.importance<vip then
|
||||||
|
vip=target.importance
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Loop over targets.
|
||||||
|
for _,_opszone in pairs(self.zonequeue) do
|
||||||
|
local opszone=_opszone --Ops.OpsZone#OPSZONE
|
||||||
|
|
||||||
|
-- Current owner of the zone.
|
||||||
|
local ownercoalition=opszone:GetOwner()
|
||||||
|
|
||||||
|
local hasMission=opszone.missionPatrol and opszone.missionPatrol:IsNotOver() or false
|
||||||
|
|
||||||
|
if ownercoalition~=self.coalition and not hasMission then
|
||||||
|
|
||||||
|
env.info(string.format("Zone %s is owned by coalition %d", opszone.zone:GetName(), ownercoalition))
|
||||||
|
|
||||||
|
-- Recruit ground assets that
|
||||||
|
local recruited, assets, legions=self:RecruitAssetsForZone(opszone, AUFTRAG.Type.PATROLZONE, 1, 3, {Group.Category.GROUND}, {GROUP.Attribute.GROUND_INFANTRY})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Zone Check Functions
|
-- Zone Check Functions
|
||||||
@ -1367,10 +1445,12 @@ function CHIEF:_GetMissionTypeForGroupAttribute(Attribute)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Recruit assets for a given mission.
|
--- Recruit assets for a given TARGET.
|
||||||
-- @param #CHIEF self
|
-- @param #CHIEF self
|
||||||
-- @param Ops.Target#TARGET Target The target.
|
-- @param Ops.Target#TARGET Target The target.
|
||||||
-- @param #string MissionType Mission Type.
|
-- @param #string MissionType Mission Type.
|
||||||
|
-- @param #number NassetsMin Min number of required assets.
|
||||||
|
-- @param #number NassetsMax Max number of required assets.
|
||||||
-- @return #boolean If `true` enough assets could be recruited.
|
-- @return #boolean If `true` enough assets could be recruited.
|
||||||
-- @return #table Assets that have been recruited from all legions.
|
-- @return #table Assets that have been recruited from all legions.
|
||||||
-- @return #table Legions that have recruited assets.
|
-- @return #table Legions that have recruited assets.
|
||||||
@ -1379,11 +1459,19 @@ function CHIEF:RecruitAssetsForTarget(Target, MissionType, NassetsMin, NassetsMa
|
|||||||
-- Cohorts.
|
-- Cohorts.
|
||||||
local Cohorts={}
|
local Cohorts={}
|
||||||
for _,_legion in pairs(self.commander.legions) do
|
for _,_legion in pairs(self.commander.legions) do
|
||||||
local legion=_legion --Ops.Legion#LEGION
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
-- Loops over cohorts.
|
|
||||||
for _,_cohort in pairs(legion.cohorts) do
|
-- Check that runway is operational.
|
||||||
local cohort=_cohort --Ops.Cohort#COHORT
|
local Runway=legion:IsAirwing() and legion:IsRunwayOperational() or true
|
||||||
table.insert(Cohorts, cohort)
|
|
||||||
|
if legion:IsRunning() and Runway then
|
||||||
|
|
||||||
|
-- Loops over cohorts.
|
||||||
|
for _,_cohort in pairs(legion.cohorts) do
|
||||||
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
|
table.insert(Cohorts, cohort)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1393,8 +1481,123 @@ function CHIEF:RecruitAssetsForTarget(Target, MissionType, NassetsMin, NassetsMa
|
|||||||
-- Recruite assets.
|
-- Recruite assets.
|
||||||
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, MissionType, nil, NassetsMin, NassetsMax, TargetVec2)
|
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, MissionType, nil, NassetsMin, NassetsMax, TargetVec2)
|
||||||
|
|
||||||
return recruited, assets, legions
|
|
||||||
|
|
||||||
|
return recruited, assets, legions
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Recruit assets for a given OPS zone.
|
||||||
|
-- @param #CHIEF self
|
||||||
|
-- @param Ops.OpsZone#OPSZONE OpsZone The OPS zone
|
||||||
|
-- @param #string MissionType Mission Type.
|
||||||
|
-- @param #number NassetsMin Min number of required assets.
|
||||||
|
-- @param #number NassetsMax Max number of required assets.
|
||||||
|
-- @param #table Categories Group categories of the assets.
|
||||||
|
-- @param #table Attributes Generalized group attributes.
|
||||||
|
-- @return #boolean If `true` enough assets could be recruited.
|
||||||
|
-- @return #table Assets that have been recruited from all legions.
|
||||||
|
-- @return #table Legions that have recruited assets.
|
||||||
|
function CHIEF:RecruitAssetsForZone(OpsZone, MissionType, NassetsMin, NassetsMax, Categories, Attributes)
|
||||||
|
|
||||||
|
-- Cohorts.
|
||||||
|
local Cohorts={}
|
||||||
|
for _,_legion in pairs(self.commander.legions) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
|
||||||
|
-- Check that runway is operational.
|
||||||
|
local Runway=legion:IsAirwing() and legion:IsRunwayOperational() or true
|
||||||
|
|
||||||
|
if legion:IsRunning() and Runway then
|
||||||
|
|
||||||
|
-- Loops over cohorts.
|
||||||
|
for _,_cohort in pairs(legion.cohorts) do
|
||||||
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
|
table.insert(Cohorts, cohort)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Target position.
|
||||||
|
local TargetVec2=OpsZone.zone:GetVec2()
|
||||||
|
|
||||||
|
-- Recruite assets.
|
||||||
|
local recruitedInf, assetsInf, legionsInf=LEGION.RecruitCohortAssets(Cohorts, MissionType, nil, NassetsMin, NassetsMax, TargetVec2, nil, nil, nil, nil, Categories, Attributes)
|
||||||
|
|
||||||
|
if recruitedInf then
|
||||||
|
|
||||||
|
env.info(string.format("Recruited %d assets from for PATROL mission", #assetsInf))
|
||||||
|
|
||||||
|
-- Get max weight.
|
||||||
|
local weightMax=nil
|
||||||
|
for _,_asset in pairs(assetsInf) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
if weightMax==nil or weightMax<=asset.weight then
|
||||||
|
weightMax=asset.weight
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Recruite assets.
|
||||||
|
local recruitedTrans, assetsTrans, legionsTrans=
|
||||||
|
LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.OPSTRANSPORT, nil, NassetsMin, NassetsMax, TargetVec2, nil, nil, nil, weightMax, {Group.Category.HELICOPTER, Group.Category.GROUND})
|
||||||
|
|
||||||
|
local transport=nil --Ops.OpsTransport#OPSTRANSPORT
|
||||||
|
if recruitedTrans then
|
||||||
|
env.info(string.format("Recruited %d assets for OPSTRANSPORT mission", #assetsTrans))
|
||||||
|
|
||||||
|
-- Create an OPSTRANSPORT assignment.
|
||||||
|
transport=OPSTRANSPORT:New(nil, nil, OpsZone.zone)
|
||||||
|
|
||||||
|
-- Add cargo assets to transport.
|
||||||
|
for _,_legion in pairs(legionsInf) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
local tpz=transport:AddTransportZoneCombo(legion.spawnzone, OpsZone.zone)
|
||||||
|
for _,_asset in pairs(assetsInf) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
if asset.legion.alias==legion.alias then
|
||||||
|
transport:AddAssetCargo(asset, tpz)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add carrier assets.
|
||||||
|
for _,_asset in pairs(assetsTrans) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
transport:AddAsset(asset)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Assign TRANSPORT to legions. This also sends the request for the assets.
|
||||||
|
for _,_legion in pairs(legionsTrans) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
self.commander:TransportAssign(legion, transport)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
-- Uncrecruite
|
||||||
|
LEGION.UnRecruitAssets(assetsTrans)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create Patrol zone mission.
|
||||||
|
local mission=AUFTRAG:NewPATROLZONE(OpsZone.zone)
|
||||||
|
|
||||||
|
for _,asset in pairs(assetsInf) do
|
||||||
|
mission:AddAsset(asset)
|
||||||
|
end
|
||||||
|
|
||||||
|
mission.opstransport=transport
|
||||||
|
|
||||||
|
for _,_legion in pairs(legionsInf) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
self.commander:MissionAssign(legion, mission)
|
||||||
|
end
|
||||||
|
|
||||||
|
OpsZone.missionPatrol=mission
|
||||||
|
|
||||||
|
else
|
||||||
|
LEGION.UnRecruitAssets(assetsInf)
|
||||||
|
end
|
||||||
|
|
||||||
|
return recruited, assets, legions
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
-- @field #string name Name of the cohort.
|
-- @field #string name Name of the cohort.
|
||||||
-- @field #string templatename Name of the template group.
|
-- @field #string templatename Name of the template group.
|
||||||
-- @field #string aircrafttype Type of the units the cohort is using.
|
-- @field #string aircrafttype Type of the units the cohort is using.
|
||||||
|
-- @field #number category Group category of the assets: `Group.Category.AIRPLANE`, `Group.Category.HELICOPTER`, `Group.Category.GROUND`, `Group.Category.SHIP`, `Group.Category.TRAIN`.
|
||||||
-- @field Wrapper.Group#GROUP templategroup Template group.
|
-- @field Wrapper.Group#GROUP templategroup Template group.
|
||||||
-- @field #table assets Cohort assets.
|
-- @field #table assets Cohort assets.
|
||||||
-- @field #table missiontypes Capabilities (mission types and performances) of the cohort.
|
-- @field #table missiontypes Capabilities (mission types and performances) of the cohort.
|
||||||
@ -124,6 +125,9 @@ function COHORT:New(TemplateGroupName, Ngroups, CohortName)
|
|||||||
-- Generalized attribute.
|
-- Generalized attribute.
|
||||||
self.attribute=self.templategroup:GetAttribute()
|
self.attribute=self.templategroup:GetAttribute()
|
||||||
|
|
||||||
|
-- Group category.
|
||||||
|
self.category=self.templategroup:GetCategory()
|
||||||
|
|
||||||
-- Aircraft type.
|
-- Aircraft type.
|
||||||
self.aircrafttype=self.templategroup:GetTypeName()
|
self.aircrafttype=self.templategroup:GetTypeName()
|
||||||
|
|
||||||
|
|||||||
@ -118,13 +118,13 @@ function COMMANDER:New()
|
|||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
|
|
||||||
|
|
||||||
--- Triggers the FSM event "MissionAssign".
|
--- Triggers the FSM event "MissionAssign". Mission is added to a LEGION mission queue and already requested. Needs assets to be added to the mission!
|
||||||
-- @function [parent=#COMMANDER] MissionAssign
|
-- @function [parent=#COMMANDER] MissionAssign
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
-- @param Ops.Legion#LEGION Legion The Legion.
|
-- @param Ops.Legion#LEGION Legion The Legion.
|
||||||
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
--- Triggers the FSM event "MissionAssign" after a delay.
|
--- Triggers the FSM event "MissionAssign" after a delay. Mission is added to a LEGION mission queue and already requested. Needs assets to be added to the mission!
|
||||||
-- @function [parent=#COMMANDER] __MissionAssign
|
-- @function [parent=#COMMANDER] __MissionAssign
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
-- @param #number delay Delay in seconds.
|
-- @param #number delay Delay in seconds.
|
||||||
@ -161,6 +161,12 @@ function COMMANDER:New()
|
|||||||
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
-- @param Ops.Auftrag#AUFTRAG Mission The mission.
|
||||||
|
|
||||||
|
|
||||||
|
--- Triggers the FSM event "TransportAssign".
|
||||||
|
-- @function [parent=#COMMANDER] TransportAssign
|
||||||
|
-- @param #COMMANDER self
|
||||||
|
-- @param Ops.Legion#LEGION Legion The Legion.
|
||||||
|
-- @param Ops.OpsTransport#OPSTRANSPORT Transport The transport.
|
||||||
|
|
||||||
--- Triggers the FSM event "TransportAssign" after a delay.
|
--- Triggers the FSM event "TransportAssign" after a delay.
|
||||||
-- @function [parent=#COMMANDER] __TransportAssign
|
-- @function [parent=#COMMANDER] __TransportAssign
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
@ -227,7 +233,7 @@ end
|
|||||||
|
|
||||||
--- Add an BRIGADE to the commander.
|
--- Add an BRIGADE to the commander.
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
-- @param Ops.Brigade#BRIGADE Briagde The brigade to add.
|
-- @param Ops.Brigade#BRIGADE Brigade The brigade to add.
|
||||||
-- @return #COMMANDER self
|
-- @return #COMMANDER self
|
||||||
function COMMANDER:AddBrigade(Brigade)
|
function COMMANDER:AddBrigade(Brigade)
|
||||||
|
|
||||||
@ -511,7 +517,7 @@ end
|
|||||||
-- FSM Events
|
-- FSM Events
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- On after "MissionAssign" event. Mission is added to a LEGION mission queue.
|
--- On after "MissionAssign" event. Mission is added to a LEGION mission queue and already requested. Needs assets to be added to the mission already.
|
||||||
-- @param #COMMANDER self
|
-- @param #COMMANDER self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
@ -690,16 +696,89 @@ function COMMANDER:CheckMissionQueue()
|
|||||||
-- Add asset to mission.
|
-- Add asset to mission.
|
||||||
for _,_asset in pairs(assets) do
|
for _,_asset in pairs(assets) do
|
||||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
asset.isReserved=true
|
|
||||||
mission:AddAsset(asset)
|
mission:AddAsset(asset)
|
||||||
end
|
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)
|
||||||
|
|
||||||
|
-- Transport available (or not required).
|
||||||
|
local TransportAvail=true
|
||||||
|
|
||||||
|
-- Escort requested and available.
|
||||||
if EscortAvail then
|
if EscortAvail then
|
||||||
|
|
||||||
|
-- Check if mission assets need a transport.
|
||||||
|
if mission.opstransport then
|
||||||
|
|
||||||
|
-- Weight of the heaviest cargo group. Necessary condition that this fits into on carrier unit!
|
||||||
|
local weightGroup=0
|
||||||
|
|
||||||
|
-- Calculate the max weight of the cargo assets.
|
||||||
|
for _,_asset in pairs(assets) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
local weight=asset.weight
|
||||||
|
if weight>weightGroup then
|
||||||
|
weightGroup=weight
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
env.info(string.format("FF mission requires transport for cargo weight %d", weightGroup))
|
||||||
|
|
||||||
|
-- Recruit transport assets.
|
||||||
|
local TransportAvail, assetsTrans, legionsTrans=self:RecruitAssetsForTransport(mission.opstransport, weightGroup)
|
||||||
|
|
||||||
|
if TransportAvail then
|
||||||
|
|
||||||
|
env.info(string.format("FF Transport available with %d carrier assets", #assetsTrans))
|
||||||
|
|
||||||
|
-- Add cargo assets to transport.
|
||||||
|
for _,_legion in pairs(legions) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
|
||||||
|
local pickupzone=legion.spawnzone
|
||||||
|
if legion.airbase and legion:IsRunwayOperational() then
|
||||||
|
pickupzone=ZONE_AIRBASE:New(legion.airbasename, 4000)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add TZC from legion spawn zone to deploy zone.
|
||||||
|
local tpz=mission.opstransport:AddTransportZoneCombo(pickupzone, mission.opstransport:GetDeployZone())
|
||||||
|
mission.opstransport:SetEmbarkZone(legion.spawnzone, tpz)
|
||||||
|
|
||||||
|
-- Add cargo assets to transport.
|
||||||
|
for _,_asset in pairs(assets) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
if asset.legion.alias==legion.alias then
|
||||||
|
mission.opstransport:AddAssetCargo(asset, tpz)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add carrier assets.
|
||||||
|
for _,_asset in pairs(assetsTrans) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
mission.opstransport:AddAsset(asset)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Assign TRANSPORT to legions. This also sends the request for the assets.
|
||||||
|
for _,_legion in pairs(legionsTrans) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
self:TransportAssign(legion, mission.opstransport)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
-- Uncrecruit transport assets.
|
||||||
|
LEGION.UnRecruitAssets(assetsTrans)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Escort and transport must be available (or not required).
|
||||||
|
if EscortAvail and TransportAvail then
|
||||||
|
|
||||||
-- Assign mission to legion(s).
|
-- Assign mission to legion(s).
|
||||||
for _,_legion in pairs(legions) do
|
for _,_legion in pairs(legions) do
|
||||||
local legion=_legion --Ops.Legion#LEGION
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
@ -741,11 +820,14 @@ end
|
|||||||
-- @return #table Legions that have recruited assets.
|
-- @return #table Legions that have recruited assets.
|
||||||
function COMMANDER:RecruitAssetsForMission(Mission)
|
function COMMANDER:RecruitAssetsForMission(Mission)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
env.info(string.format("FF recruiting assets for mission %s [%s]", Mission:GetName(), Mission:GetType()))
|
||||||
|
|
||||||
-- Cohorts.
|
-- Cohorts.
|
||||||
local Cohorts=Mission.squadrons
|
local Cohorts=Mission.squadrons
|
||||||
if not Cohorts then
|
if not Cohorts then
|
||||||
Cohorts={}
|
Cohorts={}
|
||||||
for _,_legion in pairs(Mission.mylegions or self.legions) do
|
for _,_legion in pairs(Mission.specialLegions or self.legions) do
|
||||||
local legion=_legion --Ops.Legion#LEGION
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
-- Loops over cohorts.
|
-- Loops over cohorts.
|
||||||
for _,_cohort in pairs(legion.cohorts) do
|
for _,_cohort in pairs(legion.cohorts) do
|
||||||
@ -781,7 +863,7 @@ function COMMANDER:RecruitAssetsForEscort(Mission, Assets)
|
|||||||
local Cohorts=Mission.squadrons
|
local Cohorts=Mission.squadrons
|
||||||
if not Cohorts then
|
if not Cohorts then
|
||||||
Cohorts={}
|
Cohorts={}
|
||||||
for _,_legion in pairs(Mission.mylegions or self.legions) do
|
for _,_legion in pairs(Mission.specialLegions or self.legions) do
|
||||||
local legion=_legion --Ops.Legion#LEGION
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
-- Loops over cohorts.
|
-- Loops over cohorts.
|
||||||
for _,_cohort in pairs(legion.cohorts) do
|
for _,_cohort in pairs(legion.cohorts) do
|
||||||
@ -917,33 +999,56 @@ function COMMANDER:CheckTransportQueue()
|
|||||||
-- 1. Select best assets from legions
|
-- 1. Select best assets from legions
|
||||||
-- 2. Assign mission to legions that have the best assets.
|
-- 2. Assign mission to legions that have the best assets.
|
||||||
---
|
---
|
||||||
|
|
||||||
-- Recruite assets from legions.
|
|
||||||
local recruited, assets, legions=self:RecruitAssetsForTransport(transport)
|
|
||||||
|
|
||||||
if recruited then
|
|
||||||
|
|
||||||
-- Add asset to transport.
|
|
||||||
for _,_asset in pairs(assets) do
|
|
||||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
|
||||||
asset.isReserved=true
|
|
||||||
transport:AddAsset(asset)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Assign transport to legion(s).
|
-- Get all undelivered cargo ops groups.
|
||||||
for _,_legion in pairs(legions) do
|
local cargoOpsGroups=transport:GetCargoOpsGroups(false)
|
||||||
local legion=_legion --Ops.Legion#LEGION
|
|
||||||
|
|
||||||
-- Debug message.
|
|
||||||
self:I(self.lid..string.format("Assigning transport UID=%d to legion %s", transport.uid, legion.alias))
|
|
||||||
|
|
||||||
-- Add mission to legion.
|
-- Weight of the heaviest cargo group. Necessary condition that this fits into on carrier unit!
|
||||||
self:TransportAssign(legion, transport)
|
local weightGroup=0
|
||||||
|
|
||||||
end
|
-- Calculate the max weight so we know which cohorts can provide carriers.
|
||||||
|
if #cargoOpsGroups>0 then
|
||||||
|
for _,_opsgroup in pairs(cargoOpsGroups) do
|
||||||
|
local opsgroup=_opsgroup --Ops.OpsGroup#OPSGROUP
|
||||||
|
local weight=opsgroup:GetWeightTotal()
|
||||||
|
if weight>weightGroup then
|
||||||
|
weightGroup=weight
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if weightGroup>0 then
|
||||||
|
|
||||||
-- Only ONE transport is assigned.
|
-- Recruite assets from legions.
|
||||||
return
|
local recruited, assets, legions=self:RecruitAssetsForTransport(transport, weightGroup)
|
||||||
|
|
||||||
|
if recruited then
|
||||||
|
|
||||||
|
-- Add asset to transport.
|
||||||
|
for _,_asset in pairs(assets) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
transport:AddAsset(asset)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Assign transport to legion(s).
|
||||||
|
for _,_legion in pairs(legions) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
|
||||||
|
-- Debug message.
|
||||||
|
self:I(self.lid..string.format("Assigning transport UID=%d to legion %s", transport.uid, legion.alias))
|
||||||
|
|
||||||
|
-- Add mission to legion.
|
||||||
|
self:TransportAssign(legion, transport)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Only ONE transport is assigned.
|
||||||
|
return
|
||||||
|
else
|
||||||
|
-- Not recruited.
|
||||||
|
LEGION.UnRecruitAssets(assets)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -964,37 +1069,29 @@ end
|
|||||||
-- @return #boolean If `true`, enough assets could be recruited.
|
-- @return #boolean If `true`, enough assets could be recruited.
|
||||||
-- @return #table Recruited assets.
|
-- @return #table Recruited assets.
|
||||||
-- @return #table Legions that have recruited assets.
|
-- @return #table Legions that have recruited assets.
|
||||||
function COMMANDER:RecruitAssetsForTransport(Transport)
|
function COMMANDER:RecruitAssetsForTransport(Transport, CargoWeight)
|
||||||
|
|
||||||
-- Get all undelivered cargo ops groups.
|
|
||||||
local cargoOpsGroups=Transport:GetCargoOpsGroups(false)
|
|
||||||
|
|
||||||
local weightGroup=0
|
if weightGroup==0 then
|
||||||
|
|
||||||
-- At least one group should be spawned.
|
|
||||||
if #cargoOpsGroups>0 then
|
|
||||||
|
|
||||||
-- Calculate the max weight so we know which cohorts can provide carriers.
|
|
||||||
for _,_opsgroup in pairs(cargoOpsGroups) do
|
|
||||||
local opsgroup=_opsgroup --Ops.OpsGroup#OPSGROUP
|
|
||||||
local weight=opsgroup:GetWeightTotal()
|
|
||||||
if weight>weightGroup then
|
|
||||||
weightGroup=weight
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- No cargo groups!
|
-- No cargo groups!
|
||||||
return false
|
return false, {}, {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Cohorts.
|
-- Cohorts.
|
||||||
local Cohorts={}
|
local Cohorts={}
|
||||||
for _,_legion in pairs(self.legions) do
|
for _,_legion in pairs(self.legions) do
|
||||||
local legion=_legion --Ops.Legion#LEGION
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
-- Loops over cohorts.
|
|
||||||
for _,_cohort in pairs(legion.cohorts) do
|
-- Check that runway is operational.
|
||||||
local cohort=_cohort --Ops.Cohort#COHORT
|
local Runway=legion:IsAirwing() and legion:IsRunwayOperational() or true
|
||||||
table.insert(Cohorts, cohort)
|
|
||||||
|
if legion:IsRunning() and Runway then
|
||||||
|
|
||||||
|
-- Loops over cohorts.
|
||||||
|
for _,_cohort in pairs(legion.cohorts) do
|
||||||
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
|
table.insert(Cohorts, cohort)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1006,7 +1103,7 @@ function COMMANDER:RecruitAssetsForTransport(Transport)
|
|||||||
local NreqMin,NreqMax=Transport:GetRequiredCarriers()
|
local NreqMin,NreqMax=Transport:GetRequiredCarriers()
|
||||||
|
|
||||||
-- Recruit assets and legions.
|
-- Recruit assets and legions.
|
||||||
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.OPSTRANSPORT, nil, NreqMin, NreqMax, TargetVec2, nil, nil, nil, weightGroup)
|
local recruited, assets, legions=LEGION.RecruitCohortAssets(Cohorts, AUFTRAG.Type.OPSTRANSPORT, nil, NreqMin, NreqMax, TargetVec2, nil, nil, nil, CargoWeight)
|
||||||
|
|
||||||
return recruited, assets, legions
|
return recruited, assets, legions
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1864,10 +1864,11 @@ function FLIGHTGROUP:onafterArrived(From, Event, To)
|
|||||||
self.flightcontrol:SetFlightStatus(self, FLIGHTCONTROL.FlightStatus.ARRIVED)
|
self.flightcontrol:SetFlightStatus(self, FLIGHTCONTROL.FlightStatus.ARRIVED)
|
||||||
end
|
end
|
||||||
|
|
||||||
local airwing=self:GetAirWing()
|
--TODO: Check that current base is airwing base.
|
||||||
|
local airwing=self:GetAirWing() --airwing:GetAirbaseName()==self.currbase:GetName()
|
||||||
|
|
||||||
-- Check what to do.
|
-- Check what to do.
|
||||||
if airwing then
|
if airwing and not (self:IsPickingup() or self:IsTransporting()) then
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Airwing asset group %s arrived ==> Adding asset back to stock of airwing %s", self.groupname, airwing.alias))
|
self:T(self.lid..string.format("Airwing asset group %s arrived ==> Adding asset back to stock of airwing %s", self.groupname, airwing.alias))
|
||||||
|
|||||||
@ -275,7 +275,7 @@ function LEGION:AddMission(Mission)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Add ops transport to transport Legions.
|
-- Add ops transport to transport Legions.
|
||||||
if Mission.opstransport then
|
if Mission.opstransport and false then
|
||||||
|
|
||||||
local PickupZone=self.spawnzone
|
local PickupZone=self.spawnzone
|
||||||
local DeployZone=Mission.opstransport.tzcDefault.DeployZone
|
local DeployZone=Mission.opstransport.tzcDefault.DeployZone
|
||||||
@ -622,7 +622,7 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
|
|||||||
|
|
||||||
-- Cancel the current ALERT 5 mission.
|
-- Cancel the current ALERT 5 mission.
|
||||||
if currM and currM.type==AUFTRAG.Type.ALERT5 then
|
if currM and currM.type==AUFTRAG.Type.ALERT5 then
|
||||||
asset.flightgroup:MissionCancel(currM)
|
asset.flightgroup:MissionCancel(currM)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -673,8 +673,8 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
|
|||||||
|
|
||||||
if request then
|
if request then
|
||||||
if self.isShip then
|
if self.isShip then
|
||||||
self:T(self.lid.."FF request late activated")
|
--self:T(self.lid.."FF request late activated")
|
||||||
request.lateActivation=true
|
--request.lateActivation=true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1793,7 +1793,7 @@ end
|
|||||||
-- Recruiting and Optimization Functions
|
-- Recruiting and Optimization Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Recruit assets from Cohorts for the given parameters.
|
--- Recruit assets from Cohorts for the given parameters. **NOTE** that we set the `asset.isReserved=true` flag so it cant be recruited by anyone else.
|
||||||
-- @param #table Cohorts Cohorts included.
|
-- @param #table Cohorts Cohorts included.
|
||||||
-- @param #string MissionTypeRecruit Mission type for recruiting the cohort assets.
|
-- @param #string MissionTypeRecruit Mission type for recruiting the cohort assets.
|
||||||
-- @param #string MissionTypeOpt Mission type for which the assets are optimized. Default is the same as `MissionTypeRecruit`.
|
-- @param #string MissionTypeOpt Mission type for which the assets are optimized. Default is the same as `MissionTypeRecruit`.
|
||||||
@ -1804,10 +1804,12 @@ end
|
|||||||
-- @param #number RangeMax Max range in meters.
|
-- @param #number RangeMax Max range in meters.
|
||||||
-- @param #number RefuelSystem Refuelsystem.
|
-- @param #number RefuelSystem Refuelsystem.
|
||||||
-- @param #number CargoWeight Cargo weight for recruiting transport carriers.
|
-- @param #number CargoWeight Cargo weight for recruiting transport carriers.
|
||||||
|
-- @param #table Categories Group categories.
|
||||||
|
-- @param #table Attributes Group attributes. See `GROUP.Attribute.`
|
||||||
-- @return #boolean If `true` enough assets could be recruited.
|
-- @return #boolean If `true` enough assets could be recruited.
|
||||||
-- @return #table Recruited assets.
|
-- @return #table Recruited assets. **NOTE** that we set the `asset.isReserved=true` flag so it cant be recruited by anyone else.
|
||||||
-- @return #table Legions of recruited assets.
|
-- @return #table Legions of recruited assets.
|
||||||
function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt, NreqMin, NreqMax, TargetVec2, Payloads, RangeMax, RefuelSystem, CargoWeight)
|
function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt, NreqMin, NreqMax, TargetVec2, Payloads, RangeMax, RefuelSystem, CargoWeight, Categories, Attributes)
|
||||||
|
|
||||||
-- The recruited assets.
|
-- The recruited assets.
|
||||||
local Assets={}
|
local Assets={}
|
||||||
@ -1815,10 +1817,39 @@ function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt,
|
|||||||
-- Legions of recruited assets.
|
-- Legions of recruited assets.
|
||||||
local Legions={}
|
local Legions={}
|
||||||
|
|
||||||
|
-- Set MissionTypeOpt to Recruit if nil.
|
||||||
if MissionTypeOpt==nil then
|
if MissionTypeOpt==nil then
|
||||||
MissionTypeOpt=MissionTypeRecruit
|
MissionTypeOpt=MissionTypeRecruit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Function to check category.
|
||||||
|
local function CheckCategory(_cohort)
|
||||||
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
|
if Categories and #Categories>0 then
|
||||||
|
for _,category in pairs(Categories) do
|
||||||
|
if category==cohort.category then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Function to check attribute.
|
||||||
|
local function CheckAttribute(_cohort)
|
||||||
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
|
if Attributes and #Attributes>0 then
|
||||||
|
for _,attribute in pairs(Attributes) do
|
||||||
|
if attribute==cohort.attribute then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Loops over cohorts.
|
-- Loops over cohorts.
|
||||||
for _,_cohort in pairs(Cohorts) do
|
for _,_cohort in pairs(Cohorts) do
|
||||||
local cohort=_cohort --Ops.Cohort#COHORT
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
@ -1838,9 +1869,19 @@ function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt,
|
|||||||
-- Can carry the cargo?
|
-- Can carry the cargo?
|
||||||
local CanCarry=CargoWeight and cohort.cargobayLimit>=CargoWeight or true
|
local CanCarry=CargoWeight and cohort.cargobayLimit>=CargoWeight or true
|
||||||
|
|
||||||
-- Check OnDuty, capable, in range and refueling type (if TANKER).
|
-- Right category.
|
||||||
if cohort:IsOnDuty() and Capable and InRange and Refuel and CanCarry then
|
local RightCategory=CheckCategory(cohort)
|
||||||
|
|
||||||
|
-- Right attribute.
|
||||||
|
local RightAttribute=CheckAttribute(cohort)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
cohort:I(cohort.lid..string.format("State=%s: Capable=%s, InRange=%s, Refuel=%s, CanCarry=%s, RightCategory=%s, RightAttribute=%s",
|
||||||
|
cohort:GetState(), tostring(Capable), tostring(InRange), tostring(Refuel), tostring(CanCarry), tostring(RightCategory), tostring(RightAttribute)))
|
||||||
|
|
||||||
|
-- Check OnDuty, capable, in range and refueling type (if TANKER).
|
||||||
|
if cohort:IsOnDuty() and Capable and InRange and Refuel and CanCarry and RightCategory and RightAttribute then
|
||||||
|
|
||||||
-- Recruit assets from cohort.
|
-- Recruit assets from cohort.
|
||||||
local assets, npayloads=cohort:RecruitAssets(MissionTypeRecruit, 999)
|
local assets, npayloads=cohort:RecruitAssets(MissionTypeRecruit, 999)
|
||||||
|
|
||||||
@ -1893,6 +1934,7 @@ function LEGION.RecruitCohortAssets(Cohorts, MissionTypeRecruit, MissionTypeOpt,
|
|||||||
-- Add assets to mission.
|
-- Add assets to mission.
|
||||||
for i=1,Nassets do
|
for i=1,Nassets do
|
||||||
local asset=Assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem
|
local asset=Assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
asset.isReserved=true
|
||||||
Legions[asset.legion.alias]=asset.legion
|
Legions[asset.legion.alias]=asset.legion
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -3801,20 +3801,7 @@ function OPSGROUP:_GetNextMission()
|
|||||||
-- Look for first mission that is SCHEDULED.
|
-- Look for first mission that is SCHEDULED.
|
||||||
for _,_mission in pairs(self.missionqueue) do
|
for _,_mission in pairs(self.missionqueue) do
|
||||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
|
|
||||||
-- Local transport.
|
|
||||||
local transport=true
|
|
||||||
if mission.opstransport then
|
|
||||||
local cargos=mission.opstransport:GetCargoOpsGroups(false) or {}
|
|
||||||
for _,_opsgroup in pairs(cargos) do
|
|
||||||
local opscargo=_opsgroup --Ops.OpsGroup#OPSGROUP
|
|
||||||
if opscargo.groupname==self.groupname then
|
|
||||||
transport=false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- TODO: One could think of opsgroup specific start conditions. A legion also checks if "ready" but it can be other criteria for the group to actually start the mission.
|
-- TODO: One could think of opsgroup specific start conditions. A legion also checks if "ready" but it can be other criteria for the group to actually start the mission.
|
||||||
-- Good example is the above transport. The legion should start the mission but the group should only start after the transport is finished.
|
-- Good example is the above transport. The legion should start the mission but the group should only start after the transport is finished.
|
||||||
|
|
||||||
@ -3826,12 +3813,24 @@ function OPSGROUP:_GetNextMission()
|
|||||||
isEscort=false
|
isEscort=false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Local transport.
|
||||||
|
local isTransport=true
|
||||||
|
if mission.opstransport then
|
||||||
|
local cargos=mission.opstransport:GetCargoOpsGroups(false) or {}
|
||||||
|
for _,_opsgroup in pairs(cargos) do
|
||||||
|
local opscargo=_opsgroup --Ops.OpsGroup#OPSGROUP
|
||||||
|
if opscargo.groupname==self.groupname then
|
||||||
|
isTransport=false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Conditons to start.
|
-- Conditons to start.
|
||||||
local isScheduled=mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.SCHEDULED
|
local isScheduled=mission:GetGroupStatus(self)==AUFTRAG.GroupStatus.SCHEDULED
|
||||||
local isReadyToGo=(mission:IsReadyToGo() or self.legion)
|
local isReadyToGo=(mission:IsReadyToGo() or self.legion)
|
||||||
local isImportant=(mission.importance==nil or mission.importance<=vip)
|
local isImportant=(mission.importance==nil or mission.importance<=vip)
|
||||||
local isTransport=transport
|
|
||||||
|
|
||||||
-- Check necessary conditions.
|
-- Check necessary conditions.
|
||||||
if isScheduled and isReadyToGo and isImportant and isTransport and isEscort then
|
if isScheduled and isReadyToGo and isImportant and isTransport and isEscort then
|
||||||
|
|||||||
@ -168,6 +168,7 @@ OPSTRANSPORT.Status={
|
|||||||
-- @field #table DisembarkCarriers Carriers where the cargo is directly disembarked to.
|
-- @field #table DisembarkCarriers Carriers where the cargo is directly disembarked to.
|
||||||
-- @field #boolean disembarkActivation If true, troops are spawned in late activated state when disembarked from carrier.
|
-- @field #boolean disembarkActivation If true, troops are spawned in late activated state when disembarked from carrier.
|
||||||
-- @field #boolean disembarkInUtero If true, troops are disembarked "in utero".
|
-- @field #boolean disembarkInUtero If true, troops are disembarked "in utero".
|
||||||
|
-- @field #boolean assets Cargo assets.
|
||||||
|
|
||||||
--- Path used for pickup or transport.
|
--- Path used for pickup or transport.
|
||||||
-- @type OPSTRANSPORT.Path
|
-- @type OPSTRANSPORT.Path
|
||||||
@ -1225,14 +1226,16 @@ end
|
|||||||
--- Add asset to transport.
|
--- Add asset to transport.
|
||||||
-- @param #OPSTRANSPORT self
|
-- @param #OPSTRANSPORT self
|
||||||
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset to be added.
|
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset to be added.
|
||||||
|
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||||
-- @return #OPSTRANSPORT self
|
-- @return #OPSTRANSPORT self
|
||||||
function OPSTRANSPORT:AddAsset(Asset)
|
function OPSTRANSPORT:AddAsset(Asset, TransportZoneCombo)
|
||||||
|
|
||||||
-- Debug info
|
-- Debug info
|
||||||
self:T(self.lid..string.format("Adding asset \"%s\" to transport", tostring(Asset.spawngroupname)))
|
self:T(self.lid..string.format("Adding asset carrier \"%s\" to transport", tostring(Asset.spawngroupname)))
|
||||||
|
|
||||||
-- Add asset to table.
|
-- Add asset to table.
|
||||||
self.assets=self.assets or {}
|
self.assets=self.assets or {}
|
||||||
|
|
||||||
table.insert(self.assets, Asset)
|
table.insert(self.assets, Asset)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -1258,6 +1261,28 @@ function OPSTRANSPORT:DelAsset(Asset)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add cargo asset.
|
||||||
|
-- @param #OPSTRANSPORT self
|
||||||
|
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset to be added.
|
||||||
|
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||||
|
-- @return #OPSTRANSPORT self
|
||||||
|
function OPSTRANSPORT:AddAssetCargo(Asset, TransportZoneCombo)
|
||||||
|
|
||||||
|
-- Debug info
|
||||||
|
self:T(self.lid..string.format("Adding asset cargo \"%s\" to transport and TZC=%s", tostring(Asset.spawngroupname), TransportZoneCombo and TransportZoneCombo.uid or "N/A"))
|
||||||
|
|
||||||
|
-- Add asset to table.
|
||||||
|
self.assetsCargo=self.assetsCargo or {}
|
||||||
|
|
||||||
|
table.insert(self.assetsCargo, Asset)
|
||||||
|
|
||||||
|
TransportZoneCombo.assetsCargo=TransportZoneCombo.assetsCargo or {}
|
||||||
|
|
||||||
|
TransportZoneCombo.assetsCargo[Asset.spawngroupname]=Asset
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Add LEGION to the transport.
|
--- Add LEGION to the transport.
|
||||||
-- @param #OPSTRANSPORT self
|
-- @param #OPSTRANSPORT self
|
||||||
-- @param Ops.Legion#LEGION Legion The legion.
|
-- @param Ops.Legion#LEGION Legion The legion.
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
--
|
--
|
||||||
-- **Main Features:**
|
-- **Main Features:**
|
||||||
--
|
--
|
||||||
-- * Monitor if zone is captured.
|
-- * Monitor if a zone is captured.
|
||||||
|
-- * Monitor if an airbase is captured.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@ -17,6 +18,8 @@
|
|||||||
-- @field #string ClassName Name of the class.
|
-- @field #string ClassName Name of the class.
|
||||||
-- @field #number verbose Verbosity of output.
|
-- @field #number verbose Verbosity of output.
|
||||||
-- @field Core.Zone#ZONE zone The zone.
|
-- @field Core.Zone#ZONE zone The zone.
|
||||||
|
-- @field Wrapper.Airbase#AIRBASE airbase The airbase that is monitored.
|
||||||
|
-- @field #string airbaseName Name of the airbase that is monitored.
|
||||||
-- @field #string zoneName Name of the zone.
|
-- @field #string zoneName Name of the zone.
|
||||||
-- @field #number zoneRadius Radius of the zone in meters.
|
-- @field #number zoneRadius Radius of the zone in meters.
|
||||||
-- @field #number ownerCurrent Coalition of the current owner of the zone.
|
-- @field #number ownerCurrent Coalition of the current owner of the zone.
|
||||||
@ -30,7 +33,7 @@
|
|||||||
-- @field #number Tattacked Abs. mission time stamp when an attack was started.
|
-- @field #number Tattacked Abs. mission time stamp when an attack was started.
|
||||||
-- @field #number dTCapture Time interval in seconds until a zone is captured.
|
-- @field #number dTCapture Time interval in seconds until a zone is captured.
|
||||||
-- @field #boolean neutralCanCapture Neutral units can capture. Default `false`.
|
-- @field #boolean neutralCanCapture Neutral units can capture. Default `false`.
|
||||||
-- @field #drawZone If `true`, draw the zone on the F10 map.
|
-- @field #boolean drawZone If `true`, draw the zone on the F10 map.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- Be surprised!
|
--- Be surprised!
|
||||||
@ -63,6 +66,7 @@ OPSZONE.version="0.1.0"
|
|||||||
-- ToDo list
|
-- ToDo list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- TODO: Capture airbases.
|
||||||
-- TODO: Pause/unpause evaluations.
|
-- TODO: Pause/unpause evaluations.
|
||||||
-- TODO: Capture time, i.e. time how long a single coalition has to be inside the zone to capture it.
|
-- TODO: Capture time, i.e. time how long a single coalition has to be inside the zone to capture it.
|
||||||
-- TODO: Can neutrals capture? No, since they are _neutral_!
|
-- TODO: Can neutrals capture? No, since they are _neutral_!
|
||||||
@ -113,17 +117,19 @@ function OPSZONE:New(Zone, CoalitionOwner)
|
|||||||
self:SetObjectCategories()
|
self:SetObjectCategories()
|
||||||
self:SetUnitCategories()
|
self:SetUnitCategories()
|
||||||
|
|
||||||
|
self.drawZone=true
|
||||||
|
|
||||||
-- Status timer.
|
-- Status timer.
|
||||||
self.timerStatus=TIMER:New(OPSZONE.Status, self)
|
self.timerStatus=TIMER:New(OPSZONE.Status, self)
|
||||||
|
|
||||||
|
|
||||||
-- FMS start state is EMPTY.
|
-- FMS start state is EMPTY.
|
||||||
self:SetStartState("Empty")
|
self:SetStartState("Stopped")
|
||||||
|
|
||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
self:AddTransition("*", "Start", "*") -- Start FSM.
|
self:AddTransition("Stopped", "Start", "Empty") -- Start FSM.
|
||||||
self:AddTransition("*", "Stop", "*") -- Stop FSM.
|
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
||||||
|
|
||||||
self:AddTransition("*", "Captured", "Guarded") -- Zone was captured.
|
self:AddTransition("*", "Captured", "Guarded") -- Zone was captured.
|
||||||
self:AddTransition("*", "Empty", "Empty") -- No red or blue units inside the zone.
|
self:AddTransition("*", "Empty", "Empty") -- No red or blue units inside the zone.
|
||||||
@ -372,9 +378,16 @@ function OPSZONE:IsContested()
|
|||||||
return self.isContested
|
return self.isContested
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if FMS is stopped.
|
||||||
|
-- @param #OPSZONE self
|
||||||
|
-- @return #boolean If `true`, FSM is stopped
|
||||||
|
function OPSZONE:IsStopped()
|
||||||
|
local is=self:is("Stopped")
|
||||||
|
return is
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Start/Stop and Status Functions
|
-- Start/Stop Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Start OPSZONE FSM.
|
--- Start OPSZONE FSM.
|
||||||
@ -395,6 +408,25 @@ function OPSZONE:onafterStart(From, Event, To)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Stop OPSZONE FSM.
|
||||||
|
-- @param #OPSZONE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
function OPSZONE:onafterStop(From, Event, To)
|
||||||
|
|
||||||
|
-- Info.
|
||||||
|
self:I(self.lid..string.format("Stopping OPSZONE"))
|
||||||
|
|
||||||
|
-- Reinit the timer.
|
||||||
|
self.timerStatus:Stop()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Status Functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Update status.
|
--- Update status.
|
||||||
-- @param #OPSZONE self
|
-- @param #OPSZONE self
|
||||||
function OPSZONE:Status()
|
function OPSZONE:Status()
|
||||||
@ -434,7 +466,7 @@ function OPSZONE:onafterCaptured(From, Event, To, NewOwnerCoalition)
|
|||||||
-- Set owners.
|
-- Set owners.
|
||||||
self.ownerPrevious=self.ownerCurrent
|
self.ownerPrevious=self.ownerCurrent
|
||||||
self.ownerCurrent=NewOwnerCoalition
|
self.ownerCurrent=NewOwnerCoalition
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "Empty" event.
|
--- On after "Empty" event.
|
||||||
@ -445,7 +477,7 @@ end
|
|||||||
function OPSZONE:onafterEmpty(From, Event, To)
|
function OPSZONE:onafterEmpty(From, Event, To)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Zone is empty now"))
|
self:T(self.lid..string.format("Zone is empty EVENT"))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -462,19 +494,6 @@ function OPSZONE:onafterAttacked(From, Event, To, AttackerCoalition)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- On after "Empty" event.
|
|
||||||
-- @param #OPSZONE self
|
|
||||||
-- @param #string From From state.
|
|
||||||
-- @param #string Event Event.
|
|
||||||
-- @param #string To To state.
|
|
||||||
function OPSZONE:onafterEmpty(From, Event, To)
|
|
||||||
|
|
||||||
-- Debug info.
|
|
||||||
self:T(self.lid..string.format("Zone is empty now"))
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- On after "Defeated" event.
|
--- On after "Defeated" event.
|
||||||
-- @param #OPSZONE self
|
-- @param #OPSZONE self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
@ -504,6 +523,14 @@ function OPSZONE:onenterGuarded(From, Event, To)
|
|||||||
-- Not attacked any more.
|
-- Not attacked any more.
|
||||||
self.Tattacked=nil
|
self.Tattacked=nil
|
||||||
|
|
||||||
|
if self.drawZone then
|
||||||
|
self.zone:UndrawZone()
|
||||||
|
|
||||||
|
local color=self:_GetZoneColor()
|
||||||
|
|
||||||
|
self.zone:DrawZone(nil, color, 1.0, color, 0.7)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On enter "Guarded" state.
|
--- On enter "Guarded" state.
|
||||||
@ -519,6 +546,34 @@ function OPSZONE:onenterAttacked(From, Event, To)
|
|||||||
-- Time stamp when the attack started.
|
-- Time stamp when the attack started.
|
||||||
self.Tattacked=timer.getAbsTime()
|
self.Tattacked=timer.getAbsTime()
|
||||||
|
|
||||||
|
if self.drawZone then
|
||||||
|
self.zone:UndrawZone()
|
||||||
|
|
||||||
|
local color={1,1,1}
|
||||||
|
|
||||||
|
self.zone:DrawZone(nil, color, 1.0, color, 0.9)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On enter "Empty" event.
|
||||||
|
-- @param #OPSZONE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
function OPSZONE:onenterEmpty(From, Event, To)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Zone is empty now"))
|
||||||
|
|
||||||
|
if self.drawZone then
|
||||||
|
self.zone:UndrawZone()
|
||||||
|
|
||||||
|
local color=self:_GetZoneColor()
|
||||||
|
|
||||||
|
self.zone:DrawZone(nil, color, 1.0, color, 0.2)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -837,6 +892,49 @@ function OPSZONE:OnEventHit(EventData)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Monitor hit events.
|
||||||
|
-- @param #OPSZONE self
|
||||||
|
-- @param Core.Event#EVENTDATA EventData The event data.
|
||||||
|
function OPSZONE:OnEventBaseCaptured(EventData)
|
||||||
|
|
||||||
|
if EventData and EventData.Place and self.airbase and self.airbaseName then
|
||||||
|
|
||||||
|
-- Place is the airbase that was captured.
|
||||||
|
local airbase=EventData.Place --Wrapper.Airbase#AIRBASE
|
||||||
|
|
||||||
|
-- Check that this airbase belongs or did belong to this warehouse.
|
||||||
|
if EventData.PlaceName==self.airbaseName then
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Misc Functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Get RGB color of zone depending on current owner.
|
||||||
|
-- @param #OPSZONE self
|
||||||
|
-- @return #table RGB color.
|
||||||
|
function OPSZONE:_GetZoneColor()
|
||||||
|
|
||||||
|
local color={0,0,0}
|
||||||
|
|
||||||
|
if self.ownerCurrent==coalition.side.NEUTRAL then
|
||||||
|
color={0, 1, 0}
|
||||||
|
elseif self.ownerCurrent==coalition.side.BLUE then
|
||||||
|
color={1, 0, 0}
|
||||||
|
elseif self.ownerCurrent==coalition.side.RED then
|
||||||
|
color={0, 0, 1}
|
||||||
|
else
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return color
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user