private async Task <bool> TypeOneVehicleBehavior() { if (!Query.IsInVehicle()) { return(false); } while (Me.IsAlive) { var target = NpcList.FirstOrDefault(); var vehicle = VehicleList.FirstOrDefault(); if (target == null || vehicle != null && target.Location.Distance(vehicle.Location) > 15) { TreeRoot.StatusText = "Waiting for Mob to Come Into Range or Appear."; await Coroutine.Yield(); continue; } if (vehicle != null && target.Location.Distance(vehicle.Location) <= 15) { TreeRoot.StatusText = "Attacking: " + target.SafeName + ", AttackButton: " + AttackButton; if (Me.CurrentTargetGuid != target.Guid) { target.Target(); } Lua.DoString("CastPetAction({0})", AttackButton); await Coroutine.Sleep(WaitTime); Counter++; return(true); } await Coroutine.Yield(); } return(false); }
private async Task <bool> TypeTwoVehicleBehavior() { if (!Query.IsInVehicle()) { return(false); } while (Me.IsAlive) { if (Counter > NumOfTimes && QuestId == 0 || Me.IsQuestComplete(QuestId)) { Lua.DoString("VehicleExit()"); _isBehaviorDone = true; return(true); } var target = NpcList.FirstOrDefault(); if (target != null) { await Coroutine.Sleep(OftenToUse); TreeRoot.StatusText = "Attacking: " + target.SafeName + ", AttackButton: " + AttackButton + ", Times Used: " + Counter; target.Target(); Lua.DoString("CastPetAction({0})", AttackButton); SpellManager.ClickRemoteLocation(target.Location); await Coroutine.Sleep(WaitTime); Counter++; } await Coroutine.Yield(); } return(false); }
protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( new Decorator(c => (Counter > NumOfTimes) || Me.IsQuestComplete(QuestId), new Action(c => { TreeRoot.StatusText = "Finished!"; if (GoHomeButton > 0) { Lua.DoString("CastPetAction({0})", GoHomeButton); } _isBehaviorDone = true; return RunStatus.Success; }) ), // Enable combat while not in a vehicle new Decorator(ctx => (LevelBot.BehaviorFlags & BehaviorFlags.Combat) == 0 && !Query.IsInVehicle(), new Action(ctx => LevelBot.BehaviorFlags |= BehaviorFlags.Combat)), // Disable combat while in a vehicle new Decorator(ctx => (LevelBot.BehaviorFlags & BehaviorFlags.Combat) != 0 && Query.IsInVehicle(), new Action(ctx => LevelBot.BehaviorFlags &= ~BehaviorFlags.Combat)), new Decorator(c => NpcVehicleList.Any() && !Query.IsInVehicle(), new Action(c => { if (!NpcVehicleList[0].WithinInteractRange) { Navigator.MoveTo(NpcVehicleList[0].Location); TreeRoot.StatusText = "Moving To Vehicle - " + NpcVehicleList[0].SafeName + " Yards Away: " + NpcVehicleList[0].Location.Distance(Me.Location); } else { NpcVehicleList[0].Interact(); MountedPoint = Me.Location; } }) ), new Decorator(c => SpellType == 1, new ActionRunCoroutine(ctx => TypeOneVehicleBehavior())), new Decorator(c => SpellType == 2, new ActionRunCoroutine(ctx => TypeTwoVehicleBehavior())), new Decorator(c => Query.IsInVehicle() && SpellType == 3, new PrioritySelector( ret => NpcList.OrderBy(u => u.DistanceSqr).FirstOrDefault(u => Me.Transport.IsSafelyFacing(u)), new Decorator( ret => ret != null, new PrioritySelector( new Decorator( ret => Me.CurrentTarget == null || Me.CurrentTarget != (WoWUnit)ret, new Action(ret => ((WoWUnit)ret).Target())), new Decorator( ret => !Me.Transport.IsSafelyFacing(((WoWUnit)ret), 10), new Action(ret => Me.CurrentTarget.Face())), new Sequence( new Action( ctx => { Vector3 v = Vector3.Normalize(Me.CurrentTarget.Location - StyxWoW.Me.Location); Lua.DoString( string.Format( "local pitch = {0}; local delta = pitch - VehicleAimGetAngle(); VehicleAimIncrement(delta); CastPetAction({1});", Math.Asin(v.Z).ToString(CultureInfo.InvariantCulture), AttackButton)); }), new Sleep(WaitTime), new Action(ctx => Counter++)))))), new Decorator(c => SpellType == 4, new Action(c => { if (!Query.IsInVehicle()) { return RunStatus.Failure; } if (Counter > NumOfTimes && QuestId == 0 || Me.IsQuestComplete(QuestId)) { Lua.DoString("VehicleExit()"); _isBehaviorDone = true; return RunStatus.Success; } var target = NpcList.FirstOrDefault(); if (target != null) { if (Me.CurrentTargetGuid != target.Guid) { target.Target(); } WoWMovement.ClickToMove(target.Location); Lua.DoString("CastPetAction({0})", AttackButton); SpellManager.ClickRemoteLocation(target.Location); Counter++; } return RunStatus.Running; })), new Decorator(c => SpellType == 5, new Action(c => { if (!Query.IsInVehicle()) { return RunStatus.Failure; } if (Counter > NumOfTimes && QuestId == 0 || Me.IsQuestComplete(QuestId)) { Lua.DoString("VehicleExit()"); _isBehaviorDone = true; return RunStatus.Success; } var target = NpcList.FirstOrDefault(); if (target != null) { if (Me.CurrentTargetGuid != target.Guid) { target.Target(); } WoWMovement.ConstantFace(Me.CurrentTargetGuid); Lua.DoString("CastPetAction({0})", AttackButton); if (QuestId == 0) { Counter++; } } var target2 = NpcListSecondary.FirstOrDefault(); if (target2 != null) { if (Me.CurrentTargetGuid != target2.Guid) { target2.Target(); } WoWMovement.ConstantFace(Me.CurrentTargetGuid); Lua.DoString("CastPetAction({0})", AttackButton); if (QuestId == 0) { Counter++; } } Lua.DoString("CastPetAction({0})", AttackButton2); return RunStatus.Running; })) ))); }