@@ -153,6 +153,8 @@ function Create(self)
153
153
self .actorMovementUpdateTimer = Timer (15 );
154
154
155
155
self .heldInputTimer = Timer (50 );
156
+
157
+ self .allowExpensiveFindClosestNode = SceneMan .SceneWidth * SceneMan .SceneHeight < 10000000 ;
156
158
157
159
self .leaveAutomoverNetworkPieSlice = CreatePieSlice (" Leave Automover Network" , " Base.rte" );
158
160
self .chooseTeleporterPieSlice = CreatePieSlice (" Choose Teleporter" , " Base.rte" );
@@ -185,7 +187,7 @@ function Update(self)
185
187
if self .actorMovementUpdateTimer :IsPastSimTimeLimit () then
186
188
for actorUniqueID , actorData in pairs (self .affectedActors ) do
187
189
local actor = actorData .actor ;
188
- if not MovableMan :IsActor (actor ) or not self .combinedAutomoverArea :IsInside (actor .Pos ) then
190
+ if not MovableMan :ValidMO (actor ) or not self .combinedAutomoverArea :IsInside (actor .Pos ) then
189
191
self :removeActorFromAutomoverTable (actor , actorUniqueID );
190
192
else
191
193
if actor :NumberValueExists (" Automover_LeaveAutomoverNetwork" ) then
@@ -585,7 +587,7 @@ automoverUtilityFunctions.addAllPaths = function(self)
585
587
end
586
588
end
587
589
588
- while type ( next (tentativeNodes )) ~= " nil" do
590
+ while next (tentativeNodes ) ~= nil do
589
591
local closestNode ;
590
592
local distanceToClosestNode ;
591
593
for tentativeNode , tentativeNodeData in pairs (tentativeNodes ) do
@@ -668,7 +670,7 @@ automoverUtilityFunctions.findClosestNode = function(self, positionToFindClosest
668
670
end
669
671
end
670
672
end
671
- if nodeSatisfiesConditions and checkForShortestPathfinderPath then
673
+ if nodeSatisfiesConditions and checkForShortestPathfinderPath and self . allowExpensiveFindClosestNode then
672
674
nodeSatisfiesConditions = false ;
673
675
local lengthOfScenePathToNode = SceneMan .Scene :CalculatePath (positionToFindClosestNodeFor , node .Pos , false , GetPathFindingDefaultDigStrength (), pathfinderTeam );
674
676
if lengthOfScenePathToClosestNode == nil or lengthOfScenePathToNode < lengthOfScenePathToClosestNode then
@@ -801,7 +803,6 @@ automoverVisualEffectsFunctions.drawVisualEffects = function(self)
801
803
end
802
804
end
803
805
804
-
805
806
automoverActorFunctions .checkForNewActors = function (self )
806
807
for box in self .combinedAutomoverArea .Boxes do
807
808
for movableObject in MovableMan :GetMOsInBox (box , - 1 , true ) do
@@ -841,7 +842,7 @@ automoverActorFunctions.removeActorFromAutomoverTable = function(self, actor, op
841
842
optionalActorUniqueID = actor .UniqueID ;
842
843
end
843
844
844
- if MovableMan :IsActor (actor ) then
845
+ if MovableMan :ValidMO (actor ) then
845
846
actor .PieMenu :RemovePieSlicesByPresetName (self .leaveAutomoverNetworkPieSlice .PresetName );
846
847
actor .PieMenu :RemovePieSlicesByPresetName (self .chooseTeleporterPieSlice .PresetName );
847
848
@@ -1304,30 +1305,31 @@ automoverActorFunctions.handleActorThatHasReachedItsEndNode = function(self, act
1304
1305
end
1305
1306
end
1306
1307
else
1307
- if teamNodeTable [waypointData .endNode ].zoneBox :IsWithinBox (actor .Pos ) then
1308
- waypointData .actorReachedEndNodeForTargetOutsideAutomoverArea = true ;
1309
- end
1310
- if waypointData .actorReachedEndNodeForTargetOutsideAutomoverArea and waypointData .delayTimer :IsPastSimTimeLimit () then
1311
- local scenePathSize = SceneMan .Scene :CalculatePath (actor .Pos , waypointData .targetPosition , false , GetPathFindingDefaultDigStrength (), self .Team );
1312
- local secondScenePathEntryPosition ;
1313
- local scenePathEntryIndex = 0 ;
1314
- for scenePathEntryPosition in SceneMan .Scene .ScenePath do
1315
- if scenePathEntryIndex == 2 then
1316
- secondScenePathEntryPosition = scenePathEntryPosition ;
1317
- break ;
1308
+ if teamNodeTable [waypointData .endNode ].zoneBox :IsWithinBox (actor .Pos ) and waypointData .exitPath == nil then
1309
+ waypointData .exitPath = {};
1310
+ local distanceFromActorToTargetPosition = SceneMan :ShortestDistance (waypointData .targetPosition , actor .Pos , self .checkWrapping );
1311
+ if distanceFromActorToTargetPosition :MagnitudeIsLessThan (20 ) or not SceneMan :CastStrengthRay (actor .Pos , distanceFromActorToTargetPosition , 5 , Vector (), 4 , rte .grassID , true ) then
1312
+ waypointData .exitPath [# waypointData .exitPath + 1 ] = waypointData .targetPosition ;
1313
+ else
1314
+ SceneMan .Scene :CalculatePath (actor .Pos , waypointData .targetPosition , false , GetPathFindingDefaultDigStrength (), self .Team );
1315
+ for scenePathEntryPosition in SceneMan .Scene .ScenePath do
1316
+ waypointData .exitPath [# waypointData .exitPath + 1 ] = scenePathEntryPosition ;
1318
1317
end
1319
- scenePathEntryIndex = scenePathEntryIndex + 1 ;
1320
1318
end
1321
- if secondScenePathEntryPosition ~= nil then
1322
- local distanceFromActorToSecondScenePathEntryPosition = SceneMan :ShortestDistance (secondScenePathEntryPosition , actor .Pos , self .checkWrapping );
1323
- actorData .direction = getDirectionForDistanceLargerAxis (distanceFromActorToSecondScenePathEntryPosition , 0 );
1324
-
1325
- local endNodeData = teamNodeTable [waypointData .endNode ];
1326
- if not endNodeData .zoneBox :IsWithinBox (secondScenePathEntryPosition ) and (endNodeData .connectedNodeData [actorData .direction ] == nil or not endNodeData .connectingAreas [actorData .direction ]:IsInside (secondScenePathEntryPosition )) then
1327
- actor .Vel = actor .Vel + (distanceFromActorToSecondScenePathEntryPosition .Normalized :FlipX (true ):FlipY (true ) * self .movementAcceleration * 10 );
1328
- end
1319
+ waypointData .delayTimer :Reset ();
1320
+ elseif waypointData .exitPath ~= nil and # waypointData .exitPath > 0 then
1321
+ local distanceFromActorToFirstExitPathPosition = SceneMan :ShortestDistance (waypointData .exitPath [1 ], actor .Pos , self .checkWrapping );
1322
+ if distanceFromActorToFirstExitPathPosition :MagnitudeIsLessThan (20 ) then
1323
+ table.remove (waypointData .exitPath , 1 );
1324
+ local distanceFromActorToFirstExitPathPosition = SceneMan :ShortestDistance (waypointData .exitPath [1 ], actor .Pos , self .checkWrapping );
1329
1325
end
1326
+ PrimitiveMan :DrawCircleFillPrimitive (0 , waypointData .exitPath [1 ], 10 , 7 )
1327
+ actorData .direction = getDirectionForDistanceLargerAxis (distanceFromActorToFirstExitPathPosition , 0 );
1330
1328
1329
+ local endNodeData = teamNodeTable [waypointData .endNode ];
1330
+ if not endNodeData .zoneBox :IsWithinBox (waypointData .exitPath [1 ]) and (endNodeData .connectedNodeData [actorData .direction ] == nil or not endNodeData .connectingAreas [actorData .direction ]:IsInside (waypointData .exitPath [1 ])) then
1331
+ actor .Vel = actor .Vel + (distanceFromActorToFirstExitPathPosition .Normalized :FlipX (true ):FlipY (true ) * self .movementAcceleration * 10 );
1332
+ end
1331
1333
waypointData .delayTimer :Reset ();
1332
1334
end
1333
1335
end
0 commit comments