private async Task <bool> MainCoroutine()
        {
            if (IsDone || BotPoi.Current.Type != PoiType.None || Targeting.Instance.FirstUnit != null)
            {
                return(false);
            }

            if (_noMobsAtCurrentWaypoint == null)
            {
                _noMobsAtCurrentWaypoint =
                    new UtilityCoroutine.NoMobsAtCurrentWaypoint(
                        () => HuntingGrounds,
                        () => MovementBy,
                        null,
                        () => { if (!WaitForNpcs)
                                {
                                    BehaviorDone("Terminating--\"WaitForNpcs\" is false.");
                                }
                        },
                        () =>
                        TargetExclusionAnalysis.Analyze(
                            Element,
                            () => PursuitList.GetPursuitedObjects(),
                            TargetExclusionChecks));
            }

            // move to waypoints when there's nothing else to do.
            return(await _noMobsAtCurrentWaypoint);
        }
        // 30May2013-08:11UTC chinajade
        private List <string> TargetExclusionChecks(WoWObject wowObject)
        {
            var exclusionReasons = TargetExclusionAnalysis.CheckCore(wowObject, this);

            TargetExclusionAnalysis.CheckAuras(exclusionReasons, wowObject, TargetOnlyIfMobHasAuraId, TargetOnlyIfMobMissingAuraId);

            var wowUnit = wowObject as WoWUnit;

            if (wowUnit != null)
            {
                if (wowUnit.HealthPercent < TargetOnlyIfHealthPercentAbove)
                {
                    exclusionReasons.Add(string.Format("Health({0:F1}) < TargetOnlyIfHealthPercentAbove({1:F1})",
                                                       wowUnit.HealthPercent, TargetOnlyIfHealthPercentAbove));
                }

                if (wowUnit.HealthPercent > TargetOnlyIfHealthPercentBelow)
                {
                    exclusionReasons.Add(string.Format("Health({0:F1}) > TargetOnlyIfHealthPercentBelow({1:F1})",
                                                       wowUnit.HealthPercent, TargetOnlyIfHealthPercentBelow));
                }
            }

            return(exclusionReasons);
        }
예제 #3
0
        protected override Composite CreateMainBehavior()
        {
            return(new PrioritySelector(context =>
            {
                SelectedTarget = Targeting.Instance.FirstUnit;
                return context;
            },

                                        new ActionRunCoroutine(ctx => _warnIfBagsFull
                                                               ?? (_warnIfBagsFull = new UtilityCoroutine.WarnIfBagsFull())),

                                        // Wait additional time requested by profile writer...
                                        // NB: We must do this prior to checking for 'behavior done'.  Otherwise, profiles
                                        // that don't have an associated quest, and put the behavior in a <While> loop will not behave
                                        // as the profile writer expects.  They expect the delay to be executed if the interaction
                                        // succeeded.
                                        new Decorator(context => !_waitTimerAfterUsingItem.IsFinished,
                                                      new Action(context =>
            {
                TreeRoot.StatusText = string.Format("Completing {0} wait of {1}",
                                                    Utility.PrettyTime(TimeSpan.FromSeconds((int)_waitTimerAfterUsingItem.TimeLeft.TotalSeconds)),
                                                    Utility.PrettyTime(_waitTimerAfterUsingItem.WaitTime));
            })),

                                        // Done due to count completing?
                                        new Decorator(context => (QuestObjectiveIndex <= 0) && (Counter >= NumOfTimes),
                                                      new Action(context => { BehaviorDone(); })),

                                        // Go after viable target...
                                        new Decorator(context => Query.IsViable(SelectedTarget),
                                                      // HV: there's no range restriction on POI.Kill so this isn't needed anymore.
                                                      //new PrioritySelector(
                                                      //    new Decorator(context => SelectedTarget.Distance >= CharacterSettings.Instance.PullDistance,
                                                      //        new UtilityBehaviorPS.MoveTo(
                                                      //            context => SelectedTarget.Location,
                                                      //            context => SelectedTarget.Name,
                                                      //            context => MovementBy)),
                                                      // Set Kill POI, if Honorbuddy doesn't think there is anything to do...
                                                      // NB: We don't want to do this blindly (i.e., we check for PoiType.None), to allow HB
                                                      // the decision to loot/sell/repair/etc as needed.
                                                      new DecoratorIsPoiType(PoiType.None,
                                                                             new ActionFail(context => Utility.Target(SelectedTarget, false, PoiType.Kill)))
                                                      ),

                                        // No mobs in immediate vicinity...
                                        new Decorator(context => !Query.IsViable(SelectedTarget),
                                                      new ActionRunCoroutine(
                                                          context =>
                                                          _noMobsAtCurrentWaypoint ??
                                                          (_noMobsAtCurrentWaypoint =
                                                               new UtilityCoroutine.NoMobsAtCurrentWaypoint(
                                                                   () => HuntingGrounds,
                                                                   () => MovementBy,
                                                                   () => { /*NoOp*/ },
                                                                   () => TargetExclusionAnalysis.Analyze(
                                                                       Element,
                                                                       () => Query.FindMobsAndFactions(MobIds),
                                                                       TargetExclusionChecks)))))
                                        ));
        }
        // 4JUn2013-08:11UTC chinajade
        private List <string> TargetExclusionChecks(WoWObject wowObject)
        {
            var exclusionReasons = TargetExclusionAnalysis.CheckCore(wowObject, this);

            TargetExclusionAnalysis.CheckCollectionDistance(exclusionReasons, wowObject, CollectionDistance);

            var wowUnit = wowObject as WoWUnit;

            if (wowUnit != null)
            {
                if (!wowUnit.Attackable)
                {
                    exclusionReasons.Add("!Attackable");
                }

                TargetExclusionAnalysis.CheckMobState(exclusionReasons, wowUnit, MobStateType.Alive, 100.0);
                TargetExclusionAnalysis.CheckAuras(exclusionReasons, wowUnit, null, Utility.ToEnumerable(ItemAppliesAuraId));
            }

            return(exclusionReasons);
        }
        private List <string> TargetExclusionChecks(WoWObject wowObject)
        {
            var exclusionReasons = TargetExclusionAnalysis.CheckCore(wowObject, this);

            return(exclusionReasons);
        }
        protected override Composite CreateMainBehavior()
        {
            return(new PrioritySelector(
                       // If we don't have a selected target, find one...
                       new Decorator(context => !IsMobQualified(SelectedTarget),
                                     new PrioritySelector(
                                         new ActionFail(context => { SelectedTarget = FindQualifiedMob(); }),

                                         // No qualifed mobs in immediate vicinity...
                                         new Decorator(context => !IsMobQualified(SelectedTarget),
                                                       new PrioritySelector(
                                                           new Decorator(context => Me.GotTarget,
                                                                         new Action(context => { Me.ClearTarget(); })),

                                                           // NB: if the terminateBehaviorIfNoTargetsProvider argument evaluates to 'true', calling
                                                           // this sub-behavior will terminate the overall behavior.
                                                           new ActionRunCoroutine(context =>
                                                                                  _noMobsAtCurrentWaypoint ??
                                                                                  (_noMobsAtCurrentWaypoint =
                                                                                       new UtilityCoroutine.NoMobsAtCurrentWaypoint(
                                                                                           () => HuntingGrounds,
                                                                                           () => MovementBy,
                                                                                           () => { if (!WaitForNpcs)
                                                                                                   {
                                                                                                       BehaviorDone("Terminating--\"WaitForNpcs\" is false.");
                                                                                                   }
                                                                                           },
                                                                                           () => TargetExclusionAnalysis.Analyze(
                                                                                               Element,
                                                                                               () => Query.FindMobsAndFactions(MobIds),
                                                                                               TargetExclusionChecks))))))
                                         )),

                       // If qualified mob was found, move within range, if needed...
                       // NB: A mob can lose its 'qualified' status for several reasons.  For instance,
                       // another player moves close to or tags the mob while we're on our way to it.
                       new Decorator(context => IsMobQualified(SelectedTarget),
                                     new PrioritySelector(
                                         new ActionFail(context => { Utility.Target(SelectedTarget); }),
                                         new Decorator(context => IsDistanceCloseNeeded(SelectedTarget),
                                                       new ActionRunCoroutine(
                                                           context => UtilityCoroutine.MoveTo(
                                                               SelectedTarget.Location,
                                                               SelectedTarget.SafeName,
                                                               MovementBy))),
                                         new ActionRunCoroutine(context => CommonCoroutines.StopMoving()),
                                         new Action(context =>
            {
                Utility.Target(SelectedTarget, true);
                BehaviorDone();
            })
                                         ))
                       ));
        }