Ejemplo n.º 1
0
        public Composite CreateBehavior_KillGnome()
        {
            WoWUnit attackTarget = null;

            return(new Decorator(r => !Me.IsQuestComplete(QuestId) && Query.IsInVehicle(),
                                 new PrioritySelector(ctx => attackTarget = GetAttackTarget(),
                                                      new Decorator(ctx => attackTarget != null,
                                                                    new PrioritySelector(
                                                                        new ActionFail(ctx => _stuckTimer.Reset()),
                                                                        new ActionSetActivity("Moving to Attack"),
                                                                        new Decorator(ctx => Me.CurrentTargetGuid != attackTarget.Guid,
                                                                                      new ActionFail(ctx => attackTarget.Target())),
                                                                        new Decorator(ctx => !WoWMovement.ActiveMover.IsSafelyFacing(attackTarget, 30),
                                                                                      new ActionFail(ctx => attackTarget.Face())),

                                                                        // cast 'Incinerate' ability on melee range target.
                                                                        new Decorator(
                                                                            ctx => Me.Location.DistanceSqr(attackTarget.Location) <= 15 * 15,
                                                                            new PrioritySelector(
                                                                                new Decorator(
                                                                                    ctx => Me.Location.DistanceSqr(attackTarget.Location) <= 15 * 15 && (Me.IsMoving || Me.CharmedUnit.IsMoving),
                                                                                    new ActionFail(ctx => WoWMovement.ClickToMove(Me.CharmedUnit.Location))),
                                                                                new Action(ctx => Lua.DoString("CastPetAction(1)")))),
                                                                        new Decorator(ctx => Me.Location.DistanceSqr(attackTarget.Location) > 15 * 15,
                                                                                      new Action(ctx => Navigator.MoveTo(attackTarget.Location))))),
                                                      new Decorator(
                                                          ctx => attackTarget == null,
                                                          new PrioritySelector(
                                                              new Decorator(
                                                                  ctx => Me.Location.DistanceSqr(_waitPoint) > 10 * 10,
                                                                  new PrioritySelector(
                                                                      // can't set path precision so I'll just handle it directly...
                                                                      // the IronShredder takes wide turns so needs a higher path precision than normal
                                                                      new Decorator(
                                                                          ctx =>
            {
                var nav = Navigator.NavigationProvider as MeshNavigator;
                if (nav == null)
                {
                    return false;
                }
                if (nav.CurrentMovePath == null || nav.CurrentMovePath.Index >= nav.CurrentMovePath.Path.Points.Length)
                {
                    return false;
                }
                WoWPoint point = nav.CurrentMovePath.Path.Points[nav.CurrentMovePath.Index];
                return point.DistanceSqr(Me.Location) < 6 * 6;
            },
                                                                          new Action(ctx => ((MeshNavigator)Navigator.NavigationProvider).CurrentMovePath.Index++)),

                                                                      CreateBehavior_Antistuck(),

                                                                      new Action(ctx => Navigator.MoveTo(_waitPoint)))),
                                                              new ActionSetActivity("No viable targets, waiting."))),
                                                      new ActionAlwaysSucceed())));
        }
        private WoWPoint GetTinyBubbleMoveTo()
        {
            var myLoc = Me.Location;

            if (_tinyBubbleMoveTo != WoWPoint.Empty && _tinyBubbleMoveTo.DistanceSqr(myLoc) > 4 * 4)
            {
                return(_tinyBubbleMoveTo);
            }

            return(_tinyBubbleMoveTo =
                       (from obj in ObjectManager.ObjectList
                        where obj.Entry == TinyBubbleId && !Blacklist.Contains(obj, BlacklistFlags.Interact)
                        let loc = obj.Location
                                  let distanceSqurared = loc.DistanceSqr(myLoc)
                                                         where IsElegibleBubble(obj, distanceSqurared)
                                                         orderby distanceSqurared
                                                         select loc).FirstOrDefault());
        }
Ejemplo n.º 3
0
        // 22Mar2013-11:49UTC chinajade
        private int FindIndexOfNearestWaypoint(WoWPoint location)
        {
            var indexOfNearestWaypoint = IVisitStrategy.InvalidWaypointIndex;
            var distanceSqrMin         = double.MaxValue;

            for (var index = 0; index < Waypoints.Count; ++index)
            {
                var distanceSqr = location.DistanceSqr(FindWaypointAtIndex(index).Location);

                if (distanceSqr < distanceSqrMin)
                {
                    distanceSqrMin         = distanceSqr;
                    indexOfNearestWaypoint = index;
                }
            }

            return(indexOfNearestWaypoint);
        }
Ejemplo n.º 4
0
 public async static Task <bool> FlyTo(WoWPoint destination, string destinationName = null)
 {
     if (destination.DistanceSqr(_lastMoveTo) > 5 * 5)
     {
         if (MoveToLogTimer.IsFinished)
         {
             if (string.IsNullOrEmpty(destinationName))
             {
                 destinationName = destination.ToString();
             }
             AutoAnglerBot.Log("Flying to {0}", destinationName);
             MoveToLogTimer.Reset();
         }
         _lastMoveTo = destination;
     }
     Flightor.MoveTo(destination);
     return(true);
 }
Ejemplo n.º 5
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())
                                                  ))));
        }
Ejemplo n.º 6
0
        public async static Task <bool> MoveTo(WoWPoint destination, string destinationName = null)
        {
            if (destination.DistanceSqr(_lastMoveTo) > 5 * 5)
            {
                if (MoveToLogTimer.IsFinished)
                {
                    if (string.IsNullOrEmpty(destinationName))
                    {
                        destinationName = destination.ToString();
                    }
                    AutoAnglerBot.Log("Moving to {0}", destinationName);
                    MoveToLogTimer.Reset();
                }
                _lastMoveTo = destination;
            }
            var moveResult = Navigator.MoveTo(destination);

            return(moveResult != MoveResult.Failed && moveResult != MoveResult.PathGenerationFailed);
        }
        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())))));
        }
Ejemplo n.º 8
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root = new PrioritySelector(
                                 // if not in a turret than move to one and interact with it
                                 new Decorator(ret => !InVehicle,
                                               new Sequence(ctx => GetMustang(), // set Turret as context
                                                            new DecoratorContinue(ctx => ctx != null && ((WoWUnit)ctx).DistanceSqr > 5 * 5,
                                                                                  new Action(ctx =>
            {
                Navigator.MoveTo(((WoWUnit)ctx).Location);
                TreeRoot.StatusText = "Moving To Mustang";
            })),
                                                            new DecoratorContinue(ctx => ctx != null && ((WoWUnit)ctx).DistanceSqr <= 5 * 5,
                                                                                  new Action(ctx =>
            {
                Logging.Write("Interacting with Mustang");
                if (Me.Mounted)
                {
                    Mount.Dismount();
                }
                ((WoWUnit)ctx).Interact();
            })))),
                                 // Find the nearest spider and if none exist then move to thier spawn location
                                 new Decorator(ret => _currentTarget == null || !_currentTarget.IsValid || !_currentTarget.IsAlive,
                                               new Action(ctx =>
            {
                _currentTarget = ObjectManager.GetObjectsOfType <WoWUnit>()
                                 .Where(
                    u =>
                    u.IsAlive && !_blackList.Contains(u.Guid) && u.Entry == 44284).
                                 OrderBy(u => u.DistanceSqr).FirstOrDefault();
                if (_currentTarget == null)
                {
                    Navigator.MoveTo(_spiderLocation);
                    Logging.Write("No spiders found. Moving to spawn point");
                }
                else
                {
                    _movetoPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation,
                                                                    _currentTarget.
                                                                    Location, -5);
                    Logging.Write("Locked on a new target. Distance {0}", _currentTarget.Distance);
                }
            })),


                                 new Sequence(
                                     new Action(ctx => TreeRoot.StatusText = "Scaring spider towards lumber mill"),
                                     new Action(ctx =>
            {                                    // blacklist spider if it doesn't move
                if (DateTime.Now - _stuckTimeStamp > TimeSpan.FromSeconds(6))
                {
                    _stuckTimeStamp = DateTime.Now;
                    if (_movetoPoint.DistanceSqr(_lastMovetoPoint) < 3 * 3)
                    {
                        Logging.Write("Blacklisting spider");
                        _blackList.Add(_currentTarget.Guid);
                        _currentTarget = null;
                        return RunStatus.Failure;
                    }
                    _lastMovetoPoint = _movetoPoint;
                }
                return RunStatus.Success;
            }),
                                     new Action(ctx =>
            {
                // update movepoint
                _movetoPoint =
                    WoWMathHelper.CalculatePointFrom(_lumberMillLocation,
                                                     _currentTarget.
                                                     Location, -7);
                if (_movetoPoint.DistanceSqr(Me.Location) > 8 * 8)
                {
                    Navigator.MoveTo(_movetoPoint);
                    return RunStatus.Running;
                }
                return RunStatus.Success;
            }),
                                     new WaitContinue(2, ret => !Me.IsMoving, new ActionAlwaysSucceed()),
                                     new Action(ctx =>
            {
                using (new FrameLock())
                {
                    Me.SetFacing(_lumberMillLocation);
                    WoWMovement.Move(WoWMovement.MovementDirection.ForwardBackMovement);
                    WoWMovement.MoveStop(WoWMovement.MovementDirection.ForwardBackMovement);
                    //Lua.DoString("CastSpellByID(83605)");
                }
            }),
                                     new WaitContinue(TimeSpan.FromMilliseconds(200), ret => false, new ActionAlwaysSucceed()),
                                     new Action(ctx => Lua.DoString("CastSpellByID(83605)"))

                                     /*
                                      *            new Action(ctx =>
                                      *             {
                                      *                 var unit = ctx as WoWUnit;
                                      *                 if (unit != null && unit.IsValid && unit.IsAlive)
                                      *                 {
                                      *                     // move to a point that places the spider between player and lumber mill
                                      *                     var movetoPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation, unit.Location, -5);
                                      *                     // blacklist spider if its not moving
                                      *                     if (DateTime.Now - _stuckTimeStamp > TimeSpan.FromSeconds(6))
                                      *                     {
                                      *                         _stuckTimeStamp = DateTime.Now;
                                      *                         if (movetoPoint.DistanceSqr(_lastMovetoPoint) < 2 * 2)
                                      *                         {
                                      *                             Logging.Write("Blacklisting spider");
                                      *                             _blackList.Add(unit.Guid);
                                      *                             return RunStatus.Failure;
                                      *                         }
                                      *                         _lastMovetoPoint = movetoPoint;
                                      *                     }
                                      *
                                      *                     if (movetoPoint.DistanceSqr(Me.Location) > 6 * 6)
                                      *                         Navigator.MoveTo(movetoPoint);
                                      *                     else
                                      *                     {
                                      *                         using (new FrameLock())
                                      *                         {
                                      *                             //WoWMovement.MoveStop();
                                      *                             //Me.SetFacing(_lumberMillLocation);
                                      *                             Lua.DoString("CastSpellByID(83605)");
                                      *                         }
                                      *                     }
                                      *                     return RunStatus.Running;
                                      *                 }
                                      *                 return RunStatus.Failure;
                                      *             })*/
                                     ))));
        }
Ejemplo n.º 9
0
        private async Task <bool> Coroutine_CombatMain()
        {
            if (IsDone)
            {
                return(false);
            }

            if (!Query.IsInVehicle())
            {
                // only move to vehicle if doing nothing else
                if (!Targeting.Instance.IsEmpty() || BotPoi.Current.Type != PoiType.None)
                {
                    return(false);
                }

                WoWUnit amber = Amber;
                // Wait for Amber to load in the ObjectMananger.
                if (amber == null || !amber.WithinInteractRange)
                {
                    var moveTo = amber != null ? amber.Location : _vehicleLoc;
                    await UtilityCoroutine.MoveTo(moveTo, "Moving to Start Amber(Human) Story", MovementBy);

                    return(true);
                }

                if (await CommonCoroutines.StopMoving())
                {
                    return(true);
                }

                if (!GossipFrame.Instance.IsVisible)
                {
                    amber.Interact();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }

                if (GossipFrame.Instance.GossipOptionEntries != null)
                {
                    GossipFrame.Instance.SelectGossipOption(0);
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }
                return(true);
            }

            if (await InteractWithUnit(HozenEnemy))
            {
                return(true);
            }

            if (await InteractWithUnit(OrcEnemy))
            {
                return(true);
            }

            if (!Me.HasAura("See Quest Invis 5"))
            {
                var turret = Turret;
                if (TurretLocation.DistanceSqr(Me.Location) > 3 * 3)
                {
                    await UtilityCoroutine.MoveTo(TurretLocation, "Turret Location", MovementBy);

                    return(true);
                }
                if (turret == null)
                {
                    TreeRoot.StatusText = "Waiting for turret to spawn";
                    return(true);
                }

                if (!turret.WithinInteractRange)
                {
                    await UtilityCoroutine.MoveTo(TurretLocation, "interact range of turret", MovementBy);

                    return(true);
                }

                if (await CommonCoroutines.StopMoving())
                {
                    return(true);
                }

                QBCLog.Info("Using turret");
                Turret.Interact();
                return(true);
            }
            return(false);
        }
        public Composite CreateBehavior_KillMantid()
        {
            WoWUnit   attackTarget   = null;
            WoWUnit   yeti           = null;
            WaitTimer leapSmashTimer = WaitTimer.TenSeconds;

            return(new Decorator(r => !Me.IsQuestComplete(QuestId) && Query.IsInVehicle() && (yeti = Me.CharmedUnit) != null,
                                 new PrioritySelector(ctx => attackTarget = GetAttackTarget(),
                                                      new Decorator(ctx => attackTarget != null,
                                                                    new PrioritySelector(
                                                                        new ActionFail(ctx => _stuckTimer.Reset()),
                                                                        new ActionSetActivity("Moving to Attack"),
                                                                        new Decorator(ctx => Me.CurrentTargetGuid != attackTarget.Guid,
                                                                                      new ActionFail(ctx => attackTarget.Target())),
                                                                        new Decorator(ctx => !Me.IsSafelyFacing(attackTarget) || !yeti.IsSafelyFacing(attackTarget),
                                                                                      new ActionFail(ctx => attackTarget.Face())),
                                                                        // cast 'Hozen Snack' ability to heal up.
                                                                        new Decorator(ctx => yeti.HealthPercent <= 70,
                                                                                      new ActionFail(ctx => Lua.DoString("CastPetAction(4)"))),
                                                                        // cast 'Leap Smash' ability on targets outside of melee
                                                                        new Decorator(
                                                                            ctx =>
                                                                            yeti.Location.DistanceSqr(attackTarget.Location) > 30 * 30 && yeti.Location.DistanceSqr(attackTarget.Location) < 90 * 90 && leapSmashTimer.IsFinished,
                                                                            new Sequence(
                                                                                new Action(ctx => Lua.DoString("CastPetAction(1)")),
                                                                                new WaitContinue(2, ctx => StyxWoW.Me.CurrentPendingCursorSpell != null, new ActionAlwaysSucceed()),
                                                                                new Action(ctx => SpellManager.ClickRemoteLocation(attackTarget.Location)),
                                                                                new Action(ctx => leapSmashTimer.Reset()))),
                                                                        // cast 'Headbutt' ability on melee range target.
                                                                        new Decorator(
                                                                            ctx => yeti.Location.DistanceSqr(attackTarget.Location) <= 25 * 25,
                                                                            new PrioritySelector(
                                                                                new Decorator(
                                                                                    ctx => yeti.Location.DistanceSqr(attackTarget.Location) <= 25 * 25 && (Me.IsMoving || Me.CharmedUnit.IsMoving),
                                                                                    new ActionFail(ctx => WoWMovement.ClickToMove(Me.CharmedUnit.Location))),
                                                                                new Action(ctx => Lua.DoString("CastPetAction(2)")))),
                                                                        new Decorator(ctx => yeti.Location.DistanceSqr(attackTarget.Location) > 25 * 25,
                                                                                      new Action(ctx => Navigator.MoveTo(attackTarget.Location))))),
                                                      new Decorator(
                                                          ctx => attackTarget == null,
                                                          new PrioritySelector(
                                                              new Decorator(
                                                                  ctx => yeti.Location.DistanceSqr(_waitPoint) > 10 * 10,
                                                                  new PrioritySelector(
                                                                      // can't set path precision so I'll just handle it directly...
                                                                      // the yeti takes wide turns so needs a higher path precision than normal
                                                                      new Decorator(
                                                                          ctx =>
            {
                var nav = Navigator.NavigationProvider as MeshNavigator;
                if (nav == null)
                {
                    return false;
                }
                if (nav.CurrentMovePath == null || nav.CurrentMovePath.Index >= nav.CurrentMovePath.Path.Points.Length)
                {
                    return false;
                }
                WoWPoint point = nav.CurrentMovePath.Path.Points[nav.CurrentMovePath.Index];
                return point.DistanceSqr(yeti.Location) < 6 * 6;
            },
                                                                          new Action(ctx => ((MeshNavigator)Navigator.NavigationProvider).CurrentMovePath.Index++)),

                                                                      CreateBehavior_Antistuck(),

                                                                      new Action(ctx => Navigator.MoveTo(_waitPoint)))),
                                                              new ActionSetActivity("No viable targets, waiting."))),
                                                      new ActionAlwaysSucceed())));
        }
Ejemplo n.º 11
0
        // Originally contributed by Chinajade.
        //
        // LICENSE:
        // This work is licensed under the
        //     Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
        //
        //Modified to work in conjunction with my behavior objects.
        /// <summary>
        /// Uses the transport.
        /// </summary>
        /// <param name="transportId">The transport identifier.</param>
        /// <param name="startLocation">The start location.</param>
        /// <param name="endLocation">The end location.</param>
        /// <param name="waitAtLocation">The wait at location.</param>
        /// <param name="standAtLocation">The stand at location.</param>
        /// <param name="getOffLocation">The get off location.</param>
        /// <param name="movement">The movement.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="navigationFailedAction">
        ///     The action to take if <paramref name="waitAtLocation" /> cant be navigated to
        /// </param>
        /// <returns>returns <c>true</c> until done</returns>
        /// <exception cref="Exception">A delegate callback throws an exception. </exception>
        public static async Task <bool> UseTransport(
            int transportId,
            WoWPoint startLocation,
            WoWPoint endLocation,
            WoWPoint waitAtLocation,
            WoWPoint standAtLocation,
            WoWPoint getOffLocation,
            MovementTypes movementType,
            string destination = null)
        {
            if (getOffLocation != WoWPoint.Empty && StyxWoW.Me.Location.DistanceSqr(getOffLocation) < 2 * 2)
            {
                return(false);
            }

            var transportLocation = GetTransportLocation(transportId);

            if (transportLocation != WoWPoint.Empty &&
                transportLocation.DistanceSqr(startLocation) < 1.5 * 1.5 &&
                waitAtLocation.DistanceSqr(Player.Location) < 2 * 2)
            {
                TreeRoot.StatusText = "Moving inside transport";
                Navigator.PlayerMover.MoveTowards(standAtLocation);
                await CommonCoroutines.SleepForLagDuration();

                // wait for bot to get on boat.
                await Coroutine.Wait(12000, () => !StyxWoW.Me.IsMoving || Navigator.AtLocation(standAtLocation));
            }

            // loop while on transport to prevent bot from doing anything else
            while (StyxWoW.Me.Transport != null && StyxWoW.Me.Transport.Entry == transportId)
            {
                if (transportLocation != WoWPoint.Empty && transportLocation.DistanceSqr(endLocation) < 1.5 * 1.5)
                {
                    TreeRoot.StatusText = "Moving out of transport";
                    Navigator.PlayerMover.MoveTowards(getOffLocation);
                    await CommonCoroutines.SleepForLagDuration();

                    // Sleep until we stop moving.
                    await Coroutine.Wait(12000, () => !StyxWoW.Me.IsMoving || Navigator.AtLocation(getOffLocation));

                    return(true);
                }

                // Exit loop if in combat or dead.
                if (StyxWoW.Me.Combat || !StyxWoW.Me.IsAlive)
                {
                    return(false);
                }

                TreeRoot.StatusText = "Waiting for the end location";
                await Coroutine.Yield();

                // update transport location.
                transportLocation = GetTransportLocation(transportId);
            }

            if (waitAtLocation.DistanceSqr(Player.Location) > 2 * 2)
            {
                var _movement = new Movement(waitAtLocation, 2f, name: "TransportWaitAtLocation", checkStuck: false);

                if (movementType == MovementTypes.ClickToMove)
                {
                    await _movement.ClickToMove();
                }
                else
                {
                    await _movement.MoveTo();
                }

                return(true);
            }
            await CommonCoroutines.LandAndDismount();

            TreeRoot.StatusText = "Waiting for transport";
            return(true);
        }
Ejemplo n.º 12
0
        protected override Composite CreateBehavior()
        {
            return _root ?? (_root = new PrioritySelector(
                // if not in a turret than move to one and interact with it
                new Decorator(ret => !InVehicle,
                    new Sequence(ctx => GetMustang(), // set Turret as context
                        new DecoratorContinue(ctx => ctx != null && ((WoWUnit)ctx).DistanceSqr > 5 * 5,
                            new Action(ctx =>
                                           {
                                               Navigator.MoveTo(((WoWUnit)ctx).Location);
                                               TreeRoot.StatusText = "Moving To Mustang";
                                           })),
                        new DecoratorContinue(ctx => ctx != null && ((WoWUnit)ctx).DistanceSqr <= 5 * 5,
                            new Action(ctx =>
                                           {
                                               Logging.Write("Interacting with Mustang");
                                               if (Me.Mounted)
                                                   Mount.Dismount();
                                               ((WoWUnit)ctx).Interact();
                                           })))),
                // Find the nearest spider and if none exist then move to thier spawn location
                    new Decorator(ret => _currentTarget == null || !_currentTarget.IsValid || !_currentTarget.IsAlive,
                            new Action(ctx =>
                                           {
                                               _currentTarget = ObjectManager.GetObjectsOfType<WoWUnit>()
                                                   .Where(
                                                       u =>
                                                       u.IsAlive && !_blackList.Contains(u.Guid) && u.Entry == 44284).
                                                   OrderBy(u => u.DistanceSqr).FirstOrDefault();
                                               if (_currentTarget == null)
                                               {
                                                   Navigator.MoveTo(_spiderLocation);
                                                   Logging.Write("No spiders found. Moving to spawn point");
                                               }
                                               else
                                               {
                                                   _movetoPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation,
                                                                                                   _currentTarget.
                                                                                                       Location, -5);
                                                   Logging.Write("Locked on a new target. Distance {0}", _currentTarget.Distance);
                                               }
                                           })),

                            new Sequence(
                                new Action(ctx => TreeRoot.StatusText = "Scaring spider towards lumber mill"),
                                new Action(ctx =>
                                               { // blacklist spider if it doesn't move
                                                   if (DateTime.Now - _stuckTimeStamp > TimeSpan.FromSeconds(6))
                                                   {
                                                       _stuckTimeStamp = DateTime.Now;
                                                       if (_movetoPoint.DistanceSqr(_lastMovetoPoint) < 3 * 3)
                                                       {
                                                           Logging.Write("Blacklisting spider");
                                                           _blackList.Add(_currentTarget.Guid);
                                                           _currentTarget = null;
                                                           return RunStatus.Failure;
                                                       }
                                                       _lastMovetoPoint = _movetoPoint;
                                                   }
                                                   return RunStatus.Success;
                                               }),
                                new Action(ctx =>
                                                {
                                                    // update movepoint
                                                    _movetoPoint =
                                                        WoWMathHelper.CalculatePointFrom(_lumberMillLocation,
                                                                                        _currentTarget.
                                                                                            Location, -7);
                                                    if (_movetoPoint.DistanceSqr(Me.Location) >8 * 8)
                                                    {
                                                        Navigator.MoveTo(_movetoPoint);
                                                        return RunStatus.Running;
                                                    }
                                                    return RunStatus.Success;
                                                }),
                                new WaitContinue(2, ret => !Me.IsMoving, new ActionAlwaysSucceed()),
                                new Action(ctx =>
                                               {
                                                   using (new FrameLock())
                                                   {
                                                       Me.SetFacing(_lumberMillLocation);
                                                       WoWMovement.Move(WoWMovement.MovementDirection.ForwardBackMovement);
                                                       WoWMovement.MoveStop(WoWMovement.MovementDirection.ForwardBackMovement);
                                                       //Lua.DoString("CastSpellByID(83605)");
                                                   }
                                               }),
                            new WaitContinue(TimeSpan.FromMilliseconds(200), ret => false, new ActionAlwaysSucceed()),
                             new Action(ctx => Lua.DoString("CastSpellByID(83605)"))

                /*
                              new Action(ctx =>
                               {
                                   var unit = ctx as WoWUnit;
                                   if (unit != null && unit.IsValid && unit.IsAlive)
                                   {
                                       // move to a point that places the spider between player and lumber mill
                                       var movetoPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation, unit.Location, -5);
                                       // blacklist spider if its not moving
                                       if (DateTime.Now - _stuckTimeStamp > TimeSpan.FromSeconds(6))
                                       {
                                           _stuckTimeStamp = DateTime.Now;
                                           if (movetoPoint.DistanceSqr(_lastMovetoPoint) < 2 * 2)
                                           {
                                               Logging.Write("Blacklisting spider");
                                               _blackList.Add(unit.Guid);
                                               return RunStatus.Failure;
                                           }
                                           _lastMovetoPoint = movetoPoint;
                                       }

                                       if (movetoPoint.DistanceSqr(Me.Location) > 6 * 6)
                                           Navigator.MoveTo(movetoPoint);
                                       else
                                       {
                                           using (new FrameLock())
                                           {
                                               //WoWMovement.MoveStop();
                                               //Me.SetFacing(_lumberMillLocation);
                                               Lua.DoString("CastSpellByID(83605)");
                                           }
                                       }
                                       return RunStatus.Running;
                                   }
                                   return RunStatus.Failure;
                               })*/
                                 )));
        }
Ejemplo n.º 13
0
        private static Composite CreateFollowBehavior()
        {
            return(new PrioritySelector(

                       new Decorator(ret => !LazyRaiderSettings.Instance.FollowTank,
                                     new ActionAlwaysSucceed()),

                       new Decorator(ret => !IsInGroup,
                                     new ActionAlwaysSucceed()),

                       new Decorator(ret => Tank.Current == null,
                                     new ActionAlwaysSucceed()),

                       new Decorator(ret => Me.CurrentHealth <= 1, // if dead or ghost
                                     new ActionAlwaysSucceed()),

                       new Decorator(ret => Tank.Health <= 1, // if dead or ghost
                                     new ActionAlwaysSucceed()),

                       new Decorator(ret => NeedToMount(),
                                     new Action(delegate
            {
                WaitForMount();
            })),

                       new Decorator(ret => NeedToDismount(),
                                     new Action(delegate
            {
                WaitForDismount();
            })),

                       new Decorator(ret => Tank.Distance > LazyRaiderSettings.Instance.FollowDistance ||
                                     (RaFHelper.Leader != null && !RaFHelper.Leader.InLineOfSpellSight),
                                     new Action(delegate
            {
                WoWPoint pt = Tank.Location;
                if (pt.DistanceSqr(_lastDest) > 1 || !Me.IsMoving)
                {
                    _lastDest = pt;
                    WoWPoint newPoint = WoWMovement.CalculatePointFrom(pt, (float)0.85 * LazyRaiderSettings.Instance.FollowDistance);
                    Log("move to tank @ {0:F1} yds", pt.Distance(Me.Location));

                    if (RaFHelper.Leader != null && RaFHelper.Leader.Mounted && (RaFHelper.Leader.IsFlying || RaFHelper.Leader.IsSwimming))
                    {
                        Flightor.MoveTo(newPoint);
                    }
                    else
                    {
                        Navigator.MoveTo(newPoint);
                    }

                    botMovement = true;
                }

                return RunStatus.Success;
            })),

                       new Decorator(ret => Me.IsMoving && botMovement,
                                     new Action(delegate
            {
                botMovement = false;
                while (IsGameStable() && Me.IsMoving)
                {
                    WoWMovement.MoveStop();
                    if (Me.IsMoving)
                    {
                        System.Threading.Thread.Sleep(25);
                    }
                }

                return RunStatus.Success;
            }))

                       ));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Uses the transport.
        /// </summary>
        /// <param name="transportId">The transport identifier.</param>
        /// <param name="transportStartLoc">The start location.</param>
        /// <param name="transportEndLoc">The end location.</param>
        /// <param name="waitAtLoc">The wait at location.</param>
        /// <param name="boardAtLoc">The stand at location.</param>
        /// <param name="getOffLoc">The get off location.</param>
        /// <param name="movement">The movement.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="navigationFailedAction">
        ///     The action to take if <paramref name="waitAtLoc" /> cant be navigated to
        /// </param>
        /// <returns>returns <c>true</c> until done</returns>
        /// <exception cref="Exception">A delegate callback throws an exception. </exception>
        public static async Task <bool> UseTransport(
            int transportId,
            WoWPoint transportStartLoc,
            WoWPoint transportEndLoc,
            WoWPoint waitAtLoc,
            WoWPoint boardAtLoc,
            WoWPoint getOffLoc,
            MovementByType movement       = MovementByType.FlightorPreferred,
            string destination            = null,
            Action navigationFailedAction = null)
        {
            if (getOffLoc != WoWPoint.Empty && Me.Location.DistanceSqr(getOffLoc) < 2 * 2)
            {
                return(false);
            }

            var transportLocation = GetTransportLocation(transportId);

            if (transportLocation != WoWPoint.Empty &&
                transportLocation.DistanceSqr(transportStartLoc) < 1.5 * 1.5 &&
                waitAtLoc.DistanceSqr(Me.Location) < 2 * 2)
            {
                TreeRoot.StatusText = "Moving inside transport";
                Navigator.PlayerMover.MoveTowards(boardAtLoc);
                await CommonCoroutines.SleepForLagDuration();

                // wait for bot to get on boat.
                await Coroutine.Wait(12000, () => !Me.IsMoving || Navigator.AtLocation(boardAtLoc));
            }

            // loop while on transport to prevent bot from doing anything else
            while (Me.Transport != null && Me.Transport.Entry == transportId)
            {
                if (transportLocation != WoWPoint.Empty && transportLocation.DistanceSqr(transportEndLoc) < 1.5 * 1.5)
                {
                    TreeRoot.StatusText = "Moving out of transport";
                    Navigator.PlayerMover.MoveTowards(getOffLoc);
                    await CommonCoroutines.SleepForLagDuration();

                    // Sleep until we stop moving.
                    await Coroutine.Wait(12000, () => !Me.IsMoving || Navigator.AtLocation(getOffLoc));

                    return(true);
                }

                // Exit loop if in combat or dead.
                if (Me.Combat || !Me.IsAlive)
                {
                    return(false);
                }

                TreeRoot.StatusText = "Waiting for the end location";
                await Coroutine.Yield();

                // update transport location.
                transportLocation = GetTransportLocation(transportId);
            }

            if (waitAtLoc.DistanceSqr(Me.Location) > 2 * 2)
            {
                if (!await MoveTo(waitAtLoc, destination ?? waitAtLoc.ToString(), movement))
                {
                    if (navigationFailedAction != null)
                    {
                        navigationFailedAction();
                    }
                }
                return(true);
            }
            await CommonCoroutines.LandAndDismount();

            TreeRoot.StatusText = "Waiting for transport";
            return(true);
        }