Example #1
0
        /// <summary>
        /// Calculates the distance between START and DESTINATION if the travel must be conducted
        /// over a surface (i.e., instead of flying).  This is most helpful in tunnels where a mob
        /// can be within X feet of you, but above or below you.  For such mobs, the direct distance
        /// is X feet, but the path you must take through the tunnels may be much much longer.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="destination"></param>
        /// <returns></returns>
        /// <remarks>17Apr2011-12:16UTC chinajade</remarks>
        public static float SurfacePathDistance(this WoWPoint start, WoWPoint destination)
        {
            float pathDistance;

            if (SurfacePathDistanceCache.TryGet(start, destination, out pathDistance))
            {
                return(pathDistance);
            }

            var groundPath = new WoWPoint[] { };

            bool canFullyNavigate;

            // Note: Use the Navigate.GeneratePath that outs a 'isPartial' boolean once it's available.
            var meshNavigator = Navigator.NavigationProvider as MeshNavigator;

            if (meshNavigator != null)
            {
                var pathResult = meshNavigator.Nav.FindPath(start, destination);
                canFullyNavigate = pathResult.Succeeded && !pathResult.IsPartialPath;

                if (canFullyNavigate)
                {
                    groundPath = pathResult.Points.Select(v => (WoWPoint)v).ToArray();
                }
            }
            else
            {
                groundPath       = Navigator.GeneratePath(start, destination) ?? new WoWPoint[0];
                canFullyNavigate = groundPath.Length > 0;
            }

            if (!canFullyNavigate || groundPath.Length <= 0)
            {
                SurfacePathDistanceCache.Add(start, destination, float.NaN);
                return(float.NaN);
            }


            // Include distance it takes us to get from start point to first point in path...
            pathDistance = start.Distance(groundPath[0]);

            // Include distance it takes us to get from last point in path to destination...
            pathDistance += groundPath[groundPath.Length - 1].Distance(destination);

            // Include distance for each point in path...
            for (int i = 0; i < (groundPath.Length - 1); ++i)
            {
                pathDistance += groundPath[i].Distance(groundPath[i + 1]);
            }

            // Sanity check...
            Contract.Provides(
                pathDistance >= start.Distance(destination),
                context => "Surface path distance must be equal to or greater than straight-line distance.");

            SurfacePathDistanceCache.Add(start, destination, pathDistance);
            return(pathDistance);
        }
 public static List <C_WoWGameObject> GetGameObjectsNearPoint(WoWPoint location, float maxdistance, WoWObjectTypes type)
 {
     return
         (ObjectCollection.Values.OfType <C_WoWGameObject>()
          .Where(obj => CheckFlag(obj.SubType, type) &&
                 location.Distance(obj.Location) <= maxdistance &&
                 !Blacklist.TempBlacklistGuids.Contains(obj.Guid))
          .OrderBy(o => location.Distance(o.Location)).ToList());
 }
 public static List <C_WoWGameObject> GetGameObjectsNearPoint(WoWPoint location, float maxdistance, string name)
 {
     return
         (ObjectCollection.Values.OfType <C_WoWGameObject>()
          .Where(obj => obj.Name == name &&
                 location.Distance(obj.Location) <= maxdistance &&
                 !Blacklist.TempBlacklistGuids.Contains(obj.Guid) &&
                 obj.IsValid)
          .OrderBy(o => location.Distance(o.Location)).ToList());
 }
 public static List <C_WoWObject> GetObjectsNearPoint(WoWPoint location, float maxdistance, bool validOnly = true)
 {
     return
         (ObjectCollection.Values
          .Where(obj => location.Distance(obj.Location) <= maxdistance && (!validOnly || obj.IsValid))
          .ToList());
 }
Example #5
0
        /*
         * public bool ArcaneBurn()
         * {
         *  if (!SpellManager.Spells["Evocation"].Cooldown && !SpellManager.Spells["Arcane Power"].Cooldown && !SpellManager.Spells["Mirror Image"] && !SpellManager.Item["Mana Gem"].Cooldown)//However you would do that check for mana gem//
         *  {
         *      return true;
         *  }
         * }
         */

        //only works with mobs, not players, need a new one for pvp.
        public static bool WillChain(int Hits, WoWPoint TargetLocal)
        {
            List <WoWUnit> hitList = new List <WoWUnit>();


            List <WoWUnit> enemyList = ObjectManager.GetObjectsOfType <WoWUnit>(false).FindAll(unit =>
                                                                                               unit.Attackable &&
                                                                                               !unit.IsFriendly &&
                                                                                               !unit.Combat &&
                                                                                               unit != Me &&
                                                                                               unit != Me.CurrentTarget);

            foreach (WoWUnit Plr in enemyList)
            {
                if (TargetLocal.Distance(Plr.Location) < 8)
                {
                    hitList.Add(Plr);
                }
            }

            if (hitList.Count > Hits)
            {
                Log("Found Targets {0} near CurrentTarget", hitList.Count.ToString());
                hitList.Clear();
                return(true);
            }
            else
            {
                hitList.Clear();
                return(false);
            }
        }
        void MoveToBanker()
        {
            WoWPoint  movetoPoint = _loc;
            WoWObject bank        = GetLocalBanker();

            if (bank != null)
            {
                movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, bank.Location, 4);
            }
            // search the database
            else if (movetoPoint == WoWPoint.Zero)
            {
                movetoPoint = MoveToAction.GetLocationFromDB(Bank == BankType.Personal ?
                                                             MoveToAction.MoveToType.NearestBanker : MoveToAction.MoveToType.NearestGB, NpcEntry);
            }
            if (movetoPoint == WoWPoint.Zero)
            {
                IsDone = true;
                Professionbuddy.Err("Unable to find bank");
            }
            if (movetoPoint.Distance(ObjectManager.Me.Location) > 4)
            {
                Util.MoveTo(movetoPoint);
            }
            // since there are many personal bank replacement addons I can't just check if frame is open and be generic.. using events isn't reliable
            else if (bank != null)
            {
                bank.Interact();
            }
            else
            {
                IsDone = true;
                Logging.Write(System.Drawing.Color.Red, "Unable to find a banker at location. aborting");
            }
        }
Example #7
0
        List <WoWPoint> CreatePathSegment(WoWPoint from, WoWPoint to)
        {
            List <WoWPoint> segment    = new List <WoWPoint>();
            WoWPoint        point      = from;
            float           step       = 50;
            float           noMeshStep = 5;

            for (float i = from.Distance(to) - step; i > 0;)
            {
                point = WoWMathHelper.CalculatePointFrom(from, to, i);
                try
                {
                    float z = Navigator.FindHeights(point.X, point.Y).Max();
                    i -= step;
                    if (Gui.smoothCheck.Checked && z > point.Z)
                    {
                        point.Z = z;
                    }
                    segment.Add(point);
                }
                catch { i -= noMeshStep; }
            }
            segment.Add(to);
            return(segment);
        }
Example #8
0
        public async Task <bool> ClickToMove(bool allowDequeue = true)
        {
            if (CurrentMovementQueue.Count == 0)
            {
                return(false);
            }

            WoWPoint location        = CurrentLocation;
            WoWPoint playerPos       = Character.Player.Location;
            float    currentDistance = location.Distance(playerPos);

            if (currentDistance <= Distance)
            {
                if (allowDequeue)
                {
                    Log("ClickToMove", String.Format("has dequeued location - {0}", location.ToString()));

                    DequeuedPoints.Enqueue(CurrentMovementQueue.Dequeue());
                    DequeuedFinalPlayerPositionPoints.Add(playerPos);
                }

                if (CurrentMovementQueue.Count == 0 || CurrentMovementQueue.Count == 1 && !allowDequeue)
                {
                    Log("ClickToMove", "is finished");
                    WoWMovement.MoveStop();
                    return(false);
                }

                return(true);
            }

            if (!WoWMovement.ClickToMoveInfo.IsClickMoving)
            {
                Log("ClickToMove", location.ToString());
                WoWMovement.ClickToMove(location);
                // await Coroutine.Sleep(StyxWoW.Random.Next(525, 800));
            }

            if (!_didResetStuckChecker)
            {
                StuckChecker.Reset();
                _didResetStuckChecker = true;
            }
            else if (_checkStuck)
            {
                if (StuckChecker.CheckStuck())
                {
                    Log("ClickToMoveResult", "Stuck Checker returned true!");
                    return(false);
                }
            }

            if (MovementCache.ShouldRecord)
            {
                MovementCache.AddPosition(playerPos, Distance);
            }

            return(true);
        }
Example #9
0
        public static WoWPoint FindNearestPoint(WoWPoint position, List <WoWPoint> points)
        {
            float    distance     = position.Distance(points[0]);
            WoWPoint currentPoint = points[0];

            for (int i = 1; i < points.Count; i++)
            {
                var testDistance = position.Distance(points[i]);
                if (testDistance < distance)
                {
                    distance     = testDistance;
                    currentPoint = points[i];
                }
            }

            return(currentPoint);
        }
Example #10
0
 protected override RunStatus Run(object context)
 {
     if (!IsDone)
     {
         WoWObject obj = null;
         if (InteractType == InteractActionType.NPC)
         {
             if (Entry != 0)
             {
                 obj =
                     ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.Entry == Entry).OrderBy(
                         u => u.Distance).FirstOrDefault();
             }
             else if (ObjectManager.Me.GotTarget)
             {
                 obj = ObjectManager.Me.CurrentTarget;
             }
         }
         else if (InteractType == InteractActionType.GameObject)
         {
             obj =
                 ObjectManager.GetObjectsOfType <WoWGameObject>().OrderBy(u => u.Distance).FirstOrDefault(
                     u => (Entry > 0 && u.Entry == Entry) || (u.SubType == GameObjectType &&
                                                              (GameObjectType != WoWGameObjectType.SpellFocus ||
                                                               (GameObjectType == WoWGameObjectType.SpellFocus &&
                                                                u.SpellFocus == SpellFocus))));
         }
         if (obj != null)
         {
             WoWPoint moveToLoc = WoWMathHelper.CalculatePointFrom(Me.Location, obj.Location, 3);
             if (moveToLoc.Distance(Me.Location) > 4)
             {
                 Util.MoveTo(moveToLoc);
             }
             else
             {
                 if (InteractDelay > 0 &&
                     (!_interactSw.IsRunning || _interactSw.ElapsedMilliseconds < InteractDelay))
                 {
                     _interactSw.Start();
                 }
                 else
                 {
                     _interactSw.Reset();
                     obj.Interact();
                     IsDone = true;
                 }
             }
         }
         if (!IsDone)
         {
             return(RunStatus.Success);
         }
         Professionbuddy.Log("InteractAction complete");
     }
     return(RunStatus.Failure);
 }
Example #11
0
        public static void Mailspell()
        {
            Logging.Write(Color.Blue, "Moving to Mailbox");
            if (mailboxLoc.X != 0f && mailboxLoc.Y != 0f && mailboxLoc.Z != 0f)
            {
                Styx.Logic.Mount.MountUp();
                while (!ObjectManager.Me.Combat && mailboxLoc.Distance(ObjectManager.Me.Location) > 5)
                {
                    Navigator.MoveTo(mailboxLoc);
                    Thread.Sleep(100);
                }
            }
            ObjectManager.Update();
            List <WoWGameObject> gObjList    = ObjectManager.GetObjectsOfType <WoWGameObject>();
            List <WoWGameObject> mailboxList = new List <WoWGameObject>();

            foreach (WoWGameObject o in gObjList)
            {
                if (o.SubType == WoWGameObjectType.Mailbox)
                {
                    mailboxList.Add(o);
                }
            }
            if (mailboxList.Count != 0)
            {
                mailboxList.Sort((p1, p2) => p1.Location.Distance(ObjectManager.Me.Location).CompareTo(p2.Location.Distance(ObjectManager.Me.Location)));
                if (mailboxList[0].Distance > 50)
                {
                    Styx.Logic.Mount.MountUp();
                }
                while (!ObjectManager.Me.Combat && mailboxList[0].Distance > 5)
                {
                    Navigator.MoveTo(mailboxList[0].Location);
                    Thread.Sleep(100);
                }
                mailboxList[0].Interact();
                Thread.Sleep(2500);
                int mailCount = mailFrame.MailCount;
                int i         = mailCount;
                Logging.Write("[Mail]:I Have {0} Mail", i);
                Logging.Write("[Mail]:Looting Mail");
                while (ObjectManager.Me.FreeNormalBagSlots >= 10 && i >= 1)

                {
                    StyxWoW.SleepForLagDuration();
                    Lua.DoString("TakeInboxItem(" + i.ToString() + ")");
                    i--;

                    if (ObjectManager.Me.FreeNormalBagSlots < 10 || mailCount < 1)
                    {
                        mailFrame.Close();
                        break;
                    }
                }
            }
        }
		public static void movetoLoc(WoWPoint loc)
		{
			while (loc.Distance(Me.Location) > 10)
			{
				Navigator.MoveTo(loc);
				Thread.Sleep(100);
				if (inCombat) return;
			}
			Thread.Sleep(2000);
		}
        private double CalculatePathCost(WoWPoint source, WoWPoint destination, IList <WoWPoint> path)
        {
            double pathCost   = 0.0;
            int    pointCount = path.Count();

            for (int i = 0; i < pointCount - 1; ++i)
            {
                pathCost = path[i].Distance(path[i + 1]);
            }

            return(source.Distance(path[0]) + pathCost + destination.Distance(path[pointCount - 1]));
        }
Example #14
0
 public static void movetoLoc(WoWPoint loc)
 {
     while (loc.Distance(Me.Location) > 10)
     {
         Navigator.MoveTo(loc);
         Thread.Sleep(100);
         if (inCombat)
         {
             return;
         }
     }
 }
Example #15
0
 private void MovementMoveToMeleeVoid(WoWUnit toUnit)
 {
     if (THSettings.Instance.AutoMove &&
         DateTime.Now > DoNotMove &&
         !IsOverrideModeOn &&
         !Me.IsCasting &&
         !Me.IsChanneling &&
         toUnit != null &&
         toUnit != Me &&
         toUnit.IsAlive &&
         //Only Move again After a certain delay or target move 3 yard from original posision
         (DateTime.Now > LastMovementTime + MovementDelay ||
          LastMovementWoWPoint.Distance(toUnit.Location) >
          DistanceToUpdateMovement) &&
         (toUnit.Distance - toUnit.BoundingRadius > Dtm(toUnit) ||
          !toUnit.IsWithinMeleeRange))
     {
         LastMovementTime     = DateTime.Now;
         LastMovementWoWPoint = toUnit.Location;
         Navigator.MoveTo(LastMovementWoWPoint);
     }
 }
Example #16
0
        // 29Apr2013-09:51UTC chinajade
        public static double HeightOverGroundOrWater(this WoWPoint location, double probeDistance = 300.0)
        {
            WoWPoint hitLocation;
            WoWPoint destination = location.Add(0.0, 0.0, -probeDistance);

            var isObstructed = GameWorld.TraceLine(location, destination,
                                                   TraceLineHitFlags.Collision
                                                   | TraceLineHitFlags.LiquidAll,
                                                   out hitLocation);

            return(isObstructed
                ? location.Distance(hitLocation)
                : double.MaxValue);
        }
 public static void MoveToLocation(WoWPoint loc)
 {
     while (loc.Distance(StyxWoW.Me.Location) > 3)
     {
         if (!Flightor.MountHelper.Mounted)
         {
             Flightor.MountHelper.MountUp();
         }
         if (!StyxWoW.Me.IsMoving)
         {
             Flightor.MoveTo(loc);
         }
     }
 }
Example #18
0
 public static void movetoLoc(WoWPoint loc)
 {
     Mount.MountUp();
     while (loc.Distance(Me.Location) > 4)
     {
         Navigator.MoveTo(loc);
         Thread.Sleep(100);
         if (inCombat)
         {
             return;
         }
     }
     Thread.Sleep(2000);
 }
        /// <summary>
        /// Calculates the distance between START and DESTINATION if the travel must be conducted
        /// over a surface (i.e., instead of flying).  This is most helpful in tunnels where a mob
        /// can be within X feet of you, but above or below you.  For such mobs, the direct distance
        /// is X feet, but the path you must take through the tunnels may be much much longer.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="destination"></param>
        /// <returns></returns>
        /// <remarks>17Apr2011-12:16UTC chinajade</remarks>
        public static float SurfacePathDistance(this WoWPoint start, WoWPoint destination)
        {
            WoWPoint[] groundPath = Navigator.GeneratePath(start, destination) ?? new WoWPoint[0];

            // We define an invalid path to be of 'infinite' length
            if (groundPath.Length <= 0)
            {
                // For targets in the air, we will be unable to calculate the
                // surface path to them.  If we're flying, we still want
                // a gauging of the distance, so we use half the max float range,
                // and tack on the line-of-site distance to the unit.
                // This allows sane ordering evaluations in LINQ queries, yet
                // still returns something close enough to 'infinite' to make
                // using the path highly undesirable.
                return((float.MaxValue / 2) + start.Distance(destination));
            }


            // Include distance it takes us to get from start point to first point in path...
            float pathDistance = start.Distance(groundPath[0]);

            // Include distance it takes us to get from last point in path to destination...
            pathDistance += groundPath[groundPath.Length - 1].Distance(destination);

            // Include distance for each point in path...
            for (int i = 0; i < (groundPath.Length - 1); ++i)
            {
                pathDistance += groundPath[i].Distance(groundPath[i + 1]);
            }

            // Sanity check...
            QuestBehaviorBase.ContractProvides(
                pathDistance >= start.Distance(destination),
                context => "Surface path distance must be equal to or greater than straight-line distance.");

            return(pathDistance);
        }
Example #20
0
 public static void StuckDetector()
 {
     if (!StyxWoW.Me.Dead)
     {
         if (!stuckSW.IsRunning)
         {
             stuckSW.Start();
             stuckWP = StyxWoW.Me.Location;
         }
         else if (stuckSW.Elapsed.TotalSeconds > 15 || stuckWP.Distance(StyxWoW.Me.Location) > 3)
         {
             stuckSW.Reset();
             stuckSW.Start();
             stuckWP = StyxWoW.Me.Location;
         }
         else if (stuckWP.Distance(StyxWoW.Me.Location) < 5 && ((stuckSW.Elapsed.Seconds > 2 && !StyxWoW.Me.IsSwimming) || stuckSW.Elapsed.Seconds > 20))
         {//is stuck
             StuckBehaviour();
             stuckSW.Reset();
             stuckSW.Start();
             stuckWP = StyxWoW.Me.Location;
         }
     }
 }
Example #21
0
        public static int CountOfAddsInRange(double distance, WoWPoint location)
        {
            List <WoWUnit> hlist =
                (from o in ObjectManager.ObjectList
                 where o is WoWUnit
                 let p = o.ToUnit()
                         where p.Distance2D < 40 &&
                         !p.Dead &&
                         p.Combat &&
                         (p.IsTargetingMyPartyMember || p.IsTargetingMeOrPet) &&
                         p.IsHostile &&
                         p.Attackable
                         select p).ToList();

            return(hlist.Count(u => location.Distance(u.Location) <= distance));
        }
Example #22
0
        public static int CountOfAddsInRange(double distance, WoWPoint location)
        {
            List<WoWUnit> hlist =
                (from o in ObjectManager.ObjectList
                 where o is WoWUnit
                 let p = o.ToUnit()
                 where p.Distance2D < 40
                       && !p.Dead
                       && p.Combat
                       && (p.IsTargetingMyPartyMember || p.IsTargetingMeOrPet)
                       && p.IsHostile
                       && p.Attackable
                 select p).ToList();

            return hlist.Count(u => location.Distance(u.Location) <= distance);
        }
Example #23
0
 public static void performSafeFlight(WoWPoint landLoc, WoWPoint targetLoc)
 {
     if (_me.Location.Distance(targetLoc) > 2)
     {
         while (landLoc.Distance(_me.Location) > 1)
         {
             Flightor.MoveTo(landLoc);
             Thread.Sleep(100);
         }
         Flightor.MountHelper.Dismount();
         while (targetLoc.Distance(_me.Location) > 1)
         {
             Navigator.MoveTo(targetLoc);
             Thread.Sleep(100);
         }
     }
 }
Example #24
0
        /// <summary>
        /// Returns the cost to travel between 2 point.
        /// Points that are not on mesh have a much higher cost.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="destination">The destination.</param>
        /// <returns></returns>
        public static float PathTraversalCost(this WoWPoint start, WoWPoint destination)
        {
            float pathDistance = SurfacePathDistance(start, destination);

            if (!float.IsNaN(pathDistance))
            {
                return(pathDistance);
            }

            // For targets in the air, we will be unable to calculate the
            // surface path to them.  If we're flying, we still want
            // a gauging of the distance, so we use half the max float range,
            // and tack on the line-of-site distance to the unit.
            // This allows sane ordering evaluations in LINQ queries, yet
            // still returns something close enough to 'infinite' to make
            // using the path highly undesirable.
            return((float.MaxValue / 2) + start.Distance(destination));
        }
Example #25
0
        private void MoveToAh()
        {
            WoWPoint movetoPoint = _loc;
            WoWUnit  auctioneer;

            if (AutoFindAh || movetoPoint == WoWPoint.Zero)
            {
                auctioneer =
                    ObjectManager.GetObjectsOfType <WoWUnit>()
                    .Where(o => o.IsAuctioneer && o.IsAlive)
                    .OrderBy(o => o.Distance)
                    .FirstOrDefault();
            }
            else
            {
                auctioneer =
                    ObjectManager.GetObjectsOfType <WoWUnit>()
                    .Where(o => o.IsAuctioneer && o.Location.Distance(_loc) < 5)
                    .OrderBy(o => o.Distance)
                    .FirstOrDefault();
            }
            if (auctioneer != null)
            {
                movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, auctioneer.Location, 3);
            }
            else if (movetoPoint == WoWPoint.Zero)
            {
                movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NearestAH, 0);
            }
            if (movetoPoint == WoWPoint.Zero)
            {
                PBLog.Warn(Strings["Error_UnableToFindAuctioneer"]);
            }
            if (movetoPoint.Distance(StyxWoW.Me.Location) > 4.5)
            {
                Util.MoveTo(movetoPoint);
            }
            else if (auctioneer != null)
            {
                auctioneer.Interact();
            }
        }
Example #26
0
        public static bool nodeIsBlacklisted(WoWPoint wp)
        {
            List <Stopwatch> sw = blackList.Keys.ToList();

            for (int i = blackList.Count - 1; i >= 0; i--)
            {
                if (sw[i].Elapsed.TotalMinutes >= blackListTime)
                {
                    blackList.Remove(sw[i]);
                }
            }
            foreach (WoWPoint wowp in blackList.Values)
            {
                if (wp.Distance(wowp) < 50)
                {
                    return(true);
                }
            }
            return(false);
        }
        public static void WaitForMount()
        {
            if (Me.Combat || Me.IsIndoors || !CharacterSettings.Instance.UseMount)
            {
                return;
            }

            WaitForStop();
            WoWPoint ptStop = Me.Location;

            var timeOut = new Stopwatch();

            timeOut.Start();

            if (!Mount.CanMount())
            {
                return;
            }

            Log("Attempting to mount via HB...");
            Mount.MountUp();
            StyxWoW.SleepForLagDuration();

            while (IsGameStable() && Me.CurrentHealth > 1 && Me.IsCasting)
            {
                Thread.Sleep(75);
            }

            if (!Me.Mounted)
            {
                Log("unable to mount after {0} ms", timeOut.ElapsedMilliseconds);
                if (ptStop.Distance(Me.Location) != 0)
                {
                    Log("character was stopped but somehow moved {0:F3} yds while trying to mount", ptStop.Distance(Me.Location));
                }
            }
            else
            {
                Log("Mounted");
            }
        }
Example #28
0
        public static double SurfacePathDistance(this WoWPoint start,
                                                 WoWPoint destination)
        {
            WoWPoint[] groundPath = Navigator.GeneratePath(start, destination) ?? new WoWPoint[0];

            // We define an invalid path to be of 'infinite' length
            if (groundPath.Length <= 0)
            {
                return(double.MaxValue);
            }


            double pathDistance = start.Distance(groundPath[0]);

            for (int i = 0; i < (groundPath.Length - 1); ++i)
            {
                pathDistance += groundPath[i].Distance(groundPath[i + 1]);
            }

            return(pathDistance);
        }
Example #29
0
        public static void GetUnstuck()
        {
            PriorityTreeState.StuckTimer.Reset();

            //PickPocketTarget.AddToStuckBlacklist();

            Enemy.ClearAllTargetData();

            WoWPoint myNewWoWPoint;

            do {
                float x, y, z;
                do {
                    x = StyxWoW.Me.Location.X + RandomNumber.GenerateRandomFloat(-20, 20);
                    y = StyxWoW.Me.Location.Y + RandomNumber.GenerateRandomFloat(-20, 20);
                } while(!Navigator.FindHeight(x, y, out z));
                myNewWoWPoint = new WoWPoint(x, y, z);
            } while(!Navigator.CanNavigateFully(StyxWoW.Me.Location, myNewWoWPoint) && myNewWoWPoint.Distance(StyxWoW.Me.Location) < 5);

            DaVinci.CustomDiagnosticLog("Unstuck: Moving to " + myNewWoWPoint);
            Navigator.MoveTo(myNewWoWPoint);
        }
Example #30
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(
                                     new Decorator(
                                         ret => wp.Distance(ObjectManager.Me.Location) > 5,
                                         new Sequence(
                                             new Action(ret => TreeRoot.StatusText = "Moving to location"),
                                             new Action(ret => Navigator.MoveTo(wp)))),
                                     new Decorator(
                                         ret => !ObjectManager.Me.HasAura("Vault Cracking Toolset"),
                                         new Sequence(
                                             new Action(ret => q14122bank[0].Interact()),
                                             new Action(ret => StyxWoW.SleepForLagDuration())
                                             )),

                                     new Decorator(
                                         ret => !IsAttached,
                                         new Sequence(
                                             new Action(ret => Lua.Events.AttachEvent("CHAT_MSG_RAID_BOSS_WHISPER", q14122msg)),
                                             new Action(ret => IsAttached = true))),
                                     new Decorator(
                                         ret => StyxWoW.Me.QuestLog.GetQuestById(14122).IsCompleted,
                                         new PrioritySelector(
                                             new Decorator(
                                                 ret => IsAttached,
                                                 new Sequence(
                                                     new Action(ret => Styx.Helpers.Logging.Write("Detaching")),
                                                     new Action(ret => Lua.Events.DetachEvent("CHAT_MSG_RAID_BOSS_WHISPER", q14122msg)),
                                                     new Action(ret => IsBehaviorDone = true)
                                                     )))),
                                     new Decorator(
                                         ret => StyxWoW.Me.QuestLog.GetQuestById(14122).IsCompleted&& ObjectManager.Me.HasAura("Vault Cracking Toolset"),
                                         new Sequence(
                                             new Action(ret => Lua.DoString("VehicleExit()"))
                                             ))
                                     )));
        }
Example #31
0
        private void MoveToBanker()
        {
            WoWPoint  movetoPoint = _loc;
            WoWObject bank        = GetLocalBanker();

            if (bank != null)
            {
                movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, bank.Location, 4);
            }
            // search the database
            else if (movetoPoint == WoWPoint.Zero)
            {
                movetoPoint = MoveToAction.GetLocationFromDB(
                    Bank == BankType.Personal
                                                ? MoveToAction.MoveToType.NearestBanker
                                                : MoveToAction.MoveToType.NearestGB,
                    NpcEntry);
            }
            if (movetoPoint == WoWPoint.Zero)
            {
                IsDone = true;
                PBLog.Warn("Unable to find bank");
            }
            if (movetoPoint.Distance(StyxWoW.Me.Location) > 4)
            {
                Util.MoveTo(movetoPoint);
            }
            // since there are many personal bank replacement addons I can't just check if frame is open and be generic.. using events isn't reliable
            else if (bank != null)
            {
                bank.Interact();
            }
            else
            {
                IsDone = true;
                PBLog.Warn(Strings["Error_UnableToFindBank"]);
            }
        }
        void MovetoAuctioneer()
        {
            WoWPoint movetoPoint = _loc;
            WoWUnit  auctioneer;

            if (AutoFindAh || movetoPoint == WoWPoint.Zero)
            {
                auctioneer = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.IsAuctioneer && o.IsAlive)
                             .OrderBy(o => o.Distance).FirstOrDefault();
            }
            else
            {
                auctioneer = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.IsAuctioneer &&
                                                                              o.Location.Distance(_loc) < 5)
                             .OrderBy(o => o.Distance).FirstOrDefault();
            }
            if (auctioneer != null)
            {
                movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, auctioneer.Location, 3);
            }
            else if (movetoPoint == WoWPoint.Zero)
            {
                movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NearestAH, 0);
            }
            if (movetoPoint == WoWPoint.Zero)
            {
                Logging.Write("Unable to location Auctioneer, Maybe he's dead?");
            }
            if (movetoPoint.Distance(ObjectManager.Me.Location) > 4.5)
            {
                Util.MoveTo(movetoPoint);
            }
            else if (auctioneer != null)
            {
                auctioneer.Interact();
            }
        }
 public static void MoveToLoc(WoWPoint loc)
 {
     Mount.MountUp(() => loc);
     while (loc.Distance(Me.Location) > 8)
     {
         Navigator.MoveTo(loc);
         Thread.Sleep(100);
         if (inCombat) return;
     }
     Thread.Sleep(2000);
 }
Example #34
0
        public WoWPoint FindLocation(WoWPoint ptOrigin)
        {
            DateTime startFind = DateTime.Now;
            int countPointsChecked = 0;
            int countFailToPointNav = 0;
            int countFailRange = 0;
            int countFailSafe = 0;
            int countFailToPointLoS = 0;
            int countFailToMobLoS = 0;
            double furthestNearMobDistSqr = 0f;
            WoWPoint ptFurthest = WoWPoint.Empty;
            bool reallyCheckRangeToLineOfSightMob = CheckRangeToLineOfSightMob && Me.GotTarget;
            WoWPoint ptAdjOrigin = ptOrigin;
            ptAdjOrigin.Z += 1f;

            WoWPoint ptDestination = new WoWPoint();
            List<WoWPoint> mobLocations = new List<WoWPoint>();
            float arcIncrement = ((float)Math.PI * 2) / RaysToCheck;

            mobLocations = AllEnemyMobLocationsToCheck;
            double minSafeDistSqr = MinSafeDistance * MinSafeDistance;

            float baseDestinationFacing = MobToRunFrom == null ?
                                            Me.RenderFacing + (float)Math.PI
                                            : Styx.Helpers.WoWMathHelper.CalculateNeededFacing(MobToRunFrom.Location, Me.Location);

            // Logger.WriteDebug( Color.Cyan, "SafeArea: search near {0:F0}d @ {1:F1} yds for mob free area", RadiansToDegrees(baseDestinationFacing), MinSafeDistance);

            for (int arcIndex = 0; arcIndex < RaysToCheck; arcIndex++)
            {
                // rather than tracing around the circle, toggle between clockwise and counter clockwise for each test
                // .. so we favor a position furthest away from mob
                float checkFacing = baseDestinationFacing;
                if ((arcIndex & 1) == 0)
                    checkFacing += arcIncrement * (arcIndex >> 1);
                else
                    checkFacing -= arcIncrement * ((arcIndex >> 1) + 1);

                for (float distFromOrigin = MinScanDistance; distFromOrigin <= MaxScanDistance; distFromOrigin += IncrementScanDistance)
                {
                    countPointsChecked++;

                    ptDestination = ptOrigin.RayCast(checkFacing, distFromOrigin);
                    if (!Navigator.CanNavigateFully(Me.Location, ptDestination))
                    {
                        // Logger.WriteDebug( Color.Cyan, "Safe Location failed navigation check for degrees={0:F1} dist={1:F1}", RadiansToDegrees(checkFacing), distFromOrigin);
                        countFailToPointNav++;
                        continue;
                    }

                    WoWPoint ptNearest = NearestMobLoc(ptDestination, mobLocations);
                    if (ptNearest == WoWPoint.Empty)
                    {
                        if (furthestNearMobDistSqr < minSafeDistSqr)
                        {
                            furthestNearMobDistSqr = minSafeDistSqr;
                            ptFurthest = ptDestination;     // set best available if others fail
                        }
                    }
                    else
                    {
                        double mobDistSqr = ptDestination.Distance2DSqr(ptNearest);
                        if (furthestNearMobDistSqr < mobDistSqr)
                        {
                            furthestNearMobDistSqr = mobDistSqr;
                            ptFurthest = ptDestination;     // set best available if others fail
                        }
                        if (mobDistSqr <= minSafeDistSqr)
                        {
                            countFailSafe++;
                            continue;
                        }
                    }

                    if (reallyCheckRangeToLineOfSightMob && RangeToLineOfSightMob < ptDestination.Distance(LineOfSightMob.Location) - LineOfSightMob.MeleeDistance())
                    {
                        countFailRange++;
                        continue;
                    }

                    if (CheckLineOfSightToSafeLocation)
                    {
                        WoWPoint ptAdjDest = ptDestination;
                        ptAdjDest.Z += 1f;
                        if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptAdjOrigin, ptAdjDest))
                        {
                            // Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                            countFailToPointLoS++;
                            continue;
                        }
                    }

                    if (CheckSpellLineOfSightToMob && LineOfSightMob != null)
                    {
                        if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSpellSight(ptDestination, LineOfSightMob.Location))
                        {
                            if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptDestination, LineOfSightMob.Location))
                            {
                                // Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                                countFailToMobLoS++;
                                continue;
                            }
                        }
                    }

                    Logger.WriteDebug(Color.Cyan, "SafeArea: Found mob-free location ({0:F1} yd radius) at degrees={1:F1} dist={2:F1} on point check# {3}", MinSafeDistance, WoWMathHelper.RadiansToDegrees(checkFacing), distFromOrigin, countPointsChecked);
                    Logger.WriteDebug(Color.Cyan, "SafeArea: processing took {0:F0} ms", (DateTime.Now - startFind).TotalMilliseconds);
                    return ptDestination;
                }
            }

            Logger.WriteDebug(Color.Cyan, "SafeArea: No mob-free location ({0:F1} yd radius) found within {1:F1} yds ({2} checked, {3} nav, {4} not safe, {5} range, {6} pt los, {7} mob los)", MinSafeDistance, MaxScanDistance, countPointsChecked, countFailToPointNav, countFailSafe, countFailRange, countFailToPointLoS, countFailToMobLoS);
            if (ChooseSafestAvailable && ptFurthest != WoWPoint.Empty)
            {
                Logger.WriteDebug(Color.Cyan, "SafeArea: choosing best available spot in {0:F1} yd radius where closest mob is {1:F1} yds", MinSafeDistance, Math.Sqrt(furthestNearMobDistSqr));
                Logger.WriteDebug(Color.Cyan, "SafeArea: processing took {0:F0} ms", (DateTime.Now - startFind).TotalMilliseconds);
                return ChooseSafestAvailable ? ptFurthest : WoWPoint.Empty;
            }

            Logger.WriteDebug(Color.Cyan, "SafeArea: processing took {0:F0} ms", (DateTime.Now - startFind).TotalMilliseconds);
            return WoWPoint.Empty;
        }
Example #35
0
 public static void MoveToLocation(WoWPoint loc)
 {
     while (loc.Distance(Me.Location) > 3)
     {
         Flightor.MountHelper.MountUp();
         Navigator.MoveTo(loc);
     }
 }
 public static void MoveToLocation(WoWPoint loc)
 {
     while (loc.Distance(StyxWoW.Me.Location) > 3) {
             if (!Flightor.MountHelper.Mounted) {
                 Flightor.MountHelper.MountUp();
             }
             if (!StyxWoW.Me.IsMoving) {
                 Flightor.MoveTo(loc);
             }
         }
 }
        private static bool Stuck()
        {
            WoWPoint myPoint = new WoWPoint(Me.X, Me.Y, Me.Z);

                if (TreeRoot.StatusText.Contains("Wait"))
            {
            TimerRestartFermo.Reset();
                TimerUnstuck.Reset();
            return false;
            }
            //if (TreeRoot.GoalText.Contains("Wait"))
            //{
            //restartStandingStillTimer.Reset();
                //TimerUnstuck.Reset();
            //return false;
            //}

            if (TreeRoot.StatusText.Contains("Downloading"))
            {
            TimerRestartFermo.Reset();
                TimerUnstuck.Reset();
            return false;
            }

            if (TreeRoot.StatusText.Contains("Loading Tile"))
            {
            TimerRestartFermo.Reset();
                TimerUnstuck.Reset();
            return false;
            }

            if (myPoint.Distance(lastPoint) > settings.StuckRange)
            {
                lastPoint = myPoint;
               TimerRestartFermo.Reset();
                TimerUnstuck.Reset();
                return false;
            }

            if (!TimerRestartFermo.IsRunning)
               TimerRestartFermo.Start();

            if (!TimerUnstuck.IsRunning)
                TimerUnstuck.Start();

            if (!archBuddyTimer.IsRunning && Me.IsFlying && Me.Combat)
                archBuddyTimer.Start();
            else if (archBuddyTimer.IsRunning && (!Me.IsFlying || !Me.Combat))
                archBuddyTimer.Reset();

            if (!swimTimer.IsRunning && Me.IsSwimming)
                swimTimer.Start();
            else if (swimTimer.IsRunning && !Me.IsSwimming)
                swimTimer.Reset();

            if (!TimerMount.IsRunning && Me.Mounted)
             	{
            TimerMount.Start();
            }
            else if (TimerMount.IsRunning && (!Me.Mounted || !Me.IsFlying ))
               	{
                 TimerMount.Reset();
            }
            if (TimerRestartFermo.Elapsed.TotalSeconds > settings.StuckRestart)
            {
               TimerRestartFermo.Reset();

                if (restartIntervalThread != null && restartIntervalThread.IsAlive)
                {
                    restartIntervalThread.Abort();
                }
                if (restartWhenStuckThread != null && restartWhenStuckThread.IsAlive)
                {
                    restartWhenStuckThread.Abort();
                }

                restartWhenStuckThread = new Thread(new ThreadStart(RestartWhenStuckThread));
                restartWhenStuckThread.Start();
                return true;
            }

            if (TimerUnstuck.Elapsed.TotalSeconds > settings.StuckRoutine && !Me.Combat)
            {
                swimTimer.Reset();
                TimerUnstuck.Reset();
                UnstuckRoutine();
                return true;
            }

            if (PoolFisherFixMins != 0 && swimTimer.Elapsed.TotalMinutes > PoolFisherFixMins)
            {
                swimTimer.Reset();
                TimerUnstuck.Reset();
                UnstuckRoutine();
                return true;
            }

            if (ArchBuddyFixMins != 0 && archBuddyTimer.Elapsed.TotalMinutes > ArchBuddyFixMins)
            {
                Log("Dismounting while flying");
                archBuddyTimer.Reset();
                Mount.Dismount();
                return true;
            }

            if (TimerMount.Elapsed.TotalSeconds > settings.MountStuck && Me.Mounted )
            {
                Log("Dismounting to unstuck");
                TimerMount.Reset();
                //Mount.Dismount();
            Lua.DoString("Dismount() CancelShapeshiftForm()");
                return true;
            }

            return false;
        }
Example #38
0
        public static WoWGameObject GetClosestObjectSalesmanHb(WoWPoint from, WoWGameObject[] objectsToArray)
        {
            PathGenerationStopwatch.Reset();
            PathGenerationStopwatch.Start();

            GarrisonButler.Diagnostic("Starting salesman algorithm.");

            //Generating data
            var objectsTo = objectsToArray.OrderBy(o => from.Distance(o.Location)).Take(5).ToArray();
            var objectsCount = objectsTo.Count();
            var vertics = new int[objectsCount + 1];
            var matrix = new double[objectsCount + 1, objectsCount + 1];

            // Adding starting point
            vertics[0] = 0;
            matrix[0, 0] = 0;
            // Adding distance from starting point to all objects
            for (int index = 0; index < objectsTo.Length; index++)
            {
                var gameObject = objectsTo[index];
                var distance = Navigator.PathDistance(@from, gameObject.Location) ?? float.MaxValue;
                matrix[0, index + 1] = (float)distance;
                matrix[index + 1, 0] = (float)distance;
            }

            // Adding distances from every points to all others
            for (int index1 = 0; index1 < objectsTo.Length; index1++)
            {
                vertics[index1 + 1] = index1 + 1;

                for (int index2 = index1; index2 < objectsTo.Length; index2++)
                {
                    if (index1 == index2)
                        matrix[index1 + 1, index2 + 1] = 0.0;
                    else
                    {
                        var distance = Navigator.PathDistance(@from, objectsTo[index2].Location) ?? float.MaxValue;
                        matrix[index1 + 1, index2 + 1] = distance;
                        matrix[index2 + 1, index1 + 1] = distance;
                    }
                }
                GarrisonButler.Diagnostic("[Salesman] Processed node in {0}ms", PathGenerationStopwatch.ElapsedMilliseconds);
            }
            double cost;
            var salesman = new Salesman(vertics, matrix);
            var route = salesman.Solve(out cost).ToArray();

            PathGenerationStopwatch.Stop();
            GarrisonButler.Diagnostic("[Salesman] Tour found in {0}ms, cost={1}, route:", PathGenerationStopwatch.ElapsedMilliseconds, cost);
            ObjectDumper.WriteToHb(route, 3);

            return objectsTo[route[1] - 1];
        }
        public override void Pulse()
        {
            #region pulsechecks
            if (!TreeRoot.IsRunning)
                return;
            if (Me.Combat && !Me.GotTarget)
            {
                GetClosestLiveUnitByID(24978).Target();
            }
            if (Me.Combat || Me.Dead || Me.IsGhost || Me.IsResting)
                return;
            #endregion
            QuestlistUpdate();
            //Logging.WriteDebug(TreeRoot.GoalText);
            if (TreeRoot.GoalText == "Goal: Kill Sunwell - Quest Bunny - Poratl x 1")
                TreeRoot.GoalText = "DHX Goal: Take Poratl Reading";
            if (TreeRoot.GoalText == "Goal: Kill Sunwell - Quest Bunny - Sunwell x 1")
                TreeRoot.GoalText = "DHX Goal: Take BloodCrystal Reading";
            if (TreeRoot.GoalText == "Goal: Kill Sunwell - Quest Bunny - Shrine x 1")
                TreeRoot.GoalText = "DHX Goal: Take Shrine Reading";
            if (TreeRoot.GoalText == "Goal: Kill mob with ID 25086 10 times")
                TreeRoot.GoalText = "DHX Goal: Free 10 Greengill Slaves";
            #region looting fix
            List<WoWUnit> LootMobList = ObjectManager.GetObjectsOfType<WoWUnit>();
            if (!StyxWoW.Me.Combat)
            {
                foreach (WoWUnit unit in LootMobList)
                {
                    if (!unit.IsAlive && unit.CanLoot)
                    {
                        while (StyxWoW.Me.Location.Distance(unit.Location) > 4 || unit.CanLoot)
                        {
                            try
                            {
                                WoWMovement.ClickToMove(unit.Location);
                            }
                            catch { }
                            if (StyxWoW.Me.Location.Distance(unit.Location) <= 4)
                            {
                                try
                                {
                                    if (unit.CanLoot)
                                    {
                                        unit.Interact();
                                        Styx.Logic.Inventory.Frames.LootFrame.LootFrame.Instance.LootAll();
                                        LootMobList.Remove(unit);
                                    }
                                    else if (unit.CanLoot)
                                    {
                                        while (unit.CanLoot)
                                        {
                                            unit.Interact();
                                            Styx.Logic.Inventory.Frames.LootFrame.LootFrame.Instance.LootAll();
                                        }
                                        LootMobList.Remove(unit);
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
            if (!StyxWoW.Me.GotTarget && !StyxWoW.Me.Combat && Styx.Logic.LootTargeting.Instance.LootingList.Count == 0)
            {
                LootMobList.Clear();
            }
            #endregion
            #region bloodberry bush loot reliability
            WoWObject bloddberrybush = GetClosestObjectByID(187333);
            if (bloddberrybush != null)
            {
                if (bloddberrybush.Distance < 5 && !Me.Combat)
                {
                    bloddberrybush.Interact();
                }
            }
            #endregion
            #region emissary of hate
            if(InvChkByID(34414))
            {
                if (Me.CanLoot || Me.Looting)
                    return;
                WoWUnit emissary = GetUnitByID(25003);
                if (emissary != null)
                {
                    if (emissary.Dead && emissary.Distance < 10)
                    {
                        useItemByID(34414);
                    }
                }
            }
            #endregion
            #region dont stop now
            ObjectManager.Update();
            while (KeyChkByID(34477) && InvTotalByID(34479) < 3 && IsQuestCompleted(11547))
            {
                Logging.WriteDebug("found key");
                WoWObject orechest = GetClosestObjectByID(187264);
                if (orechest != null)
                {
                    Logging.WriteDebug("found chest");
                    while (orechest.Distance > 3)
                    {
                        if (Me.Combat || Me.Dead || Me.IsGhost)
                            return;
                        Navigator.MoveTo(orechest.Location);
                        if (orechest.Distance < 5)
                        {
                            Navigator.Clear(); WoWMovement.MoveStop();
                            orechest.Interact();
                            Thread.Sleep(3000);
                        }
                        ObjectManager.Update();
                        return;
                    }
                }
            }
            while (!IsQuestCompleted(11536) && TreeRoot.GoalText == "Goal: Collect Darkspine Iron Ore x 3" && !KeyChkByID(34477))
            {
                if (Me.Combat || Me.Dead || Me.IsGhost)
                    return;
                WoWUnit oretarget = GetClosestLiveUnitByID(25060);
                oretarget.Target();
                oretarget.Face();
                Me.ToggleAttack();
                if (oretarget.Distance > 5)
                    Navigator.MoveTo(oretarget.Location);
            }
            #endregion
            #region pay 10 gold
            if (SSQuestIDList.Contains(11548))
            {
                Lua.DoString("StaticPopup1Button1:Click()");
            }
            #endregion

            #region greengill
            if (Me.CanLoot || Me.Looting)
                return;
            if (InvChkByID(34483))
            {
                WoWUnit greengilltarget = GetClosestUnitByID(25084);
                if (greengilltarget != null)
                {
                    if (greengilltarget.Distance < 36)
                    {
                        useItemByID(34483);
                        Styx.Logic.Combat.SpellManager.ClickRemoteLocation(greengilltarget.Location);
                        Thread.Sleep(4000);
                    }
                }
            }
            #endregion
            if (InvTotalByID(34338) >= 4)
                arms1 = true;
            #region turnin Arm the Wards
            if ((TreeRoot.GoalText == "Goal: Collect Mana Remnants x 4" || TreeRoot.GoalText == "Goal: TurnIn Arm the Wards!") && IsQuestCompleted(11523) && SSQuestIDList.Contains(11523) && !SSCompQuests.Contains(11523))
            {
                bool handindone = false;
                WoWPoint armsgoto = new WoWPoint(12892.95, -6880.174, 9.040649);
                while (armsgoto.Distance(Me.Location) > 0 || !handindone)
                {
                    if (TreeRoot.GoalText != "Goal: TurnIn Arm the Wards!")
                    {
                        TreeRoot.GoalText = "Goal: TurnIn Arm the Wards!";
                    }
                    Navigator.MoveTo(armsgoto);
                    while (armsgoto.Distance(Me.Location) < 3 && !handindone)
                    {
                        Navigator.Clear();
                        WoWMovement.MoveStop();
                        GetUnitByID(24967).Interact();
                        Thread.Sleep(2000);
                        Lua.DoString("GossipTitleButton1:Click()");
                        Thread.Sleep(2000);
                        QuestBot.QuestHelper.QuestFrame.CompleteQuest();
                        handindone = true;
                        return;
                    }
                }
            }
            #endregion
            #region ES
            if (SSQuestIDList.Contains(11525) && InvChkByID(34368) && !IsQuestCompleted(11525) && (!Me.CanLoot || !Me.Looting))
            {
                ObjectManager.Update();
                if (Me.Dead || Me.Combat || Me.IsGhost || Me.CanLoot || Me.Looting || Me.IsResting)
                    return;
                if (!IsQuestCompleted(11525))
                {
                    if (Me.Dead || Me.Combat || Me.IsGhost || Me.CanLoot || Me.Looting || Me.IsResting)
                        return;
                    WoWUnit ClosestUnit = GetClosestUnitByID(24972);
                    if (ClosestUnit == null)
                        return;
                    if (ClosestUnit.KilledByMe)
                    {
                        while (ClosestUnit.Distance > 5)
                            {
                                if (Me.Dead || Me.Combat || Me.IsGhost || Me.CanLoot || Me.Looting || Me.IsResting)
                                {
                                    Navigator.Clear(); WoWMovement.MoveStop();
                                    return;
                                }
                                Navigator.MoveTo(ClosestUnit.Location);
                            }
                            TargetByGUID(ClosestUnit.Guid);
                            Navigator.Clear(); WoWMovement.MoveStop();
                            useItemByID(34368);
                            Thread.Sleep(3000);
                            return;
                    }
                        if (ClosestUnit.Entry == 24972 && !ClosestUnit.TaggedByOther && !ClosestUnit.TaggedByMe && !ClosestUnit.Dead && !IsQuestCompleted(11525))
                        {
                            Logging.Write("found 1 alive");
                            if (ClosestUnit.Distance < 30)
                            {
                                ClosestUnit.Target();
                                Me.ToggleAttack();
                                while (!Me.Combat && ClosestUnit.Distance < 50)
                                {
                                    if (Me.Dead || Me.Combat || Me.IsGhost || Me.CanLoot || Me.Looting || Me.IsResting)
                                    {
                                        Navigator.Clear(); WoWMovement.MoveStop();
                                        return;
                                    }
                                    Navigator.MoveTo(ClosestUnit.Location);
                                    Me.ToggleAttack();
                                }
                            }
                            return;
                        }
                }
            }
            #endregion
              while (arms1 && !IsQuestCompleted(11523) && IsQuestCompleted(11525))
            {
                if (Me.Dead || Me.Combat || Me.IsGhost || Me.CanLoot || Me.Looting || Me.IsResting)
                    return;
                WoWPoint armsgoto = new WoWPoint(12913.55, -6932.246, 3.872839);
                while (armsgoto.Distance(Me.Location) > 0)
                {
                    if (Me.Dead || Me.Combat || Me.IsGhost || Me.CanLoot || Me.Looting || Me.IsResting)
                        return;
                    Navigator.MoveTo(armsgoto);
                    if (armsgoto.Distance(Me.Location) < 5)
                    {
                        useItemByID(34338);
                        Thread.Sleep(5000);
                        return;
                    }
                }
                return;
            }
            #region Know your ley lines
            if (InvChkByID(34533))
            {
                WoWObject ley1 = GetClosestObjectByID(25156);
                WoWObject ley2 = GetClosestObjectByID(25157);
                WoWObject ley3 = GetClosestObjectByID(25154);
                if (ley1 != null && !ley1done && ley1.Distance2D <5)
                {
                    Logging.WriteDebug("ley 1");
                    Thread.Sleep(2000);
                    Navigator.Clear(); WoWMovement.MoveStop();
                    useItemByID(34533);
                    Thread.Sleep(6000);
                    ley1done = true;

            //<Hotspot X="12575.54" Y="-6915.316" Z="4.602137" />

                }
                if (ley2 != null && !ley2done && ley2.Distance2D < 5)
                {
                    Logging.WriteDebug("ley 2");
                    Thread.Sleep(2000);
                    Navigator.Clear(); WoWMovement.MoveStop();
                    useItemByID(34533);
                    Thread.Sleep(6000);
                    ley2done = true;
                }
                //<Hotspot X="12771.83" Y="-6705.073" Z="2.288224" />
                if (ley3 != null && !ley3done && ley3.Distance2D < 5)
                {
                    Logging.WriteDebug("ley 2");
                    Thread.Sleep(2000);
                    Navigator.Clear(); WoWMovement.MoveStop();
                    useItemByID(34533);
                    Thread.Sleep(6000);
                    ley3done = true;
                }
            }
            #endregion
        }
Example #40
0
        /*
         public bool ArcaneBurn()
        {
            if (!SpellManager.Spells["Evocation"].Cooldown && !SpellManager.Spells["Arcane Power"].Cooldown && !SpellManager.Spells["Mirror Image"] && !SpellManager.Item["Mana Gem"].Cooldown)//However you would do that check for mana gem//
            {
                return true;
            }
         }
        */
        //only works with mobs, not players, need a new one for pvp.
        public static bool WillChain(int Hits, WoWPoint TargetLocal)
        {
            List<WoWUnit> hitList = new List<WoWUnit>();

                List<WoWUnit> enemyList = ObjectManager.GetObjectsOfType<WoWUnit>(false).FindAll(unit =>
                        unit.Attackable &&
                        !unit.IsFriendly &&
                        !unit.Combat &&
                        unit != Me &&
                        unit != Me.CurrentTarget);
                foreach (WoWUnit Plr in enemyList)
                {
                    if (TargetLocal.Distance(Plr.Location) < 8)
                    {
                        hitList.Add(Plr);
                    }

                }

            if (hitList.Count > Hits)
            {
                Log("Found Targets {0} near CurrentTarget", hitList.Count.ToString());
                hitList.Clear();
                return true;

            }
            else
            {
                hitList.Clear();
                return false;
            }
        }
Example #41
0
        public override void Pulse()
        {
            ObjectManager.Update();

            if (onstart)
            {
                Log("loaded");
                Lua.Events.AttachEvent("CHAT_MSG_RAID_BOSS_WHISPER", HandleRBW);
                Lua.Events.AttachEvent("CHAT_MSG_MONSTER_EMOTE", HandleME);
                Lua.Events.AttachEvent("CHAT_MSG_MONSTER_SAY", HandleMS);
                Lua.Events.AttachEvent("UI_ERROR_MESSAGE", HandleUEM);
                onstart = false;
            }
            #region stuck issues
            if (!Me.Dead && Me.Location.Distance(stuckloc1) < 5)
            {
                Log("In proximity of general stuck location. Moving out");
                WoWMovement.ClickToMove(safeloc1);
                Thread.Sleep(3000);
                Styx.Logic.Pathing.Navigator.Clear();
            }
            if (Me.IsGhost && Me.Location.Distance(stuckloc2) < 10)
            {
                Log("In proximity of general stuck location. Moving out");
                WoWMovement.ClickToMove(safeloc2);
                Thread.Sleep(5000);
                Styx.Logic.Pathing.Navigator.Clear();
            }
            #endregion
            #region 26026
            if ((!Me.Dead && Me.QuestLog.GetQuestById(26026) != null && q26026mob.Count > 0) || (Me.Combat && Me.ZoneId == 400 && Me.CurrentTarget != null && Me.CurrentTarget.DistanceSqr < 5 * 5 && Me.CurrentTarget.Entry != 40959))
            {
                Log("AntiFuckin'Disengage Procedure running");
                WoWMovement.MoveStop();
                while (Me.Combat && Me.CurrentTarget != null && !Me.CurrentTarget.Dead && Me.CurrentTarget.DistanceSqr < 5 * 5)
                {
                    if (!Me.IsAutoAttacking)
                    {
                        SpellManager.Cast(6603);
                    }
                    Me.CurrentTarget.Face();
                    SpellManager.Cast(34026);
                    Thread.Sleep(1000);
                    SpellManager.Cast(2973);
                    Thread.Sleep(2000);
                }

            }
            #endregion
            #region 13988
            if (!Me.Dead && Me.QuestLog.GetQuestById(13988) != null && !Me.Combat && q13988mob.Count == 0)
            {
                Log("Where the f**k did that bird go?");
                WoWMovement.MoveStop();
                Thread.Sleep(100);
                Lua.DoString("UseItemByName(46782)");
                Thread.Sleep(2000);
            }
            #endregion
            #region 25688
            if (!Me.Dead && Me.QuestLog.GetQuestById(25688) != null && !Me.QuestLog.GetQuestById(25688).IsCompleted && q25688mob.Count > 0)
            {
                Log(q25688mob[0].Name+" Disrupting ressurect. Kill it");
                q25688mob[0].Target();
                Thread.Sleep(200);
                Lua.DoString("PetAttack()");
                if (q25688mob[0].Location.Distance(Me.Pet.Location) < 5 && SpellManager.Spells.ContainsKey("Kill Command") && !SpellManager.Spells["Kill Command"].Cooldown)
                {
                    Log("Kill Command");
                    SpellManager.Cast("Kill Command");
                }
            }
            #endregion
            #region 26028
            if (Me.QuestLog.GetQuestById(26028) != null && Me.Combat && Me.CurrentTarget != null)
            {
                Log("CC override");
                Me.CurrentTarget.Face();
                Lua.DoString("RunMacroText('/click VehicleMenuBarActionButton1','0')");
                Lua.DoString("RunMacroText('/click VehicleMenuBarActionButton3','0')");
                Blacklist.Add(Me.CurrentTarget.Guid, TimeSpan.FromMinutes(1));
                Me.ClearTarget();
            }
            #endregion
            while (Me.QuestLog.GetQuestById(24958) != null && !Me.QuestLog.GetQuestById(24958).IsCompleted && Me.CurrentTarget != null && Me.CurrentTarget.Entry == 38855 && Me.CurrentTarget.IsAlive)
            {
                Log("Firing at "+Me.CurrentTarget.Name);
                WoWMovement.MoveStop();
                Me.CurrentTarget.Face();
                Thread.Sleep(100);
                Lua.DoString("UseItemByName(52043)");
                Thread.Sleep(100);
            }
            #region 25165
            if (Me.QuestLog.GetQuestById(25165) != null && !Me.QuestLog.GetQuestById(25165).IsCompleted && Me.CurrentTarget != null && Me.CurrentTarget.Entry == 3125 && Me.CurrentTarget.Location.Distance(Me.Location) <= 30 && counter == 0 && Me.CurrentTarget.IsAlive)
            {
                WoWMovement.MoveStop();
                SpellManager.Cast(75);
                while (!Me.CurrentTarget.IsCasting)
                {
                    Log("Waiting for "+Me.CurrentTarget.Name +" to start a cast");
                    Thread.Sleep(1000);
                }
                Log("Placing totem for "+Me.CurrentTarget.Name);
                Lua.DoString("UseItemByName(52505)");
                Thread.Sleep(2000);
                counter++;
            }
            if (Me.QuestLog.GetQuestById(25165) != null && !Me.QuestLog.GetQuestById(25165).IsCompleted && !Me.Combat)
            {
                counter = 0;
            }

            #endregion
            #region 27336
            if (Me.QuestLog.GetQuestById(27336) != null && !Me.QuestLog.GetQuestById(27336).IsCompleted && Me.Combat && Dothis && Me.CurrentTarget != null && (Me.CurrentTarget.Entry == 4344 || Me.CurrentTarget.Entry == 4345))
            {
                Dothis = false;
                Log("Placing totem for "+Me.CurrentTarget.Name);
                Lua.DoString("UseItemByName(33101)");
                SpellManager.Cast(781);
                Thread.Sleep(1500);
                SpellManager.Cast(3044);
            }
            if (Me.QuestLog.GetQuestById(27336) != null && !Me.QuestLog.GetQuestById(27336).IsCompleted && !Me.Combat && !Dothis)
            {
                Dothis = true;
            }
            if (Me.QuestLog.GetQuestById(27336) != null && !Me.QuestLog.GetQuestById(27336).IsCompleted && Me.Combat && Me.CurrentTarget != null && (Me.CurrentTarget.Entry == 4344 || Me.CurrentTarget.Entry == 4345) && Me.CurrentTarget.CurrentHealth < 500)
            {
                Log("Calling pet back to get the killing blow");
                Lua.DoString("PetStopAttack()");
                WoWMovement.MoveStop();
                Me.CurrentTarget.Face();
                while (Me.Combat && Me.CurrentTarget != null && !Me.CurrentTarget.Dead && Me.CurrentTarget.CurrentHealth < 500)
                {
                    SpellManager.Cast(53351);
                    SpellManager.Cast(2973);
                    Thread.Sleep(300);
                }
            }
            #endregion
            #region 13961
            if ((!dothis.IsRunning || dothis.Elapsed.Seconds > 5) && Me.QuestLog.GetQuestById(13961) != null && !Me.QuestLog.GetQuestById(13961).IsCompleted && Me.CurrentTarget != null && Me.CurrentTarget.Entry == 34503 && Me.CurrentTarget.Location.Distance(Me.Location) <= 15 && !Me.HasAura("Dragging a Razormane"))
            {
                Log("Using net on "+Me.CurrentTarget.Name);
                dothis.Reset();
                dothis.Start();
                Lua.DoString("UseItemByName(46722)");
                Thread.Sleep(100);
                Blacklist.Add(Me.CurrentTarget.Guid, TimeSpan.FromMinutes(1));
                Thread.Sleep(100);
                Me.ClearTarget();

            }
            if (Me.HasAura("Dragging a Razormane"))
            {
                Log("Dragging a Razormane");
                dothis.Reset();
            }
            #endregion
            #region tame
            if (!Me.Dead && !Me.IsGhost && Me.QuestLog.GetQuestById(881) != null && Me.CarriedItems.Any(i => i.Entry == 10327) && !Me.GotAlivePet)
            {
                Log("taming new pet!");
                while (!Me.GotAlivePet)
                {
                    ObjectManager.Update();
                    if (tamelist.Count > 0)
                    {
                        tamelist[0].Target();
                        tamelist[0].Face();
                        if (tamelist[0].Location.Distance(Me.Location) > 30)
                        {
                            Navigator.MoveTo(tamelist[0].Location);
                        }
                        if (tamelist[0].Location.Distance(Me.Location) <= 30 && !Me.IsCasting)
                        {
                            WoWMovement.MoveStop();
                            SpellManager.Cast("Tame Beast");
                        }
                    }
                    if (tamelist.Count == 0 && !Me.IsCasting)
                    {
                        WoWPoint tameloc = new WoWPoint(-22.75822, -2395.158, 91.66674);
                        if (tameloc.Distance(Me.Location) > 1)
                        {
                            Navigator.MoveTo(tameloc);
                        }
                        if (tameloc.Distance(Me.Location) <= 1)
                        {
                            WoWMovement.MoveStop();
                            Thread.Sleep(2000);
                            Lua.DoString("UseItemByName(10327)");
                        }
                    }
                }
                Me.ClearTarget();
            }
            #endregion
            #region 13621
            if (!Me.Dead && Me.QuestLog.GetQuestById(13621) != null && !Me.QuestLog.GetQuestById(13621).IsCompleted)
            {
                if (!afktimer.IsRunning)
                {
                    Log("checking stuck");
                    Log("saving current position");
                    WoWPoint prevloc = new WoWPoint(Me.X, Me.Y, Me.Z);
                    lastpoint = prevloc;
                    afktimer.Reset();
                    afktimer.Start();
                }
                if (afktimer.Elapsed.Seconds > 55 && lastpoint == Me.Location)
                {
                    Log("stuck");
                    afktimer.Reset();
                    ProfileManager.LoadNew(Path.Combine(Path.GetDirectoryName(ProfileManager.XmlLocation), "ashenvale.xml"), false);
                }
                if (afktimer.Elapsed.Seconds > 55 && lastpoint != Me.Location)
                {
                    Log("all good");
                    afktimer.Reset();
                }
            }
            if (!Me.Dead && Me.QuestLog.GetQuestById(13621) != null && Me.QuestLog.GetQuestById(13621).IsCompleted)
            {
                afktimer.Reset();
            }
            #endregion
            #region mounted & under attack
            if (Me.Mounted && Me.Combat && !Me.CarriedItems.Any(i => i.Entry == 56799))
            {
                Log("Dismount & fight");
                Mount.Dismount();
            }
            #endregion
            #region 13980
            if (!Me.Dead && Me.QuestLog.GetQuestById(13980) != null && !Me.QuestLog.GetQuestById(13980).IsCompleted && !Me.HasAura("Jinx's Elf Detection Ray"))
            {
                Log("Using Jinx's Goggles");
                Lua.DoString("UseItemByName(46776)");
            }
            #endregion
            #region 26066
            while (Me.QuestLog.GetQuestById(26066) != null && !Me.QuestLog.GetQuestById(26066).IsCompleted && Me.Combat && Me.CurrentTarget != null && (Me.CurrentTarget.Entry == 11915 || Me.CurrentTarget.Entry == 11917))
            {
                if (Me.CurrentTarget.Location.Distance(Me.Location) > 4)
                {
                    Navigator.MoveTo(Me.CurrentTarget.Location);
                }
                else
                {
                    Log("Using Whip on " +Me.CurrentTarget.Name);
                    WoWMovement.MoveStop();
                    Lua.DoString("UseItemByName(56794)");
                }
            }
            #endregion
            #region 25757
            if (!Me.Dead && Me.QuestLog.GetQuestById(25757) != null && !Me.QuestLog.GetQuestById(25757).IsCompleted && Me.Combat && Me.CurrentTarget != null && Me.CurrentTarget.Entry == 41196 && Me.CurrentTarget.CurrentHealth == 1)
            {
                Log("Moving to loot "+ Me.CurrentTarget.Name);
                while (!Me.CurrentTarget.WithinInteractRange)
                {
                    Navigator.MoveTo(Me.CurrentTarget.Location);
                }
                WoWMovement.MoveStop();
                Thread.Sleep(1000);
                Me.CurrentTarget.Interact();
                Me.ClearTarget();
            }
            #endregion
            if (Me.Race == WoWRace.Goblin && Me.ZoneId == 4720 && Me.HasAura("Near Death!") && goblinrezmob.Count > 0)
            {
                goblinrezmob[0].Interact();
                Thread.Sleep(1000);
                Lua.DoString("RunMacroText('/click QuestFrameCompleteQuestButton')");
            }
            #region 25628
            if (!Me.Dead && Me.QuestLog.GetQuestById(25628) != null && Me.Combat && Me.CurrentTarget != null && Me.CurrentTarget.Entry == 40959)
            {
                Lua.DoString("UseItemByName(55158)");
                Thread.Sleep(1000);
                Me.ClearTarget();
            }
            #endregion
            #region 27330
            if (!Me.Dead && Me.QuestLog.GetQuestById(27330) != null && Me.Combat && q27330mob.Count > 3 && Me.CurrentTarget.Entry == 45447)
            {
                Log("Ending combat");
                Lua.DoString("StopAttack()");
                Lua.DoString("PetStopAttack()");
                Me.ClearTarget();
            }
            if (!Me.Dead && Me.QuestLog.GetQuestById(27330) != null && Me.Combat && q27330mob.Count == 1 && Me.CurrentTarget.Entry == 45447)
            {
                Log("Switching target");
                q27330mob[0].Target();
            }

            #endregion
            #region 24814
            if (!Me.Dead && Me.QuestLog.GetQuestById(24814) != null && !Me.QuestLog.GetQuestById(24814).IsCompleted && Me.Combat && q24814mob.Count > 0 && Me.CurrentTarget.Entry == 38306)
            {
                Log("Switching target");
                q24814mob[0].Target();
            }
            #endregion
            #region 25591
            if (!Me.Dead && Me.QuestLog.GetQuestById(25591) != null && Me.Combat && q25591mob.Count == 1 && Me.CurrentTarget.Entry != 41083)
            {
                Log("Switching target");
                q25591mob[0].Target();
            }

            #endregion
            #region 25112
            if (!Me.Dead && Me.QuestLog.GetQuestById(25112) != null && !Me.QuestLog.GetQuestById(25112).IsCompleted && q25112mob.Count > 0)
            {
                Log("Harvesting Basillisk");
                Thread.Sleep(1000);
                q25112mob[0].Target();
                Lua.DoString("UseItemByName(52715)");
                Thread.Sleep(1000);
                localblacklist.Add(q25112mob[0].Guid);
                Me.ClearTarget();
            }
            #endregion
            #region 25701
            if (!Me.Dead && Me.QuestLog.GetQuestById(25701) != null && !Me.QuestLog.GetQuestById(25701).IsCompleted && q25701mob.Count > 0)
            {
                Log("Using knife");
                Thread.Sleep(1000);
                q25701mob[0].Target();
                Lua.DoString("UseItemByName(56012)");
                Thread.Sleep(1000);
            }
            #endregion
            #region 25111
            if (!Me.Dead && Me.QuestLog.GetQuestById(25111) != null && !Me.QuestLog.GetQuestById(25111).IsCompleted && q25111mob.Count > 0)
            {
                Log("Harvesting Fire Roc");
                Thread.Sleep(1000);
                q25111mob[0].Target();
                Lua.DoString("UseItemByName(52715)");
                Thread.Sleep(1000);
                localblacklist.Add(q25111mob[0].Guid);
                Me.ClearTarget();
            }
            #endregion
            #region 25115
            if (!Me.Dead && Me.QuestLog.GetQuestById(25115) != null && !Me.QuestLog.GetQuestById(25115).IsCompleted && q25115mob.Count > 0)
            {
                Log("Harvesting Blisterpaw Hyena");
                Thread.Sleep(1000);
                q25115mob[0].Target();
                Lua.DoString("UseItemByName(52715)");
                Thread.Sleep(1000);
                localblacklist.Add(q25115mob[0].Guid);
                Me.ClearTarget();
            }
            #endregion
            #region 24737
            if (!Me.Dead && Me.QuestLog.GetQuestById(24737) != null && !Me.QuestLog.GetQuestById(24737).IsCompleted && q24737mob.Count > 0)
            {
                Log("Harvesting Tar");
                while (Me.Location.Distance(q24737mob[0].Location) > 5)
                {
                    Navigator.MoveTo(q24737mob[0].Location);
                }
                WoWMovement.MoveStop();
                Thread.Sleep(300);
                q24737mob[0].Target();
                Lua.DoString("UseItemByName(50742)");
                Thread.Sleep(2000);
                localblacklist.Add(q24737mob[0].Guid);
                Me.ClearTarget();
            }
            #endregion
            #region 24699
            if (!Me.Dead && Me.QuestLog.GetQuestById(24699) != null && !Me.QuestLog.GetQuestById(24699).IsCompleted && q24699mob.Count > 0)
            {
                Log("Harvesting Tar");
                while (Me.Location.Distance(q24699mob[0].Location) > 5)
                {
                    Navigator.MoveTo(q24699mob[0].Location);
                }
                WoWMovement.MoveStop();
                Thread.Sleep(300);
                q24699mob[0].Target();
                Lua.DoString("UseItemByName(50746)");
                Thread.Sleep(2000);
                localblacklist.Add(q24699mob[0].Guid);
                Me.ClearTarget();
            }
            #endregion
            #region 13850
            while (!Me.Dead && Me.QuestLog.GetQuestById(13850) != null && !Me.QuestLog.GetQuestById(13850).IsCompleted && Me.Combat && Me.CurrentTarget != null && Me.CurrentTarget.Entry == 6508 && !Me.CurrentTarget.Dead && Me.HealthPercent > 30)
            {
                Log("Suicide mission");
                Lua.DoString("PetStopAttack()");
                while (Me.CurrentTarget.Location.Distance(Me.Location) > 5)
                {
                    Navigator.MoveTo(Me.CurrentTarget.Location);
                }
                WoWMovement.MoveStop();
                if (!Me.IsAutoAttacking)
                {
                    SpellManager.Cast(6603);
                }
                Thread.Sleep(1000);
            }
            #endregion
            #region 13850
            while (!Me.Dead && Me.QuestLog.GetQuestById(24697) != null && !Me.QuestLog.GetQuestById(24697).IsCompleted && Me.Combat && Me.CurrentTarget != null && (Me.CurrentTarget.Entry == 9162 || Me.CurrentTarget.Entry == 9163) && Me.CurrentTarget.HasAura("Throw Meat"))
            {
                Log("Running back to spike pit");
                WoWPoint pitloc = new WoWPoint(-7530.954, -1458.899, -279.552);
                while (Me.Location.Distance(pitloc) > 2)
                {
                    Navigator.MoveTo(pitloc);
                }
                WoWMovement.MoveStop();
                Thread.Sleep(1000);
            }
            #endregion
            #region 24963
            while (!Me.Dead && Me.QuestLog.GetQuestById(24963) != null && !Me.QuestLog.GetQuestById(24963).IsCompleted && q24963mob.Count > 0)
            {
                Log("Feeding " + q24963mob[0].Name);
                SpellManager.StopCasting();
                q24963mob[0].Target();
                Thread.Sleep(100);
                Lua.DoString("UseItemByName(52044)");
            }
            #endregion
            #region 8346
            if (!Me.Dead && Me.QuestLog.GetQuestById(8346) != null && !Me.QuestLog.GetQuestById(8346).IsCompleted && q8346mob.Count > 0 && Me.Location.Distance(q8346mob[0].Location) < 7)
            {
                Log("Casting Arcane Torrent on " + q8346mob[0].Name);
                SpellManager.StopCasting();
                q8346mob[0].Target();
                Thread.Sleep(100);
                Lua.DoString("CastSpellByName('Arcane Torrent')");
            }
            #endregion
            #region stupid bot behaviors
            if (!Me.Dead && PNDErrorCount > 5)
            {
                Log("Calling pet");
                Thread.Sleep(2000);
                Lua.DoString("CastSpellByName('Call Pet 1')");
                PNDErrorCount = 0;
            }
            if (!Me.Dead && LOSErrorCount > 5 && Me.CurrentTarget != null)
            {
                Log("moving closer to target to get in LoS");
                Navigator.MoveTo(Me.CurrentTarget.Location);
                LOSErrorCount = 0;
                Thread.Sleep(2000);
            }
            if (!Me.Dead && TooCloseErrorCount > 5 && Me.CurrentTarget != null && !Me.IsAutoAttacking)
            {
                Log("Attacking target");
                Lua.DoString("CastSpellByName('Auto Attack')");
                TooCloseErrorCount = 0;
            }
            #endregion
            #region combat overrides
            //If someone knows a better way to avoid combat or override current CC behavior please contact me.
            if (Me.Combat && Me.QuestLog.GetQuestById(24695) == null)
            {
                if (Me.HealthPercent < 30)
                {
                    Healing.UseHealthPotion();
                }
                if (Me.CurrentTarget == null && badtargets.Count > 0 && (!InCombatTimer.IsRunning || InCombatTimer.Elapsed.Seconds > 5))
                {
                    InCombatTimer.Start();
                    if (InCombatTimer.Elapsed.Seconds > 5)
                    {
                        Log("stuck in combat with " +badtargets[0].Name);
                        newtarget[0].Target();
                        InCombatTimer.Reset();
                    }
                }
                foreach (WoWUnit t in Targeting.Instance.TargetList.Where(t => Me.Level > 11 && Me.GotAlivePet && t.CurrentTargetGuid == Me.Guid && Me.Pet.CurrentTargetGuid != t.Guid && Me.CurrentTarget != null && t.CanSelect))
                {
                    Log(t.Name+" Is touching me in funny places! Let my pet join the fun");
                    WoWUnit LastTarget = Me.CurrentTarget;
                    Lua.DoString("StopAttack()");
                    t.Target();
                    Thread.Sleep(200);
                    Lua.DoString("PetAttack()");
                    if (Me.Combat && t.Location.Distance(Me.Pet.Location) > 7)
                    {
                        ObjectManager.Update();
                        Thread.Sleep(2000);
                        Lua.DoString("PetAttack()");
                    }
                    if (SpellManager.Spells.ContainsKey("Intimidation") && !SpellManager.Spells["Intimidation"].Cooldown)
                    {
                        Log("Using Intimidation");
                        SpellManager.Cast("Intimidation");
                    }
                    if (SpellManager.Spells.ContainsKey("Kill Command") && !SpellManager.Spells["Kill Command"].Cooldown)
                    {
                        Log("Kill Command");
                        SpellManager.Cast("Kill Command");
                    }
                    LastTarget.Target();
                    Thread.Sleep(500);
                }
                foreach (WoWUnit t in Targeting.Instance.TargetList.Where(t => Me.Level > 11 && Me.GotAlivePet && t.CurrentTargetGuid == Me.Guid && t.Entry == 41064 && Me.CurrentTarget != null))
                {
                    Log(t.Name+" Argo on me. Lets try to survive");
                    Lua.DoString("StopAttack()");
                    Thread.Sleep(200);
                    Lua.DoString("PetAttack()");
                    while (Me.Combat && t.Location.Distance(Me.Location) < 15 && !t.Dead)
                    {
                        ObjectManager.Update();
                        Thread.Sleep(500);
                        Lua.DoString("PetAttack()");
                        WoWMovement.Move(WoWMovement.MovementDirection.Backwards);
                        if (SpellManager.Spells.ContainsKey("Intimidation") && !SpellManager.Spells["Intimidation"].Cooldown)
                        {
                            Log("Using Intimidation");
                            SpellManager.Cast("Intimidation");
                        }
                        if (SpellManager.Spells.ContainsKey("Kill Command") && !SpellManager.Spells["Kill Command"].Cooldown)
                        {
                            Log("Kill Command");
                            SpellManager.Cast("Kill Command");
                        }
                    }
                    WoWMovement.MoveStop(WoWMovement.MovementDirection.Backwards);

                }
            }
            #endregion
            while (Me.BagItems.Exists(i => i.Entry == 49932) && Me.QuestLog.GetQuestById(24606) == null)
            {
                Styx.Logic.Inventory.Frames.Quest.QuestFrame quest = new Styx.Logic.Inventory.Frames.Quest.QuestFrame();
                Lua.DoString("UseItemByName(49932)");
                Thread.Sleep(1000);
                quest.AcceptQuest();
            }
        }
        private void PortalsRule()
        {
            while (IsStarted && !StyxWoW.IsInWorld)
            {
                Thread.Sleep(1000);
            }
            //BotPoi.Current.Type == PoiType.Repair
            //Check for BG, Instance, Zone we can't get back to
            if (!IsStarted && (CurrentPOI.Type == PoiType.Mail || CurrentPOI.Type == PoiType.Repair || CurrentPOI.Type == PoiType.Sell) && !Styx.BotManager.Current.Name.ContainsAny(BadBotBases))
            {
                Log(CurrentPOI.Type.ToString(), "detected.  Using Portalling Option");
                IsStarted = true;
                IsFinished = false;
                return;
            }
            while (!Me.IsActuallyInCombat && !MadeItToOrg && IsStarted)
            {
                OldLocation = Me.Location;
                OldMapId = Me.MapId;
                Log("Old MapId is: ", Me.MapId.ToString());
                OldZoneName = Me.ZoneText;
                Log("Old ZoneName is: ", Me.ZoneText);
                if (ObjectManager.GetObjectsOfType<WoWUnit>().Where(o => o.IsHostile && o.IsAlive && o.Distance < 5).Count() == 0)
                {
                    SpellManager.StopCasting();
                    Styx.Logic.Mount.Dismount();
                    Navigator.PlayerMover.MoveStop();
                    StyxWoW.SleepForLagDuration();
                    if (SpellManager.CanCast(3567))
                    {
                        IsStarted = true;
                        SpellManager.Cast(3567);
                        Thread.Sleep(2500);
                        while (Me.IsCasting || !StyxWoW.IsInWorld)
                        {
                            Log("Sleeping while casting", null);
                            Thread.Sleep(5000);
                        }
                        Log("End of Sleep 1, Sleep additional 5 seconds.", null);
                        Thread.Sleep(5000);
                        if (/*Me.MapId == Org*/true)
                        {
                            MadeItToOrg = true;
                        }
                        return;
                    }
                    else
                    {
                        IsStarted = false;
                    }
                }
            }


            //Move to Vendor (Sell & Repair), Move to Mailbox (Mail Items)
            while (MadeItToOrg && !DidRepair && IsStarted)
            {
                ObjectManager.Update();
                if (Me.Location.Distance(new WoWPoint(1776.5, -4338.8, -7.508744)) < 10)
                {
                    Navigator.MoveTo(new WoWPoint(1823.608, -4304.775, -12.16005));
                    foreach (WoWUnit Muragas in ObjectManager.GetObjectsOfType<WoWUnit>().Where(o => o.Entry == 3330))
                    {
                        while (Muragas.Distance > Muragas.InteractRange) { Navigator.MoveTo(Muragas.Location); Log("Moving to Repair."); }
                        Navigator.PlayerMover.MoveStop();
                        Muragas.Interact();
                        StyxWoW.SleepForLagDuration();
                        Styx.Logic.Vendors.RepairAllItems();
                        StyxWoW.SleepForLagDuration();
                        Styx.Logic.Vendors.SellAllItems();
                        StyxWoW.SleepForLagDuration();
                    }
                }
                DidRepair = true;
                return;
            }



            while (DidRepair && !CheckRunes && IsStarted)
            {
                //Check for Runes of Teleport, buy if I have less than 5
                uint NumberOfRunes = 0;
                ObjectManager.Update();
                foreach (WoWItem Runes in ObjectManager.GetObjectsOfType<WoWItem>().Where(o => o.Entry == 17031))
                {
                    if (Runes.BagSlot != -1)
                    {
                        NumberOfRunes += Runes.StackCount;
                    }
                }
                Log("Found # Runes:", NumberOfRunes.ToString());
                if (NumberOfRunes < 5)
                {
                    while (new WoWPoint(1819.77, -4305.931, -12.17886).Distance(Me.Location) > 3)
                    {
                        Navigator.MoveTo(new WoWPoint(1819.77, -4305.931, -12.17886));
                    }
                    while (new WoWPoint(1812.137, -4318.922, -11.23538).Distance(Me.Location) > 3)
                    {
                        Navigator.MoveTo(new WoWPoint(1812.137, -4318.922, -11.23538));
                    }
                    while (new WoWPoint(1831.635, -4333.173, -15.48243).Distance(Me.Location) > 3)
                    {
                        Navigator.MoveTo(new WoWPoint(1831.635, -4333.173, -15.48243));
                    }
                    foreach (WoWUnit ReagentVendor in ObjectManager.GetObjectsOfType<WoWUnit>().Where(o => o.Entry == 3335))
                    {
                        Log("Inside ReagVend Foreach.", null);
                        while (ReagentVendor.Location.Distance(Me.Location) > ReagentVendor.InteractRange) { Navigator.MoveTo(ReagentVendor.Location); }
                        Navigator.PlayerMover.MoveStop();
                        ReagentVendor.Interact();
                        while (!MerchantFrame.Instance.IsVisible) { Thread.Sleep(100); }
                        MerchantFrame.Instance.BuyItem("Rune of Teleportation", 5);
                        Log("Bought 5 'Rune of Teleportation'", null);
                        StyxWoW.SleepForLagDuration();
                    }
                    NumberOfRunes = 0;
                    while (new WoWPoint(1831.958, -4331.217, -15.48225).Distance(Me.Location) > 2)
                    {
                        Navigator.MoveTo(new WoWPoint(1831.958, -4331.217, -15.48225));
                    }
                }
                CheckRunes = true;
                return;
            }


            while (CheckRunes && !MovedOutside && IsStarted)
            {
                while (new WoWPoint(1798.782, -4325.472, -11.27483).Distance(Me.Location) > 2)
                {
                    Navigator.MoveTo(new WoWPoint(1798.782, -4325.472, -11.27483));
                    Log("Moving Outside. Step 1.", null);
                }
                while (new WoWPoint(1778.542, -4295.233, 6.407692).Distance(Me.Location) > 2)
                {
                    Navigator.MoveTo(new WoWPoint(1778.542, -4295.233, 6.407692));
                    Log("Moving Outside. Step 2", null);
                }
                while (new WoWPoint(1756.049, -4306.153, 6.61089).Distance(Me.Location) > 3)
                {
                    Navigator.MoveTo(new WoWPoint(1756.049, -4306.153, 6.61089));
                    Log("Moving Outside. Step 3", null);
                }
                while (new WoWPoint(1786.761, -4239.646, 40.70471).Distance(Me.Location) > 4)
                {
                    Navigator.MoveTo(new WoWPoint(1786.761, -4239.646, 40.70471));
                    Log("Moving Outside. Step 4", null);
                }
                MovedOutside = true;
                return;
            }


            while (MovedOutside && !DidMail && IsStarted)
            {
                if (Styx.Logic.Inventory.InventoryManager.HaveItemsToMail && Styx.Helpers.CharacterSettings.Instance.MailRecipient != null)
                {
                    ObjectManager.Update();
                    Log("Mailing Items");
                    foreach (WoWGameObject Mailbox in ObjectManager.GetObjectsOfType<WoWGameObject>().Where(o => o.Entry == 206732 && o.SubType == WoWGameObjectType.Mailbox))
                    {
                        Log("Inside Mailbox Foreach", null);
                        while (Mailbox.Location.Distance(Me.Location) > Mailbox.InteractRange) { Navigator.MoveTo(Mailbox.Location); }
                        Navigator.PlayerMover.MoveStop();
                        Thread.Sleep(1000);
                        Mailbox.Interact();
                        StyxWoW.SleepForLagDuration();
                        Styx.Logic.Vendors.MailAllItems();
                        StyxWoW.SleepForLagDuration();
                    }
                }
                else
                {
                    Log("No Items to Mail.  Continue!");
                    DidMail = true;
                    return;
                }
            }


            while (DidMail && !MovedToPortals && IsStarted)
            {
                //Move to Portal Area
                Thread.Sleep(1000);
                if (!Me.Mounted) { Flightor.MountHelper.MountUp(); }
                Thread.Sleep(1000);
                while (Me.IsCasting) { Thread.Sleep(100); }
                Log("Flightor moving to Portals");
                while (new WoWPoint(2048.148, -4376.259, 98.84513).Distance(Me.Location) > 4)
                {
                    Flightor.MoveTo(new WoWPoint(2048.148, -4376.259, 98.84513));
                    Thread.Sleep(100);
                }
                Log("Made it to Portals");
                Thread.Sleep(500);
                Flightor.MountHelper.Dismount();
                MovedToPortals = true;
                return;
            }


            while (MovedToPortals && !UsedPortal && IsStarted)
            {
                while (Me.IsCasting) { Thread.Sleep(50); }
                Thread.Sleep(500);
                if (Me.Mounted) { Flightor.MountHelper.Dismount(); }
                Thread.Sleep(500);
                ObjectManager.Update();
                foreach (WoWGameObject Portal in ObjectManager.GetObjectsOfType<WoWGameObject>().Where(o => o.Entry == 206595))
                {
                    while (Portal.Location.Distance(Me.Location) > Portal.InteractRange)
                    {
                        Navigator.MoveTo(Portal.Location);
                        Log("Moving towards ", Portal.Name);
                        Thread.Sleep(100);
                    }
                    Navigator.PlayerMover.MoveStop();
                    Thread.Sleep(500);
                    Portal.Interact();
                    Thread.Sleep(5000);
                }
                //Insert Logic to use correct portal, or just f**k off!
                if (OldMapId == 599999)
                {
                    //I don't f*****g know
                }

                if (OldZoneName == "ShitYea")
                {
                    //F**k off
                }
                UsedPortal = true;
                return;
            }


            while (MadeItToOrg && DidRepair && CheckRunes && DidMail && MovedToPortals && UsedPortal && !ReturnedToXYZ && IsStarted)
            {
                Thread.Sleep(10000);
                if (Me.MapId == OldMapId)
                {
                    if (BotManager.Current.Name == "Grind Bot")
                    {
                        Log("Using 'Grind Bot'.");
                        /*if(Styx.Logic.Profiles.Quest.ProfileHelperFunctionsBase.CanFly())
                        {
                            Log("Flying back to Original XYZ.");
                            Flightor.MountHelper.MountUp();
                            Thread.Sleep(1000);
                            while (Me.IsCasting) { Thread.Sleep(100); }
                            while (OldLocation.Distance(Me.Location) > 5)
                            {
                                Flightor.MoveTo(OldLocation);
                                Thread.Sleep(100);
                            }
                        }*/
                        //Doesn't fackin work!
                        Thread.Sleep(5000);
                        Log("Returning to Orig XYZ");
                        while (OldLocation.Distance(Me.Location) > 5)
                        {
                            Navigator.MoveTo(OldLocation);
                            Thread.Sleep(100);
                        }
                        Log("At Original XYZ.");
                        IsFinished = true;
                    }
                    /*
                    if (BotManager.Current.Name == "Gatherbuddy2")
                    {
                        Flightor.MountHelper.MountUp();
                        IsFinished = true;
                    }
                    if (BotManager.Current.Name == "Questing")
                    {
                        Flightor.MountHelper.MountUp();
                        Thread.Sleep(500);
                        while (Me.IsCasting) { Thread.Sleep(100); }
                        StyxWoW.SleepForLagDuration();
                        Flightor.MoveTo(OldLocation);
                        IsFinished = true;
                    }
                    if (BotManager.Current.Name == "ArchaeologyBuddy")
                    {
                        Flightor.MountHelper.MountUp();
                        IsFinished = true;
                    }*/
                }
                IsFinished = true;
                ReturnedToXYZ = true;
                return;
            }

            if (IsStarted && IsFinished)
            {
                Log("Successful internention of Sell/Mail/Repair");
                Log("Now waiting for another opportunity...");
                MadeItToOrg = false;
                DidRepair = false;
                CheckRunes = false;
                DidMail = false;
                MovedOutside = false;
                MovedToPortals = false;
                UsedPortal = false;
                ReturnedToXYZ = false;
                IsStarted = false;
                IsFinished = false;
            }
            if (IsStarted && !IsFinished)
            {
                Log("Well I messed up somewhere.", null);
                Log("You're character is now stuck, and I don't have the logic to get it back to where it was apparently, so please attach this log in the MageHelper thread and explain where you were farming.", null);
                IsStarted = true;
                IsFinished = true;
            }

            /* ZONE ID LIST
             * 0 = Kalimdor
             * 1 = Eastern Kingdoms
             * 8 = Outlands
             * 10 = Northrend
             * 11 = Maelstrom
             * 5042 = Deepholm
             * 5389 = Tol Barad Peninsula
             * 
             */

        }//End of PortalsRule()
 public static bool nodeIsBlacklisted(WoWPoint wp)
 {
     List<Stopwatch> sw = blackList.Keys.ToList();
     for (int i = blackList.Count - 1; i >= 0; i--)
     {
         if (sw[i].Elapsed.TotalMinutes >= blackListTime)
         {
             blackList.Remove(sw[i]);
         }
     }
     foreach (WoWPoint wowp in blackList.Values)
     {
         if (wp.Distance(wowp) < 50)
         {
             return true;
         }
     }
     return false;
 }
Example #44
0
 protected override RunStatus Run(object context)
 {
     if (!IsDone)
     {
         WoWPoint movetoPoint = loc;
         if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible)
         {
             if (AutoFindMailBox || movetoPoint == WoWPoint.Zero)
             {
                 _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.SubType == WoWGameObjectType.Mailbox)
                            .OrderBy(o => o.Distance).FirstOrDefault();
             }
             else
             {
                 _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.SubType == WoWGameObjectType.Mailbox &&
                                                                                   o.Location.Distance(loc) < 10)
                            .OrderBy(o => o.Distance).FirstOrDefault();
             }
             if (_mailbox != null)
             {
                 movetoPoint = WoWMathHelper.CalculatePointFrom(me.Location, _mailbox.Location, 3);
             }
             if (movetoPoint == WoWPoint.Zero)
             {
                 return(RunStatus.Failure);
             }
             if (movetoPoint.Distance(ObjectManager.Me.Location) > 4.5)
             {
                 Util.MoveTo(movetoPoint);
             }
             else if (_mailbox != null)
             {
                 _mailbox.Interact();
             }
             return(RunStatus.Running);
         }
         else
         {
             List <WoWItem> ItemList = BuildItemList();
             if (ItemList == null || ItemList.Count == 0)
             {
                 IsDone = true;
                 return(RunStatus.Failure);
             }
             using (new FrameLock()) {
                 MailFrame.Instance.SwitchToSendMailTab();
                 foreach (WoWItem item in ItemList)
                 {
                     item.UseContainerItem();
                 }
                 Lua.DoString(string.Format("SendMail ('{0}',' ','');SendMailMailButton:Click();", CharacterSettings.Instance.MailRecipient.ToFormatedUTF8()));
             }
             if (IsDone)
             {
                 Professionbuddy.Log("Done sending {0} via mail",
                                     UseCategory ? string.Format("Items that belong to category {0} and subcategory {1}", Category, SubCategory) :
                                     string.Format("Items that match Id of {0}", ItemID));
             }
             else
             {
                 return(RunStatus.Running);
             }
         }
     }
     return(RunStatus.Failure);
 }
Example #45
0
        protected override Composite CreateBehavior()
        {
            return _root ?? (_root =
                new PrioritySelector(

                    new Decorator(ret => Counter >= 1,
                        new Action(ret => _isDone = true)),

                        new PrioritySelector(

                            new Decorator(ret => !MovedToTarget,
                                new Action(delegate
                                {
                                    // using Styx.Logic.BehaviorTree;
                                    TreeRoot.GoalText = "Ship Behavior: Running";
                                    TreeRoot.StatusText = "Moving To Dock";

                                    if (DockLocation.Distance(me.Location) > 3)
                                    {
                                        Navigator.MoveTo(DockLocation);
                                    }
                                    else
                                    {
                                        MovedToTarget = true;
                                        return RunStatus.Success;
                                    }

                                    return RunStatus.Running;

                                })
                                ),

                            new Decorator(ret => MovedToTarget,
                                new Action(delegate
                                {
                                    objectList = ObjectManager.GetObjectsOfType<WoWGameObject>()
                                        .Where(u => u.Entry == ObjectID)
                                        .OrderBy(u => u.Distance).ToList();


                                    TreeRoot.StatusText = "Waiting For Ship";

                                    foreach (WoWGameObject value in objectList)
                                    {
                                        Tripper.Tools.Math.Matrix m = value.GetWorldMatrix();

                                        WoWPoint matrixLocation = new WoWPoint(m.M41, m.M42, m.M43);

                                        //Logging.Write("" + matrixLocation.X + " " + matrixLocation.Y + " " + matrixLocation.Z);

                                        if (GetOffLocation.Distance(me.Location) < 3)
                                        {
                                                _isDone = true;
                                                return RunStatus.Success;
                                        }

                                        if (matrixLocation.Distance(me.Location) < 20 && !MovedOnShip)
                                        {
                                            TreeRoot.StatusText = "Moving Onto Ship";
                                            Thread.Sleep(3000);
                                            WoWMovement.ClickToMove(GetOnLocation);
                                            MovedOnShip = true;
                                        }
                                        else if (MovedOnShip)
                                        {
                                            TreeRoot.StatusText = "On Ship, Waiting";
                                            if (ShipStandLocation.X > 0)
                                            {
                                                WoWMovement.ClickToMove(ShipStandLocation);
                                            }
                                            if (matrixLocation.Distance(EndLocation) < 20)
                                            {
                                                TreeRoot.StatusText = "Moving Off Ship";
                                                Thread.Sleep(3000);
                                                WoWMovement.ClickToMove(GetOffLocation);
                                                MovedOnShip = true;
                                            }
                                        }

                                        return RunStatus.Success;
                                    }

                                    return RunStatus.Running;
                                })
                                ),

                            new Action(ret => Logging.Write(""))
                        )
                    ));
        }
        public static WoWPoint getSaveLocation(WoWPoint Location, int minDist, int maxDist, int traceStep)
        {
            Logging.WriteNavigator("{0} - Navigation: Looking for save Location around {1}.", TimeNow, Location);

            float _PIx2 = 3.14159f * 2f;

            for (int i = 0, x = minDist; i < traceStep && x < maxDist; i++)
            {
                WoWPoint p = Location.RayCast((i * _PIx2) / traceStep, x);

                p.Z = getGroundZ(p);
                WoWPoint pLoS = p;
                pLoS.Z = p.Z + 0.5f;

                if (p.Z != float.MinValue && StyxWoW.Me.Location.Distance(p) > 1)
                {
                    if (getHighestSurroundingSlope(p) < 1.2f && GameWorld.IsInLineOfSight(pLoS, Location) /*&& Navigator.CanNavigateFully(StyxWoW.Me.Location, Location)*/)
                    {
                        Logging.WriteNavigator("{0} - Navigation: Moving to {1}. Distance: {2}", TimeNow, p, Location.Distance(p));
                        return p;
                    }
                }

                if (i == (traceStep - 1))
                {
                    i = 0;
                    x++;
                }
            }
            Logging.Write(System.Drawing.Color.Red, "{0} - No valid points returned by RayCast...", TimeNow);
            return WoWPoint.Empty;
        }
        private bool TotemManagerUpdate()
        {
            int countTotems = 0;

            _ptTotems = new WoWPoint();
            _totem = new WoWUnit[5];

#if USE_OLD_SEARCH
            List<WoWUnit> totemList = (from o in ObjectManager.ObjectList
                   where o is WoWUnit
                   let unit = o.ToUnit()
                   where unit.CreatedByUnitGuid == _me.Guid
                    && unit.CreatureType == WoWCreatureType.Totem
                   select unit
                   ).ToList();

            foreach (WoWUnit totem in totemList)
            {
                int indexTotem = 0;
                try
                {
                    countTotems++;
                    indexTotem = _dictTotemSlot[(TotemId)totem.CreatedBySpellId];
                    _totem[indexTotem] = totem;
                    if ( totem.Distance < _ptTotems.Distance(_me.Location) )
                        _ptTotems = totem.Location;
                }
                catch
                {
                    Shaman.Wlog("NOTIFY SHAMWOW DEVELOPER:  Unknown totem: totem spell id={0}, totem name='{1}', index totem={2}", totem.CreatedBySpellId, totem.Name, indexTotem);
                }
            }
#else
            foreach (WoWTotemInfo ti in _me.Totems)
            {               
                if (ti.WoWTotem != WoWTotem.None)
                {
                    countTotems++;

                    try
                    {
                        WoWUnit totem = ObjectManager.GetObjectByGuid<WoWUnit>(ti.Guid);
                        int indexTotem = _dictTotemSlot[(TotemId)totem.CreatedBySpellId];
                        _totem[indexTotem] = totem;
                        if (totem.Distance < _ptTotems.Distance(_me.Location))
                            _ptTotems = totem.Location;
                    }
                    catch
                    {
                        Shaman.Wlog("NOTIFY SHAMWOW DEVELOPER:  Unknown totem: totem spell id={0}, totem name='{1}'",  ti.Spell.Id, ti.Name );
                    }
                }
            }
#endif

#if SHOW_TOTEM_COUNT           
            if ( countTotems > 0 )
                Shaman.Dlog("TotemManagerUpdate:  found {0} totems with closest {1:F1} yds away at {2}", countTotems, _ptTotems.Distance(_me.Location), _ptTotems.ToString());
#endif

            return countTotems > 0;
        }
Example #48
0
 List<WoWPoint> CreatePathSegment(WoWPoint from, WoWPoint to, Height ht)
 {
     List<WoWPoint> segment = new List<WoWPoint>();
     WoWPoint point = from;
     float step = 50;
     float noMeshStep = 5;
     for (float i = from.Distance(to) - step; i > 0; )
     {
         point = WoWMathHelper.CalculatePointFrom(from, to, i);
         try
         {
             float z = ht == Height.High ? Navigator.FindHeights(point.X, point.Y).Max() :
                 Navigator.FindHeights(point.X, point.Y).Min();
             i -= step;
             /* TODO - REENABLE THISif (Gui.smoothCheck.Checked && z > point.Z)
             {
                 point.Z = z;
             }
              * */
             segment.Add(point);
         }
         catch { i -= noMeshStep; }
     }
     segment.Add(to);
     return segment;
 }
        public override void Pulse()
        {
            if (Styx.Logic.BehaviorTree.TreeRoot.StatusText.ToLower().Contains("loading tile")) { return; }
            if (!TimeToAlertTimer.IsRunning) TimeToAlertTimer.Start();
            if (TimeToAlertTimer.Elapsed.Minutes >= 15) { TotalBaseTime(); TimeToAlertTimer.Reset(); TimeToAlertTimer.Start(); }
                if (IsNotSafe()) return;
                /*if (System.Math.Round((DateTime.Now - _TotalStartTime).TotalMinutes) != 0 && Convert.ToInt32((DateTime.Now - _TotalStartTime).TotalMinutes) % 2 == 0)
                { Log(string.Format("Total time since originally started; Hours:{0} Mins:{1}", (DateTime.Now - _TotalStartTime).TotalHours.ToString(), (DateTime.Now - _TotalStartTime).TotalMinutes.ToString())); }
                if (System.Math.Round((DateTime.Now - _BaseStartTime).TotalMinutes) != 0 && Convert.ToInt32((DateTime.Now - _BaseStartTime).TotalMinutes) % 2 == 0)
                { Log(string.Format("Total time since Group {0} started; Hours:{1} Mins:{2}",_CurrentProfile.ToString(), (DateTime.Now - _BaseStartTime).TotalHours.ToString(), (DateTime.Now - _BaseStartTime).TotalMinutes.ToString())); }
                */
                if (!LoadedFirst)
                {
                    _CurrentProfile = 0;
                    /*if (!BotManager.Current.Name.Contains(_Manager.BotBase[_CurrentProfile]) || _Manager.FilePath[_CurrentProfile].Contains(Styx.Logic.Profiles.ProfileManager.XmlLocation))*/
                    LoadedFirst = true; StartChanger();
                }


                if (_Manager.LoopAfter && !IsNotSafe() && ((DateTime.Now - _TotalStartTime).TotalMinutes >= ((_Manager.LoopHours * 60) + _Manager.LoopMinutes)))
                {
                    TotalRunningTime();
                    Log("Total Time to loop has been reached. Sending 'ForceQuit()' to WoW.");
                    Styx.Helpers.InactivityDetector.ForceLogout(true);
                    TreeRoot.Stop();
                }
                if (EXITNOW) { TotalRunningTime(); Log("ExitNow set to true. Sending 'ForceQuit()' to WoW."); Styx.Helpers.InactivityDetector.ForceLogout(true); TreeRoot.Stop(); }


                #region NeedHearth
                if (NeedHearth)
                {
                    Stopwatch HearthTimer = new Stopwatch();
                    bool HasHeartStone = false;
                    ObjectManager.Update();
                    WoWItem stone;
                    SpellManager.StopCasting();
                    if (Me.IsFlying)
                    {
                        Log("Landing.");
                        Navigator.PlayerMover.MoveStop();
                        StyxWoW.SleepForLagDuration();
                        while (Me.IsFlying) { WoWMovement.Move(WoWMovement.MovementDirection.Descend, TimeSpan.FromSeconds(5)); }
                        WoWMovement.MoveStop();
                        Log("Landed.");
                    }
                    Styx.Logic.Mount.Dismount();
                    Navigator.PlayerMover.MoveStop();
                    StyxWoW.SleepForLagDuration();
                    Thread.Sleep(500);
                    /*if (Me.Class == WoWClass.Mage)
                    {
                        SpellManager.StopCasting();
                        Styx.Logic.Mount.Dismount();
                        Navigator.PlayerMover.MoveStop();
                        StyxWoW.SleepForLagDuration();
                        if (SpellManager.CanCast(3567))
                        {
                            SpellManager.Cast(3567);
                            Thread.Sleep(2500);
                            while (Me.IsCasting || !StyxWoW.IsInWorld)
                            {
                                Log("Sleeping while casting", null);
                                Thread.Sleep(5000);
                            }
                            Log("End of Sleep 1, Sleep additional 5 seconds.", null);
                            Thread.Sleep(5000);
                        }
                    }
                    else
                    {*/
                    Log("Looking for Hearthstone!.");
                    foreach (WoWItem _item in ObjectManager.GetObjectsOfType<WoWItem>().Where(o => o.BagSlot != 1 && o.Entry == 6948))
                    {
                        HasHeartStone = true;
                        Log("Has a Stone.");
                        if (_item.Cooldown < 1)
                        {
                            Log("Not on cooldown!");
                            DidUseHearth = true;
                            stone = _item;
                            Thread.Sleep(1000);
                            _item.Use();
                            HearthTimer.Start();
                            Thread.Sleep(2000);
                            while (Me.IsCasting) { Log("Sleep while Casting."); Thread.Sleep(100); }
                            Thread.Sleep(500);
                            if (HearthTimer.Elapsed.Seconds >= 9) { HearthTimer.Reset(); NeedHearth = false; Log("Hearthstone worked!"); }
                            else { HearthTimer.Reset(); NeedHearth = true; Log("Something Interrupted Hearthstone!"); return; }
                        }
                    }
                    if (!HasHeartStone) { Log("You don't have a HearthStone idiot. GO GET ONE!  ExitNow!"); EXITNOW = true; return; }
                    return;
                }
                #endregion

                #region AfterHearth
                if (AfterHearth && !NeedHearth)
                {
                    WoWPoint Outside = new WoWPoint(0, 0, 0);
                    Log("Sleepy for 5 seconds. At Home City.");
                    Thread.Sleep(5000);
                    ObjectManager.Update();

                    foreach (WoWUnit iKeeper in ObjectManager.GetObjectsOfType<WoWUnit>().Where(o => (o.Entry == 6929 || o.Entry == 46642 || o.Entry == 44235 || o.Entry == 6740) && o.Location.Distance(Me.Location) < 30))
                    {
                        if (iKeeper.Entry == 6929)
                        { Outside = new WoWPoint(1558.945, -4385.643, 16.88019); Log("Hearth set to Valley of Strength."); }
                        if (iKeeper.Entry == 46642)
                        { Outside = new WoWPoint(1935.14, -4696.542, 35.96473); Log("Hearth set to Valley of Honor."); }
                        if (iKeeper.Entry == 44235)
                        { Outside = new WoWPoint(-8380.801, 618.5749, 95.62397); Log("Hearth set to Dwarven district."); }
                        if (iKeeper.Entry == 6740)
                        { Outside = new WoWPoint(-8853.698, 656.3289, 96.68601); Log("Hearth set to Trade district."); }
                        break;
                    }
                    Log("Moving Outside to prevent flying stucks.");
                    while (Outside.Distance(Me.Location) >= 3) { Navigator.MoveTo(Outside); }
                    AfterHearth = false;
                    return;
                }
                #endregion

                if (!NeedHearth && !AfterHearth && NeedToRepairMailSell)
                { RepairSellMail(_Manager.Repair, _Manager.Sell, _Manager.Mail); return; }

                #region IsNewZone
                if (!SitAtHearth && !NeedHearth && !AfterHearth && !NeedToRepairMailSell && IsNewZone)
                {
                    WoWPoint PortalsHorde = new WoWPoint(2055.473, -4378.082, 98.84528);
                    WoWPoint PortalsAlly = new WoWPoint(-8209.668, 428.5376, 118.0617);

                    if (Me.IsHorde)
                    {
                        //if (RepairAtHearth) { } //Embedded if sell at hearth
                        //if (MailAtHearth) { }

                        ObjectManager.Update();
                        while (PortalsHorde.Distance(Me.Location) > 5)
                        {
                            if (!Flightor.MountHelper.Mounted && Flightor.MountHelper.CanMount)
                            {
                                Flightor.MountHelper.MountUp();
                                StyxWoW.SleepForLagDuration();
                                Thread.Sleep(500);
                                while (Me.IsCasting) { Thread.Sleep(100); }
                            }
                            Log("Mounted and flying to Org Portals!");
                            Flightor.MoveTo(PortalsHorde);
                            Thread.Sleep(250);
                        }
                        Log("Dismounting.");
                        Flightor.MountHelper.Dismount();
                        StyxWoW.SleepForLagDuration();
                        WoWMovement.MoveStop(WoWMovement.MovementDirection.All);
                        Navigator.PlayerMover.MoveStop();

                        Log("Sleep a little bit at portals.");
                        Thread.Sleep(ranNum(10000, 10000));
                        Thread.Sleep(10000);
                        //if (!DidReturnForFly) { DidReturnForFly = true; return; }
                        ObjectManager.Update();
                        uint Portal = 0;
                        foreach (KeyValuePair<uint, string> check in _Manager.ZonePairHorde)
                        {
                            if (check.Value.ToLower() == _Manager.Zone[_CurrentProfile].ToLower()) { Portal = check.Key; Log("Portal Id is: ", check.Key.ToString()); }
                        }
                        foreach (WoWGameObject _portal in ObjectManager.GetObjectsOfType<WoWGameObject>().Where(o => o.Entry == Portal))
                        {
                            while (_portal.Location.Distance(Me.Location) > _portal.InteractRange)
                            {
                                Navigator.MoveTo(_portal.Location);
                                Log(string.Format("Moving towards: {0}.", _portal.Name));
                                Thread.Sleep(100);
                            }
                            Navigator.PlayerMover.MoveStop();
                            WoWMovement.MoveStop(WoWMovement.MovementDirection.All);
                            WoWMovement.MoveStop();
                            Thread.Sleep(ranNum(500, 2000));
                            _portal.Interact();
                            Thread.Sleep(1000);
                            IsNewZone = false;
                        }


                    }


                    if (Me.IsAlliance)
                    {
                        ObjectManager.Update();
                        while (PortalsAlly.Distance(Me.Location) > 5)
                        {
                            if (!Flightor.MountHelper.Mounted && Flightor.MountHelper.CanMount)
                            {
                                Flightor.MountHelper.MountUp();
                                StyxWoW.SleepForLagDuration();
                                Thread.Sleep(500);
                                while (Me.IsCasting) { Thread.Sleep(100); }
                            }
                            Log("Mounted and flying to Storm Portals!");
                            Flightor.MoveTo(PortalsAlly);
                            Thread.Sleep(250);
                        }
                        Log("Dismounting.");
                        Flightor.MountHelper.Dismount();
                        StyxWoW.SleepForLagDuration();
                        WoWMovement.MoveStop(WoWMovement.MovementDirection.All);
                        Navigator.PlayerMover.MoveStop();


                        Log("Sleep a little bit at portals.");
                        Thread.Sleep(ranNum(10000, 20000));
                        
                        ObjectManager.Update();
                        uint Portal = 0;
                        foreach (KeyValuePair<uint, string> check in _Manager.ZonePairAlly)
                        {
                            if (check.Value.ToLower() == _Manager.Zone[_CurrentProfile].ToLower()) { Portal = check.Key; Log("Portal Id is: ", check.Key.ToString()); }
                        }
                        foreach (WoWGameObject _portal in ObjectManager.GetObjectsOfType<WoWGameObject>().Where(o => o.Entry == Portal))
                        {
                            while (_portal.Location.Distance(Me.Location) > _portal.InteractRange)
                            {
                                Navigator.MoveTo(_portal.Location);
                                Log(string.Format("Moving towards: {0}.", _portal.Name));
                                Thread.Sleep(100);
                            }
                            Navigator.PlayerMover.MoveStop();
                            WoWMovement.MoveStop(WoWMovement.MovementDirection.All);
                            WoWMovement.MoveStop();
                            Thread.Sleep(ranNum(500, 2000));
                            _portal.Interact();
                            Thread.Sleep(1000);
                            IsNewZone = false;
                        }
                        //Need someone to get the Innkeepers and XYZs!
                        /*outside the inn <Hotspot X="-8858.316" Y="658.7656" Z="96.58434" />
                         *<Vendor Name="Innkeeper Allison" Entry="6740" Type="Food" X="-8867.786" Y="673.6729" Z="97.90324" />
                         *[12:45:57 PM] codenamegamma1: Potal to Blasted Lands - ID 195141
                         *
                         * [12:48:55 PM] codenamegamma1: Portal to Tol Barad - ID 206594 - Location <Hotspot X="-8208.711" Y="450.1579" Z="117.7044" />
                         * 
                         * 
                         */
                    }
                    if (IsNewZone) { Log("Failed to find the portal.  This will cause HB to endlessly loop. Will instead ExitNow."); EXITNOW = true; return; }
                    else Log("Sent your toon through the portal to :", _Manager.Zone[_CurrentProfile]);
                    DidUsePortal = true;
                    return;

                }
                #endregion

                if (DidUsePortal)
                { MoveAfterPortal(); }

                #region NeedToFly
                if (NeedToFly && !NeedHearth && !IsNewZone && !SitAtHearth)
                {
                    
                    Log("Sleepy for 5 seconds.");
                    Thread.Sleep(5000);
                    //Need a returnBool from Lua IsFlyableArea()
                    ObjectManager.Update();
                    if (_Manager.BotBase[_CurrentProfile] == "Grind Bot")
                    {
                        Log("BotBase is 'Grind Bot'.  Flying started.");
                        //StopWatch GrindTimer = new StopWatch();
                        //GrindTimer.Start()
                        Styx.Logic.Profiles.ProfileManager.CurrentProfile.GrindArea.GetNextHotspot();
                        Styx.Logic.AreaManagement.Hotspot hotspot = Styx.Logic.Profiles.ProfileManager.CurrentProfile.GrindArea.CurrentHotSpot;
                        while (hotspot.Position.Distance(Me.Location) > 30 && !IsNotSafe())
                        {
                            if (!Flightor.MountHelper.Mounted && Flightor.MountHelper.CanMount)
                            {
                                Flightor.MountHelper.MountUp();
                                StyxWoW.SleepForLagDuration();
                                Thread.Sleep(250);
                                while (Me.IsCasting) { Thread.Sleep(100); }
                            }
                            Log("Mounted and flying to HotSpot!");
                            Flightor.MoveTo(hotspot.Position);
                            Thread.Sleep(100);
                            //if (GrindTimer.Elapsed.Minutes > 5) { Log("Took over 5 minutes to attempt flying to first hotspot.\nBreaking while loop."); whileTimer.Reset(); break; }
                        }
                        if (hotspot.Position.Distance(Me.Location) <= 30)
                        {
                            Log("Landing.");
                            Navigator.PlayerMover.MoveStop();
                            StyxWoW.SleepForLagDuration();
                            WoWMovement.Move(WoWMovement.MovementDirection.Descend, TimeSpan.FromSeconds(1));
                            WoWMovement.MoveStop();
                            Flightor.MountHelper.Dismount();
                            Navigator.Clear();
                            Log("Landed at HotSpot. Thread released.");
                            NeedToFly = false;
                        }
                    }

                    //Questing is not currently supported.  Lot of shit to look at with this.
                    if (_Manager.BotBase[_CurrentProfile] == "Questing")
                    {

                        Stopwatch QuestTimer = new Stopwatch();
                        if (!QuestTimer.IsRunning) { QuestTimer.Start(); return; }
                        QuestTimer.Reset();
                        WoWPoint POI_ = Styx.Logic.POI.BotPoi.Current.Location;
                        while (POI_.Distance(Me.Location) > 30 && !IsNotSafe())
                        {
                            if (!Flightor.MountHelper.Mounted && Flightor.MountHelper.CanMount)
                            {
                                Flightor.MountHelper.MountUp();
                                StyxWoW.SleepForLagDuration();
                                Thread.Sleep(250);
                                while (Me.IsCasting) { Thread.Sleep(100); }
                            }
                            Log("Mounted and flying to first POI!");
                            Flightor.MoveTo(POI_);
                            Thread.Sleep(100);
                            //if (whileTimer.Elapsed.Minutes > 5) { Log("Took over 5 minutes to attempt flying to first hotspot.\nBreaking while loop."); whileTimer.Reset(); break; }
                        }
                        if (POI_.Distance(Me.Location) <= 30)
                        {
                            Log("Landing.");
                            Navigator.PlayerMover.MoveStop();
                            StyxWoW.SleepForLagDuration();
                            while (Me.IsFlying) { WoWMovement.Move(WoWMovement.MovementDirection.Descend, TimeSpan.FromSeconds(1)); }
                            WoWMovement.MoveStop();
                            Log("Landed at POI. Thread released.");
                            NeedToFly = false;
                        }
                    }
                }
                #endregion

                if (!NeedToFly && DidJustRestart) { Log("We're done here for now.  Awaiting something to do :) "); DidJustRestart = false; }


                if (ItemCheck(6948).Cooldown <= 5)
                { return; }

                if (_Manager.HearthRMS  && ((Me.BagsFull || Me.FreeBagSlots <= (Styx.Logic.Profiles.ProfileManager.CurrentProfile.MinFreeBagSlots + 1) && _Manager.Sell) || (Styx.Logic.POI.BotPoi.Current.Type == Styx.Logic.POI.PoiType.Mail && _Manager.Mail) || (Styx.Logic.POI.BotPoi.Current.Type == Styx.Logic.POI.PoiType.Sell && _Manager.Sell) || (Styx.Logic.POI.BotPoi.Current.Type == Styx.Logic.POI.PoiType.Repair && _Manager.Repair)))
                {
                    _CurrentProfile++;
                    Log("Found HB needs to Mail/Sell/Repair.");
                    ForcedSRM = true;
                    Log(string.Format("Profile {0} completed", _CurrentProfile.ToString()));
                    TotalRunningTime();
                    if (_CurrentProfile >= 2)
                    {
                        if (!_Manager.ThreeEnabled && _Manager.FourEnabled) { _CurrentProfile = 3; }
                        if (!_Manager.ThreeEnabled && !_Manager.FourEnabled && _Manager.LoopAfter) { _CurrentProfile = 0; }
                        if (!_Manager.ThreeEnabled && !_Manager.FourEnabled && !_Manager.LoopAfter && _Manager.LogOutAfter) { EXITNOW = true; return; }
                    }
                    StartChanger();
                }


                if ((DateTime.Now - _BaseStartTime).TotalMinutes >= ((_Manager.Hours[_CurrentProfile] * 60) + _Manager.Mins[_CurrentProfile]))
                {
                    _CurrentProfile++;
                    Log(string.Format("Profile {0} completed", _CurrentProfile.ToString()));
                    TotalRunningTime();
                    if (_CurrentProfile >= 2)
                    {
                        if (!_Manager.ThreeEnabled && _Manager.FourEnabled) { _CurrentProfile = 3; }
                        if (!_Manager.ThreeEnabled && !_Manager.FourEnabled && _Manager.LoopAfter) { _CurrentProfile = 0; }
                        if (!_Manager.ThreeEnabled && !_Manager.FourEnabled && !_Manager.LoopAfter && _Manager.LogOutAfter) { EXITNOW = true; return; }
                    }
                    StartChanger();
                }
            

        }//End of Pulse
Example #50
0
 public static void performSafeFlight(WoWPoint landLoc, WoWPoint targetLoc)
 {
     if (_me.Location.Distance(targetLoc) > 2)
     {
         while (landLoc.Distance(_me.Location) > 1)
         {
             Flightor.MoveTo(landLoc);
             Thread.Sleep(100);
         }
         Flightor.MountHelper.Dismount();
         while (targetLoc.Distance(_me.Location) > 1)
         {
             Navigator.MoveTo(targetLoc);
             Thread.Sleep(100);
         }
     }
 }
Example #51
0
        public WoWPoint FindLocation(WoWPoint ptOrigin)
        {
            DateTime startFind = DateTime.UtcNow;
            int countPointsChecked = 0;
            int countFailDiff = 0;
            int countFailTrace = 0;
            int countFailToPointNav = 0;
            int countFailRange = 0;
            int countFailSafe = 0;
            int countFailToPointLoS = 0;
            int countFailToMobLoS = 0;
            TimeSpan spanTrace = TimeSpan.Zero;
            TimeSpan spanNav = TimeSpan.Zero;
            double furthestNearMobDistSqr = 0f;
            WoWPoint ptFurthest = WoWPoint.Empty;
            float facingFurthest = 0f;

            bool reallyCheckRangeToLineOfSightMob = CheckRangeToLineOfSightMob && Me.GotTarget();
            WoWPoint ptAdjOrigin = ptOrigin;
            // ptAdjOrigin.Z += 1f;   // comment out origin adjustment since using GetTraceLinePos()

            WoWPoint ptDestination = new WoWPoint();
            List<WoWPoint> mobLocations = new List<WoWPoint>();
            float arcIncrement = ((float)Math.PI * 2) / RaysToCheck;

            mobLocations = AllEnemyMobLocationsToCheck;
            double minSafeDistSqr = MinSafeDistance * MinSafeDistance;

            #if OLD_WAY
            float baseDestinationFacing = MobToRunFrom == null ?
                                            Me.RenderFacing + (float)Math.PI
                                            : Styx.Helpers.WoWMathHelper.CalculateNeededFacing(MobToRunFrom.Location, Me.Location);
            #else
            float baseDestinationFacing;
            if (PreferredDirection == Disengage.Direction.None && MobToRunFrom != null)
                baseDestinationFacing = Styx.Helpers.WoWMathHelper.CalculateNeededFacing(MobToRunFrom.Location, Me.Location);
            else if (PreferredDirection == Disengage.Direction.Frontwards)
                baseDestinationFacing = Me.RenderFacing;
            else // if (PreferredDirection == Disengage.Direction.Backwards)
                baseDestinationFacing = Me.RenderFacing + (float)Math.PI;
            #endif
            Logger.WriteDebug( Color.Cyan, "SafeArea: facing {0:F0} degrees, looking for safespot towards {1:F0} degrees",
                WoWMathHelper.RadiansToDegrees(Me.RenderFacing),
                WoWMathHelper.RadiansToDegrees(baseDestinationFacing)
                );

            for (int arcIndex = 0; arcIndex < RaysToCheck; arcIndex++)
            {
                // rather than tracing around the circle, toggle between clockwise and counter clockwise for each test
                // .. so we favor a position furthest away from mob
                float checkFacing = baseDestinationFacing;
                if ((arcIndex & 1) == 0)
                    checkFacing += arcIncrement * (arcIndex >> 1);
                else
                    checkFacing -= arcIncrement * ((arcIndex >> 1) + 1);

                checkFacing = WoWMathHelper.NormalizeRadian(checkFacing);
                for (float distFromOrigin = MinScanDistance; distFromOrigin <= MaxScanDistance; distFromOrigin += IncrementScanDistance)
                {
                    countPointsChecked++;

                    ptDestination = ptOrigin.RayCast(checkFacing, distFromOrigin);

                    Logger.WriteDebug("SafeArea: checking {0:F1} degrees at {1:F1} yds", WoWMathHelper.RadiansToDegrees(checkFacing), distFromOrigin);

                    DateTime start = DateTime.UtcNow;
                    bool failTrace = Movement.MeshTraceline(Me.Location, ptDestination);
                    spanTrace += DateTime.UtcNow - start;

                    bool failNav;
                    if (DirectPathOnly)
                    {
                        failNav = failTrace;
                        spanNav = spanTrace;
                    }
                    else
                    {
                        start = DateTime.UtcNow;
                        failNav = !Navigator.CanNavigateFully(Me.Location, ptDestination);
                        spanNav += DateTime.UtcNow - start;
                    }

                    if (failTrace)
                        countFailTrace++;

                    if (failTrace != failNav)
                        countFailDiff++;

                    if (failNav)
                    {
                        // Logger.WriteDebug( Color.Cyan, "Safe Location failed navigation check for degrees={0:F1} dist={1:F1}", RadiansToDegrees(checkFacing), distFromOrigin);
                        countFailToPointNav++;
                        continue;
                    }

                    WoWPoint ptNearest = NearestMobLoc(ptDestination, mobLocations);
                    if (ptNearest == WoWPoint.Empty)
                    {
                        if (furthestNearMobDistSqr < minSafeDistSqr)
                        {
                            furthestNearMobDistSqr = minSafeDistSqr;
                            ptFurthest = ptDestination;     // set best available if others fail
                            facingFurthest = checkFacing;
                        }
                    }
                    else
                    {
                        double mobDistSqr = ptDestination.Distance2DSqr(ptNearest);
                        if (furthestNearMobDistSqr < mobDistSqr)
                        {
                            furthestNearMobDistSqr = mobDistSqr;
                            ptFurthest = ptDestination;     // set best available if others fail
                            facingFurthest = checkFacing;
                        }
                        if (mobDistSqr <= minSafeDistSqr)
                        {
                            countFailSafe++;
                            continue;
                        }
                    }

                    if (reallyCheckRangeToLineOfSightMob && RangeToLineOfSightMob < ptDestination.Distance(LineOfSightMob.Location) - LineOfSightMob.MeleeDistance())
                    {
                        countFailRange++;
                        continue;
                    }

                    if (CheckLineOfSightToSafeLocation)
                    {
                        WoWPoint ptAdjDest = ptDestination;
                        ptAdjDest.Z += 1f;
                        if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptAdjOrigin, ptAdjDest))
                        {
                            // Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                            countFailToPointLoS++;
                            continue;
                        }
                    }

                    if (CheckSpellLineOfSightToMob && LineOfSightMob != null)
                    {
                        if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSpellSight(ptDestination, LineOfSightMob.GetTraceLinePos()))
                        {
                            if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptDestination, LineOfSightMob.GetTraceLinePos()))
                            {
                                // Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                                countFailToMobLoS++;
                                continue;
                            }
                        }
                    }

                    Logger.WriteDebug(Color.Cyan, "SafeArea: Found mob-free location ({0:F1} yd radius) at degrees={1:F1} dist={2:F1} on point check# {3} at {4}, {5}, {6}", MinSafeDistance, WoWMathHelper.RadiansToDegrees(checkFacing), distFromOrigin, countPointsChecked, ptDestination.X, ptDestination.Y, ptDestination.Z);
                    Logger.WriteDebug(Color.Cyan, "SafeArea: processing took {0:F0} ms", (DateTime.UtcNow - startFind).TotalMilliseconds);
                    Logger.WriteDebug(Color.Cyan, "SafeArea: meshtrace took {0:F0} ms / fullynav took {1:F0} ms", spanTrace.TotalMilliseconds, spanNav.TotalMilliseconds);
                    Logger.WriteDebug(Color.Cyan, "SafeArea: stats for ({0:F1} yd radius) found within {1:F1} yds ({2} checked, {3} nav, {4} not safe, {5} range, {6} pt los, {7} mob los, {8} mesh trace)", MinSafeDistance, MaxScanDistance, countPointsChecked, countFailToPointNav, countFailSafe, countFailRange, countFailToPointLoS, countFailToMobLoS, countFailTrace);
                    return ptDestination;
                }
            }

            Logger.WriteDebug(Color.Cyan, "SafeArea: No mob-free location ({0:F1} yd radius) found within {1:F1} yds ({2} checked, {3} nav, {4} not safe, {5} range, {6} pt los, {7} mob los, {8} mesh trace)", MinSafeDistance, MaxScanDistance, countPointsChecked, countFailToPointNav, countFailSafe, countFailRange, countFailToPointLoS, countFailToMobLoS, countFailTrace);
            if (ChooseSafestAvailable && ptFurthest != WoWPoint.Empty)
            {
                Logger.WriteDebug(Color.Cyan, "SafeArea: choosing best available spot in {0:F1} yd radius where closest mob is {1:F1} yds", MinSafeDistance, Math.Sqrt(furthestNearMobDistSqr));
                Logger.WriteDebug(Color.Cyan, "SafeArea: processing took {0:F0} ms", (DateTime.UtcNow - startFind).TotalMilliseconds);
                Logger.WriteDebug(Color.Cyan, "SafeArea: meshtrace took {0:F0} ms / fullynav took {1:F0} ms", spanTrace.TotalMilliseconds, spanNav.TotalMilliseconds);
                return ChooseSafestAvailable ? ptFurthest : WoWPoint.Empty;
            }

            Logger.WriteDebug(Color.Cyan, "SafeArea: processing took {0:F0} ms", (DateTime.UtcNow - startFind).TotalMilliseconds);
            Logger.WriteDebug(Color.Cyan, "SafeArea: meshtrace took {0:F0} ms / fullynav took {1:F0} ms", spanTrace.TotalMilliseconds, spanNav.TotalMilliseconds);
            return WoWPoint.Empty;
        }
Example #52
0
        public static bool IsKitingPossible(int minScan = -1)
        {
            if (MovementManager.IsMovementDisabled)
                return false;
            if (!SingularRoutine.IsAllowed(CapabilityFlags.Kiting))
                return false;

            // note:  PullDistance MUST be longer than our out of melee distance (DISTANCE_WE_NEED_TO_START_BACK_PEDDLING)
            // otherwise it will run back and forth
            if (IsKitingActive() || !Me.IsAlive || Spell.IsCasting())
                return false;

            if (Me.Stunned || Me.IsStunned())
            {
                Logger.WriteDebug("IsKitingPossible: suppressed while Stunned");
                return false;
            }

            if (Me.Rooted || Me.IsRooted())
            {
                Logger.WriteDebug("IsKitingPossible: suppressed while Rooted");
                return false;
            }

            if (Me.IsFalling)
            {
                Logger.WriteDebug("IsKitingPossible: suppressed while Falling");
                return false;
            }

            WoWUnit mob = SafeArea.NearestEnemyMobAttackingMe;
            //mob = Me.CurrentTarget;  // FOR TESTING ONLY
            if (mob == null)
            {
                Logger.WriteDebug("IsKitingPossible: error - cannot find a Mob Near us to Kite away from");
                return false;
            }

            // check if 5yds beyond melee
            if (mob.SpellDistance() > 10f)
            {
                Logger.WriteDebug("IsKitingPossible: {0} @ {1:F1} yds is already > 10 yds away", mob.SafeName(), mob.SpellDistance());
                return false;
            }

            SafeArea sa = new SafeArea();
            if (Battlegrounds.IsInsideBattleground)
            {
                sa.MinSafeDistance = 12;
                sa.MinScanDistance = minScan == -1 ? 15 : minScan;
                sa.IncrementScanDistance = 10;
                sa.MaxScanDistance = sa.MinScanDistance + 2 * sa.IncrementScanDistance;
                sa.RaysToCheck = 18;
                sa.MobToRunFrom = mob;
                sa.LineOfSightMob = Me.CurrentTarget;
                sa.CheckLineOfSightToSafeLocation = false;
                sa.CheckSpellLineOfSightToMob = false;
                sa.DirectPathOnly = true;   // faster to check direct path than navigable route
            }
            else
            {
                sa.MinSafeDistance = 20;
                sa.MinScanDistance = minScan == -1 ? 10 : minScan;
                sa.IncrementScanDistance = 5;
                sa.MaxScanDistance = sa.MinScanDistance + (2 * sa.IncrementScanDistance);
                sa.RaysToCheck = 36;
                sa.MobToRunFrom = mob;
                sa.LineOfSightMob = Me.CurrentTarget;
                sa.CheckLineOfSightToSafeLocation = false;
                sa.CheckSpellLineOfSightToMob = false;
                sa.DirectPathOnly = true;   // faster to check direct path than navigable route
            }

            locSafeSpot = sa.FindLocation();
            if (locSafeSpot == WoWPoint.Empty)
            {
                return false;
            }

            return BeginKiting(String.Format("^Kiting(begin): moving {0:F1} yds away from {1}", locSafeSpot.Distance(StyxWoW.Me.Location), mob.SafeName()));
        }
Example #53
0
        public static void VanishPoint()
        {
            WoWPoint myNewWoWPoint;

            do {
                float x, y, z;
                do {
                    x = StyxWoW.Me.Location.X + RandomNumber.GenerateRandomFloat(-20, 20);
                    y = StyxWoW.Me.Location.Y + RandomNumber.GenerateRandomFloat(-20, 20);
                } while(!Navigator.FindHeight(x, y, out z));

                myNewWoWPoint = new WoWPoint(x, y, z);
            } while(!Navigator.CanNavigateFully(StyxWoW.Me.Location, myNewWoWPoint) && myNewWoWPoint.Distance(StyxWoW.Me.Location) < 5);

            DaVinci.CustomDiagnosticLog("Vanish: Moving to " + myNewWoWPoint + " for safety.");
            Navigator.MoveTo(myNewWoWPoint);
        }