From 7a8881974caa8b340eb235954b36892739e5fb77 Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Wed, 28 Mar 2018 16:42:37 +0200 Subject: [PATCH] Optimizations of cargo deployment. --- .../Moose/AI/AI_Cargo_Troops.lua | 10 +++---- Moose Development/Moose/Core/Cargo.lua | 27 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Moose Development/Moose/AI/AI_Cargo_Troops.lua b/Moose Development/Moose/AI/AI_Cargo_Troops.lua index defb6bd81..f0d524be3 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Troops.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Troops.lua @@ -148,7 +148,7 @@ function AI_CARGO_TROOPS:onafterLoad( CargoCarrier, From, Event, To ) if CargoCarrier and CargoCarrier:IsAlive() then CargoCarrier:RouteStop() - self:Board() + self:__Board( 10 ) self.CargoGroup:Board( CargoCarrier, 25 ) end @@ -162,7 +162,7 @@ function AI_CARGO_TROOPS:onafterBoard( CargoCarrier, From, Event, To ) if CargoCarrier and CargoCarrier:IsAlive() then self:F({ IsLoaded = self.CargoGroup:IsLoaded() } ) if not self.CargoGroup:IsLoaded() then - self:__Board( 1 ) + self:__Board( 10 ) else self:__Loaded( 1 ) end @@ -190,7 +190,7 @@ function AI_CARGO_TROOPS:onafterUnload( CargoCarrier, From, Event, To ) if CargoCarrier and CargoCarrier:IsAlive() then CargoCarrier:RouteStop() self.CargoGroup:UnBoard( ) - self:__Unboard( 1 ) + self:__Unboard( 10 ) end end @@ -202,9 +202,9 @@ function AI_CARGO_TROOPS:onafterUnboard( CargoCarrier, From, Event, To ) if CargoCarrier and CargoCarrier:IsAlive() then if not self.CargoGroup:IsUnLoaded() then - self:__Unboard( 1 ) + self:__Unboard( 10 ) else - self:Unloaded() + self:__Unloaded( 1 ) end end diff --git a/Moose Development/Moose/Core/Cargo.lua b/Moose Development/Moose/Core/Cargo.lua index 8cfa3037f..e0a42c690 100644 --- a/Moose Development/Moose/Core/Cargo.lua +++ b/Moose Development/Moose/Core/Cargo.lua @@ -771,25 +771,26 @@ do -- CARGO_UNIT -- if there is no ToPointVec2 given, then use the CargoRoutePointVec2 - ToPointVec2 = ToPointVec2 or CargoCarrierPointVec2:GetRandomCoordinateInRadius( NearRadius, 5 ) - local DirectionVec3 = CargoCarrierPointVec2:GetDirectionVec3(ToPointVec2) - local Angle = CargoCarrierPointVec2:GetAngleDegrees(DirectionVec3) - - local CargoDeployPointVec2 = CargoCarrierPointVec2:Translate( DeployDistance, Angle ) - local CargoDeployPointVec2 = CargoCarrierPointVec2:GetRandomCoordinateInRadius( NearRadius, 5 ) + local FromDirectionVec3 = CargoCarrierPointVec2:GetDirectionVec3( ToPointVec2 or CargoRoutePointVec2 ) + local FromAngle = CargoCarrierPointVec2:GetAngleDegrees(FromDirectionVec3) + local FromPointVec2 = CargoCarrierPointVec2:Translate( DeployDistance, FromAngle ) + --local CargoDeployPointVec2 = CargoCarrierPointVec2:GetRandomCoordinateInRadius( 10, 5 ) + + ToPointVec2 = ToPointVec2 or CargoCarrierPointVec2:GetRandomCoordinateInRadius( NearRadius, DeployDistance ) - local FromPointVec2 = CargoCarrierPointVec2 - -- Respawn the group... if self.CargoObject then - self.CargoObject:ReSpawn( CargoDeployPointVec2:GetVec3(), CargoDeployHeading ) + self.CargoObject:ReSpawn( FromPointVec2:GetVec3(), CargoDeployHeading ) self:F( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } ) self.CargoCarrier = nil local Points = {} - Points[#Points+1] = CargoCarrierPointVec2:WaypointGround( Speed ) - Points[#Points+1] = ToPointVec2:WaypointGround( Speed ) + -- From + Points[#Points+1] = FromPointVec2:WaypointGround( Speed, "Vee" ) + + -- To + Points[#Points+1] = ToPointVec2:WaypointGround( Speed, "Vee" ) local TaskRoute = self.CargoObject:TaskRoute( Points ) self.CargoObject:SetTask( TaskRoute, 1 ) @@ -1375,7 +1376,7 @@ function CARGO_GROUP:OnEventCargoDead( EventData ) function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... ) self:F( {From, Event, To, ToPointVec2, NearRadius } ) - NearRadius = NearRadius or 100 + NearRadius = NearRadius or 25 local Timer = 1 @@ -1390,7 +1391,7 @@ function CARGO_GROUP:OnEventCargoDead( EventData ) function( Cargo, NearRadius ) Cargo:__UnBoard( Timer, ToPointVec2, NearRadius ) - Timer = Timer + 10 + Timer = Timer + 3 end, { NearRadius } )