Пример #1
0
        public static void Roll(int rollId, WAEItem itemToRoll, string reason, RollType rollType)
        {
            int    waitTime       = 1000 + new Random().Next(1, 3000);
            string adjustedReason = reason == "" ? "" : $"[{reason}]";

            if (rollType == RollType.PASS)
            {
                Logger.Log($"Rolling PASS in {waitTime}ms for {itemToRoll.Name} {adjustedReason}");
                Thread.Sleep(waitTime);
                Lua.LuaDoString($"ConfirmLootRoll({rollId}, 0)");
            }

            if (rollType == RollType.GREED)
            {
                Logger.Log($"Rolling GREED in {waitTime}ms for {itemToRoll.Name} {adjustedReason}");
                Thread.Sleep(waitTime);
                Lua.LuaDoString($"ConfirmLootRoll({rollId}, 2)");
            }

            if (rollType == RollType.NEED)
            {
                Logger.Log($"Rolling NEED in {waitTime}ms for {itemToRoll.Name} ({itemToRoll.WeightScore}) {adjustedReason}");
                Thread.Sleep(waitTime);
                Lua.LuaDoString($"ConfirmLootRoll({rollId}, 1)");
            }
        }
 private static bool SuitableForTitansGrips(WAEItem weapon)
 {
     return(KnowTitansGrip &&
            (ItemSkillsDictionary[weapon.ItemSubType] == SkillLine.TwoHandedSwords ||
             ItemSkillsDictionary[weapon.ItemSubType] == SkillLine.TwoHandedAxes ||
             ItemSkillsDictionary[weapon.ItemSubType] == SkillLine.TwoHandedMaces));
 }
Пример #3
0
    public static void Add(WAEItem item)
    {
        if (ItemDb.Count > 300)
        {
            ItemDb.RemoveRange(0, 100);
        }

        if (!ContainsByItemLink(item.Name))
        {
            ItemDb.Add(item);
        }
    }
    private static void ReplaceBag(WAEContainer bagToReplace, WAEItem newBag)
    {
        if (bagToReplace.EmptyBagInOtherBags())
        {
            Logger.Log($"Replacing {bagToReplace.ThisBag.Name} with {newBag.Name}");

            if (newBag.InBag == bagToReplace.Position)
            {
                newBag = AllItems.Find(b => b.ItemLink == newBag.ItemLink);
            }

            newBag.MoveToBag(bagToReplace.Position);

            WAELootFilter.ProtectFromFilter(newBag.ItemLink);
            Lua.LuaDoString($"EquipPendingItem(0);");
            //Lua.LuaDoString($"StaticPopup1Button1:Click()");
        }
        Scan();
    }
    private static bool WeaponIsIdeal(WAEItem weapon)
    {
        if (weapon == null || !ItemSkillsDictionary.ContainsKey(weapon.ItemSubType))
        {
            return(false);
        }

        if (ClassSpec == ClassSpec.RogueAssassination &&
            ItemSkillsDictionary[weapon.ItemSubType] != SkillLine.Daggers)
        {
            return(false);
        }

        if ((ClassSpec == ClassSpec.WarriorArms && KnowTitansGrip) &&
            (ItemSkillsDictionary[weapon.ItemSubType] == SkillLine.TwoHandedSwords ||
             ItemSkillsDictionary[weapon.ItemSubType] == SkillLine.TwoHandedAxes ||
             ItemSkillsDictionary[weapon.ItemSubType] == SkillLine.TwoHandedMaces))
        {
            return(true);
        }

        if (AutoEquipSettings.CurrentSettings.EquipShields &&
            ItemSkillsDictionary[weapon.ItemSubType] == SkillLine.Shield)
        {
            return(true);
        }

        if (AutoEquipSettings.CurrentSettings.EquipTwoHanders &&
            TwoHanders.Contains(ItemSkillsDictionary[weapon.ItemSubType]))
        {
            return(true);
        }

        if (AutoEquipSettings.CurrentSettings.EquipOneHanders &&
            ItemSkillsDictionary[weapon.ItemSubType] != SkillLine.Shield &&
            OneHanders.Contains(ItemSkillsDictionary[weapon.ItemSubType]))
        {
            return(true);
        }

        return(false);
    }
Пример #6
0
    public WAEContainer(int position)
    {
        Position = position;
        Capacity = GetContainerNbSlots();
        if (Position != 0)
        {
            string bagItemLink = Lua.LuaDoString <string>($"return GetContainerItemLink(0, {Position - 4})");
            ThisBag = new WAEItem(bagItemLink);
            if (ThisBag.QuiverCapacity > 0)
            {
                IsQuiver = true;
            }
            if (ThisBag.AmmoPouchCapacity > 0)
            {
                IsAmmoPouch = true;
            }
        }
        else
        {
            IsOriginalBackpack = true;
        }

        string[] allItems = GetAllItemLinks(Capacity).Split('$');
        for (int i = 0; i < allItems.Length; i++)
        {
            WAEItem item;
            if (allItems[i] != "BAG")
            {
                if (allItems[i] != "null")
                {
                    item = new WAEItem(allItems[i], inBagSlot: i, inBag: Position);
                    Slots.Add(new WAEContainerSlot(i, position, item));
                    Items.Add(item);
                    WAEContainers.AllItems.Add(item);
                }
                else
                {
                    Slots.Add(new WAEContainerSlot(i, position, null));
                }
            }
        }
    }
    public static WAEItem GetBiggestAmmoContainerFromBags()
    {
        string  equippedRanged          = WAECharacterSheet.Ranged.Item?.ItemSubType;
        WAEItem bestAmmoContainerInBags = null;

        if (equippedRanged == TypeRanged.Bows.ToString() || equippedRanged == TypeRanged.Crossbows.ToString())
        {
            bestAmmoContainerInBags = AllItems
                                      .FindAll(item => item.QuiverCapacity > 0)
                                      .OrderByDescending(item => item.QuiverCapacity)
                                      .FirstOrDefault();
        }
        else if (equippedRanged == TypeRanged.Guns.ToString())
        {
            bestAmmoContainerInBags = AllItems
                                      .FindAll(item => item.AmmoPouchCapacity > 0)
                                      .OrderByDescending(item => item.AmmoPouchCapacity)
                                      .FirstOrDefault();
        }
        return(bestAmmoContainerInBags);
    }
 private void CloneFromDB(WAEItem existingCopy)
 {
     Name              = existingCopy.Name;
     ItemLink          = existingCopy.ItemLink;
     ItemRarity        = existingCopy.ItemRarity;
     ItemLevel         = existingCopy.ItemLevel;
     ItemMinLevel      = existingCopy.ItemMinLevel;
     ItemType          = existingCopy.ItemType;
     ItemSubType       = existingCopy.ItemSubType;
     ItemStackCount    = existingCopy.ItemStackCount;
     ItemEquipLoc      = existingCopy.ItemEquipLoc;
     ItemTexture       = existingCopy.ItemTexture;
     ItemSellPrice     = existingCopy.ItemSellPrice;
     BagCapacity       = existingCopy.BagCapacity;
     QuiverCapacity    = existingCopy.QuiverCapacity;
     AmmoPouchCapacity = existingCopy.AmmoPouchCapacity;
     UniqueId          = existingCopy.UniqueId;
     WeightScore       = existingCopy.WeightScore;
     ItemStats         = existingCopy.ItemStats;
     WeaponSpeed       = existingCopy.WeaponSpeed;
     ItemId            = existingCopy.ItemId;
 }
Пример #9
0
    public bool EmptyBagInOtherBags()
    {
        List <WAEContainerSlot> freeSlots = new List <WAEContainerSlot>();

        // record free slots
        foreach (WAEContainer container in WAEContainers.ListContainers.Where(b => b.IsOriginalBackpack || !b.IsAmmoPouch && !b.IsQuiver))
        {
            if (container != this)
            {
                freeSlots.AddRange(container.Slots.Where(slot => slot.OccupiedBy == null));
            }
        }

        // Move Items
        if (freeSlots.Count > Items.Count)
        {
            Logger.Log($"Moving items out of {ThisBag.Name}");
            for (int i = 0; i < Items.Count; i++)
            {
                WAEContainerSlot destination = freeSlots[i];
                WAEItem          smallBag    = Items[i];
                smallBag.PickupFromBag();
                ToolBox.Sleep(100);
                smallBag.MoveToBag(destination.BagPosition, destination.Slot);
                ToolBox.Sleep(100);
            }
        }

        WAEContainers.Scan();

        // Check if bag to move is actually empty
        if (GetContainerNbFreeSlots() == GetContainerNbSlots())
        {
            return(true);
        }

        return(false);
    }
    public WAEItem(string itemLink,
                   int rewardSlot = -1,
                   int rollId     = -1,
                   int inBag      = -1,
                   int inBagSlot  = -1)
    {
        UniqueId   = ++UniqueIdCounter;
        ItemLink   = itemLink;
        RewardSlot = rewardSlot;
        RollId     = rollId;
        InBag      = inBag;
        InBagSlot  = inBagSlot;

        if (itemLink.Length < 10)
        {
            return;
        }

        RecordItemId(itemLink);

        WAEItem existingCopy = WAEItemDB.Get(ItemLink);

        if (existingCopy != null)
        {
            CloneFromDB(existingCopy);
        }
        else
        {
            string iteminfo = Lua.LuaDoString <string>($@"
                itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType,
                itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(""{ItemLink.Replace("\"", "\\\"")}"");

                if (itemSellPrice == null) then
                    itemSellPrice = 0
                end

                if (itemEquipLoc == null) then
                    itemEquipLoc = ''
                end

                return itemName..'§'..itemLink..'§'..itemRarity..'§'..itemLevel..
                '§'..itemMinLevel..'§'..itemType..'§'..itemSubType..'§'..itemStackCount..
                '§'..itemEquipLoc..'§'..itemTexture..'§'..itemSellPrice");

            string[] infoArray = iteminfo.Split('§');

            if (infoArray.Length < 11)
            {
                Logger.LogDebug($"Item {itemLink} doesn't have the correct number of info. Skipping.");
                return;
            }

            Name           = infoArray[0];
            ItemLink       = itemLink;
            ItemRarity     = int.Parse(infoArray[2]);
            ItemLevel      = int.Parse(infoArray[3]);
            ItemMinLevel   = int.Parse(infoArray[4]);
            ItemType       = infoArray[5];
            ItemSubType    = infoArray[6];
            ItemStackCount = int.Parse(infoArray[7]);
            ItemEquipLoc   = infoArray[8];
            ItemTexture    = infoArray[9];
            ItemSellPrice  = int.Parse(infoArray[10]);

            if (Main.WoWVersion <= ToolBox.WoWVersion.TBC)
            {
                RecordToolTipTBC();
                RecordBagSpaceTBC();
            }
            else
            {
                RecordToolTipWotLK();
                RecordStatsWotLK();
            }

            WAEItemDB.Add(this);
            if (AutoEquipSettings.CurrentSettings.LogItemInfo)
            {
                LogItemInfo();
            }
        }
    }
Пример #11
0
        public static void CheckLootRoll()
        {
            DateTime dateBegin = DateTime.Now;

            for (int i = RollList.Count - 1; i >= 0; i--)
            {
                int rollId = RollList[i];

                bool   canNeed  = Lua.LuaDoString <bool>($"_, _, _, _, _, canNeed, _, _, _, _, _, _ = GetLootRollItemInfo({rollId});", "canNeed") || Main.WoWVersion <= ToolBox.WoWVersion.TBC;
                string itemLink = Lua.LuaDoString <string>($"itemLink = GetLootRollItemLink({rollId});", "itemLink");

                if (itemLink.Length < 10)
                {
                    Logger.LogDebug($"Couldn't get item link of roll {rollId}, skipping");
                    RollList.Remove(rollId);
                    continue;
                }

                WAEItem itemToRoll = new WAEItem(itemLink, rollId: rollId);

                if (AutoEquipSettings.CurrentSettings.AlwaysPass)
                {
                    Roll(rollId, itemToRoll, "Always pass", RollType.PASS);
                    RollList.Remove(rollId);
                    continue;
                }

                if (AutoEquipSettings.CurrentSettings.AlwaysGreed)
                {
                    Roll(rollId, itemToRoll, "Always greed", RollType.GREED);
                    RollList.Remove(rollId);
                    continue;
                }

                WAECharacterSheet.Scan();
                WAEContainers.Scan();
                WAEContainers.AllItems.Add(itemToRoll);

                if (canNeed && itemToRoll.ItemEquipLoc != "" && itemToRoll.ItemSubType != "Bag")
                {
                    // Weapons
                    if (WAEEnums.TwoHanders.Contains(WAEEnums.ItemSkillsDictionary[itemToRoll.ItemSubType]) ||
                        WAEEnums.OneHanders.Contains(WAEEnums.ItemSkillsDictionary[itemToRoll.ItemSubType]) ||
                        (itemToRoll.ItemSubType == "Miscellaneous" && ToolBox.ImACaster()))
                    {
                        WAECharacterSheet.AutoEquipWeapons();
                    }

                    // Ranged
                    if (WAECharacterSheet.Ranged.InvTypes.Contains(itemToRoll.ItemEquipLoc))
                    {
                        WAECharacterSheet.AutoEquipRanged();
                    }

                    // Trinket
                    if (itemToRoll.ItemEquipLoc == "INVTYPE_TRINKET")
                    {
                        WAECharacterSheet.AutoEquipTrinkets();
                    }

                    // Ring
                    if (itemToRoll.ItemEquipLoc == "INVTYPE_FINGER")
                    {
                        WAECharacterSheet.AutoEquipRings();
                    }

                    // Armor
                    foreach (WAECharacterSheetSlot armorSlot in WAECharacterSheet.ArmorSlots)
                    {
                        if (armorSlot.InvTypes.Contains(itemToRoll.ItemEquipLoc))
                        {
                            WAECharacterSheet.AutoEquipArmor();
                            break;
                        }
                    }
                }

                if (!itemToRoll.HasBeenRolled)
                {
                    Roll(rollId, itemToRoll, "", RollType.GREED);
                }

                RollList.Remove(rollId);
            }

            Logger.LogPerformance($"Loot Roll Check Process time : {(DateTime.Now.Ticks - dateBegin.Ticks) / 10000} ms");
        }
    public static void AutoEquipWeapons()
    {
        //Logger.LogDebug($"************ Weapon scan debug *****************");
        bool currentWeaponsAreIdeal = WeaponIsIdeal(MainHand.Item) && WeaponIsIdeal(OffHand.Item) ||
                                      WeaponIsIdeal(MainHand.Item) && OffHand.Item == null && AutoEquipSettings.CurrentSettings.EquipTwoHanders && !AutoEquipSettings.CurrentSettings.EquipOneHanders;
        float unIdealDebuff = 0.6f;

        float currentMainHandScore = MainHand.Item != null ? MainHand.Item.WeightScore : 0f;
        float currentOffHandScore  = OffHand.Item != null?OffHand.Item.GetOffHandWeightScore() : 0f;

        float currentCombinedWeaponsScore = currentMainHandScore + currentOffHandScore;

        if (!currentWeaponsAreIdeal)
        {
            currentCombinedWeaponsScore = currentCombinedWeaponsScore * unIdealDebuff;
        }

        // Equip restricted to what we allow
        List <WAEItem> listAllMainHandWeapons = GetEquipableWeaponsFromBags(MainHand);

        if (MainHand.Item != null)
        {
            listAllMainHandWeapons.Add(MainHand.Item);
        }
        List <WAEItem> listAllOffHandWeapons = GetEquipableWeaponsFromBags(OffHand);

        if (OffHand.Item != null)
        {
            listAllOffHandWeapons.Add(OffHand.Item);
        }

        listAllMainHandWeapons = listAllMainHandWeapons.OrderByDescending(w => w.WeightScore).ToList();
        listAllOffHandWeapons  = listAllOffHandWeapons.OrderByDescending(w => w.WeightScore).ToList();

        // Get ideal Two Hand
        WAEItem ideal2H = listAllMainHandWeapons
                          .Where(w => TwoHanders.Contains(ItemSkillsDictionary[w.ItemSubType]))
                          .Where(weapon => WeaponIsIdeal(weapon))
                          .FirstOrDefault();

        // Get second choice Two Hand
        WAEItem secondChoice2H = listAllMainHandWeapons
                                 .Where(w => TwoHanders.Contains(ItemSkillsDictionary[w.ItemSubType]))
                                 .Where(w => w != ideal2H)
                                 .FirstOrDefault();

        // Get ideal Main hand
        WAEItem idealMainhand = listAllMainHandWeapons
                                .Where(w => OneHanders.Contains(ItemSkillsDictionary[w.ItemSubType]) ||
                                       SuitableForTitansGrips(w))
                                .Where(weapon => WeaponIsIdeal(weapon) || MainHand.Item == null)
                                .FirstOrDefault();

        // Get Second choice Main hand
        WAEItem secondChoiceMainhand = listAllMainHandWeapons
                                       .Where(w => OneHanders.Contains(ItemSkillsDictionary[w.ItemSubType]) || SuitableForTitansGrips(w))
                                       .Where(w => w != idealMainhand)
                                       .FirstOrDefault();

        // Swap if both ideal are One Hand/Main Hand
        if (idealMainhand != null &&
            secondChoiceMainhand != null &&
            secondChoiceMainhand.WeightScore > idealMainhand.WeightScore &&
            idealMainhand.ItemLink != secondChoiceMainhand.ItemLink &&
            idealMainhand.ItemEquipLoc == "INVTYPE_WEAPON" &&
            secondChoiceMainhand.ItemEquipLoc == "INVTYPE_WEAPONMAINHAND")
        {
            WAEItem first = idealMainhand;
            idealMainhand        = secondChoiceMainhand;
            secondChoiceMainhand = first;
        }

        // Get ideal OffHand
        WAEItem idealOffHand = listAllOffHandWeapons
                               //.Where(w => w.ItemSubType == "Miscellaneous" || OneHanders.Contains(ItemSkillsDictionary[w.ItemSubType]))
                               .Where(w => WeaponIsIdeal(w) || OffHand.Item == null || !WeaponIsIdeal(OffHand.Item))
                               .Where(w => DualWield.KnownSpell ||
                                      ItemSkillsDictionary[w.ItemSubType] == SkillLine.Shield ||
                                      !DualWield.KnownSpell && w.ItemSubType == "Miscellaneous" ||
                                      SuitableForTitansGrips(w))
                               .Where(w => w != idealMainhand && w != ideal2H)
                               .FirstOrDefault();

        // Get second choice OffHand
        WAEItem secondChoiceOffhand = listAllOffHandWeapons
                                      .Where(w => w.ItemSubType == "Miscellaneous" ||
                                             (DualWield.KnownSpell && OneHanders.Contains(ItemSkillsDictionary[w.ItemSubType])) ||
                                             SuitableForTitansGrips(w))
                                      .Where(w => DualWield.KnownSpell ||
                                             ItemSkillsDictionary[w.ItemSubType] == SkillLine.Shield ||
                                             !DualWield.KnownSpell && w.ItemSubType == "Miscellaneous")
                                      .Where(w => w != secondChoiceMainhand)
                                      .FirstOrDefault();

        float scoreIdealMainHand = idealMainhand == null ? 0 : idealMainhand.WeightScore;
        float scoreIdealOffhand  = idealOffHand == null ? 0 : idealOffHand.GetOffHandWeightScore();

        float scoreSecondChoiceMainHand = secondChoiceMainhand == null ? 0 : secondChoiceMainhand.WeightScore;
        float scoreSecondOffhand        = secondChoiceOffhand == null ? 0 : secondChoiceOffhand.GetOffHandWeightScore();

        float finalScore2hands    = ideal2H == null ? 0 : ideal2H.WeightScore;
        float finalScoreDualWield = scoreIdealMainHand + scoreIdealOffhand;

        float finalScoreSecondDualWield    = (scoreSecondChoiceMainHand + scoreSecondOffhand) * unIdealDebuff;
        float finalScoreSecondChoice2hands = secondChoice2H == null ? 0 : secondChoice2H.WeightScore * unIdealDebuff;

        /*
         * if (AutoEquipSettings.CurrentSettings.LogItemInfo)
         * {
         *  Logger.LogDebug($"Current is preffered : {currentWeaponsAreIdeal} ({currentCombinedWeaponsScore})");
         *  Logger.LogDebug($"2H 1 {ideal2H?.Name} ({finalScore2hands}) -- 2H 2 {secondChoice2H?.Name} ({finalScoreSecondChoice2hands})");
         *  Logger.LogDebug($"1H 1 {idealMainhand?.Name} ({scoreIdealMainHand}) -- 1H 2 {secondChoiceMainhand?.Name} ({scoreSecondChoiceMainHand})");
         *  Logger.LogDebug($"OFFHAND 1 {idealOffHand?.Name} ({scoreIdealOffhand}) -- OFFHAND 2 {secondChoiceOffhand?.Name} ({scoreSecondOffhand})");
         *  Logger.LogDebug($"COMBINED 1 {idealMainhand?.Name} + {idealOffHand?.Name} ({finalScoreDualWield}) -- COMBINED 2 {secondChoiceMainhand?.Name} + {secondChoiceOffhand?.Name} ({finalScoreSecondDualWield})");
         * }
         */

        if (finalScoreDualWield > currentCombinedWeaponsScore ||
            finalScore2hands > currentCombinedWeaponsScore)
        {
            if (finalScore2hands > finalScoreDualWield)
            {
                ideal2H.EquipSelectRoll(MainHand.InventorySlotID, "Better overall score");
                return;
            }
            else
            {
                if (idealMainhand != null)
                {
                    idealMainhand?.EquipSelectRoll(MainHand.InventorySlotID, "Better overall score");
                    idealOffHand?.EquipSelectRoll(OffHand.InventorySlotID, "Better overall score");
                    return;
                }
            }
        }

        if (finalScoreSecondDualWield > currentCombinedWeaponsScore ||
            finalScoreSecondChoice2hands > currentCombinedWeaponsScore)
        {
            if (finalScoreSecondChoice2hands > finalScoreSecondDualWield)
            {
                secondChoice2H.EquipSelectRoll(MainHand.InventorySlotID, "Better overall score");
                return;
            }
            else
            {
                if (secondChoiceMainhand != null)
                {
                    secondChoiceMainhand?.EquipSelectRoll(MainHand.InventorySlotID, "Better overall score");
                    secondChoiceOffhand?.EquipSelectRoll(OffHand.InventorySlotID, "Better overall score");
                    return;
                }
            }
        }
    }
Пример #13
0
 public WAEContainerSlot(int slot, int bag, WAEItem occupiedBy)
 {
     Slot        = slot;
     BagPosition = bag;
     OccupiedBy  = occupiedBy;
 }
    public static void BagEquip()
    {
        //Logger.LogDebug("*** Bag equip...");
        DateTime dateBegin = DateTime.Now;

        if (AutoEquipSettings.CurrentSettings.AutoEquipBags)
        {
            bool         ImHunterAndNeedAmmoBag  = ObjectManager.Me.WowClass == WoWClass.Hunter && AutoEquipSettings.CurrentSettings.EquipQuiver;
            int          maxAmountOfBags         = ImHunterAndNeedAmmoBag ? 4 : 5;
            WAEContainer equippedQuiver          = ListContainers.Find(bag => bag.IsQuiver);
            WAEContainer equippedAmmoPouch       = ListContainers.Find(bag => bag.IsAmmoPouch);
            bool         hasRangedWeaponEquipped = WAECharacterSheet.Ranged.Item != null;
            string       equippedRanged          = WAECharacterSheet.Ranged.Item?.ItemSubType;

            if (AutoEquipSettings.CurrentSettings.EquipQuiver)
            {
                // Move ammoContainer to position 4
                if (equippedQuiver != null && equippedQuiver.Position != 4)
                {
                    equippedQuiver.MoveToSlot(4);
                    Scan();
                    equippedQuiver = ListContainers.Find(bag => bag.IsQuiver);
                }
                if (equippedAmmoPouch != null && equippedAmmoPouch.Position != 4)
                {
                    equippedAmmoPouch.MoveToSlot(4);
                    Scan();
                    equippedAmmoPouch = ListContainers.Find(bag => bag.IsAmmoPouch);
                }

                // We have an ammo container equipped
                if (ImHunterAndNeedAmmoBag && (equippedQuiver != null || equippedAmmoPouch != null))
                {
                    WAEContainer equippedAmmoContainer   = equippedQuiver == null ? equippedAmmoPouch : equippedQuiver;
                    WAEItem      bestAmmoContainerInBags = GetBiggestAmmoContainerFromBags();

                    if (bestAmmoContainerInBags != null)
                    {
                        // Check we have the right type of ammo container
                        if ((equippedRanged == TypeRanged.Bows.ToString() || equippedRanged == TypeRanged.Crossbows.ToString()) && !equippedAmmoContainer.IsQuiver)
                        {
                            ReplaceBag(equippedAmmoContainer, bestAmmoContainerInBags);
                        }
                        else if (equippedRanged == TypeRanged.Guns.ToString() && !equippedAmmoContainer.IsAmmoPouch)
                        {
                            ReplaceBag(equippedAmmoContainer, bestAmmoContainerInBags);
                        }
                        // Try to find a better one
                        else if (bestAmmoContainerInBags.QuiverCapacity > equippedAmmoContainer.Capacity ||
                                 bestAmmoContainerInBags.AmmoPouchCapacity > equippedAmmoContainer.Capacity)
                        {
                            ReplaceBag(equippedAmmoContainer, bestAmmoContainerInBags);
                        }
                    }
                }

                // We have no ammo container equipped
                if (ImHunterAndNeedAmmoBag && equippedQuiver == null && equippedAmmoPouch == null)
                {
                    if (!hasRangedWeaponEquipped || equippedRanged == TypeRanged.Thrown.ToString())
                    {
                        maxAmountOfBags = 5;
                    }
                    else
                    {
                        WAEItem bestAmmoContainerInBags = GetBiggestAmmoContainerFromBags();
                        // We found an ammo container to equip
                        if (bestAmmoContainerInBags != null)
                        {
                            if (GetEmptyContainerSlots().Count > 0)
                            {
                                // There is an empty slot
                                int availableSpot = GetEmptyContainerSlots().Last();
                                Logger.Log($"Equipping {bestAmmoContainerInBags.Name} in slot {availableSpot}");
                                bestAmmoContainerInBags.MoveToBag(availableSpot);

                                Lua.LuaDoString($"EquipPendingItem(0);");
                                //Lua.LuaDoString($"StaticPopup1Button1:Click()");
                                WAELootFilter.ProtectFromFilter(bestAmmoContainerInBags.ItemLink);

                                Scan();
                            }
                            else
                            {
                                // No empty slot, we need to replace a bag by an ammo container
                                WAEContainer smallestEquippedBag = GetSmallestEquippedBag();
                                ReplaceBag(smallestEquippedBag, bestAmmoContainerInBags);
                            }
                        }
                    }
                }
            }
            else
            {
                // The user doesn't want to have quiver equipped, removing them
                if (equippedQuiver != null || equippedAmmoPouch != null)
                {
                    WAEContainer equippedAmmoContainer = equippedQuiver == null ? equippedAmmoPouch : equippedQuiver;
                    WAEItem      biggestBagInBags      = GetBiggestBagFromBags();
                    if (biggestBagInBags != null)
                    {
                        ReplaceBag(equippedAmmoContainer, biggestBagInBags);
                    }
                }
            }

            // Bag equip if we have at least 1 empty slot
            if (GetNbBagEquipped() < maxAmountOfBags)
            {
                List <int> emptyContainerSlots = GetEmptyContainerSlots();
                int        nbEmpty             = emptyContainerSlots.Count;
                int        nbloop = emptyContainerSlots.Count;

                foreach (int emptySlotId in emptyContainerSlots)
                {
                    WAEItem biggestBag = GetBiggestBagFromBags();

                    if (biggestBag != null)
                    {
                        Logger.Log($"Equipping {biggestBag.Name}");
                        int availableSpot = GetEmptyContainerSlots().First();
                        biggestBag.MoveToBag(availableSpot);

                        Lua.LuaDoString($"EquipPendingItem(0);");
                        //Lua.LuaDoString($"StaticPopup1Button1:Click()");
                        WAELootFilter.ProtectFromFilter(biggestBag.ItemLink);

                        Scan();
                    }
                    if (GetNbBagEquipped() >= maxAmountOfBags)
                    {
                        break;
                    }
                }
            }

            // Bag equip to replace one for better capacity
            if (GetNbBagEquipped() >= maxAmountOfBags)
            {
                WAEContainer smallestEquippedBag = GetSmallestEquippedBag();
                WAEItem      biggestBagInBags    = GetBiggestBagFromBags();

                if (smallestEquippedBag != null &&
                    biggestBagInBags != null &&
                    smallestEquippedBag.Capacity < biggestBagInBags.BagCapacity &&
                    smallestEquippedBag.Position != 0)
                {
                    ReplaceBag(smallestEquippedBag, biggestBagInBags);
                }
            }
        }

        Logger.LogPerformance($"Bag Equip Process time : {(DateTime.Now.Ticks - dateBegin.Ticks) / 10000} ms");
    }