Beispiel #1
0
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }
            if (IsDone)
            {
                return(false);
            }

            if ((DoOnce && DoneOnce) || Items.Count == 0)
            {
                return(false);
            }

            foreach (C_WoWItem item in Items)
            {
                TreeRoot.StatusText = String.Format("Behavior Item Interaction {0}", item.Name);

                item.Interact();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Wait(5000, () => !StyxWoW.Me.IsCasting);

                await Coroutine.Yield();

                await Coroutine.Sleep(1250);
            }

            DoneOnce = true;

            return(false);
        }
Beispiel #2
0
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }

            if (IsDone)
            {
                return(false);
            }

            if (await StartMovement.MoveTo())
            {
                return(true);
            }

            if (!InteractionObjectValid)
            {
                GarrisonBase.Err("Interaction Object Id {0} not valid or found!", InteractionEntryId);
                return(false);
            }

            if (GossipHelper.IsOpen)
            {
                int index = QuestHelper.GetAvailableQuestIndexFromGossipFrame(QuestID);
                if (index == -1)
                {
                    GarrisonBase.Err("Failed to find quest {0} in gossip frame!", QuestID);
                    return(false);
                }
                GossipFrame.Instance.SelectAvailableQuest(index);
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                return(true);
            }

            if (await Movement())
            {
                return(true);
            }

            if (await Interaction())
            {
                return(true);
            }

            if (_specialMovement != null && await _specialMovement.ClickToMove())
            {
                return(true);
            }

            if (await EndMovement.MoveTo())
            {
                return(true);
            }

            IsDone = true;
            return(false);
        }
        private static async Task <bool> SplitItem(C_WoWItem item, int Count, int BagIndex, int BagSlot)
        {
            if (!LuaCommands.CursorHasItem())
            {
                //Split Item..
                bool pickup =
                    await CommonCoroutines.WaitForLuaEvent("CURSOR_UPDATE",
                                                           2500,
                                                           null,
                                                           () => LuaCommands.SplitContainerItem(item.BagIndex + 1, item.BagSlot + 1, Count));

                await CommonCoroutines.SleepForRandomUiInteractionTime();

                if (pickup)
                {
                    //Select Empty Bag Slot
                    await CommonCoroutines.WaitForLuaEvent(
                        "CURSOR_UPDATE",
                        2500,
                        null,
                        () => LuaCommands.PickupContainerItem(BagIndex, BagSlot + 1));

                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
        public static async Task <bool> Healthstone()
        {
            if (!PaladinSettings.Instance.HealthstoneUse)
            {
                return(false);
            }

            if (StyxWoW.Me.HealthPercent > PaladinSettings.Instance.HealthstoneHp)
            {
                return(false);
            }

            var healthstone = FindItem(5512);

            if (!CanUseItem(healthstone))
            {
                return(false);
            }

            healthstone.UseContainerItem();
            await CommonCoroutines.SleepForRandomUiInteractionTime();

            Helpers.Logger.PrintLog("Using Healthstone");
            return(true);
        }
        private async Task <bool> Movement()
        {
            if (!_questActionFinished && !QuestHelper.QuestFrameOpen)
            {
                if (InteractionObject.WithinInteractRange)
                {
                    InteractionObject.Interact();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }

                #region SpecialMovement
                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(InteractionObject.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);
                        }
                    }
                }
                #endregion

                if (_npcMovement == null)
                {
                    _npcMovement = new Movement(InteractionObject, InteractionObject.InteractRange - 0.25f);
                }

                await _npcMovement.MoveTo(false);

                return(true);
            }

            return(false);
        }
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }
            if (IsDone)
            {
                return(false);
            }


            if (_entryId != 0)
            {
                if (StyxWoW.Me.CurrentTarget != null)
                {
                    if (StyxWoW.Me.CurrentTarget.Entry == _entryId)
                    {
                        IsDone = true;
                        return(false);
                    }
                }

                var _units = ObjectCacheManager.GetWoWUnits(_entryId);
                if (_units.Count > 0)
                {
                    TreeRoot.StatusText = String.Format("Behavior Targeting Unit {0}", _units[0].Name);
                    _units[0].RefWoWUnit.Target();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }
            }
            else
            {
                var _units = ObjectCacheManager.GetUnitsNearPoint(_location, 5f);
                if (_units.Count > 0)
                {
                    if (StyxWoW.Me.CurrentTarget != null)
                    {
                        if (StyxWoW.Me.CurrentTarget.Entry == _units[0].Entry)
                        {
                            IsDone = true;
                            return(false);
                        }
                    }

                    TreeRoot.StatusText = String.Format("Behavior Targeting Unit {0}", _units[0].Name);
                    _units[0].RefWoWUnit.Target();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }
            }


            return(false);
        }
        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);
        }
        private async Task <bool> Interaction()
        {
            if (Building.CheckedWorkOrderStartUp)
            {
                return(false);
            }

            if ((Building.Type != BuildingType.TradingPost && Building.Type != BuildingType.Barn) &&
                Building.WorkOrder.TotalWorkorderStartups() == 0)
            {
                GarrisonBase.Debug("Total Work Order Startup Count is Zero!");
                Building.CheckedWorkOrderStartUp = true;
                return(false);
            }

            TreeRoot.StatusText = String.Format("Behavior {0} [{1}] Interaction", Type.ToString(), Building.Type);
            if (LuaEvents.ShipmentOrderFrameOpen)
            {
                if (BaseSettings.CurrentSettings.DEBUG_FAKESTARTWORKORDER || !LuaUI.WorkOrder.StartWorkOrder.IsEnabled())
                {
                    if (Building.Type != BuildingType.Barn)
                    {
                        Building.CheckedWorkOrderStartUp = true;
                    }
                    else
                    {
                        CurrentBarnCurrceny = null;
                        BarnWorkOrderCurrencies.RemoveAt(0);
                    }

                    //if (_specialMovement != null) _specialMovement.UseDeqeuedPoints(true);
                    GarrisonBase.Log("Order Button Disabled!");
                    Building.WorkOrder.Refresh();
                    LuaUI.WorkOrder.Close.Click();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    await Coroutine.Yield();

                    return(Building.Type == BuildingType.Barn);
                }

                await CommonCoroutines.SleepForRandomUiInteractionTime();

                if (Building.Type == BuildingType.WarMillDwarvenBunker)
                {
                    LuaUI.WorkOrder.StartWorkOrder.Click();
                }
                else
                {
                    LuaUI.WorkOrder.CreateAllWorkOrder.Click();
                }

                await Coroutine.Yield();
            }

            return(true);
        }
Beispiel #9
0
        private static async Task <bool> DisenchantInteraction(List <C_WoWItem> items)
        {
            if (Player.CurrentPendingCursorSpellId == DisenchantSpellId)
            {
                //Item Interaction!
                GarrisonBase.Log("Disenchant Cursor!");

                if (items.Count > 0)
                {
                    var item = items[0];
                    GarrisonBase.Debug("Disenchanting Item {0} ({1}) Quality {2}", item.Name, item.Entry, item.Quality);
                    bool bagChanged = await CommonCoroutines.WaitForLuaEvent(
                        "BAG_UPDATE",
                        6200,
                        null,
                        item.Use);

                    PlayerInventory.ItemDisenchantingBlacklistedGuids.Add(item.Guid);

                    //Force update if bag didn't change.. (so we ignore this item now)
                    if (!bagChanged)
                    {
                        Player.Inventory.UpdateBagItems();
                    }

                    return(true);
                }
                return(false);
            }

            var spell = DisenchantSpell;

            if (spell != null)
            {
                bool cursorChanged = await CommonCoroutines.WaitForLuaEvent(
                    "CURRENT_SPELL_CAST_CHANGED",
                    StyxWoW.Random.Next(555, 2002),
                    null,
                    spell.Cast);

                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Yield();

                await Coroutine.Sleep(StyxWoW.Random.Next(1222, 2222));
            }
            else
            {
                GarrisonBase.Err("Disenchanting Spell returned null!");
                return(false);
            }



            return(true);
        }
        /// <summary>Buys an item from the specified wow object.</summary>
        /// <param name="wowObject">The wow object. Navigates to <paramref name="searchLocation" /> null</param>
        /// <param name="searchLocation">The search location of <paramref name="wowObject" />.</param>
        /// <param name="itemId">The item identifier.</param>
        /// <param name="quantity">The quantity to buy.</param>
        /// <param name="movementBy">The movement type to use.</param>
        /// <param name="navigationFailedAction">
        ///     The action to take if <paramref name="wowObject" /> or
        ///     <paramref name="searchLocation" /> cant be navigated to
        /// </param>
        /// <param name="notFoundAction">
        ///     The action to take if
        ///     <paramref name="wowObject" /> is not found at
        ///     <paramref name="searchLocation" />.
        /// </param>
        /// <param name="noVendorFrameAction">
        ///     The action to take if interaction with
        ///     <paramref name="wowObject" /> didn't open a vendor frame.
        /// </param>
        /// <param name="itemNotFoundAction">The action to take if <paramref name="wowObject"/> does not offer <paramref name="itemId"/> </param>
        /// <param name="insufficientFundsAction">The action to take if toon doesn't have enough funds to buy <paramref name="itemId"/> </param>
        /// <returns></returns>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public static async Task <bool> BuyItem(
            WoWObject wowObject,
            Vector3 searchLocation,
            int itemId,
            int quantity,
            MovementByType movementBy      = MovementByType.FlightorPreferred,
            Action navigationFailedAction  = null,
            Action notFoundAction          = null,
            Action noVendorFrameAction     = null,
            Action itemNotFoundAction      = null,
            Action insufficientFundsAction = null)
        {
            if (!MerchantFrame.Instance.IsVisible)
            {
                return(await Gossip(
                           wowObject,
                           searchLocation,
                           movementBy,
                           navigationFailedAction,
                           notFoundAction,
                           null,
                           noVendorFrameAction,
                           GossipEntry.GossipEntryType.Vendor));
            }

            var item = MerchantFrame.Instance.GetAllMerchantItems().FirstOrDefault(i => i.ItemId == itemId);

            if (item == null)
            {
                if (itemNotFoundAction != null)
                {
                    itemNotFoundAction();
                }
                return(false);
            }

            if (!MerchantFrame.Instance.BuyItem(item.Index, quantity))
            {
                if (insufficientFundsAction != null)
                {
                    insufficientFundsAction();
                }
                return(false);
            }

            await CommonCoroutines.SleepForRandomUiInteractionTime();

            MerchantFrame.Instance.Close();
            await CommonCoroutines.SleepForLagDuration();

            return(true);
        }
        private static async Task ClickGossipOption(GossipEntry gossipEntry, int gossipPage)
        {
            // Log the gossip option we're about to take...
            QBCLog.DeveloperInfo(
                "Selecting Gossip Option({0}) on page {1}: \"{2}\"",
                gossipEntry.Index + 1,
                gossipPage,
                gossipEntry.Text);

            GossipFrame.Instance.SelectGossipOption(gossipEntry.Index);
            await CommonCoroutines.SleepForLagDuration();

            await CommonCoroutines.SleepForRandomUiInteractionTime();
        }
        private async Task <bool> HandleQuestCompletion()
        {
            if (!Me.IsQuestComplete(QuestId))
            {
                return(false);
            }
            // Exit vehicle after quest is completed
            QBCLog.Info("Finished!");
            Lua.DoString("VehicleExit()");
            await CommonCoroutines.SleepForRandomUiInteractionTime();

            _isBehaviorDone = true;
            return(true);
        }
Beispiel #13
0
        private async Task <bool> Interaction()
        {
            if (GarrisonResourceCacheObject != null && GarrisonResourceCacheObject.RefWoWObject.IsValid && GarrisonResourceCacheObject.GetCursor == WoWCursorType.InteractCursor)
            {
                GarrisonResourceCacheObject.Interact();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await CommonCoroutines.SleepForRandomReactionTime();

                await Coroutine.Yield();

                return(true);
            }

            return(false);
        }
Beispiel #14
0
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }
            if (IsDone)
            {
                return(false);
            }

            LuaCommands.ClickStaticPopupButton(_buttonIndex);
            await CommonCoroutines.SleepForRandomUiInteractionTime();

            return(true);
        }
Beispiel #15
0
        public override async Task <bool> BehaviorRoutine()
        {
            if (IsDone)
            {
                return(false);
            }

            if (QuestHelper.QuestContainedInQuestLog(QuestID))
            {
                QuestLog.Instance.AbandonQuestById(QuestID);
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                return(true);
            }

            return(false);
        }
Beispiel #16
0
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }
            if (IsDone)
            {
                return(false);
            }

            var millingHerbs = Player.Inventory.GetBagItemsMilling();

            if (millingHerbs.Count == 0)
            {
                IsDone = true;
                return(false);
            }

            if (Player.CurrentPendingCursorSpellId != 51005)
            {
                if (!MillingSpell.Cooldown && MillingSpell.CanCast)
                {
                    await CommonCoroutines.WaitForLuaEvent(
                        "CURRENT_SPELL_CAST_CHANGED",
                        10000,
                        () => false,
                        MillingSpell.Cast);
                }
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                return(true);
            }

            GarrisonBase.Debug("Milling Herb {0} stack {1}", millingHerbs[0].Name, millingHerbs[0].StackCount);
            await CommonCoroutines.WaitForLuaEvent(
                "BAG_UPDATE",
                10000,
                () => false,
                millingHerbs[0].Use);

            await CommonCoroutines.SleepForRandomUiInteractionTime();

            return(true);
        }
Beispiel #17
0
        private async Task <bool> InteractWithUnit(WoWUnit unit)
        {
            if (unit == null)
            {
                return(false);
            }

            // Wait for sully to move away from the bombs so we don't blow him up.
            if (unit.Entry == MobId_SullysBombBarrel)
            {
                await Coroutine.Sleep(4000);
            }

            unit.Interact();
            await CommonCoroutines.SleepForRandomUiInteractionTime();

            return(true);
        }
Beispiel #18
0
        internal static async Task <bool> CloseFrames()
        {
            if (GossipHelper.IsOpen)
            {
                GossipFrame.Instance.Close();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Yield();

                return(true);
            }

            if (MerchantHelper.IsOpen)
            {
                MerchantFrame.Instance.Close();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Yield();

                return(true);
            }

            if (TaxiFlightHelper.IsOpen)
            {
                TaxiFrame.Instance.Close();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Yield();

                return(true);
            }

            if (MailHelper.IsOpen)
            {
                MailFrame.Instance.Close();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Yield();

                return(true);
            }

            return(false);
        }
Beispiel #19
0
        //private bool _checkedMasterPlanAddon = false;
        //internal async Task<bool> CheckAddons()
        //{
        //    if (_checkedMasterPlanAddon) return false;
        //    if (DisabledMasterPlanAddon) return false;

        //    await Coroutine.Yield();
        //    await Coroutine.Sleep(StyxWoW.Random.Next(1200, 2522));
        //    if (!BaseSettings.CurrentSettings.DisableMasterPlanAddon || !LuaCommands.IsAddonLoaded("MasterPlan"))
        //    {
        //        _checkedMasterPlanAddon = true;
        //        return false;
        //    }

        //    LuaCommands.DisableAddon("MasterPlan");
        //    LuaCommands.ReloadUI();
        //    DisabledMasterPlanAddon = true;
        //    _checkedMasterPlanAddon = true;
        //    await Coroutine.Wait(6000, () => !StyxWoW.IsInGame);
        //    return true;
        //}

        internal async Task <bool> InitalizeGarrisonManager()
        {
            if (GarrisonManager.Initalized)
            {
                return(false);
            }

            await CommonCoroutines.WaitForLuaEvent("GARRISON_SHOW_LANDING_PAGE", 2500, null, LuaCommands.ClickGarrisonMinimapButton);

            await CommonCoroutines.SleepForRandomUiInteractionTime();

            await Coroutine.Sleep(StyxWoW.Random.Next(1234, 2331));

            Lua.DoString("GarrisonLandingPage.CloseButton:Click()");
            await CommonCoroutines.SleepForRandomUiInteractionTime();

            GarrisonManager.Initalize();
            return(true);
        }
        private async Task <bool> Movement()
        {
            if (CommandTable == null)
            {
                //Error Cannot find object!
                GarrisonBase.Err("Could Not Find Command Table!");
                IsDone = true;
                return(false);
            }

            if (CommandTable.Distance < 4.56 && CommandTable.LineOfSight)
            {
                if (GarrisonMissionFrame.Instance.IsVisible)
                {
                    _interactattempts = 0;
                    return(false);
                }

                CommandTable.Interact();
                _interactattempts++;
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                if (_interactattempts > 3)
                {
                    GarrisonBase.Err("Attempted over 3 interactions with command table! Starting mvoement..");
                    StartMovement.CurrentMovementQueue.Enqueue(MovementCache.GarrisonEntrance);
                    _interactattempts = 0;
                }

                return(true);
            }



            if (_movement == null)
            {
                _movement = new Movement(CommandTable.Location, 4.55f, name: "CommandTable");
            }

            await _movement.MoveTo(false);

            return(true);
        }
Beispiel #21
0
        private async Task <bool> Interaction()
        {
            foreach (C_WoWItem salvageCrate in SalvagableGoods)
            {
                salvageCrate.Interact();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Wait(5000, () => !StyxWoW.Me.IsCasting);

                await Coroutine.Yield();

                await Coroutine.Sleep(1250);
            }

            if (StyxWoW.LastRedErrorMessage.Contains("Requires Salvage Yard"))
            {
                WoWMovement.Move(WoWMovement.MovementDirection.Forward, new TimeSpan(0, 0, 0, 2));
            }
            return(true);
        }
Beispiel #22
0
        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);
        }
Beispiel #23
0
        private async Task <bool> BuyMount(int vendorId, WoWPoint vendorLocation, int itemId)
        {
            var item = Me.BagItems.FirstOrDefault(i => i.Entry == itemId);

            if (item == null)
            {
                return(await UtilityCoroutine.BuyItem(
                           vendorId,
                           vendorLocation,
                           itemId,
                           1,
                           noVendorFrameAction : () => QBCLog.Fatal("Npc ({0}) does not offer a vendor frame", vendorId),
                           itemNotFoundAction : () => QBCLog.Fatal("Npc ({0}) does not sell the item with ID: {1}", vendorId, itemId),
                           insufficientFundsAction : () => QBCLog.Fatal("Toon does not have enough funds to buy {0} from {1}", itemId, vendorId)));
            }
            item.Use();
            _purchasedMountTimer.Reset();
            await CommonCoroutines.SleepForRandomUiInteractionTime();

            return(true);
        }
Beispiel #24
0
        private async Task <bool> Movement()
        {
            if (LuaEvents.MailOpen)
            {
                return(false);
            }

            if (Mailbox == null)
            {
                if (await StartMovement.MoveTo())
                {
                    return(true);
                }

                //No object found..
                IsDone = true;
                GarrisonBase.Err("Could not find mail box object!");
                return(false);
            }

            if (Mailbox.WithinInteractRange)
            {
                Mailbox.Interact();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Sleep(StyxWoW.Random.Next(1250, 2555));

                return(true);
            }

            if (_movement == null)
            {
                _movement = new Movement(Mailbox.Location, 6f, name: "Mailbox");
            }

            await _movement.MoveTo(false);

            return(true);
        }
        private async Task <bool> Interaction()
        {
            if (InteractionObject != null && InteractionObject.IsValid)
            {
                if (entryId == 0)
                {
                    entryId = InteractionObject.Entry;
                }
                GarrisonBase.Log("Activating " + InteractionObject.Name + ", waiting...");
                InteractionObject.Interact();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Wait(5000, () => !StyxWoW.Me.IsCasting && !InteractionObject.IsValid);

                await Coroutine.Sleep(StyxWoW.Random.Next(1999, 3001));

                return(true);
            }

            Building.CanActivate = false;

            if (Building.Type == BuildingType.HerbGarden || Building.Type == BuildingType.Mines)
            {//Since activating herb/mine building resets the nodes, we should reset our last checked so we can redo it..
                if (Building.Type == BuildingType.HerbGarden)
                {
                    BaseSettings.CurrentSettings.LastCheckedHerbString = "0001-01-01T00:00:00";
                }
                else
                {
                    BaseSettings.CurrentSettings.LastCheckedMineString = "0001-01-01T00:00:00";
                }

                BaseSettings.SerializeToXML(BaseSettings.CurrentSettings);
            }

            return(false);
        }
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }
            if (IsDone)
            {
                return(false);
            }

            if (Building.WorkOrder.Pending - Building.WorkOrder.Pickup <= 5)
            {
                return(false);
            }

            var rushOrderItems = Character.Player.Inventory.GetBagItemsById((int)Building.WorkOrder.RushOrderItemType);

            if (rushOrderItems.Count > 0)
            {
                var item = rushOrderItems[0];
                await CommonCoroutines.WaitForLuaEvent(
                    "BAG_UPDATE",
                    10000,
                    () => false,
                    item.Interact);

                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Sleep(3500);

                Building.WorkOrder.Refresh();
                return(true);
            }

            return(false);
        }
        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);
        }
Beispiel #28
0
        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);
        }
Beispiel #29
0
        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);
        }
        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);
        }