Exemplo n.º 1
0
 public override PullResult Pull(PUnit target)
 {
     //Logging.Debug("Pull started");
     Buff();
     PrePull(target);
     if (Behavior.UseAutoAttack)
     {
         target.InteractWithTarget();
     }
     if (!MoveHelper.MoveToUnit(target, Behavior.PullDistance))
     {
         return(PullResult.CouldNotPull);
     }
     if (Behavior.SendPet)
     {
         PetAttackKey.SendKey();
     }
     foreach (Rule rule in Behavior.PullController.GetRules.Where(rule => rule.IsOk))
     {
         target.Face();
         rule.ExecuteAction(Behavior.GlobalCooldown);
     }
     // Logging.Debug("Pull done");
     if (PPullBlackList.IsBlacklisted(target))
     {
         return(PullResult.CouldNotPull);
     }
     return(PullResult.Success);
 }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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
     {
     }
 }