Пример #1
0
 internal static void ResetDisenchanting()
 {
     _disenchantMovement        = null;
     IsDisenchanting            = false;
     _disenchantobject          = null;
     _checkedDisenchantingSkill = false;
     _usingDisenchantingSkill   = false;
 }
Пример #2
0
        internal static void UpdateCache()
        {
            Character.Player.Update();

            FoundOreObject  = false;
            FoundHerbObject = false;

            Blacklist.CheckTempBlacklists();

            //GarrisonBase.Debug("Updating Object Cache");
            var guidsSeenThisLoop = new List <WoWGuid>();

            using (StyxWoW.Memory.AcquireFrame())
            {
                ObjectManager.Update();
                foreach (var obj in ObjectManager.ObjectList)
                {
                    var tmpEntry = obj.Entry;
                    if (Blacklist.TempBlacklistEntryIDs.Contains(tmpEntry))
                    {
                        continue;
                    }
                    if (Blacklist.BlacklistEntryIDs.Contains(tmpEntry))
                    {
                        //Styx.CommonBot.Blacklist.Add(obj, BlacklistFlags.All, new TimeSpan(1, 0, 0, 0), "Perma Blacklist");
                        continue;
                    }

                    var tmpGuid = obj.Guid;
                    if (guidsSeenThisLoop.Contains(tmpGuid))
                    {
                        continue;
                    }
                    guidsSeenThisLoop.Add(tmpGuid);

                    if (Blacklist.TempBlacklistGuids.Contains(tmpGuid))
                    {
                        continue;
                    }

                    C_WoWObject wowObj;
                    if (!ObjectCollection.TryGetValue(tmpGuid, out wowObj))
                    {
                        //Create new object!
                        switch (obj.Type)
                        {
                        case WoWObjectType.Unit:
                            var objUnit = new C_WoWUnit(obj.ToUnit());
                            ObjectCollection.Add(tmpGuid, objUnit);
                            wowObj = ObjectCollection[tmpGuid];
                            break;

                        case WoWObjectType.GameObject:
                            var gameObject = obj.ToGameObject();
                            if (CacheStaticLookUp.BlacklistedGameObjectTypes.Contains(gameObject.SubType))
                            {
                                Blacklist.TempBlacklistEntryIDs.Add(tmpEntry);
                                continue;
                            }
                            var objGame = new C_WoWGameObject(gameObject);
                            ObjectCollection.Add(tmpGuid, objGame);
                            wowObj = ObjectCollection[tmpGuid];
                            break;

                        default:
                            Blacklist.TempBlacklistEntryIDs.Add(tmpEntry);
                            continue;
                        }
                    }
                    else
                    {
                        wowObj.LoopsUnseen = 0;
                    }


                    if (!wowObj.IsValid && wowObj.IgnoresRemoval)
                    {
                        wowObj.UpdateReference(obj);
                    }

                    if (wowObj.RequiresUpdate)
                    {
                        wowObj.Update();
                    }
                }
            }

            foreach (var obj in ObjectCollection.Values)
            {
                if (!guidsSeenThisLoop.Contains(obj.Guid))
                {
                    obj.LoopsUnseen++;
                }

                if (CheckFlag(obj.SubType, WoWObjectTypes.Herb) && obj.ShouldLoot)
                {
                    FoundHerbObject = true;
                }
                if (CheckFlag(obj.SubType, WoWObjectTypes.OreVein) && obj.ShouldLoot)
                {
                    FoundOreObject = true;
                }

                if (obj.LoopsUnseen >= 5 && !obj.IgnoresRemoval)
                {
                    obj.NeedsRemoved = true;
                }
            }

            //Trim our collection every 5th refresh.
            _updateLoopCounter++;
            if (_updateLoopCounter > 4)
            {
                _updateLoopCounter = 0;
                CheckForCacheRemoval();
            }

            _lastUpdatedCacheCollection = DateTime.Now;
        }
Пример #3
0
        internal static async Task <bool> Disenchanting()
        {
            if (IsDisenchanting)
            {
                if (!_checkedDisenchantingSkill)
                {
                    _checkedDisenchantingSkill = true;
                    _usingDisenchantingSkill   =
                        Player.Professions.ProfessionSkills.ContainsKey(SkillLine.Enchanting) &&
                        GetDisenchantingItems.Count > 0;
                }

                if (_usingDisenchantingSkill)
                {
                    var items = GetDisenchantingItems;
                    if (items.Count == 0)
                    {
                        if (await Common.CloseFrames())
                        {
                            return(true);
                        }
                        ResetDisenchanting();
                        return(true);
                    }

                    await DisenchantInteraction(items);

                    return(true);
                }

                #region Garrison Disenchanting

                var forgeItems = GetDisenchantForgeItems;
                if (forgeItems.Count == 0)
                {
                    if (await Common.CloseFrames())
                    {
                        return(true);
                    }
                    ResetDisenchanting();
                    return(true);
                }

                if (_disenchantobject == null)
                {
                    var disenchantObjects = DisenchantingForgeObjects;
                    if (disenchantObjects.Count > 0)
                    {
                        _disenchantobject = disenchantObjects[0];
                        GarrisonBase.Debug("Disenchant Behavior found object at {0}", _disenchantobject.Location);
                    }
                }

                if (_disenchantMovement == null || _disenchantMovement.CurrentMovementQueue.Count == 0)
                {
                    if (_disenchantobject == null)
                    {
                        var mailboxWoWPoint = GarrisonManager.Buildings[BuildingType.EnchantersStudy].EntranceMovementPoint;
                        _disenchantMovement = new Movement(new[] { mailboxWoWPoint }, 20f, "Enchanters Study Entrance");
                    }
                    else
                    {
                        _disenchantMovement = new Movement(_disenchantobject, _disenchantobject.InteractRange - 0.25f, "Disenchant Object Movement");
                    }
                }


                if (_disenchantobject != null)
                {
                    if (_disenchantobject.WithinInteractRange)
                    {
                        bool disenchanting = await DisenchantForgeInteraction(_disenchantobject, forgeItems);

                        if (!disenchanting)
                        {
                            ResetDisenchanting();
                            return(true);
                        }

                        return(true);
                    }
                }

                if (_disenchantMovement != null)
                {
                    bool movement = await DisenchantMovement();

                    if (!movement)
                    {
                        //Failed to move?
                        GarrisonBase.Debug("Failed to move to disenchant location!");
                        return(false);
                    }
                }

                return(true);

                #endregion
            }

            return(false);
        }
Пример #4
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);
        }