mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OPS
Improved OPSTRANSPORT
This commit is contained in:
@@ -2248,7 +2248,7 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
|
||||
|
||||
if not self.group:IsAirborne(true) then
|
||||
-- this should really not happen, either the AUFTRAG is cancelled before the group was airborne or it is stuck at the ground for some reason
|
||||
self:I(self.lid..string.format("WARNING: Group is not AIRBORNE ==> RTB event is suspended for 20 sec"))
|
||||
self:I(self.lid..string.format("WARNING: Group [%s] is not AIRBORNE ==> RTB event is suspended for 20 sec", self:GetState()))
|
||||
allowed=false
|
||||
Tsuspend=-20
|
||||
local groupspeed = self.group:GetVelocityMPS()
|
||||
@@ -2256,7 +2256,7 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
|
||||
self.RTBRecallCount = self.RTBRecallCount+1
|
||||
end
|
||||
if self.RTBRecallCount>6 then
|
||||
self:I(self.lid..string.format("WARNING: Group is not moving and was called RTB %d times. Assuming a problem and despawning!", self.RTBRecallCount))
|
||||
self:I(self.lid..string.format("WARNING: Group [%s] is not moving and was called RTB %d times. Assuming a problem and despawning!", self:GetState(), self.RTBRecallCount))
|
||||
self.RTBRecallCount=0
|
||||
self:Despawn(5)
|
||||
return
|
||||
@@ -2342,6 +2342,65 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- On before "LandAtAirbase" event.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Wrapper.Airbase#AIRBASE airbase The airbase to hold at.
|
||||
function FLIGHTGROUP:onbeforeLandAtAirbase(From, Event, To, airbase)
|
||||
|
||||
if self:IsAlive() then
|
||||
|
||||
local allowed=true
|
||||
local Tsuspend=nil
|
||||
|
||||
if airbase==nil then
|
||||
self:E(self.lid.."ERROR: Airbase is nil in LandAtAirase() call!")
|
||||
allowed=false
|
||||
end
|
||||
|
||||
-- Check that coaliton is okay. We allow same (blue=blue, red=red) or landing on neutral bases.
|
||||
if airbase and airbase:GetCoalition()~=self.group:GetCoalition() and airbase:GetCoalition()>0 then
|
||||
self:E(self.lid..string.format("ERROR: Wrong airbase coalition %d in LandAtAirbase() call! We allow only same as group %d or neutral airbases 0", airbase:GetCoalition(), self.group:GetCoalition()))
|
||||
return false
|
||||
end
|
||||
|
||||
if self.currbase and self.currbase:GetName()==airbase:GetName() then
|
||||
self:E(self.lid.."WARNING: Currbase is already same as LandAtAirbase airbase. LandAtAirbase canceled!")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Check if the group has landed at an airbase. If so, we lost control and RTBing is not possible (only after a respawn).
|
||||
if self:IsLanded() then
|
||||
self:E(self.lid.."WARNING: Flight has already landed. LandAtAirbase canceled!")
|
||||
return false
|
||||
end
|
||||
|
||||
if self:IsParking() then
|
||||
allowed=false
|
||||
Tsuspend=-30
|
||||
self:E(self.lid.."WARNING: Flight is parking. LandAtAirbase call delayed by 30 sec")
|
||||
elseif self:IsTaxiing() then
|
||||
allowed=false
|
||||
Tsuspend=-1
|
||||
self:E(self.lid.."WARNING: Flight is parking. LandAtAirbase call delayed by 1 sec")
|
||||
end
|
||||
|
||||
if Tsuspend and not allowed then
|
||||
self:__LandAtAirbase(Tsuspend, airbase)
|
||||
end
|
||||
|
||||
return allowed
|
||||
else
|
||||
self:E(self.lid.."WARNING: Group is not alive! LandAtAirbase call not allowed")
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- On after "LandAtAirbase" event.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string From From state.
|
||||
|
||||
@@ -1462,7 +1462,7 @@ end
|
||||
|
||||
--- Add an a waypoint to the route.
|
||||
-- @param #NAVYGROUP self
|
||||
-- @param Core.Point#COORDINATE Coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude.
|
||||
-- @param Core.Point#COORDINATE Coordinate The coordinate of the waypoint. Use `COORDINATE:SetAltitude()` to define the altitude.
|
||||
-- @param #number Speed Speed in knots. Default is default cruise speed or 70% of max speed.
|
||||
-- @param #number AfterWaypointWithID Insert waypoint after waypoint given ID. Default is to insert as last waypoint.
|
||||
-- @param #number Depth Depth at waypoint in meters. Only for submarines.
|
||||
@@ -1514,9 +1514,6 @@ function NAVYGROUP:_InitGroup(Template)
|
||||
-- Get template of group.
|
||||
local template=Template or self:_GetTemplate()
|
||||
|
||||
--TODO: Submarine check
|
||||
--self.isSubmarine=self.group:IsSubmarine()
|
||||
|
||||
-- Ships are always AI.
|
||||
self.isAI=true
|
||||
|
||||
|
||||
@@ -6846,7 +6846,7 @@ function OPSGROUP:AddWeightCargo(UnitName, Weight)
|
||||
|
||||
-- For airborne units, we set the weight in game.
|
||||
if self.isFlightgroup then
|
||||
--trigger.action.setUnitInternalCargo(element.name, element.weightCargo) --https://wiki.hoggitworld.com/view/DCS_func_setUnitInternalCargo
|
||||
trigger.action.setUnitInternalCargo(element.name, element.weightCargo) --https://wiki.hoggitworld.com/view/DCS_func_setUnitInternalCargo
|
||||
end
|
||||
|
||||
end
|
||||
@@ -7515,10 +7515,18 @@ function OPSGROUP:onafterUnloading(From, Event, To)
|
||||
if cargo.opsgroup:IsLoaded(self.groupname) and not cargo.opsgroup:IsDead() then
|
||||
|
||||
-- Disembark to carrier.
|
||||
local needscarrier=false
|
||||
local carrier=nil
|
||||
local carrierGroup=nil
|
||||
local needscarrier=false --#boolean
|
||||
local carrier=nil --Ops.OpsGroup#OPSGROUP.Element
|
||||
local carrierGroup=nil --Ops.OpsGroup#OPSGROUP
|
||||
|
||||
-- Try to get the OPSGROUP if deploy zone is a ship.
|
||||
if zone and zone:IsInstanceOf("ZONE_AIRBASE") and zone:GetAirbase():IsShip() then
|
||||
local shipname=zone:GetAirbase():GetName()
|
||||
local ship=UNIT:FindByName(shipname)
|
||||
local group=ship:GetGroup()
|
||||
carrierGroup=_DATABASE:GetOpsGroup(group:GetName())
|
||||
carrier=carrierGroup:GetElementByName(shipname)
|
||||
end
|
||||
|
||||
if self.cargoTZC.DisembarkCarriers and #self.cargoTZC.DisembarkCarriers>0 then
|
||||
|
||||
@@ -7554,8 +7562,10 @@ function OPSGROUP:onafterUnloading(From, Event, To)
|
||||
|
||||
-- Issue warning.
|
||||
self:E(self.lid.."ERROR: Deploy/disembark zone is a ZONE_AIRBASE of a ship! Where to put the cargo? Dumping into the sea, sorry!")
|
||||
--TODO: Dumb into sea.
|
||||
|
||||
|
||||
-- Unload but keep "in utero" (no coordinate provided).
|
||||
self:Unload(cargo.opsgroup)
|
||||
|
||||
else
|
||||
|
||||
---
|
||||
@@ -7800,9 +7810,6 @@ function OPSGROUP:onafterDelivered(From, Event, To, CargoTransport)
|
||||
-- Check if this was the current transport.
|
||||
if self.cargoTransport and self.cargoTransport.uid==CargoTransport.uid then
|
||||
|
||||
-- This is not a carrier anymore.
|
||||
self:_NewCarrierStatus(OPSGROUP.CarrierStatus.NOTCARRIER)
|
||||
|
||||
-- Checks
|
||||
if self:IsPickingup() then
|
||||
-- Delete pickup waypoint?
|
||||
@@ -7810,6 +7817,8 @@ function OPSGROUP:onafterDelivered(From, Event, To, CargoTransport)
|
||||
if wpindex then
|
||||
self:RemoveWaypoint(wpindex)
|
||||
end
|
||||
-- Remove landing airbase.
|
||||
self.isLandingAtAirbase=nil
|
||||
elseif self:IsLoading() then
|
||||
-- Nothing to do?
|
||||
elseif self:IsTransporting() then
|
||||
@@ -7818,6 +7827,9 @@ function OPSGROUP:onafterDelivered(From, Event, To, CargoTransport)
|
||||
-- Nothing to do?
|
||||
end
|
||||
|
||||
-- This is not a carrier anymore.
|
||||
self:_NewCarrierStatus(OPSGROUP.CarrierStatus.NOTCARRIER)
|
||||
|
||||
-- Startup uncontrolled aircraft to allow it to go back.
|
||||
if self:IsFlightgroup() then
|
||||
|
||||
@@ -7939,7 +7951,7 @@ function OPSGROUP:onafterTransportCancel(From, Event, To, Transport)
|
||||
|
||||
-- Transport delivered.
|
||||
if calldelivered then
|
||||
self:Delivered(Transport)
|
||||
self:__Delivered(-2, Transport)
|
||||
end
|
||||
|
||||
else
|
||||
@@ -9067,7 +9079,7 @@ function OPSGROUP._PassingWaypoint(opsgroup, uid)
|
||||
-- Land at current pos and wait for 60 min max.
|
||||
local coordinate=nil
|
||||
if opsgroup.cargoTZC then
|
||||
coordinate=opsgroup.cargoTZC.PickupZone:GetCoordinate()
|
||||
coordinate=opsgroup.cargoTZC.PickupZone:GetRandomCoordinate(nil, nil, {land.SurfaceType.LAND})
|
||||
else
|
||||
coordinate=opsgroup:GetCoordinate()
|
||||
end
|
||||
@@ -9088,7 +9100,7 @@ function OPSGROUP._PassingWaypoint(opsgroup, uid)
|
||||
-- Land at current pos and wait for 60 min max.
|
||||
local coordinate=nil
|
||||
if opsgroup.cargoTZC then
|
||||
coordinate=opsgroup.cargoTZC.DeployZone:GetCoordinate()
|
||||
coordinate=opsgroup.cargoTZC.DeployZone:GetRandomCoordinate(nil, nil, {land.SurfaceType.LAND})
|
||||
else
|
||||
coordinate=opsgroup:GetCoordinate()
|
||||
end
|
||||
|
||||
@@ -385,13 +385,11 @@ function OPSTRANSPORT:New(CargoGroups, PickupZone, DeployZone)
|
||||
--- Triggers the FSM event "Cancel".
|
||||
-- @function [parent=#OPSTRANSPORT] Cancel
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param Ops.OpsTransport#OPSTRANSPORT Transport The transport.
|
||||
|
||||
--- Triggers the FSM event "Cancel" after a delay.
|
||||
-- @function [parent=#OPSTRANSPORT] __Cancel
|
||||
-- @param #OPSTRANSPORT self
|
||||
-- @param #number delay Delay in seconds.
|
||||
-- @param Ops.OpsTransport#OPSTRANSPORT Transport The transport.
|
||||
|
||||
--- On after "Cancel" event.
|
||||
-- @function [parent=#OPSTRANSPORT] OnAfterCancel
|
||||
@@ -399,7 +397,6 @@ function OPSTRANSPORT:New(CargoGroups, PickupZone, DeployZone)
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param Ops.OpsTransport#OPSTRANSPORT Transport The transport.
|
||||
|
||||
|
||||
--- Triggers the FSM event "Loaded".
|
||||
@@ -1789,7 +1786,7 @@ function OPSTRANSPORT:onafterCancel(From, Event, To)
|
||||
local Ngroups = #self.carriers
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("CANCELLING transport in status %s. Will wait for %d carrier groups to report DONE before evaluation", self.status, Ngroups))
|
||||
self:I(self.lid..string.format("CANCELLING transport in status %s. Will wait for %d carrier groups to report DONE before evaluation", self:GetState(), Ngroups))
|
||||
|
||||
-- Time stamp.
|
||||
self.Tover=timer.getAbsTime()
|
||||
@@ -1848,7 +1845,7 @@ function OPSTRANSPORT:onafterCancel(From, Event, To)
|
||||
|
||||
-- Special mission states.
|
||||
if self:IsPlanned() or self:IsQueued() or self:IsRequested() or Ngroups==0 then
|
||||
self:T(self.lid..string.format("Cancelled transport was in %s stage with %d carrier groups assigned and alive. Call it DELIVERED!", self.status, Ngroups))
|
||||
self:T(self.lid..string.format("Cancelled transport was in %s stage with %d carrier groups assigned and alive. Call it DELIVERED!", self:GetState(), Ngroups))
|
||||
self:Delivered()
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user