protected override Composite CreateBehavior() { return (new PrioritySelector( new Decorator(ret => !_isInitialized, new Action(ret => ParsePaths())), // Go home. new Decorator(ret => Quest != null && Quest.IsCompleted || _remountTimer.Elapsed.TotalMinutes >= 14, new PrioritySelector( new Decorator(ret => ObjectManager.GetObjectsOfType <WoWUnit>().FirstOrDefault(r => r.Entry == 29107 && Vehicle.Location.Distance(r.Location) <= 10) != null, new Sequence( new Action(ret => Lua.DoString("VehicleExit()")), new Action(ret => _isBehaviorDone = Quest.IsCompleted), new Action(ret => _remountTimer.Reset()) )), new Decorator(ret => Vehicle == null, new Sequence(ret => Me.CarriedItems.FirstOrDefault(i => i.Entry == ItemId), new DecoratorContinue(ret => ret == null, new Sequence( new Action(ret => LogMessage("fatal", "Unable to find ItemId({0}) in inventory.", ItemId)) )), new WaitContinue(60, ret => ((WoWItem)ret).Cooldown == 0, // Use the item new Sequence( new Action(ret => ((WoWItem)ret).UseContainerItem()), new Action(ret => ParsePaths())) ), // Wait until we are in the vehicle new WaitContinue(5, ret => Vehicle != null, new Sequence( new Action(ret => _remountTimer.Reset()), new Action(ret => _remountTimer.Start()), new Action(ret => WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend, TimeSpan.FromMilliseconds(500))) ) ))), new Decorator(ret => EndPath.Peek().Distance(Vehicle.Location) <= 6, new Action(ret => EndPath.Dequeue())), new Sequence( new Action(ret => TreeRoot.StatusText = "Flying back to turn in the quest"), new Action(ret => WoWMovement.ClickToMove(EndPath.Peek()))) )), new Decorator(ret => Vehicle == null, new Sequence(ret => Me.CarriedItems.FirstOrDefault(i => i.Entry == ItemId), new DecoratorContinue(ret => ret == null, new Sequence( new Action(ret => LogMessage("fatal", "Unable to locate ItemId({0}) in inventory.", ItemId)) )), new WaitContinue(60, ret => ((WoWItem)ret).Cooldown == 0, // Use the item new Sequence( new Action(ret => ParsePaths()), new Action(ret => ((WoWItem)ret).UseContainerItem())) ), // Wait until we are in the vehicle new WaitContinue(5, ret => Vehicle != null, new Sequence( new Action(ret => _remountTimer.Reset()), new Action(ret => _remountTimer.Start()), new Action(ret => WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend, TimeSpan.FromMilliseconds(500))) ) ))), new Decorator(ret => Vehicle != null, new PrioritySelector( new Decorator(ret => !_remountTimer.IsRunning, new Action(ret => _remountTimer.Start())), new Decorator( ret => StartPoint != WoWPoint.Empty, new PrioritySelector( new Decorator( ret => Vehicle.Location.Distance2D(StartPoint) < 15, new Sequence( new Action(ret => TreeRoot.StatusText = "Pathing through"), new Action(ret => StartPoint = WoWPoint.Empty))), new Sequence( new Action(ret => TreeRoot.StatusText = "Moving towards start point"), new Action(ret => Navigator.PlayerMover.MoveTowards(StartPoint))))), new Decorator(ret => Path.Peek().Distance2DSqr(Vehicle.Location) <= 30 * 30, new Action(ret => Path.Dequeue())), new Decorator(ret => (Vehicle.HealthPercent <= 70 || Vehicle.ManaPercent <= 35) && HealNpcs != null && HealSpell != null && !HealSpell.Spell.Cooldown, new PrioritySelector( ret => HealNpcs.Where(n => Vehicle.IsSafelyFacing(n)).OrderBy(n => n.DistanceSqr).FirstOrDefault(), new Decorator( ret => ret != null && ((WoWUnit)ret).InLineOfSight, new PrioritySelector( new Decorator( ret => ((WoWUnit)ret).Location.Distance(Vehicle.Location) > 15, new Action(ret => WoWMovement.ClickToMove(((WoWUnit)ret).Location.Add(0, 0, 10)))), new Action(ret => { WoWMovement.MoveStop(); CastPetAction(HealSpell); }))))), new Sequence( ret => KillNpcs.Where(n => n.Distance2DSqr > 20 * 20 && Vehicle.IsSafelyFacing(n)).OrderBy(n => n.DistanceSqr).FirstOrDefault(), new DecoratorContinue( ret => ret != null && ((WoWUnit)ret).InLineOfSight && AttackSpell != null && !AttackSpell.Spell.Cooldown && !StyxWoW.GlobalCooldown, new Sequence( new Action(ret => { Vector3 v = ((WoWUnit)ret).Location - StyxWoW.Me.Location; v.Normalize(); Lua.DoString(string.Format( "local pitch = {0}; local delta = pitch - VehicleAimGetAngle() + 0.1; VehicleAimIncrement(delta);", Math.Asin(v.Z).ToString(CultureInfo.InvariantCulture))); }), new Action(ret => CastPetAction(AttackSpell)), new Action(ret => StyxWoW.SleepForLagDuration()))), new Action(ret => StyxWoW.SleepForLagDuration()), new Action(ret => WoWMovement.ClickToMove(Path.Peek())) ) )))); }
public void OnEndPath() { EndPath?.Invoke(); }