// Empty, for now #endregion #region Overrides of CustomForcedBehavior public override void OnStart() { // Hunting ground processing... // NB: We had to defer this processing from the constructor, because XElement isn't available // to parse child XML nodes until OnStart() is called. HuntingGrounds = HuntingGroundsType.GetOrCreate(Element, "HuntingGrounds", HuntingGroundCenter); IsAttributeProblem |= HuntingGrounds.IsAttributeProblem; // Let QuestBehaviorBase do basic initializaion of the behavior, deal with bad or deprecated attributes, // capture configuration state, install BT hooks, etc. This will also update the goal text. OnStart_QuestBehaviorCore( string.Format("Using {0} on {1}", GetItemNameFromId(ItemId), string.Join(", ", MobIds.Select(m => GetMobNameFromId(m)).Distinct()))); // If the quest is complete, this behavior is already done... // So we don't want to falsely inform the user of things that will be skipped. if (!IsDone) { ItemToUse = Me.CarriedItems.FirstOrDefault(i => (i.Entry == ItemId)); if (ItemToUse == null) { LogError("[PROFILE ERROR] Unable to locate in our bags", GetItemNameFromId(ItemId)); TreeRoot.Stop(); BehaviorDone(); } CurrentHuntingGroundWaypoint = HuntingGrounds.FindFirstWaypoint(Me.Location); } }
protected override Composite CreateMainBehavior() { return(new PrioritySelector( // If quest is done, behavior is done... new Decorator(context => IsDone, new Action(context => { LogInfo("Finished"); BehaviorDone(); })), // Done due to count completing? new Decorator(context => Counter >= NumOfTimesToUseItem, new Action(context => { BehaviorDone(); })), // If item is no longer viable to use, warn user and we're done... new Decorator(context => !IsViable(ItemToUse), new Action(context => { LogError("We no longer have a viable Item({0}) to use--terminating", ItemId); TreeRoot.Stop(); BehaviorDone(); })), // If no viable target, find a new mob to harass... new Decorator(context => !IsViableForItemUse(SelectedTarget), new PrioritySelector( new Action(context => { Me.ClearTarget(); SelectedTarget = FindBestTarget(); // Target selected mob as feedback to user... if ((SelectedTarget != null) && (Me.CurrentTarget != SelectedTarget)) { SelectedTarget.Target(); } return RunStatus.Failure; // fall through }), // If we couldn't find a mob, move back to center of hunting grounds... new Decorator(context => SelectedTarget == null, new PrioritySelector( new Decorator(context => Me.Location.Distance(CurrentHuntingGroundWaypoint.Location) <= CurrentHuntingGroundWaypoint.Radius, new Action(context => { CurrentHuntingGroundWaypoint = HuntingGrounds.FindNextWaypoint(CurrentHuntingGroundWaypoint.Location); })), UtilityBehaviorPS_MoveTo( context => CurrentHuntingGroundWaypoint.Location, context => string.IsNullOrEmpty(CurrentHuntingGroundWaypoint.Name) ? "to next hunting ground waypoint" : string.Format("to hunting ground waypoint '{0}'", CurrentHuntingGroundWaypoint.Name) ), new Decorator(context => Me.Location.Distance(HuntingGroundCenter) <= Navigator.PathPrecision, new Action(context => { LogInfo("Waiting for mobs to respawn."); })) )) )), // Pick a fight, if needed... new Decorator(context => !Me.Combat && IsViableForItemUse(SelectedTarget), UtilityBehaviorPS_GetMobsAttention(context => SelectedTarget)) )); }