Beispiel #1
0
        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);
        }
        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 #3
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);
        }
Beispiel #4
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 #5
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);
        }
        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);
        }
        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> Interaction()
        {
            if (_questActionFinished)
            {
                return(false);
            }
            if (!QuestFrame.Instance.IsVisible)
            {
                return(true);
            }

            switch (QuestHelper.QuestFrameType)
            {
            case QuestHelper.QuestFrameTypes.Progress:
                QuestFrame.Instance.ClickContinue();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Sleep(5000);

                break;

            case QuestHelper.QuestFrameTypes.Complete:
                GarrisonBase.Log("Completing Quest..");

                if (RewardIndex > -1)
                {
                    GarrisonBase.Log("Selecting Reward Index {0}", RewardIndex);
                    QuestFrame.Instance.SelectQuestReward(RewardIndex);
                    await CommonCoroutines.SleepForRandomUiInteractionTime();
                }

                if (!BaseSettings.CurrentSettings.DEBUG_FAKEFINISHQUEST)
                {
                    var successTurnedIn = await CommonCoroutines.WaitForLuaEvent(
                        "QUEST_FINISHED",
                        7500,
                        null,
                        QuestFrame.Instance.CompleteQuest);

                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    await CommonCoroutines.SleepForLagDuration();

                    if (successTurnedIn)
                    {
                        _questActionFinished = true;
                        if (buildingType != BuildingType.Unknown && GarrisonManager.Buildings.ContainsKey(buildingType))
                        {
                            GarrisonManager.Buildings[buildingType].FirstQuestCompleted = true;
                        }
                        if (_specialMovement != null)
                        {
                            _specialMovement.UseDeqeuedPoints(true);
                        }
                        return(false);
                    }

                    return(true);
                }

                if (_specialMovement != null)
                {
                    _specialMovement.UseDeqeuedPoints(true);
                }
                _questActionFinished = true;
                return(false);
            }

            return(true);
        }
Beispiel #9
0
        private async Task <bool> UseFlightPath()
        {
            if (TaxiFlightHelper.IsOpen)
            {
                await CommonCoroutines.SleepForLagDuration();

                if (!TaxiFrame.Instance.IsVisible)
                {
                    //Error.. LuaEvents says open but frame instance does not!
                    GarrisonBase.Debug("UseFlightPath TaxiFrame Is not Visible");
                    _nonVisiblityCount++;

                    if (_nonVisiblityCount > 3)
                    {
                        //Attempted 3 times.. giving up!
                        GarrisonBase.Debug("UseFlightPath TaxiFrame Is not Visible 3x -- failed!");
                        return(false);
                    }

                    return(true);
                }

                _nonVisiblityCount = 0;

                var taxiFrameNodes = TaxiFrame.Instance.Nodes.Where(n => n.Reachable && n.Name.ToLower().Contains(_selectedTaxiNode.Name)).ToList();

                if (taxiFrameNodes.Count == 0)
                {
                    //Error could not find matching node!
                    GarrisonBase.Debug("UseFlightPath could not find any matching nodes!");
                    return(false);
                }

                GarrisonBase.Debug("UseFlightPath taking node {0}", taxiFrameNodes[0].Name);
                await CommonCoroutines.WaitForLuaEvent("TAXIMAP_CLOSED",
                                                       3500,
                                                       null, () =>
                {
                    taxiFrameNodes[0].TakeNode();
                    IsDone = true;
                });

                await CommonCoroutines.SleepForRandomUiInteractionTime();

                if (Player.LastErrorMessage == "You are busy and can't use the taxi service now.")
                {
                    IsDone = false;
                    await Coroutine.Yield();

                    return(true);
                }

                IsDone = true;
                return(false);
            }

            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!");
                    return(false);
                }
                var gossipOptionTaxi = GossipHelper.GossipOptions.FirstOrDefault(o => o.Type == GossipEntry.GossipEntryType.Taxi);

                QuestManager.GossipFrame.SelectGossipOption(gossipOptionTaxi.Index);
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                return(true);
            }

            return(false);
        }
Beispiel #10
0
        private async Task <bool> Interaction()
        {
            if (_questActionFinished || !QuestFrame.Instance.IsVisible)
            {
                return(false);
            }

            if (_completeQuest)
            {
                if (QuestHelper.QuestFrameType == QuestHelper.QuestFrameTypes.Complete)
                {
                    if (_rewardIndex > -1)
                    {
                        GarrisonBase.Log("Selecting Reward Index {0}", _rewardIndex);
                        QuestFrame.Instance.SelectQuestReward(_rewardIndex);
                        await CommonCoroutines.SleepForRandomUiInteractionTime();
                    }

                    if (BaseSettings.CurrentSettings.DEBUG_FAKEFINISHQUEST)
                    {
                        if (_specialMovement != null)
                        {
                            _specialMovement.UseDeqeuedPoints(true);
                        }
                        _questActionFinished = true;
                        return(false);
                    }

                    var successTurnedIn = await CommonCoroutines.WaitForLuaEvent(
                        "QUEST_TURNED_IN",
                        7500,
                        null,
                        QuestFrame.Instance.CompleteQuest);

                    if (successTurnedIn)
                    {
                        if (_specialMovement != null)
                        {
                            _specialMovement.UseDeqeuedPoints(true);
                        }
                        _questActionFinished = true;
                        return(false);
                    }

                    return(true);
                }

                if (QuestHelper.QuestFrameType == QuestHelper.QuestFrameTypes.Progress)
                {
                    QuestFrame.Instance.ClickContinue();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    await Coroutine.Yield();

                    return(true);
                }

                GarrisonBase.Err("QuestPickup attempted to complete quest but was not on correct frame!");
                _questActionFinished = true;
                return(false);
            }

            var successAccepted = await CommonCoroutines.WaitForLuaEvent(
                "QUEST_ACCEPTED",
                7500,
                null,
                QuestFrame.Instance.AcceptQuest);

            //
            if (successAccepted)
            {
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await CommonCoroutines.SleepForLagDuration();

                await Coroutine.Sleep(1250);

                _questActionFinished = true;
                return(false);
            }

            return(true);
        }
Beispiel #11
0
        private async Task <bool> Interaction()
        {
            /*
             * Check Cursor Spell ID
             * Click Interaction
             * Await for event CURRENT_SPELL_CAST_CHANGED
             *      -If event did not fire then check for confirmation popup
             *
             * Item Interaction
             *
             *
             */

            if (Player.CurrentPendingCursorSpellId == 160201)
            {
                //Item Interaction!
                GarrisonBase.Log("Disenchant Cursor!");

                if (Player.Inventory.DisenchantItems.Count > 0)
                {
                    var item = Player.Inventory.DisenchantItems[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);
            }

            bool cursorChanged = await CommonCoroutines.WaitForLuaEvent(
                "CURRENT_SPELL_CAST_CHANGED",
                StyxWoW.Random.Next(555, 2002),
                null,
                DisenchantingObject.Interact);


            await CommonCoroutines.SleepForRandomUiInteractionTime();

            await Coroutine.Yield();

            await Coroutine.Sleep(StyxWoW.Random.Next(1222, 2222));

            if (!cursorChanged)
            {
                if (LuaCommands.IsStaticPopupVisible())
                {
                    LuaCommands.ClickStaticPopupButton(1);
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }
                GarrisonBase.Err("Could not find static popup confirmation frame!");
            }


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

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



            if (GossipHelper.IsOpen)
            {
                if (GossipHelper.GossipOptions.All(o => o.Type != GossipEntry.GossipEntryType.Vendor))
                {
                    //Could not find Vendor Option!
                    GarrisonBase.Err("Primal Trader behavior could not find vendoring gossip!");
                    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)
            {
                await Coroutine.Yield();

                if (ExchangeItemInfo.Cost <= TotalPrimalSpiritCount)
                {
                    if (StyxWoW.Me.IsMoving)
                    {
                        await CommonCoroutines.StopMoving();
                    }

                    await Coroutine.Sleep(StyxWoW.Random.Next(1005, 1666));

                    bool success = false;

                    await CommonCoroutines.WaitForLuaEvent("BAG_UPDATE",
                                                           StyxWoW.Random.Next(1255, 1777),
                                                           null,
                                                           () => success = MerchantHelper.BuyItem(ExchangeItemInfo.ItemId, 1, true));

                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    await Coroutine.Yield();

                    if (success)
                    {
                        return(true);
                    }
                }

                IsDone = true;
                return(false);
            }

            if (InteractionObject != null)
            {
                if (InteractionObject.WithinInteractRange)
                {
                    if (StyxWoW.Me.IsMoving)
                    {
                        await CommonCoroutines.StopMoving();
                    }
                    await CommonCoroutines.SleepForLagDuration();

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

                    return(true);
                }

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

                await _npcMovement.MoveTo(false);

                return(true);
            }


            return(false);
        }
        private async Task <bool> Interaction()
        {
            if (!_commandtableCompletemissionsWaittimer.IsFinished)
            {
                return(true);
            }
            _commandtableCompletemissionsWaittimer.Reset();

            if (GarrisonManager.AvailableMissionIds.Count == 0)
            {
                await Coroutine.Yield();

                return(false);
            }

            if (LuaUI.MissionFrame.IsMissionCompleteDialogVisible)
            {
                //Complete Dialog is visible..
                //We need to add complete missions to coroutines
                //Add it again..
                //Finish this behavior
                GarrisonBase.Log("Garrison Mission Complete Is Visible!");
                BehaviorManager.Behaviors.Insert(1, new BehaviorMissionComplete());
                BehaviorManager.Behaviors.Insert(2, new BehaviorMissionStartup());
                LuaUI.MissionFrame.Close.Click();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Yield();

                return(false);
            }

            //Find our next mission.. if any.
            double _successChance = 0;

            if (_currentMission == null)
            {
                int[] followerIds;
                var   removalList = new List <int>();
                for (int i = 0; i < GarrisonManager.AvailableMissions.Count; i++)
                {
                    var mission = GarrisonManager.AvailableMissions[i];

                    if (mission.Level >= mission.MinimumLevel &&
                        mission.Priority > 0 &&
                        mission.Cost <= Character.Player.AvailableGarrisonResource)
                    {
                        _successChance = LuaCommands.GetMissionBestSuccessAttempt(mission.Id, out followerIds);
                        if (_successChance < mission.SuccessRate)
                        {
                            removalList.Add(i);
                            continue;
                        }
                        _currentMission = mission;
                        break;
                    }

                    removalList.Add(i);
                }

                if (removalList.Count > 0)
                {
                    foreach (var mission in removalList.OrderByDescending(k => k).Select(k => GarrisonManager.AvailableMissions[k]))
                    {
                        GarrisonManager.AvailableMissionIds.Remove(mission.Id);
                        GarrisonManager.AvailableMissions.Remove(mission);
                    }
                }
            }

            if (_currentMission != null)
            {
                GarrisonBase.Log("Starting Mission {0} Rewards {1} Priority {2} Success {3}",
                                 _currentMission.Name, _currentMission.RewardTypes, _currentMission.Priority, _successChance);



                //GARRISON_FOLLOWER_LIST_UPDATE
                await
                CommonCoroutines.WaitForLuaEvent("GARRISON_FOLLOWER_LIST_UPDATE", 7500, null, Action);

                await Coroutine.Sleep(2218);

                await
                CommonCoroutines.WaitForLuaEvent("GARRISON_MISSION_STARTED",
                                                 7500,
                                                 null,
                                                 LuaUI.MissionFrame.StartMissionButton.Click);

                await Coroutine.Sleep(2500);

                //LuaCommands.CloseMission();
                //await Coroutine.Sleep(1500);
                GarrisonManager.AvailableMissionIds.Remove(_currentMission.Id);
                GarrisonManager.AvailableMissions.Remove(_currentMission);
                _currentMission = null;
                await Coroutine.Yield();

                return(true);
            }

            _currentMission = null;
            GarrisonManager.AvailableMissions.Clear();
            GarrisonManager.AvailableMissionIds.Clear();
            return(false);
        }
Beispiel #14
0
        private static async Task <bool> DisenchantForgeInteraction(C_WoWGameObject disenchantobject, List <C_WoWItem> items)
        {
            if (disenchantobject.GetCursor != WoWCursorType.InteractCursor)
            {
                GarrisonBase.Debug("Disenchant Interaction failed -- Cursor was not InteractCursor!");
                return(false);
            }

            if (Player.CurrentPendingCursorSpellId == 160201)
            {
                //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);
            }

            bool cursorChanged = await CommonCoroutines.WaitForLuaEvent(
                "CURRENT_SPELL_CAST_CHANGED",
                StyxWoW.Random.Next(555, 2002),
                null,
                disenchantobject.Interact);


            await CommonCoroutines.SleepForRandomUiInteractionTime();

            await Coroutine.Yield();

            await Coroutine.Sleep(StyxWoW.Random.Next(1222, 2222));

            if (!cursorChanged)
            {
                if (LuaCommands.IsStaticPopupVisible())
                {
                    LuaCommands.ClickStaticPopupButton(1);
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }
            }


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

            //Requires Anvil
            if (Skill == SkillLine.Blacksmithing || Skill == SkillLine.Engineering)
            {
                if (_movement != null && await _movement.MoveTo(false))
                {
                    return(true);
                }
            }

            Frame f = new Frame("TradeSkillFrame");

            //PreCheck (close any tradeskill frames!)
            if (!_prechecks)
            {
                if (f.IsVisible)
                {
                    LuaCommands.CloseTradeSkillFrame();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    await Coroutine.Sleep(StyxWoW.Random.Next(750, 2222));
                }
                _prechecks = true;
                await CommonCoroutines.SleepForRandomUiInteractionTime();
            }

            //Open Crafting Spellbook
            if (!LuaEvents.TradeSkillFrameOpen)
            {
                WoWSpell.FromId(SkillBookId).Cast();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await Coroutine.Sleep(StyxWoW.Random.Next(1777, 3333));

                return(true);
            }

            //Craft Item
            if (!Spell.Cooldown && Spell.CanCast)
            {
                await CommonCoroutines.WaitForLuaEvent(
                    "BAG_UPDATE",
                    10000,
                    () => false,
                    Spell.Cast);

                return(true);
            }

            //Close UI
            if (f.IsVisible)
            {
                LuaCommands.CloseTradeSkillFrame();
                await CommonCoroutines.SleepForRandomUiInteractionTime();
            }

            return(false);
        }