示例#1
0
        public Composite UtilityBehaviorPS_SpankMobWithinAggroRange(ProvideWoWPointDelegate destinationDelegate,
                                                                    ProvideDoubleDelegate extraRangePaddingDelegate   = null,
                                                                    Func <IEnumerable <int> > excludedUnitIdsDelegate = null)
        {
            extraRangePaddingDelegate = extraRangePaddingDelegate ?? (context => 0.0);
            excludedUnitIdsDelegate   = excludedUnitIdsDelegate ?? (() => new List <int>());

            return(new Decorator(context => !Me.Combat,
                                 new PrioritySelector(
                                     // If a mob is targeting us, deal with it immediately, so subsequent activities won't be interrupted...
                                     // NB: This can happen if we 'drag mobs' behind us on the way to our destination.
                                     new Decorator(context => !IsViableForFighting(_ubpsSpankMobWithinAggroRange_Mob),
                                                   new Action(context =>
            {
                ProvideBoolDelegate extraQualifiers =
                    (obj) =>
                {
                    var wowUnit = obj as WoWUnit;

                    return (wowUnit != null)
                    // exclude opposing faction: both players and their pets show up as "PlayerControlled"
                    && !wowUnit.PlayerControlled &&
                    !excludedUnitIdsDelegate().Contains((int)wowUnit.Entry);
                };

                _ubpsSpankMobWithinAggroRange_Mob =
                    FindHostileUnitsWithinAggroRangeOFDestination(
                        destinationDelegate(context),
                        extraRangePaddingDelegate(context),
                        extraQualifiers)
                    .OrderBy(u => u.DistanceSqr).FirstOrDefault();

                return RunStatus.Failure;               // fall through
            })),

                                     // Spank any mobs we find being naughty...
                                     new Decorator(context => _ubpsSpankMobWithinAggroRange_Mob != null,
                                                   UtilityBehaviorPS_SpankMob(context => _ubpsSpankMobWithinAggroRange_Mob))
                                     )));
        }
示例#2
0
        /// <summary>
        /// Descends to a height safe for dismounting.  "Safe" is defined as 'not flying, or no more than
        /// MAXDISMOUNTHEIGHTDELEGATE above the ground.
        /// <para>Notes:<list type="bullet">
        /// <item><description><para> * If MAXDISMOUNTHEIGHTDELEGATE is not provided, a suitable value
        /// is used.</para></description></item>
        /// </list></para>
        /// </summary>
        /// <returns></returns>
        /// <remarks>17Apr2013-01:44UTC chinajade</remarks>
        public Composite UtilityBehaviorPS_DescendForDismount(ProvideDoubleDelegate maxDismountHeightDelegate = null)
        {
            maxDismountHeightDelegate = maxDismountHeightDelegate ?? (context => 8.0);

            Func <object, bool> isReadyToDismount = (context =>
            {
                return
                (!StyxWoW.Me.IsFlying ||
                 StyxWoW.Me.GetTraceLinePos().IsOverGroundOrWater(maxDismountHeightDelegate(context)));
            });

            return(new PrioritySelector(
                       // Descend, if needed...
                       new Decorator(context => !isReadyToDismount(context),
                                     new Sequence(
                                         new Action(context =>
            {
                LogDeveloperInfo("Descending before dismount");
                Navigator.PlayerMover.Move(WoWMovement.MovementDirection.Descend);
            }),
                                         new WaitContinue(Delay_WoWClientMovementThrottle,
                                                          context => isReadyToDismount(context) || !Me.IsMoving,
                                                          new ActionAlwaysSucceed())
                                         )),

                       // Stop descending...
                       new Decorator(context => Me.MovementInfo.IsDescending,
                                     new Sequence(
                                         new Action(context =>
            {
                LogDeveloperInfo("Stopping descent");
                WoWMovement.MoveStop(WoWMovement.MovementDirection.Descend);
            }),
                                         new WaitContinue(Delay_WoWClientMovementThrottle,
                                                          context => !Me.MovementInfo.IsDescending,
                                                          new ActionAlwaysSucceed())
                                         ))
                       ));
        }
        /// <summary>
        /// Descends to a height safe for dismounting.  "Safe" is defined as 'not flying, or no more than
        /// MAXDISMOUNTHEIGHTDELEGATE above the ground.
        /// <para>Notes:<list type="bullet">
        /// <item><description><para> * If MAXDISMOUNTHEIGHTDELEGATE is not provided, a suitable value
        /// is used.</para></description></item>
        /// </list></para>
        /// </summary>
        /// <returns></returns>
        /// <remarks>17Apr2013-01:44UTC chinajade</remarks>
        public Composite UtilityBehaviorPS_DescendForDismount(ProvideDoubleDelegate maxDismountHeightDelegate = null)
        {
            maxDismountHeightDelegate = maxDismountHeightDelegate ?? (context => 8.0);

            Func<object, bool> isReadyToDismount = (context =>
            {
                return
                    !StyxWoW.Me.IsFlying
                    || StyxWoW.Me.GetTraceLinePos().IsOverGroundOrWater(maxDismountHeightDelegate(context));
            });

            return new PrioritySelector(
                // Descend, if needed...
                new Decorator(context => !isReadyToDismount(context), 
                    new Sequence(
                        new Action(context =>
                        {
                            LogDeveloperInfo("Descending before dismount");
                            Navigator.PlayerMover.Move(WoWMovement.MovementDirection.Descend);
                        }),
                        new WaitContinue(Delay_WoWClientMovementThrottle,
                            context => isReadyToDismount(context) || !Me.IsMoving,
                            new ActionAlwaysSucceed())
                    )),

                // Stop descending...
                new Decorator(context => Me.MovementInfo.IsDescending,
                    new Sequence(
                        new Action(context =>
                        {
                            LogDeveloperInfo("Stopping descent");
                            WoWMovement.MoveStop(WoWMovement.MovementDirection.Descend);
                        }),
                        new WaitContinue(Delay_WoWClientMovementThrottle,
                            context => !Me.MovementInfo.IsDescending,
                            new ActionAlwaysSucceed())
                    ))
            );
        }
示例#4
0
        public Composite UtilityBehaviorPS_MoveTo(ProvideWoWPointDelegate destinationDelegate,
                                                  ProvideStringDelegate destinationNameDelegate,
                                                  ProvideDoubleDelegate precisionDelegate  = null,
                                                  CanRunDecoratorDelegate suppressMountUse = null,
                                                  ProvideWoWPointDelegate locationObserver = null)
        {
            ContractRequires(destinationDelegate != null, context => "locationRetriever may not be null");
            ContractRequires(destinationNameDelegate != null, context => "destinationNameDelegate may not be null");
            precisionDelegate = precisionDelegate ?? (context => Me.Mounted ? 8.0 : 5.0);
            suppressMountUse  = suppressMountUse ?? (context => false);
            locationObserver  = locationObserver ?? (context => Me.Location);

            return(new Decorator(context => MovementBy != MovementByType.None,
                                 new PrioritySelector(
                                     new Action(context =>
            {
                _ubpsMoveTo_Location = destinationDelegate(context);
                return RunStatus.Failure;           // fall through
            }),
                                     new Decorator(context => !suppressMountUse(context) && !Me.InVehicle && !Me.Mounted &&
                                                   Mount.CanMount() &&
                                                   Mount.ShouldMount(_ubpsMoveTo_Location),
                                                   new Action(context => { Mount.MountUp(() => _ubpsMoveTo_Location); })),

                                     new Decorator(context => (locationObserver(context).Distance((_ubpsMoveTo_Location)) > precisionDelegate(context)),
                                                   new Sequence(
                                                       new CompositeThrottle(TimeSpan.FromMilliseconds(1000),
                                                                             new Action(context => { TreeRoot.StatusText = "Moving to " + (destinationNameDelegate(context) ?? _ubpsMoveTo_Location.ToString()); })),
                                                       new Action(context =>
            {
                var moveResult = MoveResult.Failed;

                // Use Flightor, if allowed...
                if ((MovementBy == MovementByType.FlightorPreferred) && Me.IsOutdoors && Me.MovementInfo.CanFly)
                {
                    Flightor.MoveTo(_ubpsMoveTo_Location);
                    // <sigh> Its simply a crime that Flightor doesn't implement the INavigationProvider interface...
                    moveResult = MoveResult.Moved;
                }

                // Use Navigator to get there, if allowed...
                else if ((MovementBy == MovementByType.NavigatorPreferred) || (MovementBy == MovementByType.NavigatorOnly) ||
                         (MovementBy == MovementByType.FlightorPreferred))
                {
                    if (!Me.IsSwimming)
                    {
                        moveResult = Navigator.MoveTo(_ubpsMoveTo_Location);
                    }
                }

                // If Navigator couldn't move us, resort to click-to-move if allowed...
                if (!((moveResult == MoveResult.Moved) ||
                      (moveResult == MoveResult.ReachedDestination) ||
                      (moveResult == MoveResult.PathGenerated)))
                {
                    if (MovementBy == MovementByType.NavigatorOnly)
                    {
                        LogWarning("Failed to mesh move--is area unmeshed? Or, are we flying or swimming?");
                        return RunStatus.Failure;
                    }

                    WoWMovement.ClickToMove(_ubpsMoveTo_Location);
                }

                return RunStatus.Success;
            }),
                                                       new WaitContinue(Delay_WoWClientMovementThrottle, context => false, new ActionAlwaysSucceed())
                                                       ))
                                     )));
        }
        public Composite UtilityBehaviorPS_SpankMobWithinAggroRange(ProvideWoWPointDelegate destinationDelegate,
                                                                    ProvideDoubleDelegate extraRangePaddingDelegate = null,
                                                                    Func<IEnumerable<int>> excludedUnitIdsDelegate = null)
        {
            extraRangePaddingDelegate = extraRangePaddingDelegate ?? (context => 0.0);
            excludedUnitIdsDelegate = excludedUnitIdsDelegate ?? (() => new List<int>());

            return new Decorator(context => !Me.Combat,
                new PrioritySelector(
                    // If a mob is targeting us, deal with it immediately, so subsequent activities won't be interrupted...
                    // NB: This can happen if we 'drag mobs' behind us on the way to our destination.
                    new Decorator(context => !IsViableForFighting(_ubpsSpankMobWithinAggroRange_Mob),
                        new Action(context =>
                        {
                            ProvideBoolDelegate extraQualifiers =
                            (obj) =>
                            {
                                var wowUnit = obj as WoWUnit;

                                return (wowUnit != null)
                                    // exclude opposing faction: both players and their pets show up as "PlayerControlled"
                                    && !wowUnit.PlayerControlled
                                    && !excludedUnitIdsDelegate().Contains((int)wowUnit.Entry);
                            };

                            _ubpsSpankMobWithinAggroRange_Mob =
                                FindHostileUnitsWithinAggroRangeOFDestination(
                                    destinationDelegate(context),
                                    extraRangePaddingDelegate(context),
                                    extraQualifiers)
                                .OrderBy(u => u.DistanceSqr).FirstOrDefault();

                            return RunStatus.Failure;   // fall through
                        })),

                    // Spank any mobs we find being naughty...
                    new Decorator(context => _ubpsSpankMobWithinAggroRange_Mob != null,
                        UtilityBehaviorPS_SpankMob(context => _ubpsSpankMobWithinAggroRange_Mob))
                ));
        }
        public Composite UtilityBehaviorPS_MoveTo(ProvideWoWPointDelegate destinationDelegate,
                                                    ProvideStringDelegate destinationNameDelegate,
                                                    ProvideDoubleDelegate precisionDelegate = null,
                                                    CanRunDecoratorDelegate suppressMountUse = null,
                                                    ProvideWoWPointDelegate locationObserver = null)
        {
            ContractRequires(destinationDelegate != null, context => "locationRetriever may not be null");
            ContractRequires(destinationNameDelegate != null, context => "destinationNameDelegate may not be null");
            precisionDelegate = precisionDelegate ?? (context => Me.Mounted ? 8.0 : 5.0);
            suppressMountUse = suppressMountUse ?? (context => false);
            locationObserver = locationObserver ?? (context => Me.Location);

            return new Decorator(context => MovementBy != MovementByType.None,
                new PrioritySelector(
                    new Action(context =>
                    {
                        _ubpsMoveTo_Location = destinationDelegate(context);
                        return RunStatus.Failure;   // fall through
                    }),
                    new Decorator(context => !suppressMountUse(context) && !Me.InVehicle && !Me.Mounted
                                                        && Mount.CanMount()
                                                        && Mount.ShouldMount(_ubpsMoveTo_Location),
                        new Action(context => { Mount.MountUp(() => _ubpsMoveTo_Location); })),

                    new Decorator(context => (locationObserver(context).Distance((_ubpsMoveTo_Location)) > precisionDelegate(context)),
                        new Sequence(
                            new CompositeThrottle(TimeSpan.FromMilliseconds(1000),
                                new Action(context => {TreeRoot.StatusText = "Moving to " + (destinationNameDelegate(context) ?? _ubpsMoveTo_Location.ToString()); })),
                            new Action(context =>
                            {
                                var moveResult = MoveResult.Failed;

                                // Use Flightor, if allowed...
                                if ((MovementBy == MovementByType.FlightorPreferred) && Me.IsOutdoors && Me.MovementInfo.CanFly)
                                {
                                    Flightor.MoveTo(_ubpsMoveTo_Location);
                                    // <sigh> Its simply a crime that Flightor doesn't implement the INavigationProvider interface...
                                    moveResult = MoveResult.Moved;
                                }

                                // Use Navigator to get there, if allowed...
                                else if ((MovementBy == MovementByType.NavigatorPreferred) || (MovementBy == MovementByType.NavigatorOnly)
                                            || (MovementBy == MovementByType.FlightorPreferred))
                                {
                                    if (!Me.IsSwimming)
                                        { moveResult = Navigator.MoveTo(_ubpsMoveTo_Location); }
                                }

                                // If Navigator couldn't move us, resort to click-to-move if allowed...
                                if (!((moveResult == MoveResult.Moved)
                                        || (moveResult == MoveResult.ReachedDestination)
                                        || (moveResult == MoveResult.PathGenerated)))
                                {
                                    if (MovementBy == MovementByType.NavigatorOnly)
                                    {
                                        LogWarning("Failed to mesh move--is area unmeshed? Or, are we flying or swimming?");
                                        return RunStatus.Failure;
                                    }

                                    WoWMovement.ClickToMove(_ubpsMoveTo_Location);
                                }

                                return RunStatus.Success;
                            }),
                            new WaitContinue(Delay_WoWClientMovementThrottle, context => false, new ActionAlwaysSucceed())
                        ))  
                    ));
        }