Example #1
0
        private static void FindMobToPull()
        {
            while (true)
            {
                var          tmpValidTargets   = new List <PUnit>();
                List <PUnit> units             = ObjectManager.GetUnits;
                SubProfile   currentSubprofile = GrindingEngine.CurrentProfile.GetSubProfile();
                foreach (PUnit pUnit in units.Where(u => u.IsValid))
                {
                    try
                    {
                        if (IsValidTarget(pUnit) &&
                            !PPullBlackList.IsBlacklisted(pUnit) &&
                            !PBlackList.IsBlacklisted(pUnit) &&
                            pUnit.Target.Type != 4)
                        {
                            if (GrindingSettings.SkipMobsWithAdds)
                            {
                                List <PUnit> closeUnits = ObjectManager.CheckForMobsAtLoc(pUnit.Location,
                                                                                          GrindingSettings.
                                                                                          SkipAddsDistance, false);
                                if (closeUnits.Count >= GrindingSettings.SkipAddsCount)
                                {
                                    continue;
                                }
                            }
                            PUnit unit = pUnit;
                            if (
                                currentSubprofile.Spots.Any(
                                    s => unit.Location.DistanceFrom(s) < currentSubprofile.SpotRoamDistance))
                            {
                                if (!pUnit.IsPet) //Do not move, takes a long time
                                {
                                    tmpValidTargets.Add(pUnit);
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                IOrderedEnumerable <PUnit> sortednumQuery =
                    from t in tmpValidTargets
                    orderby t.Location.DistanceToSelf
                    select t;

                ValidUnits = sortednumQuery.ToList();
                Thread.Sleep(500);
            }
        }
Example #2
0
 private static void ExitCombat()
 {
     try
     {
         _combatLoopThread.Abort();
     }
     catch
     {
     }
     try
     {
         _combatThread.Abort();
     }
     catch
     {
     }
     MoveHelper.ReleaseKeys();
     if (_combatResult == CombatResult.OtherPlayerTag)
     {
         PBlackList.Blacklist(Unit, 1200, false);
     }
     if (_combatResult == CombatResult.Bugged && ObjectManager.MyPlayer.HasLivePet)
     {
         KeyHelper.SendKey("PetFollow");
     }
     if (Unit.IsDead)
     {
         _combatResult = CombatResult.Success;
     }
     if (!ObjectManager.MyPlayer.IsAlive)
     {
         _combatResult = CombatResult.Died;
     }
     Logging.Write("Combat done, result : " + _combatResult);
     InvokeCombatStatusChanged(new GCombatEventArgs(CombatType.CombatDone, Unit));
     CombatDone();
     try
     {
         Stop();
     }
     catch
     {
     }
 }
Example #3
0
        private static PUnit DefendAgainst()
        {
            PUnit defendUnit = null;

            if (ObjectManager.ShouldDefend)
            {
                if (!PBlackList.IsBlacklisted(ObjectManager.GetClosestAttacker))
                {
                    defendUnit = ObjectManager.GetClosestAttacker;
                }
                else
                {
                    foreach (PUnit un in ObjectManager.GetAttackers.Where(un => !PBlackList.IsBlacklisted(un)))
                    {
                        defendUnit = un;
                    }
                }
                return(defendUnit);
            }
            return(null);
        }
Example #4
0
        private static PUnit FindMobToLoot()
        {
            PUnit toReturn = null;

            foreach (PUnit pUnit in ObjectManager.GetUnits)
            {
                if (pUnit.IsLootable && pUnit.DistanceToSelf < 30 && !PBlackList.IsBlacklisted(pUnit))
                {
                    if (toReturn != null)
                    {
                        if (toReturn.DistanceToSelf > pUnit.DistanceToSelf)
                        {
                            toReturn = pUnit;
                        }
                    }
                    else
                    {
                        toReturn = pUnit;
                    }
                }
            }
            return(toReturn);
        }
Example #5
0
        internal static void StartCombat(PUnit u)
        {
            if (ObjectManager.MyPlayer.IsDead)
            {
                Stop();
                return;
            }
            Unit.BaseAddress = u.BaseAddress;
            InvokeCombatStatusChanged(new GCombatEventArgs(CombatType.CombatStarted));
            _combatThread = new Thread(CombatThread)
            {
                IsBackground = true
            };
            _combatThread.Name = "CombatThread";
            _combatThread.Start();
            _combatResult = CombatResult.Unknown;
            while (_combatThread.IsAlive)
            {
                try
                {
                    if (Unit.IsDead)
                    {
                        _combatResult = CombatResult.Success;
                        break;
                    }

                    if (!Unit.IsValid || PBlackList.IsBlacklisted(Unit))
                    {
                        if (!Langs.TrainingDummy(ObjectManager.MyPlayer.Target.Name))
                        {
                            _combatResult = CombatResult.Bugged;
                            break;
                        }
                    }

                    if (ObjectManager.MyPlayer.IsDead)
                    {
                        _combatResult = CombatResult.Died;
                        break;
                    }

                    if (Unit.IsPet || Unit.IsTotem)
                    {
                        Logging.Write("We are attacking a totem or a pet... doh");
                        _combatResult = CombatResult.Bugged;
                        break;
                    }

                    if (!Langs.TrainingDummy(Unit.Name) && Unit.IsTagged && !Unit.IsTaggedByMe && !Unit.IsTargetingMe &&
                        Unit != ObjectManager.MyPlayer)
                    {
                        Logging.Write("Other player tag");
                        _combatResult = CombatResult.OtherPlayerTag;
                        break;
                    }
                }
                catch (Exception e)
                {
                    Logging.Write("Exeption in combat handler: " + e);
                }
                Thread.Sleep(160);
            }
            ExitCombat();
        }
Example #6
0
 private static void CombatThread()
 {
     try
     {
         Logging.Write("Started combat engine");
         if (ObjectManager.MyPlayer.IsMounted && !ObjectManager.MyPlayer.TravelForm)
         {
             KeyHelper.SendKey("GMount");
         }
         MoveHelper.ReleaseKeys();
         if (DefendAgainst() == null)
         {
             Logging.Write("Pulling: " + Unit.Name + " " + Unit.GUID);
             MoveHelper.MoveToUnit(Unit, 30);
             if (!Unit.TargetHostile())
             {
                 if (ObjectManager.GetAttackers.Count == 0)
                 {
                     PPullBlackList.Blacklist(Unit, 800, true);
                 }
             }
             Unit.Face();
             MoveHelper.ReleaseKeys();
             PullResult result = Pull();
             Logging.Write("Pull result: " + result);
             if (result.Equals(PullResult.CouldNotPull))
             {
                 PPullBlackList.Blacklist(Unit, 800, true);
                 return;
             }
             if (PPullBlackList.IsBlacklisted(Unit))
             {
                 return;
             }
         }
         else
         {
             Logging.Write("Got into combat with: " + Unit.Name);
             Unit.TargetHostile();
             Unit.Face();
         }
         Ticker combatTimeout;
         if (ObjectManager.MyPlayer.Level > 10)
         {
             combatTimeout = new Ticker(20 * 1000);
         }
         else
         {
             combatTimeout = new Ticker(40 * 1000);
         }
         while (!Unit.IsDead)
         {
             _combatLoopThread = new Thread(DoCombat)
             {
                 IsBackground = true
             };
             _combatLoopThread.Name = "DoCombat";
             _combatLoopThread.SetApartmentState(ApartmentState.STA);
             _combatLoopThread.Start();
             while (_combatLoopThread.IsAlive)
             {
                 Thread.Sleep(50);
                 if (!Langs.TrainingDummy(Unit.Name) && combatTimeout.IsReady && Unit.Health > 85)
                 {
                     Logging.Write("Combat took to long, bugged - blacklisting");
                     _combatResult = CombatResult.Bugged;
                     if (!PBlackList.IsBlacklisted(Unit))
                     {
                         PBlackList.Blacklist(Unit, 1200, false);
                     }
                     return;
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #7
0
 public static void DoWork(PUnit unit)
 {
     MoveHelper.ReleaseKeys();
     if (!unit.IsLootable)
     {
         return;
     }
     Logging.Write("Looting: " + unit.Name);
     if (unit.DistanceToSelf > 5)
     {
         MoveHelper.MoveToLoc(unit.Location, 4, false, true);
     }
     if (ObjectManager.ShouldDefend)
     {
         Logging.Write("Skipping loot, we got into combat");
         return;
     }
     Thread.Sleep(200);
     if (ObjectManager.MyPlayer.HasLivePet)
     {
         Thread.Sleep(700);
     }
     if (ObjectManager.MyPlayer.Target != unit)
     {
         unit.Interact(false);
     }
     else
     {
         KeyHelper.SendKey("InteractTarget");
     }
     if (ObjectManager.ShouldDefend)
     {
         return;
     }
     TimeOut.Reset();
     while (!ObjectManager.MyPlayer.LootWinOpen && !TimeOut.IsReady)
     {
         Thread.Sleep(100);
     }
     TimeOut.Reset();
     if (GrindingSettings.Skin || GrindingSettings.WaitForLoot)
     {
         while (ObjectManager.MyPlayer.LootWinOpen && !TimeOut.IsReady)
         {
             Thread.Sleep(100);
         }
         Thread.Sleep(1300);
     }
     else
     {
         Thread.Sleep(200);
     }
     GrindingEngine.UpdateStats(1, 0, 0);
     PBlackList.Blacklist(unit, 300, false);
     if (unit.IsSkinnable && GrindingSettings.Skin)
     {
         Logging.Write("Skinning");
         KeyHelper.SendKey("TargetLastTarget");
         Thread.Sleep(1000);
         if (!ObjectManager.MyPlayer.Target.IsValid)
         {
             unit.Interact(false);
         }
         else
         {
             KeyHelper.SendKey("InteractTarget");
         }
         TimeOut.Reset();
         while (!ObjectManager.MyPlayer.LootWinOpen && !TimeOut.IsReady)
         {
             Thread.Sleep(100);
         }
         if (GrindingSettings.WaitForLoot)
         {
             Thread.Sleep(500);
         }
         GrindingEngine.UpdateStats(1, 0, 0);
     }
 }
Example #8
0
 public static void DoWork(PUnit unit)
 {
     MoveHelper.ReleaseKeys();
     if (unit.IsLootable)
     {
         Logging.Write("Looting: " + unit.Name, new object[0]);
         if (unit.DistanceToSelf > 5.0)
         {
             MoveHelper.MoveToLoc(unit.Location, 4.0, false, true);
         }
         if (LazyLib.Wow.ObjectManager.ShouldDefend)
         {
             Logging.Write("Skipping loot, we got into combat", new object[0]);
             return;
         }
         Thread.Sleep(200);
         if (LazyLib.Wow.ObjectManager.MyPlayer.HasLivePet)
         {
             Thread.Sleep(700);
         }
         if (LazyLib.Wow.ObjectManager.MyPlayer.Target != unit)
         {
             unit.Interact(false);
         }
         else
         {
             KeyHelper.SendKey("InteractTarget");
         }
         if (LazyLib.Wow.ObjectManager.ShouldDefend)
         {
             return;
         }
         TimeOut.Reset();
         while (!LazyLib.Wow.ObjectManager.MyPlayer.LootWinOpen && !TimeOut.IsReady)
         {
             Thread.Sleep(100);
         }
         if (GrindingSettings.WaitForLoot)
         {
             Latency.Sleep(500);
         }
         GrindingEngine.UpdateStats(1, 0, 0);
         if (!GrindingSettings.Skin)
         {
             PBlackList.Blacklist(unit, 300, false);
         }
     }
     if ((unit.IsSkinnable && GrindingSettings.Skin) && (unit.GetSkinnableType() == Constants.SkinnableType.Skining))
     {
         Logging.Write("Skinning: " + unit.Name, new object[0]);
         if (unit.DistanceToSelf > 5.0)
         {
             MoveHelper.MoveToLoc(unit.Location, 4.0, false, true);
         }
         KeyHelper.SendKey("TargetLastTarget");
         Thread.Sleep(0x3e8);
         if (!LazyLib.Wow.ObjectManager.MyPlayer.Target.IsValid)
         {
             unit.Interact(false);
         }
         else
         {
             KeyHelper.SendKey("InteractTarget");
         }
         TimeOut.Reset();
         while (!LazyLib.Wow.ObjectManager.MyPlayer.LootWinOpen && !TimeOut.IsReady)
         {
             Thread.Sleep(100);
         }
         if (GrindingSettings.WaitForLoot)
         {
             Latency.Sleep(500);
         }
         GrindingEngine.UpdateStats(1, 0, 0);
         PBlackList.Blacklist(unit, 300, false);
     }
 }
Example #9
0
        private static PUnit FindMobToLoot()
        {
            PUnit toReturn = null;

            foreach (PUnit pUnit in ObjectManager.GetUnits)
            {
                if ((pUnit.IsLootable || ((pUnit.GetSkinnableType() == Constants.SkinnableType.Skining) && GrindingSettings.Skin)) && ((pUnit.DistanceToSelf < 70.0) && !PBlackList.IsBlacklisted(pUnit)))
                // old if (pUnit.IsLootable && pUnit.DistanceToSelf < 30 && !PBlackList.IsBlacklisted(pUnit))
                {
                    if (toReturn != null)
                    {
                        if (toReturn.DistanceToSelf > pUnit.DistanceToSelf)
                        {
                            toReturn = pUnit;
                        }
                    }
                    else
                    {
                        toReturn = pUnit;
                    }
                }
            }
            return(toReturn);
        }