Ejemplo n.º 1
0
        bool StuckCheck()
        {
            if (!_stuckTimer.IsRunning || _stuckTimer.ElapsedMilliseconds >= 3000)
            {
                _stuckTimer.Reset();
                _stuckTimer.Start();

                WoWUnit veh = GetVehicle();
                if (veh.Location.Distance(_lastPoint) <= 5 || _doingUnstuck)
                {
                    if (!_doingUnstuck)
                    {
                        LogMessage("info", "Stuck... Doing unstuck routine");
                        _direction = WoWMovement.MovementDirection.JumpAscend |
                                     (_rand.Next(0, 2) == 1 ? WoWMovement.MovementDirection.StrafeRight : WoWMovement.MovementDirection.StrafeLeft)
                                     | WoWMovement.MovementDirection.Backwards;
                        WoWMovement.Move(_direction);
                        _doingUnstuck = true;
                        return(true);
                    }
                    else
                    {
                        _doingUnstuck = false;
                        WoWMovement.MoveStop(_direction);
                    }
                }
                _lastPoint = veh.Location;
            }
            return(false);
        }
        private WoWMovement.MovementDirection GetRandomMovementDirection()
        {
            // randomly move left or ritht
            WoWMovement.MovementDirection ret = StyxWoW.Random.Next(2) == 0
                ? WoWMovement.MovementDirection.StrafeLeft
                : WoWMovement.MovementDirection.StrafeRight;

            // randomly choose to go diagonal backwords + left or right
            if (StyxWoW.Random.Next(2) == 0)
            {
                ret |= WoWMovement.MovementDirection.Backwards;
            }

            // randomly choose to jump (or descend if flying or swimming)
            if (StyxWoW.Random.Next(2) == 0)
            {
                var activeMover = WoWMovement.ActiveMover;
                if (activeMover.IsFlying || activeMover.IsSwimming)
                {
                    ret |= StyxWoW.Random.Next(2) == 0
                        ? WoWMovement.MovementDirection.JumpAscend
                        : WoWMovement.MovementDirection.Descend;
                }
                else
                {
                    ret |= WoWMovement.MovementDirection.JumpAscend;
                }
            }
            return(ret);
        }
        public static async Task AvoidEnemyCast(WoWUnit unit, float enemyAttackRadius, float saveDistance)
        {
            if (!StyxWoW.Me.IsFacing(unit))
            {
                unit.Face();
                await Coroutine.Sleep(300);
            }

            float behemothRotation    = getPositive(unit.RotationDegrees);
            float invertEnemyRotation = getInvert(behemothRotation);

            WoWMovement.MovementDirection move = getPositive(StyxWoW.Me.RotationDegrees) > invertEnemyRotation
                ? WoWMovement.MovementDirection.StrafeRight
                : WoWMovement.MovementDirection.StrafeLeft;

            try
            {
                while (unit.Distance2D <= saveDistance && unit.IsCasting && ((enemyAttackRadius == 0 && !StyxWoW.Me.IsSafelyBehind(unit)) ||
                                                                             (enemyAttackRadius != 0 && unit.IsSafelyFacing(StyxWoW.Me, enemyAttackRadius)) || unit.Distance2D <= 2))
                {
                    WoWMovement.Move(move);
                    unit.Face();
                    await Coroutine.Yield();
                }
            }
            finally
            {
                WoWMovement.MoveStop();
            }
        }
Ejemplo n.º 4
0
        private RunStatus AimDirection()
        {
            double normRotation = TRAMP_LEFT_SIDE > TRAMP_RIGHT_SIDE ? 0 : 360;
            double currRotation = Me.Transport.RotationDegrees;

            Dlog("(AimRotation) Trampoline Boundary - Left Edge: {0}  Right Edge: {1}", TRAMP_LEFT_SIDE, TRAMP_RIGHT_SIDE);

            WoWMovement.MovementDirection whichWay = WoWMovement.MovementDirection.None;
            string dirCmd;

            // left/right - get current direction and turn until on trampoline
            if (Me.Transport.RotationDegrees < TRAMP_RIGHT_SIDE)
            {
                whichWay = WoWMovement.MovementDirection.TurnLeft;
                dirCmd   = "TurnLeft";
            }
            else if ((Me.Transport.RotationDegrees + normRotation) > (TRAMP_LEFT_SIDE + normRotation))
            {
                whichWay = WoWMovement.MovementDirection.TurnRight;
                dirCmd   = "TurnRight";
            }
            else // if (whichWay == WoWMovement.MovementDirection.None)
            {
                Dlog("(AimRotation) Done, Ending Rotation: {0}", Me.Transport.RotationDegrees);
                return(RunStatus.Failure);
            }

            Dlog("(AimRotation) Current Rotation: {0} - {1}", Me.Transport.RotationDegrees, whichWay.ToString().ToUpper());
#if WOWMOVEMENT_TIMED_TURNS_STOPFAILING
            WoWMovement.Move(whichWay, TimeSpan.FromMilliseconds(10));
            WoWMovement.MoveStop(whichWay);
            // loop until we actually move
            while (0.001 > (currRotation - Me.Transport.RotationDegrees))
            {
                StyxWoW.SleepForLagDuration();
            }
#elif WOWMOVEMENT_TURNS_STOPFAILING
            WoWMovement.Move(whichWay);
            Thread.Sleep(10);
            WoWMovement.MoveStop(whichWay);
            // loop until we actually move
            while (0.001 > (currRotation - Me.Transport.RotationDegrees))
            {
                StyxWoW.SleepForLagDuration();
            }
#else
            // doing LUA calls these because WoWMovement API doesn't stop turning quickly enough
            Lua.DoString(dirCmd + "Start()");
            Thread.Sleep(10);
            Lua.DoString(dirCmd + "Stop()");
#endif
            return(RunStatus.Success);
        }
Ejemplo n.º 5
0
 public void Move(WoWMovement.MovementDirection direction)
 {
 }
Ejemplo n.º 6
0
        bool StuckCheck()
        {
            if (!_stuckTimer.IsRunning || _stuckTimer.ElapsedMilliseconds >= 3000)
            {
                _stuckTimer.Reset();
                _stuckTimer.Start();

                WoWUnit veh = GetVehicle();
                if (veh.Location.Distance(_lastPoint)<=5 || _doingUnstuck)
                {
                    if (!_doingUnstuck)
                    {
                        LogMessage("info", "Stuck... Doing unstuck routine");
                        _direction = WoWMovement.MovementDirection.JumpAscend |
                            (_rand.Next(0, 2) == 1 ? WoWMovement.MovementDirection.StrafeRight : WoWMovement.MovementDirection.StrafeLeft)
                            | WoWMovement.MovementDirection.Backwards;
                        WoWMovement.Move(_direction);
                        _doingUnstuck = true;
                        return true;
                    }
                    else
                    {
                        _doingUnstuck = false;
                        WoWMovement.MoveStop(_direction);
                    }
                }
                _lastPoint = veh.Location;
            }
            return false;
        }
Ejemplo n.º 7
0
        private Composite CreateBehavior_Antistuck()
        {
            return(new PrioritySelector(
                       new Decorator(context => _stuckTimer.IsFinished,
                                     new Sequence(context => _antiStuckMyLoc = WoWMovement.ActiveMover.Location,

                                                  // Check if stuck...
                                                  new DecoratorContinue(context => _antiStuckMyLoc.DistanceSqr(_antiStuckPrevPosition) < (3 * 3),
                                                                        new Sequence(context => _antiStuckPerformSimpleSequence = _antiStuckStuckSucceedTimer.IsFinished,
                                                                                     new DecoratorContinue(context => Me.IsMounted() && !Me.IsFlying,
                                                                                                           new ActionRunCoroutine(context => CommonCoroutines.Dismount("Stuck"))),

                                                                                     // Perform simple unstuck proceedure...
                                                                                     new DecoratorContinue(context => _antiStuckPerformSimpleSequence,
                                                                                                           new Sequence(
                                                                                                               new Action(context => QBCLog.Debug("Stuck. Trying to jump")),
                                                                                                               new Action(context =>
            {
                // ensure bot is moving forward when jumping (Wow will sometimes automatically
                // stop moving if running against a wall)
                if (ShouldPerformCTM)
                {
                    WoWMovement.ClickToMove(Destination);
                }
                WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend);
            }),
                                                                                                               new Sleep(1000),
                                                                                                               new Action(context => WoWMovement.MoveStop(WoWMovement.MovementDirection.JumpAscend))
                                                                                                               )),

                                                                                     // perform less simple unstuck proceedure
                                                                                     new DecoratorContinue(context => !_antiStuckPerformSimpleSequence,
                                                                                                           new Sequence(context => _antiStuckMoveDirection = GetRandomMovementDirection(),
                                                                                                                        new Action(context => QBCLog.Debug("Stuck. Movement Directions: {0}", _antiStuckMoveDirection)),
                                                                                                                        new Action(context => WoWMovement.Move(_antiStuckMoveDirection)),
                                                                                                                        new Sleep(2000),
                                                                                                                        new Action(context => WoWMovement.MoveStop(_antiStuckMoveDirection)))),

                                                                                     new Action(context => _antiStuckStuckSucceedTimer.Reset()))),

                                                  new Action(context => _antiStuckPrevPosition = _antiStuckMyLoc),
                                                  new Action(context => _stuckTimer.Reset())
                                                  ))));
        }