Exemple #1
0
        private bool HandleMovement(WowUnit target)
        {
            if (LineOfSightCheck.Run(out bool isInLos, () => WowInterface.HookManager.IsInLineOfSight(WowInterface.ObjectManager.Player.Position, target.Position)))
            {
                TargetInLos = isInLos;
            }

            if (FacingCheck.Run())
            {
                WowInterface.HookManager.FacePosition(WowInterface.ObjectManager.Player, target.Position);
            }

            // if we are close enough, stop movement and start attacking
            double distance = WowInterface.ObjectManager.Player.Position.GetDistance(target.Position);

            if (distance <= DistanceToTarget && TargetInLos)
            {
                WowInterface.HookManager.StopClickToMoveIfActive(WowInterface.ObjectManager.Player);
                return(false);
            }
            else
            {
                Vector3 positionToGoTo = target.Position; // WowInterface.CombatClass.IsMelee ? BotMath.CalculatePositionBehind(target.Position, target.Rotation, 4) :
                WowInterface.MovementEngine.SetState(distance > 4 ? MovementEngineState.Moving : MovementEngineState.DirectMoving, positionToGoTo);
                WowInterface.MovementEngine.Execute();
                return(true);
            }
        }
Exemple #2
0
        private bool HandleMovement(WowUnit target)
        {
            // handle the LOS check
            if (target == null || target.Guid == WowInterface.ObjectManager.PlayerGuid)
            {
                TargetInLos = true;
            }
            else if (LineOfSightCheck.Run(out bool isInLos, () => WowInterface.HookManager.WowIsInLineOfSight(WowInterface.ObjectManager.Player.Position, target.Position)))
            {
                TargetInLos = isInLos;
            }

            // set LOS in CombatClass
            if (WowInterface.CombatClass != null)
            {
                WowInterface.CombatClass.TargetInLineOfSight = WowInterface.ObjectManager.TargetGuid == 0 || TargetInLos;
            }

            // check if we are facing the unit
            if (target != null &&
                !WowInterface.HookManager.WowIsClickToMoveActive() &&
                FacingCheck.Run() &&
                target.Guid != WowInterface.ObjectManager.PlayerGuid &&
                !BotMath.IsFacing(WowInterface.ObjectManager.Player.Position, WowInterface.ObjectManager.Player.Rotation, target.Position))
            {
                WowInterface.HookManager.WowFacePosition(WowInterface.ObjectManager.Player, target.Position);
            }

            // do we need to move
            if (target == null)
            {
                // just move to our group
                WowInterface.MovementEngine.SetMovementAction(MovementAction.Moving, WowInterface.ObjectManager.MeanGroupPosition);
                return(true);
            }
            else
            {
                float distance = WowInterface.ObjectManager.Player.Position.GetDistance(target.Position);

                if (distance > DistanceToKeep || !TargetInLos)
                {
                    Vector3 positionToGoTo = Vector3.Zero;

                    if (WowInterface.CombatClass != null)
                    {
                        // handle special movement needs
                        if (WowInterface.CombatClass.WalkBehindEnemy)
                        {
                            if (WowInterface.CombatClass.Role == CombatClassRole.Dps &&
                                (WowInterface.ObjectManager.Target.TargetGuid != WowInterface.ObjectManager.PlayerGuid ||
                                 WowInterface.ObjectManager.Target.Type == WowObjectType.Player))       // prevent spinning
                            {
                                // walk behind enemy
                                positionToGoTo = BotMath.CalculatePositionBehind(target.Position, target.Rotation);
                            }
                            else if (WowInterface.CombatClass.Role == CombatClassRole.Tank &&
                                     WowInterface.ObjectManager.Partymembers.Any()) // no need to rotate
                            {
                                // rotate the boss away from the group
                                Vector3 meanGroupPosition = WowInterface.ObjectManager.MeanGroupPosition;
                                positionToGoTo = BotMath.CalculatePositionBehind(target.Position, BotMath.GetFacingAngle(target.Position, meanGroupPosition));
                            }
                        }
                        else if (WowInterface.CombatClass.Role == CombatClassRole.Heal)
                        {
                            // move to group
                            positionToGoTo = target != null ? target.Position : WowInterface.ObjectManager.MeanGroupPosition;
                        }
                        else
                        {
                            // just move to the enemies melee/ranged range
                            positionToGoTo = target.Position;
                        }

                        if (TargetInLos)
                        {
                            positionToGoTo = BotUtils.MoveAhead(WowInterface.ObjectManager.Player.Position, positionToGoTo, -(DistanceToKeep * 0.8f));
                        }

                        WowInterface.MovementEngine.SetMovementAction(MovementAction.Moving, positionToGoTo);
                        return(true);
                    }

                    if (TargetInLos)
                    {
                        positionToGoTo = BotUtils.MoveAhead(WowInterface.ObjectManager.Player.Position, positionToGoTo, -(DistanceToKeep * 0.8f));
                    }

                    // just move to the enemies melee/ranged range
                    positionToGoTo = target.Position;
                    WowInterface.MovementEngine.SetMovementAction(MovementAction.Moving, positionToGoTo);
                    return(true);
                }
            }

            // no need to move
            WowInterface.MovementEngine.StopMovement();
            return(false);
        }