private async Task <bool> PomfruitFlyTo() { if (Me.IsQuestObjectiveComplete(QuestId, 1)) { return(false); } var fruit = Pomfruit.FirstOrDefault(); if (fruit == null) { return(false); } if (fruit.Location.Distance(Me.Location) > 10) { TreeRoot.StatusText = "Moving to Silkfeather Hawk"; WoWMovement.ClickToMove(fruit.Location); fruit.Target(); fruit.Face(); await Coroutine.Sleep(3000); await CommonCoroutines.StopMoving(); SpellManager.Cast(SpellId); await Coroutine.Sleep(3000); } TreeRoot.StatusText = "Finished Pulling!"; _isBehaviorDone = true; return(true); }
public static async Task <bool> FaceTarget(WoWUnit target) { if (target == null || Me.IsSafelyFacing(target) || !target.IsValidCombatUnit() || HK.RotationOnlyOn || !GeneralSettings.Instance.GeneralFacing) { return(false); } if (!lastTimeFaced.IsRunning || (target.Guid == lastUnitGuid && lastTimeFaced.ElapsedMilliseconds > 500)) { L.infoLog("Not facing target; will attempt to", InfoColor); } target.Face(); lastUnitGuid = target.Guid; if (Me.IsWithinMeleeRangeOf(target) && Me.IsMoving && GeneralSettings.Instance.GeneralMovement && !Managers.Hotkeys.RotationOnlyOn) { return(await CommonCoroutines.StopMoving()); } if (!lastTimeFaced.IsRunning) { lastTimeFaced.Start(); } else { lastTimeFaced.Restart(); } await Coroutine.Yield(); return(true); }
private static async Task <bool> Looting() { if (StyxWoW.Me.IsMoving && await CommonCoroutines.StopMoving()) { await CommonCoroutines.SleepForLagDuration(); } if (TargetManager.LootableObject.IsValid) { bool success = await CommonCoroutines.WaitForLuaEvent( "LOOT_CLOSED", 4200, null, TargetManager.LootableObject.Interact); if (TargetManager.LootableObject.InteractionAttempts > 1) { GarrisonBase.Debug("LootObject interaction attempts has excedeed max! Ignoring {0}", TargetManager.LootableObject.Name); IgnoreLootableObject(); ResetLoot(); return(false); } if (success) { await CheckLootFrame(); IgnoreLootableObject(); ResetLoot(); } } return(true); }
public static async Task <bool> EnsureMeleeRange(WoWUnit target) { if (target == null || Me.IsWithinMeleeRangeOf(target) || !target.IsValidCombatUnit() || Me.IsCasting || Me.IsChanneling || HK.RotationOnlyOn || !GeneralSettings.Instance.GeneralMovement) { return(false); } L.infoLog("Getting in melee range", InfoColor); if (Me.IsWithinMeleeRangeOf(target)) { return(await CommonCoroutines.StopMoving()); } if (!Me.IsWithinMeleeRangeOf(target)) { if (await Spell.Cast(Spell_Book.Glide, CombatColor, ShouldGlideForVengefulRetreat, "May have jumped too far back. Gliding back in.")) { fallingTimeout.Reset(); return(true); } await CommonCoroutines.MoveTo(target.RelativeLocation, target.SafeName); } return(true); }
private static async Task <bool> HandleDismount() { Navigator.Clear(); Flightor.Clear(); while (Me.Mounted) { if (Me.Location.Distance(s_targetLocation) > 5) { await Coroutine.Wait(20000, () => Flightor.MoveTo(s_targetLocation) == MoveResult.ReachedDestination); } else { await CommonCoroutines.LandAndDismount(null, true, s_targetLocation); await CommonCoroutines.StopMoving(); var _target = Me.CurrentTarget; if (_target != null) { Lua.DoString("StartAttack()"); } } //await Coroutine.Yield(); } return(true); }
private static async Task <bool> VendorInteraction(C_WoWObject vendor, List <C_WoWItem> items) { TreeRoot.StatusText = "Vendor Interaction Behavior"; if (GossipHelper.IsOpen) { await Coroutine.Yield(); if (GossipHelper.GossipOptions.All(o => o.Type != GossipEntry.GossipEntryType.Vendor)) { //Could not find Vendor Option! GarrisonBase.Debug("Vendor Gossip Has No Option for Vendoring!"); return(false); } var gossipEntryVendor = GossipHelper.GossipOptions.FirstOrDefault(o => o.Type == GossipEntry.GossipEntryType.Vendor); QuestManager.GossipFrame.SelectGossipOption(gossipEntryVendor.Index); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } if (MerchantHelper.IsOpen) { if (items.Count > 0) { foreach (var item in items) { GarrisonBase.Debug("Vendoring Item {0} ({1}) Quality {2}", item.Name, item.Entry, item.Quality); MerchantFrame.Instance.SellItem(item.ref_WoWItem); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); if (!MerchantHelper.IsOpen) { break; } } return(true); } //No vendor items found.. return(false); } if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } await CommonCoroutines.SleepForLagDuration(); vendor.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); }
/// <summary> /// (Non-Blocking) Stop the player from moving. /// </summary> /// <returns>Returns true if we are able to stop moving.</returns> public static async Task MoveStop(Func <bool> conditionCheck = null) { if (conditionCheck != null && !conditionCheck()) { return; } await CommonCoroutines.StopMoving(); }
private async Task <bool> MainCoroutine() { if (IsDone) { return(false); } if (TookPortal) { if (Me.IsMoving) { await CommonCoroutines.StopMoving(); } await Coroutine.Sleep(_postZoningDelay); BehaviorDone("Zoned into portal"); return(true); } if (Navigator.AtLocation(StartingPoint) && await WaitToRetry()) { return(true); } // Move to portal starting position... if (!Navigator.AtLocation(StartingPoint)) { if (!await UtilityCoroutine.MoveTo(StartingPoint, "Portal", MovementBy)) { QBCLog.Fatal("Unable to Navigate to StartingPoint"); } return(true); } if (await EnterPortal()) { return(true); } // Zoning failed, do we have any retries left? _retryCount += 1; if (_retryCount > MaxRetryCount) { var message = string.Format("Unable to go through portal in {0} attempts.", MaxRetryCount); // NB: Posting a 'fatal' message will stop the bot--which is what we want. QBCLog.Fatal(message); BehaviorDone(message); return(true); } RetryDelayTimer = new Stopwatch(); return(true); }
protected override Composite CreateMainBehavior() { return(new PrioritySelector( // If we don't have a selected target, find one... new Decorator(context => !IsMobQualified(SelectedTarget), new PrioritySelector( new ActionFail(context => { SelectedTarget = FindQualifiedMob(); }), // No qualifed mobs in immediate vicinity... new Decorator(context => !IsMobQualified(SelectedTarget), new PrioritySelector( new Decorator(context => Me.GotTarget, new Action(context => { Me.ClearTarget(); })), // NB: if the terminateBehaviorIfNoTargetsProvider argument evaluates to 'true', calling // this sub-behavior will terminate the overall behavior. new ActionRunCoroutine(context => _noMobsAtCurrentWaypoint ?? (_noMobsAtCurrentWaypoint = new UtilityCoroutine.NoMobsAtCurrentWaypoint( () => HuntingGrounds, () => MovementBy, null, () => { if (!WaitForNpcs) { BehaviorDone("Terminating--\"WaitForNpcs\" is false."); } }, () => TargetExclusionAnalysis.Analyze( Element, () => Query.FindMobsAndFactions(MobIds), TargetExclusionChecks)))))) )), // If qualified mob was found, move within range, if needed... // NB: A mob can lose its 'qualified' status for several reasons. For instance, // another player moves close to or tags the mob while we're on our way to it. new Decorator(context => IsMobQualified(SelectedTarget), new PrioritySelector( new ActionFail(context => { Utility.Target(SelectedTarget); }), new Decorator(context => IsDistanceCloseNeeded(SelectedTarget), new ActionRunCoroutine( context => UtilityCoroutine.MoveTo( SelectedTarget.Location, SelectedTarget.SafeName, MovementBy))), new ActionRunCoroutine(context => CommonCoroutines.StopMoving()), new Action(context => { Utility.Target(SelectedTarget, true); BehaviorDone(); }) )) )); }
/// <summary> /// A Queue for npc's we need to talk to /// </summary> //private WoWUnit CurrentUnit { get { return ObjectManager.GetObjectsOfType<WoWUnit>().FirstOrDefault(unit => unit.Entry == VehicleId); } } protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( new Decorator(ret => (QuestId != 0 && Me.QuestLog.GetQuestById((uint)QuestId) != null && Me.QuestLog.GetQuestById((uint)QuestId).IsCompleted), new Action(ret => _isBehaviorDone = true)), // 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(ret => Counter >= 1, new Action(ret => _isBehaviorDone = true)), new PrioritySelector( new Decorator(ret => IsMounted != true && _vehicleList == null, new ActionRunCoroutine(ctx => MoveToMountLocation()) ), new Decorator(ret => _vehicleList[0] != null && !_vehicleList[0].WithinInteractRange && IsMounted != true, new Action(ret => Navigator.MoveTo(_vehicleList[0].Location)) ), new Decorator(ret => StyxWoW.Me.IsMoving, new ActionRunCoroutine(ctx => CommonCoroutines.StopMoving())), new Decorator(ret => IsMounted != true, new Sequence( new Action(ctx => MountedPoint = Me.Location), new Action(ctx => _vehicleList[0].Interact()), new SleepForLagDuration(), new Action(ctx => IsMounted = true), new Action(ctx => _vehicleList = ObjectManager.GetObjectsOfType <WoWUnit>() .Where(ret => (ret.Entry == VehicleId) && !ret.IsDead).OrderBy(ret => ret.Location.Distance(MountedPoint)).ToList()), new Sleep(3000)) ), new Decorator(ret => IsMounted = true, new ActionRunCoroutine(ctx => MoveToDestination()) ), new Action(ret => QBCLog.DeveloperInfo(string.Empty)) ) ))); }
protected async Task <bool> MainCoroutine() { if (IsDone) { return(false); } if (!StyxWoW.Me.HasAura(AuraId_MechasharkXSteam)) { var controler = Controller; if (controler == null) { QBCLog.Fatal("Controler could not be found in ObjectManager"); return(true); } if (!controler.WithinInteractRange) { return((await CommonCoroutines.MoveTo(controler.Location)).IsSuccessful()); } if (await CommonCoroutines.StopMoving()) { return(true); } controler.Interact(); await Coroutine.Sleep(5000); return(true); } var hammer = Hammer; if (hammer == null) { QBCLog.Fatal("Hammer could not be found in ObjectManager"); return(true); } if (hammer.IsAlive && StyxWoW.Me.CurrentTarget != hammer) { await DoQuest(hammer); return(true); } if (StyxWoW.Me.QuestLog.GetQuestById(24817).IsCompleted) { Lua.DoString("VehicleExit()"); _isBehaviorDone = true; return(true); } return(false); }
protected override Composite CreateBehavior() { return _root ?? (_root = new PrioritySelector( new Decorator(ret => Counter >= 1, new Action(ret => _isBehaviorDone = true)), new PrioritySelector( new Decorator(ret => Counter > 0, new Sequence( new Action(ret => TreeRoot.StatusText = "Finished!"), new Action(ret => _isBehaviorDone = true), new WaitContinue(1, new Action(delegate { _isBehaviorDone = true; return RunStatus.Success; })) ) ), new Decorator(ret => MobList.Count > 0 && !MobList[0].WithinInteractRange, new Action(ret => Navigator.MoveTo(MobList[0].Location))), new Decorator(ret => MobList.Count > 0 && MobList[0].WithinInteractRange, new Sequence( new DecoratorContinue(ret => StyxWoW.Me.IsMoving, new ActionRunCoroutine(ctx => CommonCoroutines.StopMoving())), new Action(ret => TreeRoot.StatusText = "Opening Trainer - " + MobList[0].SafeName + " X: " + MobList[0].X + " Y: " + MobList[0].Y + " Z: " + MobList[0].Z), new Action(ret => MobList[0].Interact()), new WaitContinue(5, ret => TrainerFrame.Instance.IsVisible, new Action(ret => TrainerFrame.Instance.BuyAll())), new Action(ret => TrainerFrame.Instance.Close()), new Action(ret => Counter++) ) ), new Decorator(ret => RidingTrainer != null, new Action(ret => Navigator.MoveTo(RidingTrainer.Location)) ), new Action(ret => Counter++) ))); }
private async Task <bool> MoveFromEKToSilvermoonCityHorde() { var portal = ObjectManager.GetObjectsOfType <WoWGameObject>() .FirstOrDefault(g => g.Entry == GameObjectId_OrbOfTranslocation); if (portal == null || !portal.WithinInteractRange) { return(await(UtilityCoroutine.MoveTo(portal?.Location ?? _silvermoonCityPortalLoc, "Silvermoon City portal"))); } await CommonCoroutines.StopMoving(); portal.Interact(); await Coroutine.Sleep(3000); return(true); }
private async Task OpenMailbox() { WoWPoint movetoPoint = _loc; WoWGameObject mailbox; if (AutoFindMailBox || movetoPoint == WoWPoint.Zero) { mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox && o.CanUse()) .OrderBy(o => o.DistanceSqr).FirstOrDefault(); } else { mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox && o.Location.Distance(_loc) < 10 && o.CanUse()) .OrderBy(o => o.DistanceSqr).FirstOrDefault(); } if (mailbox != null) { movetoPoint = mailbox.Location; } if (movetoPoint == WoWPoint.Zero) { PBLog.Warn(Strings["Error_UnableToFindMailbox"]); return; } if (mailbox == null || !mailbox.WithinInteractRange) { await CommonCoroutines.MoveTo(movetoPoint); return; } if (Me.IsMoving) { await CommonCoroutines.StopMoving(); } mailbox.Interact(); }
public async Task <bool> Execute() { if (!IsSpecificExecutionNeeded()) { return(false); } if (IsMovementStopRequired && Me.IsMoving) { await CommonCoroutines.StopMoving(); } var activityResult = await ExecuteSpecificActivity(); if (activityResult == ActivityResult.Indeterminate) { return(ShouldBreakWhenIndeterminate); } if (activityResult == ActivityResult.Failed) { return(false); } // If we get here, we got a ActivityResult.Succeeded UseWhenPredicate.Reset(); // If predicate did not clear, then predicate is bad... // We allow for a server round-trip time to allow enough time for a potential // aura to be applied. await CommonCoroutines.SleepForLagDuration(); if (UseWhenPredicate.IsReady()) { QBCLog.Error( "For DoWhenActivity {1}, predicate ({2}) was not reset by execution.{0}" + " This is a profile problem, and can result in erratic Honorbuddy behavior.{0}" + " The predicate must return to 'false' after the action has been successfully executed.", Environment.NewLine, ActivityIdentifier, UseWhenPredicate.ExpressionAsString); } return(true); }
public async Task <bool> PhaseOneLogic() { if (Me.RelativeLocation == _phase2RelativePos) { return(false); } WoWGameObject rifle = Rifle; if (!rifle.WithinInteractRange) { return((await CommonCoroutines.MoveTo(rifle.Location)).IsSuccessful()); } await CommonCoroutines.StopMoving(); rifle.Interact(); await CommonCoroutines.SleepForRandomReactionTime(); return(true); }
private static async Task <bool> MailboxInteraction(C_WoWObject mailbox, Dictionary <string, List <C_WoWItem> > items) { if (MailHelper.IsOpen) { //Click Send Mail Tab if (!LuaCommands.IsSendMailFrameVisible()) { LuaCommands.ClickSendMailTab(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } foreach (var keypair in items) { GarrisonBase.Log("Found {0} items to mail", keypair.Value.Count); bool success = await SendMail(keypair.Key, keypair.Value); if (!success) { GarrisonBase.Debug("Sending Mail Failed!"); return(false); } await Coroutine.Yield(); return(true); } } if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } await CommonCoroutines.SleepForLagDuration(); mailbox.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); }
private async Task <bool> Coroutine_CombatMain() { if (IsDone) { return(false); } if (!Query.IsInVehicle()) { // only move to vehicle if doing nothing else if (!Targeting.Instance.IsEmpty() || BotPoi.Current.Type != PoiType.None) { return(false); } WoWUnit amber = Amber; // Wait for Amber to load in the ObjectMananger. if (amber == null || !amber.WithinInteractRange) { var moveTo = amber != null ? amber.Location : _vehicleLoc; await UtilityCoroutine.MoveTo(moveTo, "Moving to Start Amber(Human) Story", MovementBy); return(true); } if (await CommonCoroutines.StopMoving()) { return(true); } if (!GossipFrame.Instance.IsVisible) { amber.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } if (GossipFrame.Instance.GossipOptionEntries != null) { GossipFrame.Instance.SelectGossipOption(0); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } return(true); } if (await InteractWithUnit(HozenEnemy)) { return(true); } if (await InteractWithUnit(OrcEnemy)) { return(true); } if (!Me.HasAura("See Quest Invis 5")) { var turret = Turret; if (TurretLocation.DistanceSqr(Me.Location) > 3 * 3) { await UtilityCoroutine.MoveTo(TurretLocation, "Turret Location", MovementBy); return(true); } if (turret == null) { TreeRoot.StatusText = "Waiting for turret to spawn"; return(true); } if (!turret.WithinInteractRange) { await UtilityCoroutine.MoveTo(TurretLocation, "interact range of turret", MovementBy); return(true); } if (await CommonCoroutines.StopMoving()) { return(true); } QBCLog.Info("Using turret"); Turret.Interact(); return(true); } return(false); }
private async Task <bool> TrainMount() { if (!TrainInOutland && !TrainInOldWorld) { return(false); } var trainerId = GetTrainerId(); if (trainerId == 0) { return(false); } var trainer = ObjectManager.GetObjectsOfType <WoWUnit>() .Where(u => u.Entry == trainerId && !u.IsDead) .OrderBy(u => u.DistanceSqr).FirstOrDefault(); WoWPoint trainerLoc; string trainerName; if (trainer == null) { var traderEntry = Styx.CommonBot.ObjectDatabase.Query.GetNpcById((uint)trainerId); if (traderEntry == null) { return(false); } trainerLoc = traderEntry.Location; trainerName = traderEntry.Name; } else { trainerLoc = trainer.Location; trainerName = trainer.SafeName; } if (trainer == null || !trainer.WithinInteractRange) { return(await UtilityCoroutine.MoveTo(trainerLoc, "Riding Trainer: " + trainerName)); } if (await CommonCoroutines.StopMoving()) { return(true); } // Turnin any quests since they can interfer with training. if (trainer.HasQuestTurnin()) { return(await UtilityCoroutine.TurninQuest(trainer, trainer.Location)); } if (!TrainerFrame.Instance.IsVisible) { trainer.Interact(); await CommonCoroutines.SleepForLagDuration(); return(true); } TrainerFrame.Instance.BuyAll(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); }
public override async Task <bool> BehaviorRoutine() { if (await base.BehaviorRoutine()) { return(true); } if (IsDone) { return(false); } if (GossipHelper.IsOpen) { if (GossipHelper.GossipOptions.Count == 0) { _failedToFindGossipEntries++; if (_failedToFindGossipEntries > 3) { GarrisonBase.Err("Could not find any valid gossip entries!"); GossipFrame.Instance.Close(); IsDone = true; return(false); } await Coroutine.Yield(); return(true); } GossipHelper.GossipOptionEntry gossipEntry = null; if (_gossipIndex > -1) { gossipEntry = GossipHelper.GossipOptions[_gossipIndex]; } else if (!string.IsNullOrEmpty(_gossipText)) { gossipEntry = GossipHelper.GossipOptions.FirstOrDefault(g => g.Text.ToLower().Contains(_gossipText)); } if (gossipEntry == null) { GarrisonBase.Err("Could not find any valid gossip entries index [{0}] text [{1}]", _gossipIndex, _gossipText); GossipFrame.Instance.Close(); IsDone = true; return(false); } GarrisonBase.Debug("Selecting Gossip Option {0}", gossipEntry.Index); var success = await CommonCoroutines.WaitForLuaEvent("GOSSIP_SHOW", 2500, null, () => GossipFrame.Instance.SelectGossipOption(gossipEntry.Index)); GarrisonBase.Debug("Gossip Selection success = {0}", success); await CommonCoroutines.SleepForRandomUiInteractionTime(); if (!success) { return(false); } if (_oneTime) { IsDone = true; } return(!_oneTime); } C_WoWObject validobj = NpcObject != null ? NpcObject: InteractionObject != null?InteractionObject:null; if (validobj == null || !validobj.IsValid) { GarrisonBase.Err("Could not find object {0} to interact with!", _npcId); IsDone = true; return(false); } if (_npcMovement == null) { _npcMovement = new Movement(validobj.Location, _interactDistance, name: "GossipInteract"); } if (await _npcMovement.MoveTo(false)) { return(true); } if (validobj.CheckDistance(_interactDistance)) { if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } await CommonCoroutines.SleepForLagDuration(); if (GossipHelper.IsOpen) { //frame is displayed! return(true); } validobj.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } return(true); }
private async Task <bool> MoveToEnd(bool exitVehicle, WoWUnit passenger = null) { if (!Query.IsInVehicle()) { return(false); } if (Vehicle.Location.DistanceSquared(EndLocation) >= PrecisionSqr) { await UseSpeedBuff(); Flightor.MoveTo(EndLocation); return(true); } if (exitVehicle) { Lua.DoString("VehicleExit()"); await Coroutine.Sleep(2000); await Coroutine.Wait(20000, () => !Me.IsFalling); if (Me.Combat) { QBCLog.Info("Getting in vehicle to drop combat"); return(await GetInVehicleLogic()); } return(true); } if (!Query.IsViable(passenger)) { return(false); } if (Vehicle.IsMoving) { await CommonCoroutines.StopMoving("Dropping off passenger."); await CommonCoroutines.SleepForLagDuration(); } await Coroutine.Sleep(StyxWoW.Random.Next(5000, 6000)); UseVehicleButton(DropPassengerButton); await CommonCoroutines.SleepForLagDuration(); if (!await Coroutine.Wait(10000, () => !Query.IsViable(passenger) || !UnitIsRidingMyVehicle(passenger))) { QBCLog.Warning("Failed to drop passenger off"); return(false); } if (Query.IsViable(passenger)) { Blacklist.Add(passenger, BlacklistFlags.Interact, TimeSpan.FromMinutes(10), "Rescued"); } // pause a sec to see if quest completes. if (await Coroutine.Wait(2000, () => Quest.IsCompleted)) { return(true); } CycleToNearestPointInPath(); return(true); }
private async Task <bool> Interaction() { if (Building.CheckedWorkOrderPickUp) { return(false); } if (WorkOrderObject == null || !WorkOrderObject.IsValid) { //Error Cannot find object! GarrisonBase.Debug("Workorder Pickup object null!"); Building.CheckedWorkOrderPickUp = true; await Coroutine.Sleep(StyxWoW.Random.Next(755, 1449)); await Coroutine.Yield(); Building.WorkOrder.Refresh(); //if (_specialMovement != null) _specialMovement.UseDeqeuedPoints(true); return(false); } if (WorkOrderObject.WithinInteractRange) { if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } if (BaseSettings.CurrentSettings.DEBUG_FAKEPICKUPWORKORDER) { Building.CheckedWorkOrderPickUp = true; //if (_specialMovement != null) _specialMovement.UseDeqeuedPoints(true); return(false); } if (WorkOrderObject.GetCursor == WoWCursorType.PointCursor) { //Nothing to pickup! GarrisonBase.Debug("Workorder Pickup Object Non-loot Cursor!"); Building.CheckedWorkOrderPickUp = true; await Coroutine.Sleep(StyxWoW.Random.Next(755, 1449)); await Coroutine.Yield(); //Building.WorkOrder.Refresh(); Building.WorkOrder.Pending -= Building.WorkOrder.Pickup; Building.WorkOrder.Pickup = 0; //if (_specialMovement != null) _specialMovement.UseDeqeuedPoints(true); return(false); } WorkOrderObject.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Yield(); if (StyxWoW.LastRedErrorMessage.Contains("Inventory is full.")) { GarrisonBase.Log("Stopping Work Order Pickup due to inventory full!"); return(false); } return(true); } //if (_specialMovement != null) //{//Special Movement for navigating inside buildings using Click To Move // if (_specialMovement.CurrentMovementQueue.Count > 0) // { // //find the nearest point to the npc in our special movement queue // var nearestPoint = Coroutines.Movement.FindNearestPoint(WorkOrderObject.Location, _specialMovement.CurrentMovementQueue.ToList()); // //click to move.. but don't dequeue // var result = await _specialMovement.ClickToMove_Result(false); // if (!nearestPoint.Equals(_specialMovement.CurrentMovementQueue.Peek())) // { // //force dequeue now since its not nearest point // if (result == MoveResult.ReachedDestination) // _specialMovement.ForceDequeue(true); // return true; // } // //Last position was nearest and we reached our destination.. so lets finish special movement! // if (result == MoveResult.ReachedDestination) // { // _specialMovement.ForceDequeue(true); // _specialMovement.DequeueAll(false); // } // } //} //Move to the interaction object if (_movement == null) { _movement = new Movement(WorkOrderObject, WorkOrderObject.InteractRange - 0.25f, name: "WorkOrderPickup " + WorkOrderObject.Name); } await _movement.MoveTo(false); return(true); }
private async Task TargetLogic(WoWUnit target) { if (!Query.IsViable(target)) { return; } var targetDistSqr = target.Location.DistanceSquared(Vehicle.Location); if (PickUpPassengerButton == 0) { TreeRoot.StatusText = string.Format("Blowing stuff up. {0} mins before resummon is required", _flightTimer.TimeLeft.TotalMinutes); if (HealButton > 0 && targetDistSqr < 60 * 60 && (Vehicle.HealthPercent <= HealPercent || Vehicle.ManaPercent <= HealPercent) && UseVehicleButton(HealButton)) { QBCLog.Info("Used heal button {0} on NPC:{1}", HealButton, target.SafeName); return; } // return when a button is used. foreach (var button in Buttons) { if (UseVehicleButton(button)) { return; } } return; } TreeRoot.StatusText = string.Format("Rescuing {0}", target.SafeName); var pickTimer = new WaitTimer(TimeSpan.FromSeconds(20)); pickTimer.Reset(); while (target.IsValid && target.IsAlive && !UnitIsRidingMyVehicle(target) && Query.IsInVehicle() && !pickTimer.IsFinished) { Vector3 clickLocation = target.Location.RayCast(target.Rotation, 6); clickLocation.Z += 3; if (Vehicle.Location.DistanceSquared(clickLocation) > 3 * 3) { Stopwatch timer = Stopwatch.StartNew(); do { Flightor.MoveTo(clickLocation); await Coroutine.Yield(); } while (timer.ElapsedMilliseconds < 1000 && Vehicle.Location.DistanceSquared(clickLocation) > 3 * 3); } else { if (Vehicle.IsMoving) { await CommonCoroutines.StopMoving(string.Format("Picking up {0}", target.SafeName)); } UseVehicleButton(PickUpPassengerButton); if (await Coroutine.Wait(4000, () => UnitIsRidingMyVehicle(target))) { QBCLog.Info("Successfully picked up passenger {0}", target.SafeName); return; } QBCLog.Info("Failed to picked up passenger {0}", target.SafeName); await Coroutine.Yield(); } } }
private async Task <bool> VerifyFlightNpc() { if (TaxiFlightHelper.IsOpen) { await CommonCoroutines.SleepForLagDuration(); //TaxiFrame.Instance.Close(); return(TaxiFlightHelper.TaxiNodes.Count == 0); } if (GossipHelper.IsOpen) { if (GossipHelper.GossipOptions.All(o => o.Type != GossipEntry.GossipEntryType.Taxi)) { //Could not find Taxi Option! GarrisonBase.Debug("UseFlightPath gossip frame contains no taxi options!"); Common.CloseOpenFrames(); return(true); } var gossipOptionTaxi = GossipHelper.GossipOptions.FirstOrDefault(o => o.Type == GossipEntry.GossipEntryType.Taxi); QuestManager.GossipFrame.SelectGossipOption(gossipOptionTaxi.Index); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } if (_taxiNpc != null && _taxiNpc.IsValid) {//We got a valid object.. so lets move into interact range! if (_taxiNpc.WithinInteractRange) { if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } await CommonCoroutines.SleepForRandomUiInteractionTime(); _taxiNpc.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await CommonCoroutines.SleepForLagDuration(); return(true); } if (_taxiMovement == null || _taxiMovement.CurrentMovementQueue.Count == 0) { _taxiMovement = new Movement(_taxiNpc.Location, 5f - 0.25f, name: "TaxiNpcMovement"); } await _taxiMovement.MoveTo(); return(true); } if (_taxiMovement != null && _taxiMovement.CurrentMovementQueue.Count > 0) { await _taxiMovement.MoveTo(); return(true); } if (FlightPaths.NearestFlightMerchant == null) { //Attempt to get location of nearest FP.. if (_nearestflightPathInfo == null) { _nearestflightPathInfo = TaxiFlightHelper.NearestFlightPath; if (_nearestflightPathInfo == null) {//Failed! GarrisonBase.Err("UseFlightPath could not find valid flight path to move to!"); IsDone = true; return(true); } } GarrisonBase.Debug("Could not find Nearest Flight Merchant, but using nearest flight path location! {0} at {1}", _nearestflightPathInfo.Name, _nearestflightPathInfo.Location); _taxiMovement = new Movement(_nearestflightPathInfo.Location, 20f, name: "taxiNpcMovement"); return(true); } //Found valid npc object.. _taxiNpc = FlightPaths.NearestFlightMerchant; _taxiMovement = new Movement(_taxiNpc.Location, 5f - 0.25f, name: "taxinpcMovement"); return(true); }
private Composite StateBehaviorPS_PathIngressing() { return(new PrioritySelector( // If no Ingress path exists, build it... new Decorator(context => Path_Ingress == null, new Action(context => { Path_Ingress = FollowPath.FindPath_Ingress(); })), // If we've consumed our Ingress path (or the one we initially built is empty), we're done... new Decorator(context => !Path_Ingress.Any(), new Action(context => { State_MainBehavior = StateType_MainBehavior.DestinationReached; })), // If Mob_ToAvoid is too close or we get in combat, abandon current ingress, and retreat back to safespot... new Decorator(context => Query.IsViable(Mob_ToAvoid) && ((Mob_ToAvoid.Distance < FollowPath.EgressDistance) || Me.Combat), new Action(context => { Path_Ingress = null; Path_Egress = null; State_MainBehavior = StateType_MainBehavior.PathRetreating; })), new Switch <SafePathType.StrategyType>(context => FollowPath.Strategy, new Action(context => // default case { var message = string.Format("FollowPathStrategyType({0}) is unhandled", FollowPath.Strategy); QBCLog.MaintenanceError(message); TreeRoot.Stop(); BehaviorDone(message); }), new SwitchArgument <SafePathType.StrategyType>(SafePathType.StrategyType.StalkMobAtAvoidDistance, new Decorator(context => Query.IsViable(Mob_ToAvoid) && (Mob_ToAvoid.Distance < AvoidDistance), new PrioritySelector( new ActionRunCoroutine(context => CommonCoroutines.StopMoving()), new ActionAlwaysSucceed() ))), new SwitchArgument <SafePathType.StrategyType>(SafePathType.StrategyType.WaitForAvoidDistance, new PrioritySelector( // No addition action needed to implement strategy for now )) ), // If we've arrived at the current ingress waypoint, dequeue it... new Decorator(context => Navigator.AtLocation(Path_Ingress.Peek().Location), new Action(context => { FollowPath.DismissPetIfNeeded(); Path_Ingress.Dequeue(); })), // Follow the prescribed ingress path, if its still safe to proceed... new Decorator(context => IsSafeToMoveToDestination(Mob_ToAvoid), new ActionRunCoroutine( context => UtilityCoroutine.MoveTo( Path_Ingress.Peek().Location, "follow ingress path", MovementBy))), // If mob is heading our direction, hold position... new Decorator(context => !IsSafeToMoveToDestination(Mob_ToAvoid), new Sequence( new Action(context => { TreeRoot.StatusText = string.Format("Holding position to evaluate {0}'s actions.", Mob_ToAvoid.SafeName); }), new ActionRunCoroutine(context => CommonCoroutines.StopMoving()) )) )); }
private async Task <bool> CheckHearthStone() { if (await Common.CheckCommonCoroutines()) { return(true); } if (FlightPathBehavior != null && !FlightPathBehavior.IsDone && await FlightPathBehavior.BehaviorRoutine()) { return(true); } if (MovementBehavior != null && MovementBehavior.CurrentMovementQueue.Count > 0 && await MovementBehavior.MoveTo()) { return(true); } if (!StyxWoW.Me.IsCasting) { var hearthstone = Player.Inventory.GarrisonHearthstone; if (hearthstone != null) { bool oncooldown = false; var cooldownTimeLeft = hearthstone.ref_WoWItem.CooldownTimeLeft; if (cooldownTimeLeft.TotalSeconds > 0) { oncooldown = true; GarrisonBase.Log("Garrison Hearthstone on cooldown! {0} seconds left", cooldownTimeLeft.TotalSeconds); if (cooldownTimeLeft.TotalSeconds < 60) { await Coroutine.Sleep((int)cooldownTimeLeft.TotalMilliseconds); return(true); } } if (!oncooldown && hearthstone.ref_WoWItem.Usable) { if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } hearthstone.Use(); await CommonCoroutines.SleepForRandomUiInteractionTime(); await Coroutine.Wait(10000, () => StyxWoW.Me.IsCasting); await Coroutine.Yield(); if (!await Coroutine.Wait(25000, () => StyxWoW.Me.CurrentMap.IsGarrison)) { GarrisonBase.Err("Used garrison hearthstone but not in garrison yet."); return(false); } //If we are using taxi.. finish it! if (BehaviorManager.CurrentBehavior.Type == BehaviorType.Taxi) { BehaviorManager.CurrentBehavior.IsDone = true; } } else { if (Player.MapExpansionId != 5) { //Not in draenor! GarrisonBase.Err("Garrison Hearthstone is on cooldown and not currently in draenor!"); return(false); } if (!attemptedFlightPath) { GarrisonBase.Debug("Attempting flight path to garrison"); FlightPathBehavior = new BehaviorUseFlightPath(MovementCache.GarrisonEntrance); attemptedFlightPath = true; } else { GarrisonBase.Debug("Attempting movement to garrison"); if (MovementBehavior == null) { MovementBehavior = new Movement(MovementCache.GarrisonEntrance, 50f, name: "GarrisonMovement"); } } return(true); } } } await Coroutine.Sleep(StyxWoW.Random.Next(1232, 3323)); return(true); }
private async Task <bool> Movement() { if (Building.CheckedWorkOrderStartUp) { return(false); } if (WorkOrderObject == null) { GarrisonBase.Err("Could not find Work Order Npc Id {0}", Building.WorkOrderNpcEntryId); //Error Cannot find object! Building.CheckedWorkOrderStartUp = true; return(false); } if (WorkOrderObject.WithinInteractRange) { if (StyxWoW.Me.IsMoving) { await CommonCoroutines.StopMoving(); } await CommonCoroutines.SleepForLagDuration(); if (_interactionAttempts > 3) { GarrisonBase.Log("Interaction Attempts for {0} has exceeded 3! Preforming movement..", WorkOrderObject.Name); StartMovement.Reset(); _interactionAttempts = 0; return(true); } if (LuaUI.WorkOrder.IsVisible()) { //Workorder frame is displayed! _interactionAttempts = 0; return(false); } if (Building.Type == BuildingType.Barn && GossipHelper.IsOpen) { //var entries = GossipHelper.GossipOptions.Where( // entry => entry.Text.ToLower().Contains(BarnWorkOrderGossipString)).ToList(); var entries = GossipHelper.GossipOptions.Where( entry => entry.Index == BarnGossipIndex).ToList(); if (entries.Count > 0) { int index = entries[0].Index; QuestManager.GossipFrame.SelectGossipOption(index); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } else { GarrisonBase.Err("Could not find gossip index for barn currency {0}", CurrentBarnCurrceny[0].Item1.ToString()); } } _interactionAttempts++; WorkOrderObject.Interact(); await CommonCoroutines.SleepForRandomUiInteractionTime(); return(true); } //Setup the NPC movement! if (_movement == null || _movement.CurrentMovementQueue.Count == 0) { _movement = new Movement(WorkOrderObject, WorkOrderObject.InteractRange - 0.50f, WorkOrderObject.Name); } await _movement.MoveTo(); return(true); }
protected override Composite CreateMainBehavior() { return(new PrioritySelector( // PvP server considerations... // Combat is disabled while on the Taxi. If on the ground, we want it enabled // in case we get attacked on a PvP server. new Decorator(context => !LevelBot.BehaviorFlags.HasFlag(BehaviorFlags.Combat), new Action(context => { LevelBot.BehaviorFlags |= BehaviorFlags.Combat; })), // Move to flight master, and interact to take taxi ride... new Decorator(context => !Me.OnTaxi, new PrioritySelector(context => { FlightMaster = Query.FindMobsAndFactions(Utility.ToEnumerable <int>(MobId_FlightMaster)) .FirstOrDefault() as WoWUnit; return context; }, // If flight master not in view, move to where he should be... new Decorator(context => FlightMaster == null, new ActionRunCoroutine( context => UtilityCoroutine.MoveTo( WaitLocation, "FlightMaster location", MovementBy))), // Make certain the bombs are in our backpack... new ActionRunCoroutine( ctx => _waitForInventoryItem ?? (_waitForInventoryItem = new UtilityCoroutine.WaitForInventoryItem( () => ItemId_Bomb, () => { QBCLog.ProfileError( "Cannot continue without required item: {0}", Utility.GetItemNameFromId(ItemId_Bomb)); BehaviorDone(); }))), // Move to flightmaster, and gossip to hitch a ride... new Decorator(context => FlightMaster != null, new PrioritySelector( new Decorator(context => !FlightMaster.WithinInteractRange, new ActionRunCoroutine( context => UtilityCoroutine.MoveTo( FlightMaster.Location, FlightMaster.SafeName, MovementBy))), new ActionRunCoroutine(context => CommonCoroutines.StopMoving()), new Decorator(ctx => Me.Mounted, new ActionRunCoroutine(ctx => CommonCoroutines.LandAndDismount())), new Decorator(context => !GossipFrame.Instance.IsVisible, new Action(context => { FlightMaster.Interact(); })), new Action(context => { GossipFrame.Instance.SelectGossipOption(GossipOption); }) )) )) )); }
private async Task <bool> StateCoroutine_MountingVehicle() { if (Me.IsQuestComplete(QuestId)) { BehaviorDone(); return(true); } if (IsInBalloon()) { await SubCoroutine_InitializeVehicleAbilities(); BehaviorState = BehaviorStateType.RidingOutToHuntingGrounds; return(true); } // Locate a vehicle to mount... if (!Query.IsViable(Vehicle)) { Vehicle = Query.FindMobsAndFactions(Utility.ToEnumerable(MobId_SteamwheedleRescueBalloon)) .FirstOrDefault() as WoWUnit; if (Query.IsViable(Vehicle)) { Utility.Target(Vehicle); return(true); } // No vehicle found, move to staging area... if (!Navigator.AtLocation(VehicleStagingArea)) { return(await UtilityCoroutine.MoveTo(VehicleStagingArea, "Vehicle Staging Area", MovementBy)); } await(_updateUser_MountingVehicle_waitingForSpawn ?? (_updateUser_MountingVehicle_waitingForSpawn = new ThrottleCoroutineTask( Throttle.UserUpdate, async() => TreeRoot.StatusText = string.Format("Waiting for {0} to respawn.", Utility.GetObjectNameFromId(MobId_SteamwheedleRescueBalloon))))); // Wait for vehicle to respawn... return(true); } // Wait for vehicle to respawn... await(_updateUser_MountingVehicle_movingToVehicle ?? (_updateUser_MountingVehicle_movingToVehicle = new ThrottleCoroutineTask( Throttle.UserUpdate, async() => TreeRoot.StatusText = string.Format("Moving to {0}", Vehicle.SafeName)))); if (!Vehicle.WithinInteractRange) { return(await UtilityCoroutine.MoveTo(Vehicle.Location, Vehicle.SafeName, MovementBy)); } if (Me.IsMoving) { await CommonCoroutines.StopMoving(); } if (Me.Mounted && await UtilityCoroutine.ExecuteMountStrategy( MountStrategyType.DismountOrCancelShapeshift)) { return(true); } // If we got booted out of a vehicle for some reason, reset the weapons... WeaponLifeRocket = null; WeaponPirateDestroyingBomb = null; WeaponEmergencyRocketPack = null; Utility.Target(Vehicle); await Coroutine.Sleep((int)Delay.AfterInteraction.TotalMilliseconds); Vehicle.Interact(); await Coroutine.Wait(10000, IsInBalloon); return(true); }
private async Task <bool> ScareSpiders() { // if not in a turret than move to one and interact with it if (!Query.IsInVehicle()) { var mustang = GetMustang(); if (mustang == null) { QBCLog.Warning("No mustang was found nearby"); return(false); } TreeRoot.StatusText = "Moving To Mustang"; if (mustang.DistanceSqr > 5 * 5) { return((await CommonCoroutines.MoveTo(mustang.Location)).IsSuccessful()); } await CommonCoroutines.LandAndDismount(); QBCLog.Info("Interacting with Mustang"); mustang.Interact(); return(true); } // Find the nearest spider and if none exist then move to the spawn location if (!Query.IsViable(_currentTarget) || !_currentTarget.IsAlive) { _currentTarget = ObjectManager.GetObjectsOfType <WoWUnit>() .Where(u => u.IsAlive && u.Entry == 44284 && !Blacklist.Contains(u, BlacklistFlags.Interact)) .OrderBy(u => u.DistanceSqr).FirstOrDefault(); if (_currentTarget == null) { if (!Navigator.AtLocation(_spiderSpawnLocation)) { return((await CommonCoroutines.MoveTo(_spiderSpawnLocation)).IsSuccessful()); } TreeRoot.StatusText = "Waiting for spiders to spawn"; return(true); } _noMoveBlacklistTimer.Reset(); _blacklistTimer.Reset(); QBCLog.Info("Locked on a new target. Distance {0}", _currentTarget.Distance); } TreeRoot.StatusText = "Scaring spider towards lumber mill"; var moveToPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation, _currentTarget.Location, -6); if (moveToPoint.DistanceSqr((WoWMovement.ActiveMover ?? StyxWoW.Me).Location) > 4 * 4) { return((await CommonCoroutines.MoveTo(moveToPoint)).IsSuccessful()); } // spider not moving? blacklist and find a new target. if (_noMoveBlacklistTimer.ElapsedMilliseconds > 20000 && _currentTarget.Location.DistanceSqr(_spiderScareLoc) < 10 * 10) { Blacklist.Add(_currentTarget, BlacklistFlags.Interact, TimeSpan.FromMinutes(3), "Spider is not moving"); _currentTarget = null; } else if (_blacklistTimer.IsFinished) { Blacklist.Add(_currentTarget, BlacklistFlags.Interact, TimeSpan.FromMinutes(3), "Took too long"); _currentTarget = null; } else if (!_currentTarget.HasAura("Fear")) { await CommonCoroutines.StopMoving(); Me.SetFacing(_lumberMillLocation); await CommonCoroutines.SleepForLagDuration(); await Coroutine.Sleep(200); if (!_noMoveBlacklistTimer.IsRunning || _currentTarget.Location.DistanceSqr(_spiderScareLoc) >= 10 * 10) { _noMoveBlacklistTimer.Restart(); _spiderScareLoc = _currentTarget.Location; } Lua.DoString("CastSpellByID(83605)"); await Coroutine.Wait(3000, () => Query.IsViable(_currentTarget) && _currentTarget.HasAura("Fear")); } return(true); }