public override void Execute() { if (!ObjectManager.Player.IsInCombat && !AmeisenBotStateMachine.IsAnyPartymemberInCombat()) { AmeisenBotStateMachine.SetState(AmeisenBotState.Idle); return; } // we can do nothing until the ObjectManager is initialzed if (ObjectManager != null && ObjectManager.Player != null) { // use the default Target selection algorithm if the CombatClass doenst // Note: this only works for dps classes, tanks and healers need // to implement their own target selection algorithm if (CombatClass == null || !CombatClass.HandlesTargetSelection) { // make sure we got both objects refreshed before we check them ObjectManager.UpdateObject(ObjectManager.Player); ObjectManager.UpdateObject(ObjectManager.Target); // do we need to clear our target if (ObjectManager.TargetGuid > 0 && (ObjectManager.Target.IsDead || HookManager.GetUnitReaction(ObjectManager.Player, ObjectManager.Target) == WowUnitReaction.Friendly)) { HookManager.ClearTarget(); ObjectManager.UpdateObject(ObjectManager.Player); } // select a new target if our current target is invalid if ((ObjectManager.TargetGuid == 0 || (ObjectManager.Target == null || ObjectManager.Target.Guid == ObjectManager.PlayerGuid)) && SelectTargetToAttack(out WowUnit target)) { HookManager.TargetGuid(target.Guid); ObjectManager.UpdateObject(ObjectManager.Player); ObjectManager.UpdateObject(ObjectManager.Target); } } // use the default MovementEngine to move if the CombatClass doesnt if (CombatClass == null || !CombatClass.HandlesMovement) { HandleMovement(ObjectManager.Target); } // if no CombatClass is loaded, just autoattack if (CombatClass != null) { CombatClass.Execute(); } else { if (!ObjectManager.Player.IsAutoAttacking) { HookManager.StartAutoAttack(); } } } TryCount = 0; }