mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OPSTRANSPORT
This commit is contained in:
parent
978be4e383
commit
36669c80da
@ -1474,7 +1474,7 @@ function FLIGHTGROUP:onafterElementTakeoff(From, Event, To, Element, airbase)
|
||||
self:_UpdateStatus(Element, OPSGROUP.ElementStatus.TAKEOFF, airbase)
|
||||
|
||||
-- Trigger element airborne event.
|
||||
self:__ElementAirborne(2, Element)
|
||||
self:__ElementAirborne(0.1, Element)
|
||||
end
|
||||
|
||||
--- On after "ElementAirborne" event.
|
||||
@ -1749,7 +1749,7 @@ function FLIGHTGROUP:onafterAirborne(From, Event, To)
|
||||
self:LandAtAirbase(airbase)
|
||||
end
|
||||
else
|
||||
self:_CheckGroupDone(1)
|
||||
self:_CheckGroupDone()
|
||||
end
|
||||
else
|
||||
self:_UpdateMenu()
|
||||
@ -2194,7 +2194,8 @@ function FLIGHTGROUP:_CheckGroupDone(delay)
|
||||
-- Send flight to destination.
|
||||
if destbase then
|
||||
self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports ==> RTB!")
|
||||
self:__RTB(-3, destbase)
|
||||
--self:RTB(destbase)
|
||||
self:__RTB(-0.1, destbase)
|
||||
elseif destzone then
|
||||
self:T(self.lid.."Passed Final WP and No current and/or future missions/tasks/transports ==> RTZ!")
|
||||
self:__RTZ(-3, destzone)
|
||||
@ -2378,6 +2379,9 @@ function FLIGHTGROUP:_LandAtAirbase(airbase, SpeedTo, SpeedHold, SpeedLand)
|
||||
|
||||
-- Holding points.
|
||||
local c0=self.group:GetCoordinate()
|
||||
local zone=airbase:GetZone()
|
||||
env.info("FF landatairbase zone:")
|
||||
self:I({zone=zone})
|
||||
local p0=airbase:GetZone():GetRandomCoordinate():SetAltitude(UTILS.FeetToMeters(althold))
|
||||
local p1=nil
|
||||
local wpap=nil
|
||||
@ -3075,8 +3079,8 @@ function FLIGHTGROUP:_InitGroup()
|
||||
self:I(self.lid..text)
|
||||
end
|
||||
|
||||
env.info("DCS Unit BOOM_AND_RECEPTACLE="..tostring(Unit.RefuelingSystem.BOOM_AND_RECEPTACLE))
|
||||
env.info("DCS Unit PROBE_AND_DROGUE="..tostring(Unit.RefuelingSystem.PROBE_AND_DROGUE))
|
||||
--env.info("DCS Unit BOOM_AND_RECEPTACLE="..tostring(Unit.RefuelingSystem.BOOM_AND_RECEPTACLE))
|
||||
--env.info("DCS Unit PROBE_AND_DROGUE="..tostring(Unit.RefuelingSystem.PROBE_AND_DROGUE))
|
||||
|
||||
-- Init done.
|
||||
self.groupinitialized=true
|
||||
@ -3711,6 +3715,8 @@ end
|
||||
-- @return Wrapper.Airbase#AIRBASE.ParkingSpot Parking spot or nil if no spot is within distance threshold.
|
||||
function FLIGHTGROUP:GetParkingSpot(element, maxdist, airbase)
|
||||
|
||||
env.info("FF Get Parking spot for element "..element.name)
|
||||
|
||||
-- Coordinate of unit landed
|
||||
local coord=element.unit:GetCoordinate()
|
||||
|
||||
@ -3724,7 +3730,8 @@ function FLIGHTGROUP:GetParkingSpot(element, maxdist, airbase)
|
||||
if airbase and airbase:IsShip() then
|
||||
coord.x=0
|
||||
coord.z=0
|
||||
maxdist=100
|
||||
maxdist=500 -- 100 meters was not enough, e.g. on the Seawise Giant, where the spot is 139 meters from the "center"
|
||||
env.info("FF Airbase is ship")
|
||||
end
|
||||
|
||||
local spot=nil --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||
@ -3733,6 +3740,7 @@ function FLIGHTGROUP:GetParkingSpot(element, maxdist, airbase)
|
||||
for _,_parking in pairs(parking) do
|
||||
local parking=_parking --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||
dist=coord:Get2DDistance(parking.Coordinate)
|
||||
env.info(string.format("FF parking %d dist=%.1f", parking.TerminalID, dist))
|
||||
if dist<distmin then
|
||||
distmin=dist
|
||||
spot=_parking
|
||||
|
||||
@ -113,7 +113,8 @@
|
||||
-- @field #table cargoBay Table containing OPSGROUP loaded into this group.
|
||||
-- @field Ops.OpsTransport#OPSTRANSPORT cargoTransport Current cargo transport assignment.
|
||||
-- @field #string cargoStatus Cargo status of this group acting as cargo.
|
||||
-- @field #string carrierStatus Carrier status of this group acting as cargo carrier.
|
||||
-- @field #number cargoTransportUID Unique ID of the transport assignment this cargo group is associated with.
|
||||
-- @field #string carrierStatus Carrier status of this group acting as cargo carrier.
|
||||
-- @field #number cargocounter Running number of cargo UIDs.
|
||||
-- @field #OPSGROUP.CarrierLoader carrierLoader Carrier loader parameters.
|
||||
-- @field #OPSGROUP.CarrierLoader carrierUnloader Carrier unloader parameters.
|
||||
@ -1785,9 +1786,14 @@ end
|
||||
|
||||
--- Check if the group is **not** cargo.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #boolean CheckTransport If true or nil, also check if cargo is associated with a transport assignment. If not, we consider it not cargo.
|
||||
-- @return #boolean If true, group is *not* cargo.
|
||||
function OPSGROUP:IsNotCargo()
|
||||
return self.cargoStatus==OPSGROUP.CargoStatus.NOTCARGO
|
||||
function OPSGROUP:IsNotCargo(CheckTransport)
|
||||
local notcargo=self.cargoStatus==OPSGROUP.CargoStatus.NOTCARGO
|
||||
if self.cargoTransportUID==nil then
|
||||
notcargo=true
|
||||
end
|
||||
return notcargo
|
||||
end
|
||||
|
||||
--- Check if the group is currently boarding a carrier.
|
||||
@ -4575,7 +4581,7 @@ function OPSGROUP:onafterElementDead(From, Event, To, Element)
|
||||
|
||||
if self:IsCarrier() then
|
||||
if self.cargoTransport then
|
||||
self.cargoTransport:CarrierGroupDead()
|
||||
self.cargoTransport:DeadCarrierGroup(self)
|
||||
end
|
||||
end
|
||||
|
||||
@ -5349,9 +5355,14 @@ end
|
||||
-- @param #boolean Reserved If `true`, reserve space for me.
|
||||
function OPSGROUP:_SetMyCarrier(CarrierGroup, CarrierElement, Reserved)
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Setting My Carrier: %s (%s), reserved=%s", CarrierGroup:GetName(), tostring(CarrierElement.name), tostring(Reserved)))
|
||||
|
||||
self.mycarrier.group=CarrierGroup
|
||||
self.mycarrier.element=CarrierElement
|
||||
self.mycarrier.reserved=Reserved
|
||||
|
||||
self.cargoTransportUID=CarrierGroup.cargoTransport and CarrierGroup.cargoTransport.uid or nil
|
||||
|
||||
end
|
||||
|
||||
@ -5405,6 +5416,7 @@ function OPSGROUP:_RemoveMyCarrier()
|
||||
self.mycarrier.element=nil
|
||||
self.mycarrier.reserved=nil
|
||||
self.mycarrier={}
|
||||
self.cargoTransportUID=nil
|
||||
return self
|
||||
end
|
||||
|
||||
@ -5582,9 +5594,9 @@ function OPSGROUP:onafterLoading(From, Event, To)
|
||||
-- Check that cargo weight is
|
||||
if self:CanCargo(cargo.opsgroup) and not (cargo.delivered or cargo.opsgroup:IsDead()) then
|
||||
|
||||
-- Check that group is not cargo already and not busy.
|
||||
-- Check that group is NOT cargo and NOT acting as carrier already
|
||||
-- TODO: Need a better :IsBusy() function or :IsReadyForMission() :IsReadyForBoarding() :IsReadyForTransport()
|
||||
if cargo.opsgroup:IsNotCargo() and not (cargo.opsgroup:IsPickingup() or cargo.opsgroup:IsLoading() or cargo.opsgroup:IsTransporting() or cargo.opsgroup:IsUnloading() or cargo.opsgroup:IsLoaded()) then
|
||||
if cargo.opsgroup:IsNotCargo() and not (cargo.opsgroup:IsPickingup() or cargo.opsgroup:IsLoading() or cargo.opsgroup:IsTransporting() or cargo.opsgroup:IsUnloading()) then
|
||||
|
||||
-- Check if cargo is in embark/pickup zone.
|
||||
local inzone=self.cargoTransport.embarkzone:IsCoordinateInZone(cargo.opsgroup:GetCoordinate())
|
||||
@ -5640,6 +5652,22 @@ function OPSGROUP:ClearWaypoints()
|
||||
self.waypoints={}
|
||||
end
|
||||
|
||||
--- Transfer cargo from to another carrier.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #OPSGROUP CargoGroup The cargo group to be transferred.
|
||||
-- @param #OPSGROUP CarrierGroup The new carrier group.
|
||||
-- @param #OPSGROUP.Element CarrierElement The new carrier element.
|
||||
function OPSGROUP:_TransferCargo(CargoGroup, CarrierGroup, CarrierElement)
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Transferring cargo %s to new carrier group %s", CargoGroup:GetName(), CarrierGroup:GetName()))
|
||||
|
||||
-- Unload from this and directly load into the other carrier.
|
||||
self:Unload(CargoGroup)
|
||||
CarrierGroup:Load(CargoGroup, CarrierElement)
|
||||
|
||||
end
|
||||
|
||||
--- On after "Load" event. Carrier loads a cargo group into ints cargo bay.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #string From From state.
|
||||
@ -5690,7 +5718,11 @@ function OPSGROUP:onafterLoad(From, Event, To, CargoGroup, Carrier)
|
||||
CargoGroup:Embarked(self, carrier)
|
||||
|
||||
-- Trigger "Loaded" event for current cargo transport.
|
||||
self.cargoTransport:Loaded(CargoGroup, carrier)
|
||||
if self.cargoTransport then
|
||||
self.cargoTransport:Loaded(CargoGroup, carrier)
|
||||
else
|
||||
self:E(self.lid..string.format("WARNING: Loaded cargo but no current OPSTRANSPORT assignment!"))
|
||||
end
|
||||
|
||||
else
|
||||
self:E(self.lid.."ERROR: Cargo has no carrier on Load event!")
|
||||
@ -5918,14 +5950,9 @@ function OPSGROUP:onafterUnloading(From, Event, To)
|
||||
|
||||
---
|
||||
-- Delivered to another carrier group.
|
||||
---
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Transferring cargo %s to new carrier group %s", cargo.opsgroup:GetName(), carrierGroup:GetName()))
|
||||
|
||||
-- Unload from this and directly load into the other carrier.
|
||||
self:Unload(cargo.opsgroup)
|
||||
carrierGroup:Load(cargo.opsgroup, carrier)
|
||||
---
|
||||
|
||||
self:_TransferCargo(cargo.opsgroup, carrierGroup, carrier)
|
||||
|
||||
elseif zone and zone:IsInstanceOf("ZONE_AIRBASE") and zone:GetAirbase():IsShip() then
|
||||
|
||||
@ -6240,9 +6267,6 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
||||
-- Set cargo status.
|
||||
self.cargoStatus=OPSGROUP.CargoStatus.BOARDING
|
||||
|
||||
-- Set carrier. As long as the group is not loaded, we only reserve the cargo space.
|
||||
self:_SetMyCarrier(CarrierGroup, Carrier, true)
|
||||
|
||||
-- Army or Navy group.
|
||||
local CarrierIsArmyOrNavy=CarrierGroup:IsArmygroup() or CarrierGroup:IsNavygroup()
|
||||
local CargoIsArmyOrNavy=self:IsArmygroup() or self:IsNavygroup()
|
||||
@ -6279,6 +6303,9 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
||||
self:Cruise()
|
||||
end
|
||||
|
||||
-- Set carrier. As long as the group is not loaded, we only reserve the cargo space.
|
||||
self:_SetMyCarrier(CarrierGroup, Carrier, true)
|
||||
|
||||
else
|
||||
|
||||
---
|
||||
@ -6287,6 +6314,13 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Board with direct load to carrier %s", CarrierGroup:GetName()))
|
||||
|
||||
local mycarriergroup=self:_GetMyCarrierGroup()
|
||||
|
||||
-- Unload cargo first.
|
||||
if mycarriergroup then
|
||||
mycarriergroup:Unload(self)
|
||||
end
|
||||
|
||||
-- Trigger Load event.
|
||||
CarrierGroup:Load(self)
|
||||
@ -6294,10 +6328,17 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
-- Redo boarding call.
|
||||
self:T(self.lid.."Carrier not ready for boarding yet ==> repeating boarding call in 10 sec")
|
||||
self:__Board(-10, CarrierGroup, Carrier)
|
||||
|
||||
-- Set carrier. As long as the group is not loaded, we only reserve the cargo space.
|
||||
self:_SetMyCarrier(CarrierGroup, Carrier, true)
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -8085,7 +8126,7 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
|
||||
---
|
||||
|
||||
if self:_AllSimilarStatus(newstatus) then
|
||||
self:__Airborne(-0.5)
|
||||
self:__Airborne(-0.1)
|
||||
end
|
||||
|
||||
elseif newstatus==OPSGROUP.ElementStatus.LANDED then
|
||||
|
||||
@ -103,7 +103,7 @@ _OPSTRANSPORTID=0
|
||||
|
||||
--- Army Group version.
|
||||
-- @field #string version
|
||||
OPSTRANSPORT.version="0.0.6"
|
||||
OPSTRANSPORT.version="0.0.7"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -418,6 +418,23 @@ function OPSTRANSPORT:_GetCarrierNames()
|
||||
return names
|
||||
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.
|
||||
-- @return #table Ops groups.
|
||||
function OPSTRANSPORT:GetCargoOpsGroups(Delivered)
|
||||
|
||||
local opsgroups={}
|
||||
for _,_cargo in pairs(self.cargos) do
|
||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||
if Delivered==nil or cargo.delivered==Delivered then
|
||||
table.insert(opsgroups, cargo.opsgroup)
|
||||
end
|
||||
end
|
||||
|
||||
return opsgroups
|
||||
end
|
||||
|
||||
|
||||
--- Set transport start and stop time.
|
||||
-- @param #OPSTRANSPORT self
|
||||
@ -574,8 +591,33 @@ function OPSTRANSPORT:GetCarrierTransportStatus(CarrierGroup)
|
||||
return self.carrierTransportStatus[CarrierGroup.groupname]
|
||||
end
|
||||
|
||||
--- Get unique ID of the transport assignment.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @return #number UID.
|
||||
function OPSTRANSPORT:GetUID()
|
||||
return self.uid
|
||||
end
|
||||
|
||||
--- Get number of delivered cargo groups.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @return #number Total number of delivered cargo groups.
|
||||
function OPSTRANSPORT:GetNcargoDelivered()
|
||||
return self.Ndelivered
|
||||
end
|
||||
|
||||
--- Get number of cargo groups.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @return #number Total number of cargo groups.
|
||||
function OPSTRANSPORT:GetNcargoTotal()
|
||||
return self.Ncargo
|
||||
end
|
||||
|
||||
--- Get number of carrier groups assigned for this transport.
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @return #number Total number of carrier groups.
|
||||
function OPSTRANSPORT:GetNcarrier()
|
||||
return self.Ncarrier
|
||||
end
|
||||
|
||||
--- Check if an OPS group is assigned as carrier for this transport.
|
||||
-- @param #OPSTRANSPORT self
|
||||
|
||||
@ -533,6 +533,9 @@ function AIRBASE:Register(AirbaseName)
|
||||
|
||||
-- Get descriptors.
|
||||
self.descriptors=self:GetDesc()
|
||||
|
||||
-- Debug info.
|
||||
--self:I({airbase=AirbaseName, descriptors=self.descriptors})
|
||||
|
||||
-- Category.
|
||||
self.category=self.descriptors and self.descriptors.category or Airbase.Category.AIRDROME
|
||||
@ -544,12 +547,21 @@ function AIRBASE:Register(AirbaseName)
|
||||
self.isHelipad=true
|
||||
elseif self.category==Airbase.Category.SHIP then
|
||||
self.isShip=true
|
||||
-- DCS bug: Oil rigs and gas platforms have category=2 (ship). Also they cannot be retrieved by coalition.getStaticObjects()
|
||||
if self.descriptors.typeName=="Oil rig" or self.descriptors.typeName=="Ga" then
|
||||
self.isHelipad=true
|
||||
self.isShip=false
|
||||
self.category=Airbase.Category.HELIPAD
|
||||
_DATABASE:AddStatic(AirbaseName)
|
||||
end
|
||||
else
|
||||
self:E("ERROR: Unknown airbase category!")
|
||||
end
|
||||
|
||||
-- Init parking spots.
|
||||
self:_InitParkingSpots()
|
||||
|
||||
-- Get 2D position vector.
|
||||
local vec2=self:GetVec2()
|
||||
|
||||
-- Init coordinate.
|
||||
|
||||
@ -1459,15 +1459,16 @@ do -- Cargo
|
||||
self:F({Desc=Desc})
|
||||
|
||||
local Weights = {
|
||||
["Type_071"] = 245000,
|
||||
["LHA_Tarawa"] = 500000,
|
||||
["Ropucha-class"] = 150000,
|
||||
["Dry-cargo ship-1"] = 70000,
|
||||
["Dry-cargo ship-2"] = 70000,
|
||||
["Higgins_boat"] = 3700, -- Higgins Boat can load 3700 kg of general cargo or 36 men (source wikipedia).
|
||||
["USS_Samuel_Chase"] = 25000, -- Let's say 25 tons for now. Wiki says 33 Higgins boats, which would be 264 tons (can't be right!) and/or 578 troops.
|
||||
["LST_Mk2"] =2100000, -- Can carry 2100 tons according to wiki source!
|
||||
["speedboat"] = 500, -- 500 kg ~ 5 persons
|
||||
["Type_071"] = 245000,
|
||||
["LHA_Tarawa"] = 500000,
|
||||
["Ropucha-class"] = 150000,
|
||||
["Dry-cargo ship-1"] = 70000,
|
||||
["Dry-cargo ship-2"] = 70000,
|
||||
["Higgins_boat"] = 3700, -- Higgins Boat can load 3700 kg of general cargo or 36 men (source wikipedia).
|
||||
["USS_Samuel_Chase"] = 25000, -- Let's say 25 tons for now. Wiki says 33 Higgins boats, which would be 264 tons (can't be right!) and/or 578 troops.
|
||||
["LST_Mk2"] = 2100000, -- Can carry 2100 tons according to wiki source!
|
||||
["speedboat"] = 500, -- 500 kg ~ 5 persons
|
||||
["Seawise_Giant"] =261000000, -- Gross tonnage is 261,000 tonns.
|
||||
}
|
||||
self.__.CargoBayWeightLimit = ( Weights[Desc.typeName] or 50000 )
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user