예제 #1
0
 /// <summary>
 ///   Creates a move to location behavior. Will return RunStatus.Success if it has reached the location, or stopped in range. Best used at the end of a rotation.
 /// </summary>
 /// <remarks>
 ///   Created 5/1/2011.
 /// </remarks>
 /// <param name = "location">The location.</param>
 /// <param name = "stopInRange">true to stop in range.</param>
 /// <param name = "range">The range.</param>
 /// <returns>.</returns>
 public static Composite CreateMoveToLocationBehavior(LocationRetriever location, bool stopInRange, DynamicRangeRetriever range)
 {
     // Do not f**k with this. It will ensure we stop in range if we're supposed to.
     // Otherwise it'll stick to the targets ass like flies on dog shit.
     // Specifying a range of, 2 or so, will ensure we're constantly running to the target. Specifying 0 will cause us to spin in circles around the target
     // or chase it down like mad. (PVP oriented behavior)
     return(new PrioritySelector(
                new Decorator(
                    // Give it a little more than 1/2 a yard buffer to get it right. CTM is never 'exact' on where we land. So don't expect it to be.
                    ret => stopInRange && StyxWoW.Me.Location.Distance(location(ret)) < range(ret),
                    new PrioritySelector(
                        CreateEnsureMovementStoppedBehavior(),
                        // In short; if we're not moving, just 'succeed' here, so we break the tree.
                        new Action(ret => RunStatus.Success)
                        )
                    ),
                new Action(ret => Navigator.MoveTo(location(ret))),
                new Action(ret => StopMoving.InRangeOfLocation(location(ret), range(ret)))
                ));
 }
예제 #2
0
        /// <summary>
        ///   Movement for Ranged Classes or Ranged Pulls.  Move to Unit at range behavior 
        ///   that stops in line of spell sight in range of target. Moves a maximum of 
        ///   10 yds at a time to minimize run past. will also only move towards unit if
        ///   not currently moving (to allow bot/human momvement precendence.)
        /// </summary>
        /// <remarks>
        ///   Created 9/25/2012.
        /// </remarks>
        /// <param name = "toUnit">unit to move towards</param>
        /// <param name = "range">The range.</param>
        /// <returns>.</returns>       
        public static Composite CreateMoveToRangeAndStopBehavior(UnitSelectionDelegate toUnit, DynamicRangeRetriever range)
        {
            return
                new Decorator(

                    ret => !SingularSettings.Instance.DisableAllMovement && toUnit != null && toUnit(ret) != null,

                    new PrioritySelector(
                        // save check for whether we are in range to avoid duplicate calls
                        new Action( ret => {
                            inRange = toUnit(ret).Distance < range(ret) && toUnit(ret).InLineOfSpellSight;
                            return RunStatus.Failure;
                        }),

                        new Decorator(
                            ret => inRange && StyxWoW.Me.IsMoving,
                            new Action(ret => Navigator.PlayerMover.MoveStop())
                            ),

                        new Decorator(
                            ret => !inRange && (!StyxWoW.Me.IsMoving || StyxWoW.Me.Location.DistanceSqr(lastMoveToRangeSpot) < 3 * 3),
                            new Action(ret => {
                                    WoWPoint[] spots = Navigator.GeneratePath( StyxWoW.Me.Location, toUnit(ret).Location);
                                    if ( spots.GetLength(0) > 0 )
                                    {
                                        if (  spots[0].Distance(toUnit(ret).Location) < range(ret) )
                                        {
                                            float spotDist = spots[0].Distance(StyxWoW.Me.Location);
                                            float moveToDistFromSpot = spotDist - 10;
                                            if (moveToDistFromSpot > 0)
                                            {
                                                spots[0] = WoWMathHelper.CalculatePointFrom(StyxWoW.Me.Location, spots[0], moveToDistFromSpot );
                                            }
                                        }

                                        Navigator.MoveTo(spots[0]);
                                    }
                                })
                            )
                        )
                    );
        }
예제 #3
0
 /// <summary>
 ///   Creates a move to location behavior. Will return RunStatus.Success if it has reached the location, or stopped in range. Best used at the end of a rotation.
 /// </summary>
 /// <remarks>
 ///   Created 5/1/2011.
 /// </remarks>
 /// <param name = "location">The location.</param>
 /// <param name = "stopInRange">true to stop in range.</param>
 /// <param name = "range">The range.</param>
 /// <returns>.</returns>
 public static Composite CreateMoveToLocationBehavior(LocationRetriever location, bool stopInRange, DynamicRangeRetriever range)
 {
     // Do not f**k with this. It will ensure we stop in range if we're supposed to.
     // Otherwise it'll stick to the targets ass like flies on dog shit.
     // Specifying a range of, 2 or so, will ensure we're constantly running to the target. Specifying 0 will cause us to spin in circles around the target
     // or chase it down like mad. (PVP oriented behavior)
     return
         new Decorator(
             // Don't run if the movement is disabled.
             ret => !SingularSettings.Instance.DisableAllMovement,
             new PrioritySelector(
                 new Decorator(
                     // Give it a little more than 1/2 a yard buffer to get it right. CTM is never 'exact' on where we land. So don't expect it to be.
                     ret => stopInRange && StyxWoW.Me.Location.Distance(location(ret)) < range(ret),
                     new PrioritySelector(
                         CreateEnsureMovementStoppedBehavior(),
                         // In short; if we're not moving, just 'succeed' here, so we break the tree.
                         new Action(ret => RunStatus.Success)
                         )
                     ),
                 new Action(ret => Navigator.MoveTo(location(ret)))
                 ));
 }
예제 #4
0
        /// <summary>
        ///   Movement for Ranged Classes or Ranged Pulls.  Move to Unit at range behavior
        ///   that stops in line of spell sight in range of target. Moves a maximum of
        ///   10 yds at a time to minimize run past. will also only move towards unit if
        ///   not currently moving (to allow bot/human momvement precendence.)
        /// </summary>
        /// <remarks>
        ///   Created 9/25/2012.
        /// </remarks>
        /// <param name = "toUnit">unit to move towards</param>
        /// <param name = "range">The range.</param>
        /// <returns>.</returns>
        public static Composite CreateMoveToRangeAndStopBehavior(UnitSelectionDelegate toUnit, DynamicRangeRetriever range)
        {
            return
                (new Decorator(

                     ret => !SingularSettings.Instance.DisableAllMovement && toUnit != null && toUnit(ret) != null,

                     new PrioritySelector(
                         // save check for whether we are in range to avoid duplicate calls
                         new Action(ret => {
                inRange = toUnit(ret).Distance < range(ret) && toUnit(ret).InLineOfSpellSight;
                return RunStatus.Failure;
            }),

                         new Decorator(
                             ret => inRange && StyxWoW.Me.IsMoving,
                             new Action(ret => Navigator.PlayerMover.MoveStop())
                             ),

                         new Decorator(
                             ret => !inRange && (!StyxWoW.Me.IsMoving || StyxWoW.Me.Location.DistanceSqr(lastMoveToRangeSpot) < 3 * 3),
                             new Action(ret => {
                WoWPoint[] spots = Navigator.GeneratePath(StyxWoW.Me.Location, toUnit(ret).Location);
                if (spots.GetLength(0) > 0)
                {
                    if (spots[0].Distance(toUnit(ret).Location) < range(ret))
                    {
                        float spotDist = spots[0].Distance(StyxWoW.Me.Location);
                        float moveToDistFromSpot = spotDist - 10;
                        if (moveToDistFromSpot > 0)
                        {
                            spots[0] = WoWMathHelper.CalculatePointFrom(StyxWoW.Me.Location, spots[0], moveToDistFromSpot);
                        }
                    }

                    Navigator.MoveTo(spots[0]);
                }
            })
                             )
                         )
                     ));
        }
예제 #5
0
 public Composite CreateMoveToLocationBehavior(LocationRetriever location, bool stopInRange, DynamicRangeRetriever range)
 {
     // Do not f**k with this. It will ensure we stop in range if we're supposed to.
     // Otherwise it'll stick to the targets ass like flies on dog shit.
     // Specifying a range of, 2 or so, will ensure we're constantly running to the target. Specifying 0 will cause us to spin in circles around the target
     // or chase it down like mad. (PVP oriented behavior)
     return new PrioritySelector(
         new Decorator(ret => stopInRange && StyxWoW.Me.CharmedUnit.Location.Distance(location(ret)) < range(ret),
             CreateEnsureMovementStoppedBehavior()),
         new Decorator(ret => StyxWoW.Me.CharmedUnit.Location.Distance(location(ret)) > range(ret),
             new Action(ret =>
             {
                 Navigator.MoveTo(location(ret));
                 return RunStatus.Failure;
             }))
         );
 }
예제 #6
0
파일: Movement.cs 프로젝트: aash/Singular
 /// <summary>
 ///   Creates a move to location behavior. Will return RunStatus.Success if it has reached the location, or stopped in range. Best used at the end of a rotation.
 /// </summary>
 /// <remarks>
 ///   Created 5/1/2011.
 /// </remarks>
 /// <param name = "location">The location.</param>
 /// <param name = "stopInRange">true to stop in range.</param>
 /// <param name = "range">The range.</param>
 /// <returns>.</returns>
 public static Composite CreateMoveToLocationBehavior(SimpleLocationRetriever location, bool stopInRange, DynamicRangeRetriever range)
 {
     return new Decorator(
         ret => !MovementManager.IsMovementDisabled,
         new PrioritySelector(
             new Decorator(
                 req => stopInRange,
                 new PrioritySelector(
                     new Action( r => {
                         if (StopMoving.Type != StopMoving.StopType.RangeOfLocation || location(r) != StopMoving.Point || range(r) != StopMoving.Range )
                             StopMoving.InRangeOfLocation(location(r), range(r));
                         return RunStatus.Failure;
                     }),
                     new Decorator(
                         req => Me.Location.Distance(location(req)) < range(req),
                         CreateEnsureMovementStoppedBehavior()
                         )
                     )
                 ),
             new Decorator(
                 req => Me.Location.Distance(location(req)) > range(req),
                 new Action(r => {
                     string s = stopInRange ? string.Format("MoveInRangeOfLoc({0:F1} yds)", range(r)) : "MoveToLocation";
                     Logger.WriteDebug(Color.White, s + ": towards {0} @ {1:F1} yds", location(r),  range(r));
                     Navigator.MoveTo(location(r));
                 })
                 )
             )
         );
 }