Exemple #1
0
        public void Execute()
        {
            computeNewRoute = false;
            WowUnit target = WowInterface.ObjectManager.Target;

            if ((WowInterface.ObjectManager.TargetGuid != 0 && target != null && !(target.IsDead || target.Health < 1)) || SearchNewTarget(ref target, false))
            {
                Dancing = false;
                bool targetDistanceChanged = false;
                if (!LastPlayerPosition.Equals(WowInterface.ObjectManager.Player.Position))
                {
                    distanceTraveled      = WowInterface.ObjectManager.Player.Position.GetDistance(LastPlayerPosition);
                    LastPlayerPosition    = new Vector3(WowInterface.ObjectManager.Player.Position.X, WowInterface.ObjectManager.Player.Position.Y, WowInterface.ObjectManager.Player.Position.Z);
                    targetDistanceChanged = true;
                }

                if (LastTargetRotation != target.Rotation)
                {
                    computeNewRoute    = true;
                    LastTargetRotation = target.Rotation;
                }

                if (!LastTargetPosition.Equals(target.Position))
                {
                    computeNewRoute          = true;
                    LastTargetPosition       = new Vector3(target.Position.X, target.Position.Y, target.Position.Z);
                    LastBehindTargetPosition = BotMath.CalculatePositionBehind(target.Position, target.Rotation, 3f);
                    targetDistanceChanged    = true;
                }

                if (targetDistanceChanged)
                {
                    distanceToTarget       = LastPlayerPosition.GetDistance(LastTargetPosition);
                    distanceToBehindTarget = LastPlayerPosition.GetDistance(LastBehindTargetPosition);
                }

                HandleMovement(target);
                HandleAttacking(target);
            }
            else if (!Dancing)
            {
                if (distanceTraveled < 0.001)
                {
                    WowInterface.HookManager.WowClearTarget();
                    WowInterface.HookManager.LuaSendChatMessage(standingEmotes[new Random().Next(standingEmotes.Length)]);
                    Dancing = true;
                    WowInterface.Globals.ForceCombat = false;
                }
                else
                {
                    WowInterface.HookManager.WowClearTarget();
                    Dancing = true;
                }
            }
        }
Exemple #2
0
        public void OutOfCombatExecute()
        {
            computeNewRoute = false;
            List <string> buffs = WowInterface.ObjectManager.Player.Auras.Select(e => e.Name).ToList();

            if (!buffs.Any(e => e.Contains("tealth")))
            {
                WowInterface.HookManager.LuaCastSpell("Stealth");
                spells.ResetAfterTargetDeath();
            }

            if (!LastPlayerPosition.Equals(WowInterface.ObjectManager.Player.Position))
            {
                distanceTraveled   = WowInterface.ObjectManager.Player.Position.GetDistance(LastPlayerPosition);
                LastPlayerPosition = new Vector3(WowInterface.ObjectManager.Player.Position.X, WowInterface.ObjectManager.Player.Position.Y, WowInterface.ObjectManager.Player.Position.Z);
            }

            if (distanceTraveled < 0.001)
            {
                ulong   leaderGuid = WowInterface.ObjectManager.PartyleaderGuid;
                WowUnit target     = WowInterface.ObjectManager.Target;
                if ((WowInterface.ObjectManager.TargetGuid != 0 && target != null && !(target.IsDead || target.Health < 1)) || SearchNewTarget(ref target, true))
                {
                    if (!LastTargetPosition.Equals(target.Position))
                    {
                        computeNewRoute          = true;
                        LastTargetPosition       = new Vector3(target.Position.X, target.Position.Y, target.Position.Z);
                        LastBehindTargetPosition = BotMath.CalculatePositionBehind(target.Position, target.Rotation, 5f);
                        distanceToTarget         = LastPlayerPosition.GetDistance(LastTargetPosition);
                        distanceToBehindTarget   = LastPlayerPosition.GetDistance(LastBehindTargetPosition);
                    }

                    Dancing = false;
                    HandleMovement(target);
                    WowInterface.Globals.ForceCombat = true;
                    HandleAttacking(target);
                }
                else if (!Dancing || standing)
                {
                    standing = false;
                    WowInterface.HookManager.WowClearTarget();
                    WowInterface.HookManager.LuaSendChatMessage(standingEmotes[new Random().Next(standingEmotes.Length)]);
                    Dancing = true;
                }
            }
            else
            {
                if (!Dancing || !standing)
                {
                    standing = true;
                    WowInterface.HookManager.WowClearTarget();
                    Dancing = true;
                }
            }
        }
Exemple #3
0
        public void CalculatePositionBehindTest()
        {
            Vector3 topPos    = new Vector3(0, 4, 0);
            Vector3 middlePos = new Vector3(0, 0, 0);

            float   facingAngle   = BotMath.GetFacingAngle2D(topPos, middlePos);
            Vector3 calculatedPos = BotMath.CalculatePositionBehind(topPos, facingAngle, 2.0);

            Vector3 expectedPos = new Vector3(0, 6, 0);

            Assert.AreEqual(expectedPos, calculatedPos);
        }
 private bool HandleDpsMovement(WowUnit target, Vector3 targetPosition)
 {
     // handle special movement needs
     if (WowInterface.CombatClass.WalkBehindEnemy &&
         WowInterface.ObjectManager.Target.TargetGuid != WowInterface.ObjectManager.PlayerGuid ||
         WowInterface.ObjectManager.Target.Type == WowObjectType.Player)    // prevent spinning
     {
         // walk behind enemy
         Vector3 positionToGoTo = BotMath.CalculatePositionBehind(target.Position, target.Rotation);
         return(WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, positionToGoTo));
     }
     else
     {
         // just move to the enemies
         return(WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, targetPosition));
     }
 }
        public void Execute()
        {
            if (!IsGateOpen())
            {
                WowInterface.CombatClass.OutOfCombatExecute();
                return;
            }

            // --- set new state ---
            if (hasStateChanged)
            {
                hasStateChanged = false;
                hasFlag         = WowInterface.ObjectManager.Player.Auras != null && WowInterface.ObjectManager.Player.Auras.Any(e => e.SpellId == 23333 || e.SpellId == 23335);
                WowUnit teamFlagCarrier = GetTeamFlagCarrier();
                ownTeamHasFlag = teamFlagCarrier != null;
                if (ownTeamHasFlag)
                {
                    TeamFlagCarrierGuid = teamFlagCarrier.Guid;
                }
                WowUnit enemyFlagCarrier = GetEnemyFlagCarrier();
                enemyTeamHasFlag = enemyFlagCarrier != null;
                if (enemyTeamHasFlag)
                {
                    EnemyFlagCarrierGuid = enemyFlagCarrier.Guid;
                }
            }

            // --- reaction ---
            if (hasFlag)
            {
                // you've got the flag!
                WowObject tmpFlag = GetOwnFlagObject();
                ownFlag = tmpFlag ?? ownFlag;
                if (ownFlag != null)
                {
                    // own flag lies around
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, ownFlag.Position);
                    if (isAtPosition(ownFlag.Position))
                    {
                        // own flag reached, save it!
                        WowInterface.HookManager.WowObjectRightClick(ownFlag);
                        hasStateChanged = true;
                    }
                }
                else
                {
                    // bring it outside!
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseHord : baseAlly);
                }
            }
            else if (ownTeamHasFlag && enemyTeamHasFlag)
            {
                // team mate and enemy got the flag
                if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Dps)
                {
                    // run to the enemy
                    WowUnit enemyFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(EnemyFlagCarrierGuid);
                    if (enemyFlagCarrier != null)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving,
                                                                      BotUtils.MoveAhead(enemyFlagCarrier.Position, enemyFlagCarrier.Rotation, ((float)WowInterface.ObjectManager.Player.Position.GetDistance2D(enemyFlagCarrier.Position)) / 2f));
                        if (isInCombatReach(enemyFlagCarrier.Position))
                        {
                            WowInterface.HookManager.WowTargetGuid(enemyFlagCarrier.Guid);
                        }
                        if (isEnemyClose())
                        {
                            WowInterface.Globals.ForceCombat = true;
                            return;
                        }
                    }
                    else
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseAlly : baseHord);
                    }
                    WowInterface.CombatClass.OutOfCombatExecute();
                }
                else
                {
                    // run to the own flag carrier
                    WowUnit teamFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(TeamFlagCarrierGuid);
                    if (teamFlagCarrier != null)
                    {
                        if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Dps)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, BotMath.CalculatePositionBehind(teamFlagCarrier.Position, teamFlagCarrier.Rotation, 1f));
                        }
                        else if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Tank)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, BotUtils.MoveAhead(teamFlagCarrier.Position, teamFlagCarrier.Rotation, 2f));
                        }
                        else if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Heal)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, teamFlagCarrier.Position);
                        }
                        if (isEnemyClose())
                        {
                            WowInterface.Globals.ForceCombat = true;
                            return;
                        }
                    }
                    else
                    {
                        // run to the enemy
                        WowUnit enemyFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(EnemyFlagCarrierGuid);
                        if (enemyFlagCarrier != null)
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving,
                                                                          BotUtils.MoveAhead(enemyFlagCarrier.Position, enemyFlagCarrier.Rotation, ((float)WowInterface.ObjectManager.Player.Position.GetDistance2D(enemyFlagCarrier.Position)) / 2f));
                            if (WowInterface.CombatClass.Role != Statemachine.Enums.CombatClassRole.Heal && isInCombatReach(enemyFlagCarrier.Position))
                            {
                                WowInterface.HookManager.WowTargetGuid(enemyFlagCarrier.Guid);
                            }
                            if (isEnemyClose())
                            {
                                WowInterface.Globals.ForceCombat = true;
                                return;
                            }
                        }
                        else
                        {
                            WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseHord : baseAlly);
                        }
                        WowInterface.CombatClass.OutOfCombatExecute();
                    }
                }
            }
            else if (ownTeamHasFlag)
            {
                // a team mate got the flag
                WowUnit teamFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(TeamFlagCarrierGuid);
                if (teamFlagCarrier != null)
                {
                    if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Dps)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, BotMath.CalculatePositionBehind(teamFlagCarrier.Position, teamFlagCarrier.Rotation, 1f));
                    }
                    else if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Tank)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, BotUtils.MoveAhead(teamFlagCarrier.Position, teamFlagCarrier.Rotation, 2f));
                    }
                    else if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Heal)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, teamFlagCarrier.Position);
                    }
                    if (isEnemyClose())
                    {
                        WowInterface.Globals.ForceCombat = true;
                        return;
                    }
                }
                else
                {
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseHord : baseAlly);
                }
                if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Dps)
                {
                    if (isEnemyClose())
                    {
                        WowInterface.Globals.ForceCombat = true;
                        return;
                    }
                }
                WowInterface.CombatClass.OutOfCombatExecute();
            }
            else if (enemyTeamHasFlag)
            {
                // the enemy got the flag
                if (WowInterface.CombatClass.Role == Statemachine.Enums.CombatClassRole.Tank)
                {
                    WowObject tmpFlag = getEnemyFlagObject();
                    enemyFlag = tmpFlag == null ? enemyFlag : tmpFlag;
                    if (enemyFlag != null)
                    {
                        // flag lies around
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, enemyFlag.Position);
                        if (isAtPosition(enemyFlag.Position))
                        {
                            // flag reached, save it!
                            hasStateChanged = true;
                            WowInterface.HookManager.WowObjectRightClick(enemyFlag);
                        }
                    }
                    else
                    {
                        // go outside!
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseAlly : baseHord);
                        WowInterface.CombatClass.OutOfCombatExecute();
                    }
                }
                else
                {
                    WowUnit enemyFlagCarrier = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(EnemyFlagCarrierGuid);
                    if (enemyFlagCarrier != null)
                    {
                        WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving,
                                                                      BotUtils.MoveAhead(enemyFlagCarrier.Position, enemyFlagCarrier.Rotation, ((float)WowInterface.ObjectManager.Player.Position.GetDistance2D(enemyFlagCarrier.Position)) / 2f));
                        if (WowInterface.CombatClass.Role != Statemachine.Enums.CombatClassRole.Heal && isInCombatReach(enemyFlagCarrier.Position))
                        {
                            WowInterface.HookManager.WowTargetGuid(enemyFlagCarrier.Guid);
                        }
                        if (isEnemyClose())
                        {
                            WowInterface.Globals.ForceCombat = true;
                            return;
                        }
                    }
                    WowInterface.CombatClass.OutOfCombatExecute();
                }
            }
            else
            {
                // go and get the enemy flag!!!
                WowObject tmpFlag = getEnemyFlagObject();
                enemyFlag = tmpFlag ?? enemyFlag;
                if (enemyFlag != null)
                {
                    // flag lies around
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, enemyFlag.Position);
                    if (isAtPosition(enemyFlag.Position))
                    {
                        // flag reached, save it!
                        hasStateChanged = true;
                        WowInterface.HookManager.WowObjectRightClick(enemyFlag);
                    }
                }
                else
                {
                    // go outside!
                    WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseAlly : baseHord);
                    WowInterface.CombatClass.OutOfCombatExecute();
                }
            }
            if (WowInterface.MovementEngine.MovementAction == Movement.Enums.MovementAction.None)
            {
                hasStateChanged = true;
                WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, this.isHorde ? baseAlly : baseHord);
                if (isEnemyClose())
                {
                    WowInterface.Globals.ForceCombat = true;
                    return;
                }
                WowInterface.CombatClass.OutOfCombatExecute();
            }
        }
Exemple #6
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);
        }
        public Vector3 Unstuck(float maxSteering, float maxVelocity, float multiplier)
        {
            Vector3 positionBehindMe = BotMath.CalculatePositionBehind(Bot.Player.Position, Bot.Player.Rotation, 8.0f);

            return(Seek(positionBehindMe, maxSteering, maxVelocity, multiplier));
        }