Merge branch 'develop' into FF/Develop

This commit is contained in:
funkyfranky
2018-09-09 22:04:52 +02:00
3 changed files with 53 additions and 40 deletions

View File

@@ -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

View File

@@ -903,7 +903,8 @@ function AI_CARGO_DISPATCHER:onafterMonitor()
if not self.PickupZoneSet or PickupZone then if not self.PickupZoneSet or PickupZone then
for CarrierPickup, Coordinate in pairs( self.PickupCargo ) do for CarrierPickup, Coordinate in pairs( self.PickupCargo ) do
if CarrierPickup:IsAlive() == true then if CarrierPickup:IsAlive() == true then
if CargoCoordinate:Get2DDistance( Coordinate ) <= 100 then if CargoCoordinate:Get2DDistance( Coordinate ) <= 25 then
self:F( { "Coordinate not free for ", Cargo = Cargo:GetName(), Carrier:GetName(), PickupCargo = self.PickupCargo[Carrier] ~= nil } )
CoordinateFree = false CoordinateFree = false
break break
end end
@@ -1025,6 +1026,7 @@ function AI_CARGO_DISPATCHER:onafterTransport( From, Event, To, Carrier, Cargo )
end end
end end
self:F( { Carrier = Carrier:GetName(), PickupCargo = self.PickupCargo } )
self.PickupCargo[Carrier] = nil self.PickupCargo[Carrier] = nil
end end

View File

@@ -254,7 +254,6 @@ function AI_CARGO_HELICOPTER:onafterLanded( Helicopter, From, Event, To )
--self:Load( Helicopter:GetPointVec2() ) --self:Load( Helicopter:GetPointVec2() )
self:Load( self.PickupZone ) self:Load( self.PickupZone )
self.RoutePickup = false self.RoutePickup = false
self.Relocating = true
end end
end end
@@ -262,8 +261,6 @@ function AI_CARGO_HELICOPTER:onafterLanded( Helicopter, From, Event, To )
if Helicopter:GetHeight( true ) <= 5 and Helicopter:GetVelocityKMH() < 10 then if Helicopter:GetHeight( true ) <= 5 and Helicopter:GetVelocityKMH() < 10 then
self:Unload( self.DeployZone ) self:Unload( self.DeployZone )
self.RouteDeploy = false self.RouteDeploy = false
self.Transporting = false
self.Relocating = false
end end
end end
@@ -361,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
@@ -409,8 +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
self.Transporting = true for Cargo, CarrierUnit in pairs( self.Carrier_Cargo ) do
HasCargo = true
break
end
self.Relocating = false
if HasCargo then
self.Transporting = true
end
end end
end end
@@ -437,6 +440,8 @@ function AI_CARGO_HELICOPTER:onafterDeployed( Helicopter, From, Event, To, Deplo
end, Helicopter end, Helicopter
) )
self.Transporting = false
end end
--- On after Pickup event. --- On after Pickup event.
@@ -500,7 +505,9 @@ function AI_CARGO_HELICOPTER:onafterPickup( Helicopter, From, Event, To, Coordin
Helicopter:Route( Route, 1 ) Helicopter:Route( Route, 1 )
self.PickupZone = PickupZone self.PickupZone = PickupZone
self.Transporting = true
self.Relocating = true
self.Transporting = false
end end
end end
@@ -577,6 +584,8 @@ function AI_CARGO_HELICOPTER:onafterDeploy( Helicopter, From, Event, To, Coordin
-- Now route the helicopter -- Now route the helicopter
Helicopter:Route( Route, 0 ) Helicopter:Route( Route, 0 )
self.Relocating = false
self.Transporting = true
end end
end end