public override void Combat(PUnit target) { if (Behavior.UseAutoAttack) { target.InteractWithTarget(); } if (Behavior.SendPet) { PetAttackKey.SendKey(); } //Logging.Debug("Combat started"); while (true) { try { if (target.DistanceToSelf > Behavior.CombatDistance) { MoveHelper.MoveToUnit(target, Behavior.CombatDistance); } } catch { } if (!ObjectManager.MyPlayer.IsValid || ObjectManager.MyPlayer.Target != target) { target.TargetHostile(); } if (PveBehaviorSettings.AvoidAddsCombat) { ConsiderAvoidAdds(target); } foreach (Rule rule in Behavior.CombatController.GetRules.Where(rule => rule.IsOk)) { if (target.IsValid && target.IsAlive) { if (!target.Location.IsFacing()) { target.Face(); } rule.ExecuteAction(Behavior.GlobalCooldown); break; } } Thread.Sleep(10); Application.DoEvents(); } }
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 { } }