mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPSCARGO
- fixes for Legion assignment
This commit is contained in:
parent
b0c2e5409a
commit
6f126e6cd4
@ -1364,23 +1364,22 @@ function AUFTRAG:NewFUELSUPPLY(Zone)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- **[AIR]** Create an ALERT 5 mission.
|
--- **[AIR]** Create an ALERT 5 mission. Aircraft will be spawned uncontrolled and wait for an assignment. You must specify **one** mission type which is performed.
|
||||||
|
-- This determines the payload and the DCS mission task which are used when the aircraft is spawned.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param #string MissionType Mission type `AUFTRAG.Type.XXX`.
|
-- @param #string MissionType Mission type `AUFTRAG.Type.XXX`. Determines payload and mission task (intercept, ground attack, etc.).
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:NewALERT5(MissionType)
|
function AUFTRAG:NewALERT5(MissionType)
|
||||||
|
|
||||||
local mission=AUFTRAG:New(AUFTRAG.Type.ALERT5)
|
local mission=AUFTRAG:New(AUFTRAG.Type.ALERT5)
|
||||||
|
|
||||||
--mission:_TargetFromObject(Coordinate)
|
|
||||||
|
|
||||||
mission.missionTask=self:GetMissionTaskforMissionType(MissionType)
|
mission.missionTask=self:GetMissionTaskforMissionType(MissionType)
|
||||||
mission.optionROE=ENUMS.ROE.WeaponHold
|
mission.optionROE=ENUMS.ROE.WeaponHold
|
||||||
mission.optionROT=ENUMS.ROT.NoReaction
|
mission.optionROT=ENUMS.ROT.NoReaction
|
||||||
|
|
||||||
mission.alert5MissionType=MissionType
|
mission.alert5MissionType=MissionType
|
||||||
|
|
||||||
mission.missionFraction=0.0
|
mission.missionFraction=1.0
|
||||||
|
|
||||||
mission.DCStask=mission:GetDCSMissionTask()
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
@ -1828,14 +1827,18 @@ end
|
|||||||
|
|
||||||
--- Attach OPS transport to the mission. Mission assets will be transported before the mission is started at the OPSGROUP level.
|
--- Attach OPS transport to the mission. Mission assets will be transported before the mission is started at the OPSGROUP level.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param Core.Zone#ZONE PickupZone Zone where assets are picked up.
|
|
||||||
-- @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.Set#SET_OPSGROUP Carriers Set of carriers. Can also be a single group. Can also be added via the AddTransportCarriers functions.
|
-- @param Core.Set#SET_OPSGROUP Carriers Set of carriers. Can also be a single group. Can also be added via the AddTransportCarriers functions.
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:SetTransportForAssets(PickupZone, DeployZone, Carriers)
|
function AUFTRAG:SetTransportForAssets(DeployZone, DisembarkZone, Carriers)
|
||||||
|
|
||||||
-- OPS transport from pickup to deploy zone.
|
-- OPS transport from pickup to deploy zone.
|
||||||
self.opstransport=OPSTRANSPORT:New(nil, PickupZone, DeployZone)
|
self.opstransport=OPSTRANSPORT:New(nil, nil, DeployZone)
|
||||||
|
|
||||||
|
if DisembarkZone then
|
||||||
|
self.opstransport:SetDisembarkZone(DisembarkZone)
|
||||||
|
end
|
||||||
|
|
||||||
if Carriers then
|
if Carriers then
|
||||||
if Carriers:IsInstanceOf("SET_OPSGROUP") then
|
if Carriers:IsInstanceOf("SET_OPSGROUP") then
|
||||||
@ -1854,6 +1857,18 @@ function AUFTRAG:SetTransportForAssets(PickupZone, DeployZone, Carriers)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add a transport Legion. This requires an OPSTRANSPORT to be set via `AUFTRAG:SetTransportForAssets`.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @param Ops.Legion#LEGION Legion The legion.
|
||||||
|
function AUFTRAG:AddTransportLegion(Legion)
|
||||||
|
|
||||||
|
self.transportLegions=self.transportLegions or {}
|
||||||
|
|
||||||
|
table.insert(self.transportLegions, Legion)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Set Rules of Engagement (ROE) for this mission.
|
--- Set Rules of Engagement (ROE) for this mission.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param #string roe Mission ROE.
|
-- @param #string roe Mission ROE.
|
||||||
@ -2162,7 +2177,12 @@ function AUFTRAG:AddOpsGroup(OpsGroup)
|
|||||||
|
|
||||||
-- Add ops transport to new group.
|
-- Add ops transport to new group.
|
||||||
if self.opstransport then
|
if self.opstransport then
|
||||||
self.opstransport:AddCargoGroups(OpsGroup)
|
for _,_tzc in pairs(self.opstransport.tzCombos) do
|
||||||
|
local tzc=_tzc --Ops.OpsTransport#OPSTRANSPORT.TransportZoneCombo
|
||||||
|
if tzc.uid~=self.opstransport.tzcDefault.uid then
|
||||||
|
self.opstransport:AddCargoGroups(OpsGroup, tzc)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -2300,7 +2320,7 @@ function AUFTRAG:IsReadyToGo()
|
|||||||
if #self.legions>0 then
|
if #self.legions>0 then
|
||||||
end
|
end
|
||||||
if self.opstransport:IsPlanned() or self.opstransport:IsQueued() or self.opstransport:IsRequested() then
|
if self.opstransport:IsPlanned() or self.opstransport:IsQueued() or self.opstransport:IsRequested() then
|
||||||
return false
|
--return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,8 @@
|
|||||||
-- @field #number radioFreq Radio frequency in MHz the cohort uses.
|
-- @field #number radioFreq Radio frequency in MHz the cohort uses.
|
||||||
-- @field #number radioModu Radio modulation the cohort uses.
|
-- @field #number radioModu Radio modulation the cohort uses.
|
||||||
-- @field #table tacanChannel List of TACAN channels available to the cohort.
|
-- @field #table tacanChannel List of TACAN channels available to the cohort.
|
||||||
|
-- @field #number weightAsset Weight of one assets group in kg.
|
||||||
|
-- @field #number cargobayLimit Cargo bay capacity in kg.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- *It is unbelievable what a platoon of twelve aircraft did to tip the balance.* -- Adolf Galland
|
--- *It is unbelievable what a platoon of twelve aircraft did to tip the balance.* -- Adolf Galland
|
||||||
@ -67,7 +69,9 @@ COHORT = {
|
|||||||
legion = nil,
|
legion = nil,
|
||||||
Ngroups = nil,
|
Ngroups = nil,
|
||||||
engageRange = nil,
|
engageRange = nil,
|
||||||
tacanChannel = {},
|
tacanChannel = {},
|
||||||
|
weightAsset = 99999,
|
||||||
|
cargobayLimit = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- COHORT class version.
|
--- COHORT class version.
|
||||||
@ -124,7 +128,20 @@ function COHORT:New(TemplateGroupName, Ngroups, CohortName)
|
|||||||
|
|
||||||
-- Aircraft type.
|
-- Aircraft type.
|
||||||
self.aircrafttype=self.templategroup:GetTypeName()
|
self.aircrafttype=self.templategroup:GetTypeName()
|
||||||
|
|
||||||
|
local units=self.templategroup:GetUnits()
|
||||||
|
|
||||||
|
-- Weight of the whole group.
|
||||||
|
self.weightAsset=0
|
||||||
|
for i,_unit in pairs(units) do
|
||||||
|
local unit=_unit --Wrapper.Unit#UNIT
|
||||||
|
local desc=unit:GetDesc()
|
||||||
|
self.weightAsset=self.weightAsset + (desc.massMax or 666)
|
||||||
|
if i==1 then
|
||||||
|
self.cargobayLimit=unit:GetCargoBayFreeWeight()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Start State.
|
-- Start State.
|
||||||
self:SetStartState("Stopped")
|
self:SetStartState("Stopped")
|
||||||
|
|
||||||
|
|||||||
@ -253,13 +253,28 @@ function LEGION:AddMission(Mission)
|
|||||||
Mission:_TargetFromObject(self:GetCoordinate())
|
Mission:_TargetFromObject(self:GetCoordinate())
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
-- Add ops transport to transport Legions.
|
||||||
if Mission.opstransport then
|
if Mission.opstransport then
|
||||||
Mission.opstransport:SetPickupZone(self.spawnzone)
|
|
||||||
Mission.opstransport:SetEmbarkZone(self.spawnzone)
|
|
||||||
self:AddOpsTransport(Mission.opstransport)
|
-- Add a new TZC: from pickup here to the deploy zone.
|
||||||
|
local tzc=Mission.opstransport:AddTransportZoneCombo(self.spawnzone, Mission.opstransport.tzcDefault.DeployZone)
|
||||||
|
|
||||||
|
--TODO: Depending on "from where to where" the assets need to transported, we need to set ZONE_AIRBASE etc.
|
||||||
|
|
||||||
|
--Mission.opstransport:SetPickupZone(self.spawnzone)
|
||||||
|
--Mission.opstransport:SetEmbarkZone(self.spawnzone)
|
||||||
|
|
||||||
|
|
||||||
|
-- Loop over all defined transport legions.
|
||||||
|
for _,_legion in pairs(Mission.transportLegions) do
|
||||||
|
local legion=_legion --Ops.Legion#LEGION
|
||||||
|
|
||||||
|
-- Add ops transport to legion.
|
||||||
|
legion:AddOpsTransport(Mission.opstransport)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
]]
|
|
||||||
|
|
||||||
-- Add mission to queue.
|
-- Add mission to queue.
|
||||||
table.insert(self.missionqueue, Mission)
|
table.insert(self.missionqueue, Mission)
|
||||||
@ -458,8 +473,10 @@ function LEGION:_GetNextTransport()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Function to get carrier assets from all cohorts.
|
||||||
local function getAssets(n)
|
local function getAssets(n, weightGroup)
|
||||||
|
|
||||||
|
-- Selected assets.
|
||||||
local assets={}
|
local assets={}
|
||||||
|
|
||||||
-- Loop over cohorts.
|
-- Loop over cohorts.
|
||||||
@ -467,14 +484,14 @@ function LEGION:_GetNextTransport()
|
|||||||
local cohort=_cohort --Ops.Cohort#COHORT
|
local cohort=_cohort --Ops.Cohort#COHORT
|
||||||
|
|
||||||
-- Check if chort can do a transport.
|
-- Check if chort can do a transport.
|
||||||
if cohort:CheckMissionCapability({AUFTRAG.Type.OPSTRANSPORT}, cohort.missiontypes) then
|
if cohort:CheckMissionCapability({AUFTRAG.Type.OPSTRANSPORT}) and cohort.cargobayLimit>=weightGroup then
|
||||||
|
|
||||||
-- Loop over cohort assets.
|
-- Loop over cohort assets.
|
||||||
for _,_asset in pairs(cohort.assets) do
|
for _,_asset in pairs(cohort.assets) do
|
||||||
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
-- Check if asset is currently on a mission (STARTED or QUEUED).
|
-- Check if asset is currently on a mission (STARTED or QUEUED).
|
||||||
if not asset.spawned then
|
if not (asset.spawned or asset.isReserved or asset.requested) then
|
||||||
|
|
||||||
-- Add to assets.
|
-- Add to assets.
|
||||||
table.insert(assets, asset)
|
table.insert(assets, asset)
|
||||||
@ -488,6 +505,8 @@ function LEGION:_GetNextTransport()
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -498,11 +517,30 @@ function LEGION:_GetNextTransport()
|
|||||||
-- Check if transport is still queued and ready.
|
-- Check if transport is still queued and ready.
|
||||||
if transport:IsQueued() and transport:IsReadyToGo() then
|
if transport:IsQueued() and transport:IsReadyToGo() then
|
||||||
|
|
||||||
local assets=getAssets(1)
|
-- Get all undelivered cargo ops groups.
|
||||||
|
local cargoOpsGroups=transport:GetCargoOpsGroups(false)
|
||||||
if #assets>0 then
|
|
||||||
transport.assets=assets
|
-- At least one group should be spawned.
|
||||||
return transport
|
if #cargoOpsGroups>0 then
|
||||||
|
|
||||||
|
-- Calculate the max weight so we know which cohorts can provide carriers.
|
||||||
|
local weightGroup=0
|
||||||
|
for _,_opsgroup in pairs(cargoOpsGroups) do
|
||||||
|
local opsgroup=_opsgroup --Ops.OpsGroup#OPSGROUP
|
||||||
|
local weight=opsgroup:GetWeightTotal()
|
||||||
|
if weight>weightGroup then
|
||||||
|
weightGroup=weight
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get assets. If not enough assets can be found, nil is returned.
|
||||||
|
local assets=getAssets(1, weightGroup)
|
||||||
|
|
||||||
|
if assets then
|
||||||
|
transport.assets=assets
|
||||||
|
return transport
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -821,6 +859,7 @@ function LEGION:onafterOpsOnMission(From, Event, To, OpsGroup, Mission)
|
|||||||
-- Trigger event for Brigades.
|
-- Trigger event for Brigades.
|
||||||
self:ArmyOnMission(OpsGroup, Mission)
|
self:ArmyOnMission(OpsGroup, Mission)
|
||||||
else
|
else
|
||||||
|
--TODO: Flotilla
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -901,8 +940,6 @@ function LEGION:onafterNewAsset(From, Event, To, asset, assignment)
|
|||||||
-- Add asset to cohort.
|
-- Add asset to cohort.
|
||||||
cohort:AddAsset(asset)
|
cohort:AddAsset(asset)
|
||||||
|
|
||||||
-- TODO
|
|
||||||
--asset.terminalType=AIRBASE.TerminalType.OpenBig
|
|
||||||
else
|
else
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@ -5751,13 +5751,13 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
if self.verbose>=3 then
|
if self.verbose>=3 then
|
||||||
local text=""
|
local text=""
|
||||||
for i,_transport in pairs(self.cargoqueue) do
|
for i,_transport in pairs(self.cargoqueue) do
|
||||||
local transport=_transport --#Ops.OpsTransport#OPSTRANSPORT
|
local transport=_transport --Ops.OpsTransport#OPSTRANSPORT
|
||||||
local pickupzone=transport:GetPickupZone()
|
local pickupzone=transport:GetPickupZone()
|
||||||
local deployzone=transport:GetDeployZone()
|
local deployzone=transport:GetDeployZone()
|
||||||
local pickupname=pickupzone and pickupzone:GetName() or "unknown"
|
local pickupname=pickupzone and pickupzone:GetName() or "unknown"
|
||||||
local deployname=deployzone and deployzone:GetName() or "unknown"
|
local deployname=deployzone and deployzone:GetName() or "unknown"
|
||||||
text=text..string.format("\n[%d] UID=%d Status=%s: %s --> %s", i, transport.uid, transport:GetState(), pickupname, deployname)
|
text=text..string.format("\n[%d] UID=%d Status=%s: %s --> %s", i, transport.uid, transport:GetState(), pickupname, deployname)
|
||||||
for j,_cargo in pairs(transport.cargos) do
|
for j,_cargo in pairs(transport:GetCargos()) do
|
||||||
local cargo=_cargo --#OPSGROUP.CargoGroup
|
local cargo=_cargo --#OPSGROUP.CargoGroup
|
||||||
local state=cargo.opsgroup:GetState()
|
local state=cargo.opsgroup:GetState()
|
||||||
local status=cargo.opsgroup.cargoStatus
|
local status=cargo.opsgroup.cargoStatus
|
||||||
@ -5785,6 +5785,12 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
if self.cargoTransport then
|
if self.cargoTransport then
|
||||||
|
|
||||||
if self:IsNotCarrier() then
|
if self:IsNotCarrier() then
|
||||||
|
|
||||||
|
-- Unset time stamps.
|
||||||
|
self.Tpickingup=nil
|
||||||
|
self.Tloading=nil
|
||||||
|
self.Ttransporting=nil
|
||||||
|
self.Tunloading=nil
|
||||||
|
|
||||||
-- Get transport zone combo (TZC).
|
-- Get transport zone combo (TZC).
|
||||||
self.cargoTZC=self.cargoTransport:_GetTransportZoneCombo(self)
|
self.cargoTZC=self.cargoTransport:_GetTransportZoneCombo(self)
|
||||||
@ -5802,18 +5808,28 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
end
|
end
|
||||||
|
|
||||||
elseif self:IsPickingup() then
|
elseif self:IsPickingup() then
|
||||||
|
|
||||||
|
-- Set time stamp.
|
||||||
|
self.Tpickingup=self.Tpickingup or Time
|
||||||
|
|
||||||
|
-- Current pickup time.
|
||||||
|
local tpickingup=Time-self.Tpickingup
|
||||||
|
|
||||||
-- Debug Info.
|
-- Debug Info.
|
||||||
self:T(self.lid.."Picking up...")
|
self:T(self.lid..string.format("Picking up at %s [TZC UID=%d] for %s sec...", self.cargoTZC.PickupZone and self.cargoTZC.PickupZone:GetName() or "unknown", self.cargoTZC.uid, tpickingup))
|
||||||
|
|
||||||
elseif self:IsLoading() then
|
elseif self:IsLoading() then
|
||||||
|
|
||||||
-- Set loading time stamp.
|
-- Set loading time stamp.
|
||||||
--TODO: Check max loading time. If exceeded ==> abort transport.
|
|
||||||
self.Tloading=self.Tloading or Time
|
self.Tloading=self.Tloading or Time
|
||||||
|
|
||||||
|
-- Current pickup time.
|
||||||
|
local tloading=Time-self.Tloading
|
||||||
|
|
||||||
|
--TODO: Check max loading time. If exceeded ==> abort transport.
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid.."Loading...")
|
self:T(self.lid..string.format("Loading at %s [TZC UID=%d] for %s sec...", self.cargoTZC.PickupZone and self.cargoTZC.PickupZone:GetName() or "unknown", self.cargoTZC.uid, tloading))
|
||||||
|
|
||||||
local boarding=false
|
local boarding=false
|
||||||
local gotcargo=false
|
local gotcargo=false
|
||||||
@ -5847,11 +5863,23 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
end
|
end
|
||||||
|
|
||||||
elseif self:IsTransporting() then
|
elseif self:IsTransporting() then
|
||||||
|
|
||||||
|
-- Set time stamp.
|
||||||
|
self.Ttransporting=self.Ttransporting or Time
|
||||||
|
|
||||||
|
-- Current pickup time.
|
||||||
|
local ttransporting=Time-self.Ttransporting
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid.."Transporting (nothing to do)")
|
self:T(self.lid.."Transporting (nothing to do)")
|
||||||
|
|
||||||
elseif self:IsUnloading() then
|
elseif self:IsUnloading() then
|
||||||
|
|
||||||
|
-- Set time stamp.
|
||||||
|
self.Tunloading=self.Tunloading or Time
|
||||||
|
|
||||||
|
-- Current pickup time.
|
||||||
|
local tunloading=Time-self.Tunloading
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid.."Unloading ==> Checking if all cargo was delivered")
|
self:T(self.lid.."Unloading ==> Checking if all cargo was delivered")
|
||||||
@ -6084,7 +6112,7 @@ end
|
|||||||
function OPSGROUP:_CheckDelivered(CargoTransport)
|
function OPSGROUP:_CheckDelivered(CargoTransport)
|
||||||
|
|
||||||
local done=true
|
local done=true
|
||||||
for _,_cargo in pairs(CargoTransport.cargos) do
|
for _,_cargo in pairs(CargoTransport:GetCargos()) do
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
|
|
||||||
if self:CanCargo(cargo.opsgroup) then
|
if self:CanCargo(cargo.opsgroup) then
|
||||||
@ -6118,7 +6146,7 @@ function OPSGROUP:_CheckGoPickup(CargoTransport)
|
|||||||
|
|
||||||
if CargoTransport then
|
if CargoTransport then
|
||||||
|
|
||||||
for _,_cargo in pairs(CargoTransport.cargos) do
|
for _,_cargo in pairs(CargoTransport:GetCargos()) do
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
|
|
||||||
if self:CanCargo(cargo.opsgroup) then
|
if self:CanCargo(cargo.opsgroup) then
|
||||||
@ -8236,15 +8264,25 @@ function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax)
|
|||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
local Speed=UTILS.MpsToKnots(wp.speed)
|
local Speed=UTILS.MpsToKnots(wp.speed)
|
||||||
|
|
||||||
--local waypoint=self:_CreateWaypoint(wp)
|
-- Add waypoint.
|
||||||
--self:_AddWaypoint(waypoint)
|
local Waypoint=nil
|
||||||
|
|
||||||
if self:IsFlightgroup() then
|
if self:IsFlightgroup() then
|
||||||
FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, nil, Altitude, false)
|
Waypoint=FLIGHTGROUP.AddWaypoint(self, Coordinate, Speed, nil, Altitude, false)
|
||||||
elseif self:IsArmygroup() then
|
elseif self:IsArmygroup() then
|
||||||
ARMYGROUP.AddWaypoint(self, Coordinate, Speed, nil, wp.action, false)
|
Waypoint=ARMYGROUP.AddWaypoint(self, Coordinate, Speed, nil, wp.action, false)
|
||||||
elseif self:IsNavygroup() then
|
elseif self:IsNavygroup() then
|
||||||
NAVYGROUP.AddWaypoint(self, Coordinate, Speed, nil, Depth, false)
|
Waypoint=NAVYGROUP.AddWaypoint(self, Coordinate, Speed, nil, Depth, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get DCS waypoint tasks set in the ME. EXPERIMENTAL!
|
||||||
|
local DCStasks=wp.task and wp.task.params.tasks or nil
|
||||||
|
if DCStasks then
|
||||||
|
for _,DCStask in pairs(DCStasks) do
|
||||||
|
-- Wrapped Actions are commands. We do not take those.
|
||||||
|
if DCStask.id and DCStask.id~="WrappedAction" then
|
||||||
|
self:AddTaskWaypoint(DCStask,Waypoint, "ME Task")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -432,9 +432,10 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo)
|
|||||||
if GroupSet:IsInstanceOf("GROUP") or GroupSet:IsInstanceOf("OPSGROUP") then
|
if GroupSet:IsInstanceOf("GROUP") or GroupSet:IsInstanceOf("OPSGROUP") then
|
||||||
|
|
||||||
-- We got a single GROUP or OPSGROUP object.
|
-- We got a single GROUP or OPSGROUP object.
|
||||||
local cargo=self:_CreateCargoGroupData(GroupSet)
|
local cargo=self:_CreateCargoGroupData(GroupSet, TransportZoneCombo)
|
||||||
|
|
||||||
if cargo then
|
if cargo then
|
||||||
|
|
||||||
-- Add to main table.
|
-- Add to main table.
|
||||||
table.insert(self.cargos, cargo)
|
table.insert(self.cargos, cargo)
|
||||||
self.Ncargo=self.Ncargo+1
|
self.Ncargo=self.Ncargo+1
|
||||||
@ -442,6 +443,7 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo)
|
|||||||
-- Add to TZC table.
|
-- Add to TZC table.
|
||||||
table.insert(TransportZoneCombo.Cargos, cargo)
|
table.insert(TransportZoneCombo.Cargos, cargo)
|
||||||
TransportZoneCombo.Ncargo=TransportZoneCombo.Ncargo+1
|
TransportZoneCombo.Ncargo=TransportZoneCombo.Ncargo+1
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -450,6 +452,10 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo)
|
|||||||
|
|
||||||
for _,group in pairs(GroupSet.Set) do
|
for _,group in pairs(GroupSet.Set) do
|
||||||
|
|
||||||
|
-- Call iteravely for each group.
|
||||||
|
self:AddCargoGroups(group, TransportZoneCombo)
|
||||||
|
|
||||||
|
--[[
|
||||||
local cargo=self:_CreateCargoGroupData(group)
|
local cargo=self:_CreateCargoGroupData(group)
|
||||||
|
|
||||||
if cargo then
|
if cargo then
|
||||||
@ -461,6 +467,7 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo)
|
|||||||
table.insert(TransportZoneCombo.Cargos, cargo)
|
table.insert(TransportZoneCombo.Cargos, cargo)
|
||||||
TransportZoneCombo.Ncargo=TransportZoneCombo.Ncargo+1
|
TransportZoneCombo.Ncargo=TransportZoneCombo.Ncargo+1
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -469,7 +476,7 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo)
|
|||||||
if self.verbose>=1 then
|
if self.verbose>=1 then
|
||||||
local text=string.format("Added cargo groups:")
|
local text=string.format("Added cargo groups:")
|
||||||
local Weight=0
|
local Weight=0
|
||||||
for _,_cargo in pairs(self.cargos) do
|
for _,_cargo in pairs(self:GetCargos()) do
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
local weight=cargo.opsgroup:GetWeightTotal()
|
local weight=cargo.opsgroup:GetWeightTotal()
|
||||||
Weight=Weight+weight
|
Weight=Weight+weight
|
||||||
@ -874,7 +881,14 @@ function OPSTRANSPORT:GetCargos(TransportZoneCombo)
|
|||||||
if TransportZoneCombo then
|
if TransportZoneCombo then
|
||||||
return TransportZoneCombo.Cargos
|
return TransportZoneCombo.Cargos
|
||||||
else
|
else
|
||||||
return self.cargos
|
local cargos={}
|
||||||
|
for _,_tzc in pairs(self.tzCombos) do
|
||||||
|
local tzc=_tzc --#OPSTRANSPORT.TransportZoneCombo
|
||||||
|
for _,cargo in pairs(tzc.Cargos) do
|
||||||
|
table.insert(cargos, cargo)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return cargos
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1316,7 +1330,7 @@ function OPSTRANSPORT:onafterStatus(From, Event, To)
|
|||||||
if self.verbose>=3 then
|
if self.verbose>=3 then
|
||||||
|
|
||||||
text=text..string.format("\nCargos:")
|
text=text..string.format("\nCargos:")
|
||||||
for _,_cargo in pairs(self.cargos) do
|
for _,_cargo in pairs(self:GetCargos()) do
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
local carrier=cargo.opsgroup:_GetMyCarrierElement()
|
local carrier=cargo.opsgroup:_GetMyCarrierElement()
|
||||||
local name=carrier and carrier.name or "none"
|
local name=carrier and carrier.name or "none"
|
||||||
@ -1472,7 +1486,7 @@ function OPSTRANSPORT:_CheckDelivered()
|
|||||||
|
|
||||||
local done=true
|
local done=true
|
||||||
local dead=true
|
local dead=true
|
||||||
for _,_cargo in pairs(self.cargos) do
|
for _,_cargo in pairs(self:GetCargos()) do
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
|
|
||||||
if cargo.delivered then
|
if cargo.delivered then
|
||||||
@ -1611,17 +1625,31 @@ end
|
|||||||
-- @param #OPSTRANSPORT self
|
-- @param #OPSTRANSPORT self
|
||||||
-- @param Wrapper.Group#GROUP group The GROUP or OPSGROUP object.
|
-- @param Wrapper.Group#GROUP group The GROUP or OPSGROUP object.
|
||||||
-- @return Ops.OpsGroup#OPSGROUP.CargoGroup Cargo group data.
|
-- @return Ops.OpsGroup#OPSGROUP.CargoGroup Cargo group data.
|
||||||
function OPSTRANSPORT:_CreateCargoGroupData(group)
|
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||||
|
function OPSTRANSPORT:_CreateCargoGroupData(group, TransportZoneCombo)
|
||||||
|
|
||||||
|
-- Get ops group.
|
||||||
local opsgroup=self:_GetOpsGroupFromObject(group)
|
local opsgroup=self:_GetOpsGroupFromObject(group)
|
||||||
|
|
||||||
|
-- First check that this group is not already contained in this TZC.
|
||||||
|
for _,_cargo in pairs(TransportZoneCombo.Cargos or {}) do
|
||||||
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
|
if cargo.opsgroup.groupname==opsgroup.groupname then
|
||||||
|
-- Group is already contained.
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Create a new data item.
|
||||||
local cargo={} --Ops.OpsGroup#OPSGROUP.CargoGroup
|
local cargo={} --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
|
|
||||||
cargo.opsgroup=opsgroup
|
cargo.opsgroup=opsgroup
|
||||||
cargo.delivered=false
|
cargo.delivered=false
|
||||||
cargo.status="Unknown"
|
cargo.status="Unknown"
|
||||||
cargo.disembarkCarrierElement=nil
|
cargo.disembarkCarrierElement=nil
|
||||||
cargo.disembarkCarrierGroup=nil
|
cargo.disembarkCarrierGroup=nil
|
||||||
|
cargo.tzcUID=TransportZoneCombo
|
||||||
|
|
||||||
return cargo
|
return cargo
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user