Esempio n. 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 { }
        }
Esempio n. 2
0
        public override void DoThings()
        {
            if (WaypointQueue.Count > 0)
            {
                base.DoThings();
            }

            Unit   unitToLoot = AmeisenDataHolder.LootableUnits.Peek();
            double distance   = Utils.GetDistance(Me.pos, unitToLoot.pos);

            if (distance > 3)
            {
                if (!WaypointQueue.Contains(unitToLoot.pos))
                {
                    WaypointQueue.Enqueue(unitToLoot.pos);
                }
            }
            else
            {
                AmeisenCore.TargetGUID(unitToLoot.Guid);
                AmeisenCore.LuaDoString("InteractUnit(\"target\");");
                Thread.Sleep(1000);
                // We should have looted it by now based on the event
                AmeisenDataHolder.LootableUnits.Dequeue();
            }
        }
Esempio n. 3
0
 public override void Stop()
 {
     base.Stop();
     WaypointQueue.Clear();
     AmeisenCore.RunSlashCommand("/cleartarget");
     Target = null;
 }
Esempio n. 4
0
        private void GoToCorpseAndRevive()
        {
            Vector3 corpsePosition = AmeisenCore.GetCorpsePosition();

            corpsePosition.X = (int)corpsePosition.X;
            corpsePosition.Y = (int)corpsePosition.Y;
            corpsePosition.Z = (int)corpsePosition.Z;

            if (InstanceEntrances.ContainsKey(corpsePosition))
            {
                // Dungeon/Raid workaround
                // because blizzard decided to put the corpse at very low Z axis values that
                // we cant navigate to them, so we are going to use the position of the entrance instead
                corpsePosition = InstanceEntrances[corpsePosition];
            }

            if (corpsePosition.X != 0 && corpsePosition.Y != 0 && corpsePosition.Z != 0)
            {
                if (!WaypointQueue.Contains(corpsePosition))
                {
                    WaypointQueue.Enqueue(corpsePosition);
                }
            }

            if (Utils.GetDistance(Me.pos, corpsePosition) < 4.0)
            {
                AmeisenCore.RetrieveCorpse(true);
            }
        }
Esempio n. 5
0
        private void HandleMovement(Vector3 pos)
        {
            Me.Update();

            if (!WaypointQueue.Contains(pos))
            {
                WaypointQueue.Enqueue(pos);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Process a path by adding all nodes to the QaypointQueue
 /// 
 /// will set PathCalculated to true
 /// </summary>
 /// <param name="path">path to process</param>
 private void ProcessPath(List<Node> path)
 {
     AmeisenLogger.Instance.Log(LogLevel.DEBUG, "Found path: " + path.ToString(), this);
     foreach (Node node in path)
     {
         Me.Update();
         WaypointQueue.Enqueue(new Vector3(node.Position.X, node.Position.Y, node.Position.Z));
     }
 }
Esempio n. 7
0
        public override void Start()
        {
            // Startup Method
            if (CombatPackage.SpellStrategy != null)
            {
                // Updte me, target and pet
                Me?.Update();
                Target?.Update();
                Pet?.Update();

                CombatPackage.SpellStrategy.Startup(Me, Target, Pet);
            }
            WaypointQueue.Clear();
            base.Start();
        }
Esempio n. 8
0
 private void GoToUnitAndRepair(RememberedUnit closestUnit)
 {
     Me.Update();
     if (Utils.GetDistance(Me.pos, closestUnit.Position) < 3)
     {
         SellTrashAtUnit(closestUnit);
     }
     else
     {
         if (!WaypointQueue.Contains(closestUnit.Position))
         {
             WaypointQueue.Enqueue(closestUnit.Position);
         }
     }
 }
Esempio n. 9
0
        public override void DoThings()
        {
            if (WaypointQueue.Count > 0)
            {
                // Do the movement stuff
                base.DoThings();
                Thread.Sleep(100);
                return;
            }

            RefreshActiveUnit();
            Me?.Update();
            ActiveUnit?.Update();

            if (Me == null || ActiveUnit == null)
            {
                return;
            }

            /*Vector3 posToMoveTo = ActiveUnit.pos;
             * posToMoveTo = CalculateMovementOffset(
             *  posToMoveTo,
             *  GetFollowAngle(
             *      GetPartymemberCount(),
             *      GetMyPartyPosition()),
             *  AmeisenDataHolder.Settings.followDistance);*/

            //AmeisenMovementEngine.MemberCount = GetPartymemberCount();

            Vector4 targetPos = AmeisenMovementEngine.GetPosition(
                new Vector4(ActiveUnit.pos.X, ActiveUnit.pos.Y, ActiveUnit.pos.Z, ActiveUnit.Rotation),
                AmeisenDataHolder.Settings.followDistance / 10,
                GetMyPartyPosition());

            Vector3 posToMoveTo = new Vector3(targetPos.X, targetPos.Y, targetPos.Z);

            // When we are far enough away, follow
            if (WaypointQueue.Count == 0)
            {
                if (Utils.GetDistance(Me.pos, ActiveUnit.pos) > AmeisenDataHolder.Settings.followDistance)
                {
                    if (!WaypointQueue.Contains(posToMoveTo))
                    {
                        WaypointQueue.Enqueue(posToMoveTo);
                    }
                }
            }
        }
Esempio n. 10
0
        private void GoToCorpseAndRevive()
        {
            Vector3 corpsePosition = AmeisenCore.GetCorpsePosition();

            if (corpsePosition.X != 0 && corpsePosition.Y != 0 && corpsePosition.Z != 0)
            {
                if (!WaypointQueue.Contains(corpsePosition))
                {
                    WaypointQueue.Enqueue(corpsePosition);
                }
            }

            if (Utils.GetDistance(Me.pos, corpsePosition) < 10.0)
            {
                AmeisenCore.RetrieveCorpse(true);
            }
        }
Esempio n. 11
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
            {
            }
        }