@@ -297,7 +297,11 @@ function AIDriveStrategyShovelSiloLoader:getDriveData(dt, vX, vY, vZ)
297297 self .isStuckTimer :stop ()
298298 end
299299 local _ , _ , closestObject = self .siloEndProximitySensor :getClosestObjectDistanceAndRootVehicle ()
300- local isEndReached , maxSpeed = self .siloController :isEndReached (self .shovelController :getShovelNode (), 2 )
300+ local isEndReached , maxSpeed = false , math.huge
301+ if self .siloController :isSameDirection (self .shovelController :getShovelNode ()) then
302+ --- Makes sure the silo end calculation is only used, if the driver is turned in that direction...
303+ isEndReached , maxSpeed = self .siloController :isEndReached (self .shovelController :getShovelNode (), 2 )
304+ end
301305 self :setMaxSpeed (maxSpeed )
302306 if isEndReached then
303307 self :debug (" End of the silo or heap was detected." )
@@ -647,18 +651,9 @@ function AIDriveStrategyShovelSiloLoader:startDrivingToSilo(target)
647651 local dx , _ , dz = siloCourse :worldToWaypointLocal (1 , vx , 0 , vz )
648652 if dz < 0 and dz > - self .maxDistanceWithoutPathfinding and
649653 math.abs (dx ) <= math.abs (dz ) and
650- math.abs (dx ) < self .maxDistanceWithoutPathfinding * math.sqrt (2 )/ 2 then
651- --[[
652- |...|
653- |...| <- Silo
654- -----
655- x <- Target waypoint
656- ooooo
657- ooooooo <- Circle, where the pathfinding is skipped.
658- ooooo
659- o
660- ]] --
661- -- TODO: Beautify the math above :)
654+ math.abs (dx ) < self .maxDistanceWithoutPathfinding * math.sqrt (2 )/ 2 and
655+ self .siloController :isSameDirection (AIUtil .getDirectionNode (self .vehicle )) then
656+
662657 self :debug (" Start driving into the silo directly." )
663658 self :startCourse (siloCourse , 1 )
664659 self :setNewState (self .states .DRIVING_INTO_SILO )
0 commit comments