コード例 #1
0
 private void InstallHook()
 {
     if (_myHook != null)
     {
         return;
     }
     _myHook = new ActionRunCoroutine(ctx => MainLogic());
     TreeHooks.Instance.InsertHook("Questbot_Main", 0, _myHook);
     BotEvents.OnBotStopped += BotEvents_OnBotStopped;
     BotEvents.Profile.OnNewProfileLoaded += Profile_OnNewProfileLoaded;
     QBCLog.Debug(this, "Installed hook");
 }
コード例 #2
0
 private void RemoveHook()
 {
     if (_myHook == null)
     {
         return;
     }
     TreeHooks.Instance.RemoveHook("Questbot_Main", _myHook);
     _myHook = null;
     BotEvents.OnBotStopped -= BotEvents_OnBotStopped;
     BotEvents.Profile.OnNewProfileLoaded -= Profile_OnNewProfileLoaded;
     QBCLog.Debug(this, "Removed hook");
 }
コード例 #3
0
        protected Composite CreateBehavior_Antistuck()
        {
            var      prevPosition  = WoWPoint.Empty;
            WoWPoint myLoc         = WoWPoint.Empty;
            var      moveDirection = WoWMovement.MovementDirection.None;

            return(new PrioritySelector(
                       new Decorator(
                           ctx => _stuckTimer.IsFinished,
                           new Sequence(
                               ctx => myLoc = WoWMovement.ActiveMover.Location,
                               // checks if stuck
                               new DecoratorContinue(
                                   ctx => myLoc.DistanceSqr(prevPosition) < 3 * 3,
                                   new Sequence(
                                       ctx => moveDirection = GetRandomMovementDirection(),
                                       new Action(ctx => QBCLog.Debug("Stuck. Movement Directions: {0}", moveDirection)),
                                       new Action(ctx => WoWMovement.Move(moveDirection)),
                                       new WaitContinue(2, ctx => false, new ActionAlwaysSucceed()),
                                       new Action(ctx => WoWMovement.MoveStop(moveDirection)))),

                               new Action(ctx => prevPosition = myLoc),
                               new Action(ctx => _stuckTimer.Reset())))));
        }
コード例 #4
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())
                                                  ))));
        }