Exemple #1
0
        private void MoveToNode()
        {
            if (WaypointQueue.Count > 0)
            {
                Me.Update();
                Vector3 initialPosition = Me.pos;
                Vector3 targetPosition = WaypointQueue.Dequeue();

                if (WaypointQueue.Count < 2 && Utils.GetDistance(initialPosition, targetPosition) >= AmeisenDataHolder.Settings.PathfindingUsageThreshold)
                {
                    List<Node> path = FindWayToNode(initialPosition, targetPosition);

                    if (path != null)
                    {
                        ProcessPath(path);
                    }
                    else
                    {
                        // retry with thicker path
                        path = FindWayToNode(initialPosition, targetPosition, true);

                        if (path != null)
                        {
                            ProcessPath(path);
                        }
                    }
                }
                else
                {
                    MoveToNode(targetPosition);
                }
            }
            else { }
        }
Exemple #2
0
        private void MoveToNode()
        {
            if (WaypointQueue.Count > 0)
            {
                Me.Update();
                Vector3 initialPosition = Me.pos;
                if (WaypointQueue.Count == 0)
                {
                    return;
                }

                Vector3 targetPosition = WaypointQueue.Dequeue();
                double  distance       = Utils.GetDistance(initialPosition, targetPosition);

                if (distance > AmeisenDataHolder.Settings.followDistance)
                {
                    CheckIfWeAreStuckIfYesJump(Me.pos, LastPosition);

                    if (targetPosition.Z == 0)
                    {
                        targetPosition.Z = Me.pos.Z;
                    }

                    List <Vector3> navmeshPath = new List <Vector3>()
                    {
                        targetPosition
                    };

                    if (distance > AmeisenDataHolder.Settings.pathfindingUsageThreshold)
                    {
                        navmeshPath = UsePathfinding(Me.pos, targetPosition);

                        if (navmeshPath == null || navmeshPath.Count == 0)
                        {
                            Thread.Sleep(1000);
                            return;
                        }

                        if (navmeshPath.Count > 1)
                        {
                            navmeshPath.Add(targetPosition); // original position
                        }

                        movementDistance = AmeisenCore.IsMounted ? 8 : 3; // Mount distance adjustments

                        foreach (Vector3 pos in navmeshPath)
                        {
                            Me.Update();
                            double posDistance = Utils.GetDistance(Me.pos, pos);
                            int    tries       = 0;

                            if (posDistance < movementDistance)
                            {
                                continue;
                            }

                            while (tries < 10 && posDistance > movementDistance)
                            {
                                AmeisenCore.MovePlayerToXYZ(pos, InteractionType.MOVE);
                                posDistance = Utils.GetDistance(Me.pos, pos);
                                tries++;
                                Thread.Sleep(20);
                            }

                            Me.Update();
                            double distanceTraveled = posDistance - Utils.GetDistance(Me.pos, pos);
                            // if we havent moved 0.2m in this time, screw this path
                            if (tries == 10 && distanceTraveled < 0.2)
                            {
                                WaypointQueue.Clear();
                                break;
                            }
                        }
                    }
                    else
                    {
                        AmeisenCore.MovePlayerToXYZ(navmeshPath.First(), InteractionType.MOVE);
                    }

                    Me.Update();
                    LastPosition = Me.pos;
                }
            }
            else
            {
            }
        }