mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge branch 'FF/Ops' into FF/OpsDev
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **funkyfranky**
|
||||
-- ### Additions for SRS and FARP: **applevangelist**
|
||||
--
|
||||
-- @module Ops.ATIS
|
||||
-- @image OPS_ATIS.png
|
||||
@@ -615,7 +616,7 @@ _ATIS = {}
|
||||
|
||||
--- ATIS class version.
|
||||
-- @field #string version
|
||||
ATIS.version = "0.9.15"
|
||||
ATIS.version = "0.9.16"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@@ -1278,7 +1279,8 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function ATIS:onafterStart( From, Event, To )
|
||||
self:I("Airbase category is "..self.airbase:GetAirbaseCategory())
|
||||
self:T({From, Event, To})
|
||||
self:T("Airbase category is "..self.airbase:GetAirbaseCategory())
|
||||
|
||||
-- Check that this is an airdrome.
|
||||
if self.airbase:GetAirbaseCategory() == Airbase.Category.SHIP then
|
||||
@@ -1340,7 +1342,7 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function ATIS:onafterStatus( From, Event, To )
|
||||
|
||||
self:T({From, Event, To})
|
||||
-- Get FSM state.
|
||||
local fsmstate = self:GetState()
|
||||
|
||||
@@ -1362,7 +1364,7 @@ function ATIS:onafterStatus( From, Event, To )
|
||||
self:T( self.lid .. text )
|
||||
|
||||
if not self:Is("Stopped") then
|
||||
self:__Status( -60 )
|
||||
self:__Status( 60 )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1376,25 +1378,26 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function ATIS:onafterCheckQueue( From, Event, To )
|
||||
|
||||
if self.useSRS then
|
||||
|
||||
self:Broadcast()
|
||||
|
||||
else
|
||||
|
||||
if #self.radioqueue.queue == 0 then
|
||||
self:T( self.lid .. string.format( "Radio queue empty. Repeating message." ) )
|
||||
self:Broadcast()
|
||||
else
|
||||
self:T2( self.lid .. string.format( "Radio queue %d transmissions queued.", #self.radioqueue.queue ) )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
self:T({From, Event, To})
|
||||
if not self:Is("Stopped") then
|
||||
if self.useSRS then
|
||||
|
||||
self:Broadcast()
|
||||
|
||||
else
|
||||
|
||||
if #self.radioqueue.queue == 0 then
|
||||
self:T( self.lid .. string.format( "Radio queue empty. Repeating message." ) )
|
||||
self:Broadcast()
|
||||
else
|
||||
self:T2( self.lid .. string.format( "Radio queue %d transmissions queued.", #self.radioqueue.queue ) )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Check back in 5 seconds.
|
||||
self:__CheckQueue( -math.abs( self.dTQueueCheck ) )
|
||||
self:__CheckQueue( math.abs( self.dTQueueCheck ) )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1404,7 +1407,7 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function ATIS:onafterBroadcast( From, Event, To )
|
||||
|
||||
self:T({From, Event, To})
|
||||
-- Get current coordinate.
|
||||
local coord = self.airbase:GetCoordinate()
|
||||
|
||||
@@ -2156,8 +2159,9 @@ function ATIS:onafterBroadcast( From, Event, To )
|
||||
|
||||
if not self.ATISforFARPs then
|
||||
-- Active runway.
|
||||
local subtitle
|
||||
if runwayLanding then
|
||||
local subtitle=string.format("Active runway %s", runwayLanding)
|
||||
subtitle=string.format("Active runway %s", runwayLanding)
|
||||
if rwyLandingLeft==true then
|
||||
subtitle=subtitle.." Left"
|
||||
elseif rwyLandingLeft==false then
|
||||
@@ -2417,6 +2421,7 @@ end
|
||||
-- @param #string To To state.
|
||||
-- @param #string Text Report text.
|
||||
function ATIS:onafterReport( From, Event, To, Text )
|
||||
self:T({From, Event, To})
|
||||
self:T( self.lid .. string.format( "Report:\n%s", Text ) )
|
||||
|
||||
if self.useSRS and self.msrs then
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,9 @@
|
||||
--- **Ops** - Troop transport assignment for OPS groups.
|
||||
--- **Ops** - Transport assignment for OPS groups and storage.
|
||||
--
|
||||
-- ## Main Features:
|
||||
--
|
||||
-- * Transport troops from A to B
|
||||
-- * Transport of warehouse storage (fuel, weapons and equipment)
|
||||
-- * Supports ground, naval and airborne (airplanes and helicopters) units as carriers
|
||||
-- * Use combined forces (ground, naval, air) to transport the troops
|
||||
-- * Additional FSM events to hook into and customize your mission design
|
||||
@@ -63,6 +64,7 @@
|
||||
-- @field Ops.Chief#CHIEF chief Chief of the transport.
|
||||
-- @field Ops.OpsZone#OPSZONE opszone OPS zone.
|
||||
-- @field #table requestID The ID of the queued warehouse request. Necessary to cancel the request if the transport was cancelled before the request is processed.
|
||||
-- @field #number cargocounter Running number to generate cargo UIDs.
|
||||
--
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
@@ -79,7 +81,7 @@
|
||||
-- * Cargo groups are **not** split and distributed into different carrier *units*. That means that the whole cargo group **must fit** into one of the carrier units.
|
||||
-- * Cargo groups must be inside the pickup zones to be considered for loading. Groups not inside the pickup zone will not get the command to board.
|
||||
--
|
||||
-- # Constructor
|
||||
-- # Troop Transport
|
||||
--
|
||||
-- A new cargo transport assignment is created with the @{#OPSTRANSPORT.New}() function
|
||||
--
|
||||
@@ -101,6 +103,30 @@
|
||||
--
|
||||
-- You can also mix carrier types. For instance, you can assign the same transport to APCs and helicopters. Or to helicopters and airplanes.
|
||||
--
|
||||
-- # Storage Transport
|
||||
--
|
||||
-- An instance of the OPSTRANSPORT class is created similarly to the troop transport case. However, the first parameter is `nil` as not troops
|
||||
-- are transported.
|
||||
--
|
||||
-- local storagetransport=OPSTRANSPORT:New(nil, PickupZone, DeployZone)
|
||||
--
|
||||
-- ## Defining Storage
|
||||
--
|
||||
-- The storage warehouses from which the cargo is taken and to which the cargo is delivered have to be specified
|
||||
--
|
||||
-- storagetransport:AddCargoStorage(berlinStorage, batumiStorage, STORAGE.Liquid.JETFUEL, 1000)
|
||||
--
|
||||
-- Here `berlinStorage` and `batumiStorage` are @{Wrapper.Storage#STORAGE} objects of DCS warehouses.
|
||||
--
|
||||
-- Furthermore, that type of cargo (liquids or weapons/equipment) and the amount has to be specified. If weapons/equipment is the cargo,
|
||||
-- we also need to specify the weight per storage item as this cannot be retrieved from the DCS API and is not stored in any MOOSE database.
|
||||
--
|
||||
-- storagetransport:AddCargoStorage(berlinStorage, batumiStorage, ENUMS.Storage.weapons.bombs.Mk_82, 9, 230)
|
||||
--
|
||||
-- Finally, the transport is assigned to one or multiple groups, which carry out the transport
|
||||
--
|
||||
-- myopsgroup:AddOpsTransport(storagetransport)
|
||||
--
|
||||
-- # Examples
|
||||
--
|
||||
-- A carrier group is assigned to transport infantry troops from zone "Zone Kobuleti X" to zone "Zone Alpha".
|
||||
@@ -131,6 +157,7 @@ OPSTRANSPORT = {
|
||||
legions = {},
|
||||
statusLegion = {},
|
||||
requestID = {},
|
||||
cargocounter = 0,
|
||||
}
|
||||
|
||||
--- Cargo transport status.
|
||||
@@ -186,6 +213,27 @@ OPSTRANSPORT.Status={
|
||||
-- @field #number radius Radomization radius for waypoints in meters. Default 0 m.
|
||||
-- @field #boolean reverse If `true`, path is used in reversed order.
|
||||
|
||||
--- Storage data.
|
||||
-- @type OPSTRANSPORT.Storage
|
||||
-- @field Wrapper.Storage#STORAGE storageFrom Storage from.
|
||||
-- @field Wrapper.Storage#STORAGE storageTo Storage To.
|
||||
-- @field #string cargoType Type of cargo.
|
||||
-- @field #number cargoAmount Amount of cargo that should be transported.
|
||||
-- @field #number cargoReserved Amount of cargo that is reserved for a carrier group.
|
||||
-- @field #number cargoDelivered Amount of cargo that has been delivered.
|
||||
-- @field #number cargoLost Amount of cargo that was lost.
|
||||
-- @field #number cargoLoaded Amount of cargo that is loading.
|
||||
-- @field #number cargoWeight Weight of one single cargo item in kg. Default 1 kg.
|
||||
|
||||
--- Storage data.
|
||||
-- @type OPSTRANSPORT.CargoType
|
||||
-- @field #string OPSGROUP Cargo is an OPSGROUP.
|
||||
-- @field #string STORAGE Cargo is storage of DCS warehouse.
|
||||
OPSTRANSPORT.CargoType={
|
||||
OPSGROUP="OPSGROUP",
|
||||
STORAGE="STORAGE",
|
||||
}
|
||||
|
||||
--- Generic transport condition.
|
||||
-- @type OPSTRANSPORT.Condition
|
||||
-- @field #function func Callback function to check for a condition. Should return a #boolean.
|
||||
@@ -196,7 +244,7 @@ _OPSTRANSPORTID=0
|
||||
|
||||
--- Army Group version.
|
||||
-- @field #string version
|
||||
OPSTRANSPORT.version="0.7.0"
|
||||
OPSTRANSPORT.version="0.8.0"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@@ -205,6 +253,7 @@ OPSTRANSPORT.version="0.7.0"
|
||||
-- TODO: Trains.
|
||||
-- TODO: Stop transport.
|
||||
-- TODO: Improve pickup and transport paths.
|
||||
-- DONE: Storage.
|
||||
-- DONE: Disembark parameters per cargo group.
|
||||
-- DONE: Special transport cohorts/legions. Similar to mission.
|
||||
-- DONE: Cancel transport.
|
||||
@@ -576,6 +625,38 @@ function OPSTRANSPORT:AddCargoGroups(GroupSet, TransportZoneCombo, DisembarkActi
|
||||
return self
|
||||
end
|
||||
|
||||
--- Add cargo warehouse storage to be transported. This adds items such as fuel, weapons and other equipment, which is to be transported
|
||||
-- from one DCS warehouse to another.
|
||||
-- For weapons and equipment, the weight per item has to be specified explicitly as these cannot be retrieved by the DCS API. For liquids the
|
||||
-- default value of 1 kg per item should be used as the amount of liquid is already given in kg.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param Wrapper.Storage#STORAGE StorageFrom Storage warehouse from which the cargo is taken.
|
||||
-- @param Wrapper.Storage#STORAGE StorageTo Storage warehouse to which the cargo is delivered.
|
||||
-- @param #string CargoType Type of cargo, *e.g.* `"weapons.bombs.Mk_84"` or liquid type as #number.
|
||||
-- @param #number CargoAmount Amount of cargo. Liquids in kg.
|
||||
-- @param #number CargoWeight Weight of a single cargo item in kg. Default 1 kg.
|
||||
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo if other than default.
|
||||
-- @return #OPSTRANSPORT self
|
||||
function OPSTRANSPORT:AddCargoStorage(StorageFrom, StorageTo, CargoType, CargoAmount, CargoWeight, TransportZoneCombo)
|
||||
|
||||
-- Use default TZC if no transport zone combo is provided.
|
||||
TransportZoneCombo=TransportZoneCombo or self.tzcDefault
|
||||
|
||||
-- Cargo data.
|
||||
local cargo=self:_CreateCargoStorage(StorageFrom,StorageTo, CargoType, CargoAmount, CargoWeight, TransportZoneCombo)
|
||||
|
||||
if cargo then
|
||||
|
||||
-- Add total amount of ever assigned cargos.
|
||||
self.Ncargo=self.Ncargo+1
|
||||
|
||||
-- Add to TZC table.
|
||||
table.insert(TransportZoneCombo.Cargos, cargo)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Set pickup zone.
|
||||
-- @param #OPSTRANSPORT self
|
||||
@@ -1063,16 +1144,14 @@ end
|
||||
-- @return #table Cargo Ops groups. Can be and empty table `{}`.
|
||||
function OPSTRANSPORT:GetCargoOpsGroups(Delivered, Carrier, TransportZoneCombo)
|
||||
|
||||
local cargos=self:GetCargos(TransportZoneCombo)
|
||||
local cargos=self:GetCargos(TransportZoneCombo, Carrier, Delivered)
|
||||
|
||||
local opsgroups={}
|
||||
for _,_cargo in pairs(cargos) do
|
||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||
if Delivered==nil or cargo.delivered==Delivered then
|
||||
if cargo.type=="OPSGROUP" then
|
||||
if cargo.opsgroup and not (cargo.opsgroup:IsDead() or cargo.opsgroup:IsStopped()) then
|
||||
if Carrier==nil or Carrier:CanCargo(cargo.opsgroup) then
|
||||
table.insert(opsgroups, cargo.opsgroup)
|
||||
end
|
||||
table.insert(opsgroups, cargo.opsgroup)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1080,6 +1159,27 @@ function OPSTRANSPORT:GetCargoOpsGroups(Delivered, Carrier, TransportZoneCombo)
|
||||
return opsgroups
|
||||
end
|
||||
|
||||
--- Get (all) cargo @{Ops.OpsGroup#OPSGROUP}s. Optionally, only delivered or undelivered groups can be returned.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param #boolean Delivered If `true`, only delivered groups are returned. If `false` only undelivered groups are returned. If `nil`, all groups are returned.
|
||||
-- @param Ops.OpsGroup#OPSGROUP Carrier (Optional) Only count cargo groups that fit into the given carrier group. Current cargo is not a factor.
|
||||
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||
-- @return #table Cargo Ops groups. Can be and empty table `{}`.
|
||||
function OPSTRANSPORT:GetCargoStorages(Delivered, Carrier, TransportZoneCombo)
|
||||
|
||||
local cargos=self:GetCargos(TransportZoneCombo, Carrier, Delivered)
|
||||
|
||||
local opsgroups={}
|
||||
for _,_cargo in pairs(cargos) do
|
||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||
if cargo.type=="STORAGE" then
|
||||
table.insert(opsgroups, cargo.storage)
|
||||
end
|
||||
end
|
||||
|
||||
return opsgroups
|
||||
end
|
||||
|
||||
--- Get carriers.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @return #table Carrier Ops groups.
|
||||
@@ -1090,22 +1190,60 @@ end
|
||||
--- Get cargos.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||
-- @param Ops.OpsGroup#OPSGROUP Carrier Specific carrier.
|
||||
-- @param #boolean Delivered Delivered status.
|
||||
-- @return #table Cargos.
|
||||
function OPSTRANSPORT:GetCargos(TransportZoneCombo)
|
||||
|
||||
function OPSTRANSPORT:GetCargos(TransportZoneCombo, Carrier, Delivered)
|
||||
|
||||
local tczs=self.tzCombos
|
||||
if TransportZoneCombo then
|
||||
return TransportZoneCombo.Cargos
|
||||
else
|
||||
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
|
||||
tczs={TransportZoneCombo}
|
||||
end
|
||||
|
||||
local cargos={}
|
||||
for _,_tcz in pairs(tczs) do
|
||||
local tcz=_tcz --#OPSTRANSPORT.TransportZoneCombo
|
||||
for _,_cargo in pairs(tcz.Cargos) do
|
||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||
if Delivered==nil or cargo.delivered==Delivered then
|
||||
if Carrier==nil or Carrier:CanCargo(cargo) then
|
||||
table.insert(cargos, cargo)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return cargos
|
||||
end
|
||||
|
||||
--- Get total weight.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param Ops.OpsGroup#OPSGROUP.CargoGroup Cargo Cargo data.
|
||||
-- @param #boolean IncludeReserved Include reserved cargo.
|
||||
-- @return #number Weight in kg.
|
||||
function OPSTRANSPORT:GetCargoTotalWeight(Cargo, IncludeReserved)
|
||||
|
||||
local weight=0
|
||||
|
||||
if Cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
|
||||
weight=Cargo.opsgroup:GetWeightTotal(nil, IncludeReserved)
|
||||
else
|
||||
if type(Cargo.storage.cargoType)=="number" then
|
||||
if IncludeReserved then
|
||||
return Cargo.storage.cargoAmount+Cargo.storage.cargoReserved
|
||||
else
|
||||
return Cargo.storage.cargoAmount
|
||||
end
|
||||
else
|
||||
if IncludeReserved then
|
||||
return Cargo.storage.cargoAmount*100 -- Assume 100 kg per item
|
||||
else
|
||||
return (Cargo.storage.cargoAmount+Cargo.storage.cargoReserved)*100 -- Assume 100 kg per item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return weight
|
||||
end
|
||||
|
||||
--- Set transport start and stop time.
|
||||
@@ -1642,11 +1780,18 @@ function OPSTRANSPORT:onafterStatusUpdate(From, Event, To)
|
||||
text=text..string.format("\nCargos:")
|
||||
for _,_cargo in pairs(self:GetCargos()) do
|
||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||
local carrier=cargo.opsgroup:_GetMyCarrierElement()
|
||||
local name=carrier and carrier.name or "none"
|
||||
local cstate=carrier and carrier.status or "N/A"
|
||||
text=text..string.format("\n- %s: %s [%s], weight=%d kg, carrier=%s [%s], delivered=%s [UID=%s]",
|
||||
cargo.opsgroup:GetName(), cargo.opsgroup.cargoStatus:upper(), cargo.opsgroup:GetState(), cargo.opsgroup:GetWeightTotal(), name, cstate, tostring(cargo.delivered), tostring(cargo.opsgroup.cargoTransportUID))
|
||||
if cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
|
||||
local carrier=cargo.opsgroup:_GetMyCarrierElement()
|
||||
local name=carrier and carrier.name or "none"
|
||||
local cstate=carrier and carrier.status or "N/A"
|
||||
text=text..string.format("\n- %s: %s [%s], weight=%d kg, carrier=%s [%s], delivered=%s [UID=%s]",
|
||||
cargo.opsgroup:GetName(), cargo.opsgroup.cargoStatus:upper(), cargo.opsgroup:GetState(), cargo.opsgroup:GetWeightTotal(), name, cstate, tostring(cargo.delivered), tostring(cargo.opsgroup.cargoTransportUID))
|
||||
else
|
||||
--TODO: Storage
|
||||
local storage=cargo.storage
|
||||
text=text..string.format("\n- storage type=%s: amount: total=%d loaded=%d, lost=%d, delivered=%d, delivered=%s [UID=%s]",
|
||||
storage.cargoType, storage.cargoAmount, storage.cargoLoaded, storage.cargoLost, storage.cargoDelivered, tostring(cargo.delivered), tostring(cargo.uid))
|
||||
end
|
||||
end
|
||||
|
||||
text=text..string.format("\nCarriers:")
|
||||
@@ -1923,14 +2068,14 @@ function OPSTRANSPORT:_CheckDelivered()
|
||||
if cargo.delivered then
|
||||
-- This one is delivered.
|
||||
dead=false
|
||||
elseif cargo.opsgroup==nil then
|
||||
elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup==nil then
|
||||
-- This one is nil?!
|
||||
dead=false
|
||||
elseif cargo.opsgroup:IsDestroyed() then
|
||||
elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup:IsDestroyed() then
|
||||
-- This one was destroyed.
|
||||
elseif cargo.opsgroup:IsDead() then
|
||||
elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup:IsDead() then
|
||||
-- This one is dead.
|
||||
elseif cargo.opsgroup:IsStopped() then
|
||||
elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup:IsStopped() then
|
||||
-- This one is stopped.
|
||||
dead=false
|
||||
else
|
||||
@@ -2116,10 +2261,12 @@ function OPSTRANSPORT:_CreateCargoGroupData(group, TransportZoneCombo, Disembark
|
||||
end
|
||||
end
|
||||
|
||||
self.cargocounter=self.cargocounter+1
|
||||
|
||||
-- Create a new data item.
|
||||
local cargo={} --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||
|
||||
cargo.uid=self.cargocounter
|
||||
cargo.type="OPSGROUP"
|
||||
cargo.opsgroup=opsgroup
|
||||
cargo.delivered=false
|
||||
cargo.status="Unknown"
|
||||
@@ -2133,6 +2280,45 @@ function OPSTRANSPORT:_CreateCargoGroupData(group, TransportZoneCombo, Disembark
|
||||
return cargo
|
||||
end
|
||||
|
||||
--- Create a cargo group data structure.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param Wrapper.Storage#STORAGE StorageFrom Storage from.
|
||||
-- @param Wrapper.Storage#STORAGE StorageTo Storage to.
|
||||
-- @param #string CargoType Type of cargo.
|
||||
-- @param #number CargoAmount Total amount of cargo that should be transported. Liquids in kg.
|
||||
-- @param #number CargoWeight Weight of a single cargo item in kg. Default 1 kg.
|
||||
-- @param #OPSTRANSPORT.TransportZoneCombo TransportZoneCombo Transport zone combo.
|
||||
-- @return Ops.OpsGroup#OPSGROUP.CargoGroup Cargo group data.
|
||||
function OPSTRANSPORT:_CreateCargoStorage(StorageFrom, StorageTo, CargoType, CargoAmount, CargoWeight, TransportZoneCombo)
|
||||
|
||||
local storage={} --#OPSTRANSPORT.Storage
|
||||
storage.storageFrom=StorageFrom
|
||||
storage.storageTo=StorageTo
|
||||
storage.cargoType=CargoType
|
||||
storage.cargoAmount=CargoAmount
|
||||
storage.cargoDelivered=0
|
||||
storage.cargoLost=0
|
||||
storage.cargoReserved=0
|
||||
storage.cargoLoaded=0
|
||||
storage.cargoWeight=CargoWeight or 1
|
||||
|
||||
self.cargocounter=self.cargocounter+1
|
||||
|
||||
-- Create a new data item.
|
||||
local cargo={} --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||
cargo.uid=self.cargocounter
|
||||
cargo.type="STORAGE"
|
||||
cargo.opsgroup=nil
|
||||
cargo.storage=storage
|
||||
cargo.delivered=false
|
||||
cargo.status="Unknown"
|
||||
cargo.tzcUID=TransportZoneCombo
|
||||
cargo.disembarkZone=nil
|
||||
cargo.disembarkCarriers=nil
|
||||
|
||||
return cargo
|
||||
end
|
||||
|
||||
--- Count how many cargo groups are inside a zone.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param Core.Zone#ZONE Zone The zone object.
|
||||
@@ -2143,7 +2329,9 @@ end
|
||||
function OPSTRANSPORT:_CountCargosInZone(Zone, Delivered, Carrier, TransportZoneCombo)
|
||||
|
||||
-- Get cargo ops groups.
|
||||
local cargos=self:GetCargoOpsGroups(Delivered, Carrier, TransportZoneCombo)
|
||||
--local cargos=self:GetCargoOpsGroups(Delivered, Carrier, TransportZoneCombo)
|
||||
|
||||
local cargos=self:GetCargos(TransportZoneCombo, Carrier, Delivered)
|
||||
|
||||
--- Function to check if carrier is supposed to be disembarked to.
|
||||
local function iscarrier(_cargo)
|
||||
@@ -2185,22 +2373,33 @@ function OPSTRANSPORT:_CountCargosInZone(Zone, Delivered, Carrier, TransportZone
|
||||
|
||||
local N=0
|
||||
for _,_cargo in pairs(cargos) do
|
||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP
|
||||
|
||||
-- Is not cargo?
|
||||
local isNotCargo=cargo:IsNotCargo(true)
|
||||
if not isNotCargo then
|
||||
isNotCargo=iscarrier(cargo)
|
||||
end
|
||||
|
||||
-- Is in zone?
|
||||
local isInZone=cargo:IsInZone(Zone)
|
||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||
|
||||
-- Is in utero?
|
||||
local isInUtero=cargo:IsInUtero()
|
||||
local isNotCargo=true
|
||||
local isInZone=true
|
||||
local isInUtero=true
|
||||
|
||||
if cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
|
||||
local opsgroup=cargo.opsgroup
|
||||
|
||||
-- Is not cargo?
|
||||
isNotCargo=opsgroup:IsNotCargo(true)
|
||||
if not isNotCargo then
|
||||
isNotCargo=iscarrier(opsgroup)
|
||||
end
|
||||
|
||||
-- Is in zone?
|
||||
isInZone=opsgroup:IsInZone(Zone)
|
||||
|
||||
-- Is in utero?
|
||||
isInUtero=opsgroup:IsInUtero()
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Cargo=%s: notcargo=%s, iscarrier=%s inzone=%s, inutero=%s", opsgroup:GetName(), tostring(opsgroup:IsNotCargo(true)), tostring(iscarrier(opsgroup)), tostring(isInZone), tostring(isInUtero)))
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Cargo=%s: notcargo=%s, iscarrier=%s inzone=%s, inutero=%s", cargo:GetName(), tostring(cargo:IsNotCargo(true)), tostring(iscarrier(cargo)), tostring(isInZone), tostring(isInUtero)))
|
||||
|
||||
-- We look for groups that are not cargo, in the zone or in utero.
|
||||
if isNotCargo and (isInZone or isInUtero) then
|
||||
|
||||
@@ -104,7 +104,7 @@ PLAYERRECCE = {
|
||||
ClassName = "PLAYERRECCE",
|
||||
verbose = true,
|
||||
lid = nil,
|
||||
version = "0.0.17",
|
||||
version = "0.0.18",
|
||||
ViewZone = {},
|
||||
ViewZoneVisual = {},
|
||||
ViewZoneLaser = {},
|
||||
@@ -807,6 +807,7 @@ function PLAYERRECCE:_SetClientLaserCode(client,group,playername,code)
|
||||
self.ClientMenus[playername]:Remove()
|
||||
self.ClientMenus[playername]=nil
|
||||
end
|
||||
self:_BuildMenus()
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -829,6 +830,7 @@ function PLAYERRECCE:_SwitchOnStation(client,group,playername)
|
||||
self.ClientMenus[playername]:Remove()
|
||||
self.ClientMenus[playername]=nil
|
||||
end
|
||||
self:_BuildMenus(client)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -851,6 +853,7 @@ function PLAYERRECCE:_SwitchSmoke(client,group,playername)
|
||||
self.ClientMenus[playername]:Remove()
|
||||
self.ClientMenus[playername]=nil
|
||||
end
|
||||
self:_BuildMenus(client)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -873,6 +876,7 @@ function PLAYERRECCE:_SwitchLasing(client,group,playername)
|
||||
self.ClientMenus[playername]:Remove()
|
||||
self.ClientMenus[playername]=nil
|
||||
end
|
||||
self:_BuildMenus(client)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -902,6 +906,7 @@ function PLAYERRECCE:_SwitchLasingDist(client,group,playername,mindist,maxdist)
|
||||
self.ClientMenus[playername]:Remove()
|
||||
self.ClientMenus[playername]=nil
|
||||
end
|
||||
self:_BuildMenus(client)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -930,6 +935,8 @@ function PLAYERRECCE:_SmokeTargets(client,group,playername)
|
||||
|
||||
if cameraset:CountAlive() > 0 then
|
||||
self:__TargetsSmoked(-1,client,playername,cameraset)
|
||||
else
|
||||
return self
|
||||
end
|
||||
|
||||
local highsmoke = self.SmokeColor.highsmoke
|
||||
@@ -1068,7 +1075,7 @@ self:T(self.lid.."_ReportLaserTargets")
|
||||
if number > 0 and self.AutoLase[playername] then
|
||||
local Settings = ( client and _DATABASE:GetPlayerSettings( playername ) ) or _SETTINGS
|
||||
local target = self:_GetHVTTarget(targetset) -- the one we're lasing
|
||||
local ThreatLevel = target:GetThreatLevel()
|
||||
local ThreatLevel = target:GetThreatLevel() or 1
|
||||
local ThreatLevelText = "high"
|
||||
if ThreatLevel > 3 and ThreatLevel < 8 then
|
||||
ThreatLevelText = "medium"
|
||||
@@ -1078,7 +1085,7 @@ self:T(self.lid.."_ReportLaserTargets")
|
||||
local ThreatGraph = "[" .. string.rep( "■", ThreatLevel ) .. string.rep( "□", 10 - ThreatLevel ) .. "]: "..ThreatLevel
|
||||
local report = REPORT:New("Lasing Report")
|
||||
report:Add(string.rep("-",15))
|
||||
report:Add("Target type: "..target:GetTypeName())
|
||||
report:Add("Target type: "..target:GetTypeName() or "unknown")
|
||||
report:Add("Threat Level: "..ThreatGraph.." ("..ThreatLevelText..")")
|
||||
if not self.ReferencePoint then
|
||||
report:Add("Location: "..client:GetCoordinate():ToStringBULLS(self.Coalition,Settings))
|
||||
@@ -1088,14 +1095,14 @@ self:T(self.lid.."_ReportLaserTargets")
|
||||
report:Add("Laser Code: "..self.UnitLaserCodes[playername] or 1688)
|
||||
report:Add(string.rep("-",15))
|
||||
local text = report:Text()
|
||||
self:__TargetReport(-1,client,targetset,target,text)
|
||||
self:__TargetReport(1,client,targetset,target,text)
|
||||
else
|
||||
local report = REPORT:New("Lasing Report")
|
||||
report:Add(string.rep("-",15))
|
||||
report:Add("N O T A R G E T S")
|
||||
report:Add(string.rep("-",15))
|
||||
local text = report:Text()
|
||||
self:__TargetReport(-1,client,nil,nil,text)
|
||||
self:__TargetReport(1,client,nil,nil,text)
|
||||
end
|
||||
return self
|
||||
end
|
||||
@@ -1130,25 +1137,27 @@ function PLAYERRECCE:_ReportVisualTargets(client,group,playername)
|
||||
end
|
||||
report:Add(string.rep("-",15))
|
||||
local text = report:Text()
|
||||
self:__TargetReport(-1,client,targetset,nil,text)
|
||||
self:__TargetReport(1,client,targetset,nil,text)
|
||||
else
|
||||
local report = REPORT:New("Target Report")
|
||||
report:Add(string.rep("-",15))
|
||||
report:Add("N O T A R G E T S")
|
||||
report:Add(string.rep("-",15))
|
||||
local text = report:Text()
|
||||
self:__TargetReport(-1,client,nil,nil,text)
|
||||
self:__TargetReport(1,client,nil,nil,text)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- [Internal]
|
||||
--- [Internal] Build Menus
|
||||
-- @param #PLAYERRECCE self
|
||||
-- @param #PLAYERRECCE self
|
||||
function PLAYERRECCE:_BuildMenus()
|
||||
-- @param Wrapper.Client#CLIENT Client (optional) Client object
|
||||
-- @return #PLAYERRECCE self
|
||||
function PLAYERRECCE:_BuildMenus(Client)
|
||||
self:T(self.lid.."_BuildMenus")
|
||||
local clients = self.PlayerSet -- Core.Set#SET_CLIENT
|
||||
local clientset = clients:GetSetObjects()
|
||||
if Client then clientset = {Client} end
|
||||
for _,_client in pairs(clientset) do
|
||||
local client = _client -- Wrapper.Client#CLIENT
|
||||
if client and client:IsAlive() then
|
||||
@@ -1156,7 +1165,7 @@ function PLAYERRECCE:_BuildMenus()
|
||||
if not self.UnitLaserCodes[playername] then
|
||||
self:_SetClientLaserCode(nil,nil,playername,1688)
|
||||
end
|
||||
if not self.SmokeOwn[playername] then
|
||||
if self.SmokeOwn[playername] == nil then
|
||||
self.SmokeOwn[playername] = self.smokeownposition
|
||||
end
|
||||
local group = client:GetGroup()
|
||||
@@ -1919,7 +1928,7 @@ function PLAYERRECCE:onafterTargetReport(From, Event, To, Client, TargetSet, Tar
|
||||
-- send message to AttackSet
|
||||
for _,_client in pairs(self.AttackSet.Set) do
|
||||
local client = _client -- Wrapper.Client#CLIENT
|
||||
if client and client:IsAlive() then
|
||||
if client and client:IsAlive() and client ~= Client then
|
||||
MESSAGE:New(Text,45,self.Name or "FACA"):ToClient(client)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user