Beispiel #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))
                                     )));
        }
        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))
                ));
        }
Beispiel #3
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_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())
                        ))  
                    ));
        }