protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( new Decorator(ret => !_waitTimer.IsFinished, new Sequence( new Action(ret => AntiAfk()), new Action(ret => TreeRoot.StatusText = "Waiting for the story to end"), new ActionAlwaysSucceed()) ), new Decorator(ret => HighWarlordDarion != null && HighWarlordDarion.CanGossip, new PrioritySelector( new Decorator(ret => !HighWarlordDarion.WithinInteractRange, new Sequence( new Action(ret => TreeRoot.StatusText = "Moving to High Warlord Darion"), new Action(ret => Navigator.MoveTo(HighWarlordDarion.Location)))), new Sequence( new Action(ret => TreeRoot.StatusText = "Talking to High Warlord Darion"), new DecoratorContinue(ret => Me.IsMoving, new Sequence( new Action(ret => WoWMovement.MoveStop()), new Action(ret => StyxWoW.SleepForLagDuration()) )), new Action(ret => HighWarlordDarion.Interact()), new WaitContinue(5, ret => GossipFrame.Instance.IsVisible, new Sequence( new DecoratorContinue(ret => GossipFrame.Instance.GossipOptionEntries == null, new Action(ret => _waitTimer.Reset()) ), new DecoratorContinue(ret => GossipFrame.Instance.GossipOptionEntries != null, new Sequence( new Action(ret => GossipFrame.Instance.SelectGossipOption(0)), new Action(ret => StyxWoW.SleepForLagDuration()) ))) )))), new Action(ret => _waitTimer.Reset()) ))); }
private Composite CreateBehavior_CombatMain() { return(new Decorator(context => !IsDone, new PrioritySelector( // Update information for this BT visit... new Action(context => { HighWarlordDarion = ObjectManager.GetObjectsOfType <WoWUnit>(false, false).FirstOrDefault(u => u.Entry == 29173); if ((HighWarlordDarion != null) && (Me.CurrentTarget != HighWarlordDarion)) { HighWarlordDarion.Target(); } return RunStatus.Failure; }), new Switch <StateType_Behavior>(context => State_Behavior, #region State: DEFAULT new Action(context => // default case { QBCLog.MaintenanceError("State_Behavior({0}) is unhandled", State_Behavior); TreeRoot.Stop(); _isBehaviorDone = true; }), #endregion #region State: Wait for Warlord new SwitchArgument <StateType_Behavior>(StateType_Behavior.WaitingForWarlordDarion, new PrioritySelector( // Move into position to await Warlord arrival... new Decorator(context => !Navigator.AtLocation(Location_WaitToChatWithDarion), new Action(context => { TreeRoot.StatusText = "Moving into position to wait on High Warlord Darion to arrive"; Navigator.MoveTo(Location_WaitToChatWithDarion); })), // Warlord has arrived, go have a chat.. new Decorator(context => HighWarlordDarion != null, new Action(context => { State_Behavior = StateType_Behavior.ChattingToStartBattle; })), // If warlord is not here, go check the battlefield... new Decorator(context => !IsBattlefieldCheckedForDarion, new Action(context => { State_Behavior = StateType_Behavior.CheckingBattlefieldForWarlordDarion; })), new Action(context => { TreeRoot.StatusText = "Waiting for High Warlord Darion to arrive"; AntiAfk(); }) )), #endregion #region State: Check Battlefield for Warlord new SwitchArgument <StateType_Behavior>(StateType_Behavior.CheckingBattlefieldForWarlordDarion, new PrioritySelector( // Move into position to await Warlord arrival... new Decorator(context => !Navigator.AtLocation(Location_WaitForBattleToComplete), new Action(context => { TreeRoot.StatusText = "Checking battlefield for High Warlord Darion"; Navigator.MoveTo(Location_WaitForBattleToComplete); })), // If we found Warlord on battlefield, wait for battle to complete... new Decorator(context => HighWarlordDarion != null, new Action(context => { State_Behavior = StateType_Behavior.WaitingForBattleToComplete; })), // If warlord is not here, return to start point and wait... new Decorator(context => HighWarlordDarion == null, new Action(context => { IsBattlefieldCheckedForDarion = true; State_Behavior = StateType_Behavior.WaitingForWarlordDarion; })) )), #endregion #region State: Chat with Warlord new SwitchArgument <StateType_Behavior>(StateType_Behavior.ChattingToStartBattle, new PrioritySelector( // If the Warlord disappeared, go find him... new Decorator(context => HighWarlordDarion == null, new Action(context => { IsBattlefieldCheckedForDarion = false; State_Behavior = StateType_Behavior.WaitingForWarlordDarion; })), // Move close enough to chat with Warlord... new Decorator(context => !HighWarlordDarion.WithinInteractRange, new Action(context => { TreeRoot.StatusText = "Moving to " + HighWarlordDarion.SafeName; Navigator.MoveTo(HighWarlordDarion.Location); })), // Chat with warlord... // When we interact with the warlord, he will present us with either: // 1) a Quest frame (with no gossip options) // 2) a Gossip frame (with gossip options) that we use to kick off the event // Both frames always *exist*, what matters is the one the Warlord presents us with. new Decorator(context => HighWarlordDarion.CanGossip, new PrioritySelector( new Decorator(context => !(GossipFrame.Instance.IsVisible || QuestFrame.Instance.IsVisible), new Action(context => { HighWarlordDarion.Interact(); })), // Process GossipFrame or QuestFrame, whichever was presented... new Sequence( // Simulate reading frame text... new WaitContinue(VariantTimeSpan(2500, 7000), context => false, new ActionAlwaysSucceed()), // If gossip frame showing, choose correct gossip option... new DecoratorContinue(context => GossipFrame.Instance.IsVisible && GossipFrame.Instance.GossipOptionEntries.Count() > 0, new Action(context => { GossipFrame.Instance.SelectGossipOption(0); })), new WaitContinue(VariantTimeSpan(1250, 3500), context => false, new ActionAlwaysSucceed()), // Close gossip frame if that was showing... new DecoratorContinue(context => GossipFrame.Instance.IsVisible, new Action(context => { GossipFrame.Instance.Close(); })), // Close quest frame if that was showing... new DecoratorContinue(context => QuestFrame.Instance.IsVisible, new Action(context => { QuestFrame.Instance.Close(); })), new Action(context => { State_Behavior = StateType_Behavior.WaitingForBattleToStart; }) ) )), // Warlord doesn't want to chat, wait for battle to start... new Decorator(context => !HighWarlordDarion.CanGossip, new Action(context => { State_Behavior = StateType_Behavior.WaitingForBattleToStart; })) )), #endregion #region State: Wait for Battle to start new SwitchArgument <StateType_Behavior>(StateType_Behavior.WaitingForBattleToStart, new PrioritySelector( // If warlord disappeared, start over... new Decorator(context => HighWarlordDarion == null, new Action(context => { State_Behavior = StateType_Behavior.WaitingForWarlordDarion; })), // If Warlord is already on the battlefield, time to go... new Decorator(context => HighWarlordDarion.Location.Distance(Location_Battlefield.Location) <= Location_Battlefield.Radius, new Action(context => { State_Behavior = StateType_Behavior.WaitingForBattleToComplete; })), // If the warlord is not on the battlefield, follow him at a reasonable distance... new Decorator(context => HighWarlordDarion.Distance > DistanceToFollowWarlord, new Action(context => { TreeRoot.StatusText = string.Format("Following {0}", HighWarlordDarion.SafeName); Navigator.MoveTo(HighWarlordDarion.Location); })), // Move into position to await battle start... new Decorator(context => !HighWarlordDarion.IsMoving && !Navigator.AtLocation(Location_WaitToChatWithDarion), new Action(context => { TreeRoot.StatusText = "Waiting for Battle to start"; Navigator.MoveTo(Location_WaitToChatWithDarion); })) )), #endregion #region State: Wait for Battle to complete new SwitchArgument <StateType_Behavior>(StateType_Behavior.WaitingForBattleToComplete, new PrioritySelector( // If warlord disappeared, start over... new Decorator(context => HighWarlordDarion == null, new Action(context => { State_Behavior = StateType_Behavior.WaitingForWarlordDarion; })), // If the warlord is on the battlefield, wait at our safespot... new Decorator(context => HighWarlordDarion.Location.Distance(Location_Battlefield.Location) <= Location_Battlefield.Radius, new PrioritySelector( // Move to our position to wait for battle to be over... new Decorator(context => !Navigator.AtLocation(Location_WaitForBattleToComplete), new Action(context => { TreeRoot.StatusText = "Moving to safe spot"; Navigator.MoveTo(Location_WaitForBattleToComplete); })), // Wait for battle to be over... new Action(context => { TreeRoot.StatusText = "Waiting for battle to complete."; AntiAfk(); }))), // If the warlord has returned to his starting position, then start over... new Decorator(context => HighWarlordDarion.Location.Distance(Location_WaitToChatWithDarion) <= DistanceToFollowWarlord, new Action(context => { State_Behavior = StateType_Behavior.WaitingForWarlordDarion; })) )) #endregion ) ))); }