public override void OnStart() { _timer = null; PlayerQuest quest = StyxWoW.Me.QuestLog.GetQuestById(QuestId); if (quest != null) { TreeRoot.GoalText = "UseItemOn - " + quest.Name; } else { TreeRoot.GoalText = "UseItemOn: Running"; } }
protected override Composite CreateBehavior() { return _root ?? (_root = new PrioritySelector( new Decorator(ret => (Counter > NumberOfTimes && QuestId == 0) || (me.QuestLog.GetQuestById(QuestId) != null && me.QuestLog.GetQuestById(QuestId).IsCompleted), new Sequence( new Action(ret => TreeRoot.StatusText = "Finished!"), new WaitContinue(120, new Action(delegate { _isDone = true; return RunStatus.Success; })) )), new Decorator(ret => _timer != null && !_timer.IsFinished, new Sequence( new Action(ret => TreeRoot.StatusText = "UseItemOn - WaitTimer: " + _timer.TimeLeft.Seconds + " Seconds Left"), new Action(delegate { return RunStatus.Success; }) ) ), new Decorator(ret => _timer != null && _timer.IsFinished, new Sequence( new Action(ret => _timer.Reset()), new Action(ret => _timer = null), new Action(delegate { return RunStatus.Success; }) ) ), new Decorator(c => npcList.Count == 0, new Action(c => { if (!me.IsIndoors && !me.Mounted && me.Level > 19) { TreeRoot.StatusText = "Mounting!"; Styx.Logic.Mount.MountUp(); } TreeRoot.StatusText = "Moving To Location - X: " + Location.X + " Y: " + Location.Y + " Z: " + Location.Z; Navigator.MoveTo(Location); }) ), new Decorator(c => npcList.Count > 0 && InCombatHPUse > 0, new Action(c => { if (npcList[0].Location.Distance(me.Location) <= Range && InCombatHPUse > 0 && !me.IsCasting) { if (npcList[0].HealthPercent > InCombatHPUse) { TreeRoot.StatusText = "Attacking Mob - Current Health %:" + npcList[0].HealthPercent + " Attacking Until: " + InCombatHPUse; WoWMovement.MoveStop(); if (me.CurrentTarget == npcList[0]) { npcList[0].Target(); npcList[0].Face(); Thread.Sleep(300); } SpellManager.Cast(RangeSpell); return RunStatus.Running; } else { TreeRoot.StatusText = "Using Item - " + wowItem.Name + " On Mob: " + npcList[0].Name; WoWMovement.MoveStop(); npcList[0].Target(); npcList[0].Face(); Thread.Sleep(300); wowItem.Interact(); Counter++; return RunStatus.Success; } } return RunStatus.Failure; })), new Decorator(c => npcList.Count > 0 && InCombatHPUse == 0, new Action(c => { if (npcList[0].Location.Distance(me.Location) < Range) { TreeRoot.StatusText = "Using Item - " + wowItem.Name + " On Mob: " + npcList[0].Name; WoWMovement.MoveStop(); Thread.Sleep(300); npcList[0].Target(); npcList[0].Face(); Thread.Sleep(300); wowItem.Interact(); Counter++; _timer = new Timer(new TimeSpan(0, 0, 0, 0, WaitTime)); _timer.Reset(); return RunStatus.Success; } else { TreeRoot.StatusText = "Moving To Mob - " + npcList[0].Name + " Yards Away: " + npcList[0].Location.Distance(me.Location); Navigator.MoveTo(npcList[0].Location); return RunStatus.Running; } })) )); }
protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( new Decorator(ret => (Counter > NumberOfTimes && QuestId == 0) || (me.QuestLog.GetQuestById(QuestId) != null && me.QuestLog.GetQuestById(QuestId).IsCompleted), new Sequence( new Action(ret => TreeRoot.StatusText = "Finished!"), new WaitContinue(120, new Action(delegate { _isDone = true; return RunStatus.Success; })) )), new Decorator(ret => _timer != null && !_timer.IsFinished, new Sequence( new Action(ret => TreeRoot.StatusText = "UseItemOn - WaitTimer: " + _timer.TimeLeft.Seconds + " Seconds Left"), new Action(delegate { return RunStatus.Success; }) ) ), new Decorator(ret => _timer != null && _timer.IsFinished, new Sequence( new Action(ret => _timer.Reset()), new Action(ret => _timer = null), new Action(delegate { return RunStatus.Success; }) ) ), new Decorator(c => npcList.Count == 0, new Action(c => { if (!me.IsIndoors && !me.Mounted && me.Level > 19) { TreeRoot.StatusText = "Mounting!"; Styx.Logic.Mount.MountUp(); } TreeRoot.StatusText = "Moving To Location - X: " + Location.X + " Y: " + Location.Y + " Z: " + Location.Z; Navigator.MoveTo(Location); }) ), new Decorator(c => npcList.Count > 0 && InCombatHPUse > 0, new Action(c => { if (npcList[0].Location.Distance(me.Location) <= Range && InCombatHPUse > 0 && !me.IsCasting) { if (npcList[0].HealthPercent > InCombatHPUse) { TreeRoot.StatusText = "Attacking Mob - Current Health %:" + npcList[0].HealthPercent + " Attacking Until: " + InCombatHPUse; WoWMovement.MoveStop(); if (me.CurrentTarget == npcList[0]) { npcList[0].Target(); npcList[0].Face(); Thread.Sleep(300); } SpellManager.Cast(RangeSpell); return RunStatus.Running; } else { TreeRoot.StatusText = "Using Item - " + wowItem.Name + " On Mob: " + npcList[0].Name; WoWMovement.MoveStop(); npcList[0].Target(); npcList[0].Face(); Thread.Sleep(300); wowItem.Interact(); Counter++; return RunStatus.Success; } } return RunStatus.Failure; })), new Decorator(c => npcList.Count > 0 && InCombatHPUse == 0, new Action(c => { if (npcList[0].Location.Distance(me.Location) < Range) { TreeRoot.StatusText = "Using Item - " + wowItem.Name + " On Mob: " + npcList[0].Name; WoWMovement.MoveStop(); Thread.Sleep(300); npcList[0].Target(); npcList[0].Face(); Thread.Sleep(300); wowItem.Interact(); Counter++; _timer = new Timer(new TimeSpan(0, 0, 0, 0, WaitTime)); _timer.Reset(); return RunStatus.Success; } else { TreeRoot.StatusText = "Moving To Mob - " + npcList[0].Name + " Yards Away: " + npcList[0].Location.Distance(me.Location); Navigator.MoveTo(npcList[0].Location); return RunStatus.Running; } })) ))); }