From 36669c80da151c85f91a3d318945a8d053abfa3a Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 25 Jun 2021 13:23:56 +0200 Subject: [PATCH] OPSTRANSPORT --- Moose Development/Moose/Ops/FlightGroup.lua | 20 +++-- Moose Development/Moose/Ops/OpsGroup.lua | 79 ++++++++++++++----- Moose Development/Moose/Ops/OpsTransport.lua | 44 ++++++++++- Moose Development/Moose/Wrapper/Airbase.lua | 12 +++ .../Moose/Wrapper/Positionable.lua | 19 ++--- 5 files changed, 139 insertions(+), 35 deletions(-) diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 87b98c88b..61ccc80d7 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -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 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 diff --git a/Moose Development/Moose/Ops/OpsTransport.lua b/Moose Development/Moose/Ops/OpsTransport.lua index 7d9e725c3..5c093a086 100644 --- a/Moose Development/Moose/Ops/OpsTransport.lua +++ b/Moose Development/Moose/Ops/OpsTransport.lua @@ -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 diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index ca6ba1ca1..aba50cabd 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -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. diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 01a6269d9..6589193df 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -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 )