mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-24 12:05:27 +00:00
Fixing additional problems with AI cargo helicopters
This commit is contained in:
@@ -179,7 +179,7 @@ function AI_CARGO:onbeforeLoad( Carrier, From, Event, To, PickupZone )
|
|||||||
local Boarding = false
|
local Boarding = false
|
||||||
|
|
||||||
local LoadInterval = 10
|
local LoadInterval = 10
|
||||||
local LoadDelay = 10
|
local LoadDelay = 0
|
||||||
local Carrier_List = {}
|
local Carrier_List = {}
|
||||||
local Carrier_Weight = {}
|
local Carrier_Weight = {}
|
||||||
|
|
||||||
@@ -246,7 +246,8 @@ function AI_CARGO:onbeforeLoad( Carrier, From, Event, To, PickupZone )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not Loaded then
|
if not Loaded then
|
||||||
-- If the cargo wasn't loaded in one of the carriers, then we need to stop the loading.
|
-- No loading happened, so we need to pickup something else.
|
||||||
|
self.Relocating = false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -344,6 +345,7 @@ function AI_CARGO:onafterUnload( Carrier, From, Event, To, DeployZone )
|
|||||||
local CarrierUnit = CarrierUnit -- Wrapper.Unit#UNIT
|
local CarrierUnit = CarrierUnit -- Wrapper.Unit#UNIT
|
||||||
Carrier:RouteStop()
|
Carrier:RouteStop()
|
||||||
for _, Cargo in pairs( CarrierUnit:GetCargo() ) do
|
for _, Cargo in pairs( CarrierUnit:GetCargo() ) do
|
||||||
|
self:F( { Cargo = Cargo:GetName(), Isloaded = Cargo:IsLoaded() } )
|
||||||
if Cargo:IsLoaded() then
|
if Cargo:IsLoaded() then
|
||||||
Cargo:__UnBoard( UnboardDelay )
|
Cargo:__UnBoard( UnboardDelay )
|
||||||
UnboardDelay = UnboardDelay + UnboardInterval
|
UnboardDelay = UnboardDelay + UnboardInterval
|
||||||
|
|||||||
@@ -358,37 +358,35 @@ function AI_CARGO_HELICOPTER:onafterOrbit( Helicopter, From, Event, To, Coordina
|
|||||||
|
|
||||||
if Helicopter and Helicopter:IsAlive() then
|
if Helicopter and Helicopter:IsAlive() then
|
||||||
|
|
||||||
if not self:IsTransporting() then
|
local Route = {}
|
||||||
local Route = {}
|
|
||||||
|
-- local CoordinateFrom = Helicopter:GetCoordinate()
|
||||||
-- local CoordinateFrom = Helicopter:GetCoordinate()
|
-- local WaypointFrom = CoordinateFrom:WaypointAir(
|
||||||
-- local WaypointFrom = CoordinateFrom:WaypointAir(
|
-- "RADIO",
|
||||||
-- "RADIO",
|
-- POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
-- POINT_VEC3.RoutePointType.TurningPoint,
|
-- POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
-- POINT_VEC3.RoutePointAction.TurningPoint,
|
-- Speed,
|
||||||
-- Speed,
|
-- true
|
||||||
-- true
|
-- )
|
||||||
-- )
|
-- Route[#Route+1] = WaypointFrom
|
||||||
-- Route[#Route+1] = WaypointFrom
|
local CoordinateTo = Coordinate
|
||||||
local CoordinateTo = Coordinate
|
local WaypointTo = CoordinateTo:WaypointAir(
|
||||||
local WaypointTo = CoordinateTo:WaypointAir(
|
"RADIO",
|
||||||
"RADIO",
|
POINT_VEC3.RoutePointType.TurningPoint,
|
||||||
POINT_VEC3.RoutePointType.TurningPoint,
|
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
50,
|
||||||
50,
|
true
|
||||||
true
|
)
|
||||||
)
|
Route[#Route+1] = WaypointTo
|
||||||
Route[#Route+1] = WaypointTo
|
|
||||||
|
local Tasks = {}
|
||||||
local Tasks = {}
|
Tasks[#Tasks+1] = Helicopter:TaskOrbitCircle( math.random( 30, 80 ), 150, CoordinateTo:GetRandomCoordinateInRadius( 800, 500 ) )
|
||||||
Tasks[#Tasks+1] = Helicopter:TaskOrbitCircle( math.random( 30, 80 ), 150, CoordinateTo:GetRandomCoordinateInRadius( 800, 500 ) )
|
Route[#Route].task = Helicopter:TaskCombo( Tasks )
|
||||||
Route[#Route].task = Helicopter:TaskCombo( Tasks )
|
|
||||||
|
Route[#Route+1] = WaypointTo
|
||||||
Route[#Route+1] = WaypointTo
|
|
||||||
|
-- Now route the helicopter
|
||||||
-- Now route the helicopter
|
Helicopter:Route( Route, 0 )
|
||||||
Helicopter:Route( Route, 0 )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -406,9 +404,16 @@ end
|
|||||||
function AI_CARGO_HELICOPTER:onafterPickedUp( Helicopter, From, Event, To, PickupZone )
|
function AI_CARGO_HELICOPTER:onafterPickedUp( Helicopter, From, Event, To, PickupZone )
|
||||||
self:F( { Helicopter, From, Event, To } )
|
self:F( { Helicopter, From, Event, To } )
|
||||||
|
|
||||||
|
local HasCargo = false
|
||||||
if Helicopter and Helicopter:IsAlive() then
|
if Helicopter and Helicopter:IsAlive() then
|
||||||
|
for Cargo, CarrierUnit in pairs( self.Carrier_Cargo ) do
|
||||||
|
HasCargo = true
|
||||||
|
break
|
||||||
|
end
|
||||||
self.Relocating = false
|
self.Relocating = false
|
||||||
self.Transporting = true
|
if HasCargo then
|
||||||
|
self.Transporting = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user