Example #1
0
    private void BackGroundPulse(object sender, DoWorkEventArgs args)
    {
        while (isLaunched)
        {
            try
            {
                if (Conditions.InGameAndConnectedAndProductStartedNotInPause)
                {
                    lock (WAELock)
                    {
                        Logger.LogPerformance("--------------------------------------");
                        DateTime dateBegin = DateTime.Now;

                        if (!ToolBox.WEEquipToolTipExists())
                        {
                            LUASetup();
                        }

                        WAECharacterSheet.Scan();
                        WAEContainers.Scan();

                        if (!ObjectManager.Me.InCombatFlagOnly &&
                            AutoEquipSettings.CurrentSettings.AutoEquipBags &&
                            ObjectManager.Me.IsAlive)
                        {
                            WAEContainers.BagEquip();
                        }

                        if (!ObjectManager.Me.InCombatFlagOnly &&
                            AutoEquipSettings.CurrentSettings.AutoEquipGear &&
                            ObjectManager.Me.IsAlive)
                        {
                            WAECharacterSheet.AutoEquip();
                        }

                        if (AutoEquipSettings.CurrentSettings.EquipAmmo &&
                            ObjectManager.Me.IsAlive)
                        {
                            WAECharacterSheet.AutoEquipAmmo(); // Allow ammo switch during fights
                        }
                        if (!ObjectManager.Me.InCombatFlagOnly &&
                            ObjectManager.Me.IsAlive)
                        {
                            WAELootFilter.FilterLoot();
                        }

                        WAEGroupRoll.CheckLootRoll();

                        Logger.LogPerformance($"Total Process time : {(DateTime.Now.Ticks - dateBegin.Ticks) / 10000} ms");
                    }
                }
            }
            catch (Exception arg)
            {
                Logger.LogError(string.Concat(arg));
            }
            ToolBox.Sleep(5000);
        }
    }
Example #2
0
 public void MoveToSlot(int position)
 {
     Lua.LuaDoString($"PickupBagFromSlot({Position + 19});");
     ToolBox.Sleep(50);
     Lua.LuaDoString($"PutItemInBag({position + 19});");
     ToolBox.Sleep(50);
     WAEContainers.Scan();
 }
 private static WAEItem QuestRewardReceived(List <WAEItem> itemRewards)
 {
     WAEContainers.Scan();
     foreach (WAEItem reward in itemRewards)
     {
         foreach (WAEItem bagItem in WAEContainers.AllItems)
         {
             if (bagItem.ItemLink == reward.ItemLink)
             {
                 return(reward);
             }
         }
     }
     return(null);
 }
Example #4
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 bool EquipSelectRoll(int slotId, string reason)
    {
        WAELootFilter.ProtectFromFilter(ItemLink);

        // ROLL
        if (RollId >= 0)
        {
            WAEGroupRoll.Roll(RollId, this, reason, RollType.NEED);
            HasBeenRolled = true;
            WAEContainers.AllItems.Clear();
            return(true);
        }

        // SELECT REWARD
        if (RewardSlot >= 0)
        {
            Lua.LuaDoString($"GetQuestReward({RewardSlot})");
            Logger.Log($"Selecting quest reward {Name} [{reason}]");
            WAEContainers.AllItems.Clear();
            return(true);
        }

        // EQUIP
        WAECharacterSheetSlot slot = WAECharacterSheet.AllSlots.Find(s => s.InventorySlotID == slotId);

        if (slot.Item?.ItemLink == ItemLink)
        {
            return(true);
        }

        if (ItemSubType != "Arrow" && ItemSubType != "Bullet")
        {
            if (ObjectManager.Me.InCombatFlagOnly || ObjectManager.Me.IsCast)
            {
                return(false);
            }
        }

        if (InBag < 0 || InBagSlot < 0)
        {
            Logger.LogError($"Item {Name} is not recorded as being in a bag. Can't use.");
        }
        else
        {
            Logger.Log($"Equipping {Name} ({WeightScore}) [{reason}]");
            ItemEquipAttempts.Add(ItemLink);
            PickupFromBag();
            DropInInventory(slotId);
            ToolBox.Sleep(100);
            Lua.LuaDoString($"EquipPendingItem(0);");
            //Lua.LuaDoString($"StaticPopup1Button1:Click()");
            ToolBox.Sleep(200);
            WAECharacterSheet.Scan();
            WAEContainers.Scan();
            WAECharacterSheetSlot updatedSlot = WAECharacterSheet.AllSlots.Find(s => s.InventorySlotID == slotId);
            if (updatedSlot.Item == null || updatedSlot.Item.ItemLink != ItemLink)
            {
                if (GetNbEquipAttempts() < _maxNbEquipAttempts)
                {
                    Logger.LogError($"Failed to equip {Name}. Retrying soon ({GetNbEquipAttempts()}).");
                }
                else
                {
                    Logger.LogError($"Failed to equip {Name} after {GetNbEquipAttempts()} attempts.");
                }

                Lua.LuaDoString($"ClearCursor()");
                return(false);
            }
            ItemEquipAttempts.RemoveAll(i => i == ItemLink);
            WAELootFilter.AllowForFilter(ItemLink);
            return(true);
        }
        return(false);
    }
    public static void SelectReward(CancelEventArgs cancelable)
    {
        lock (Main.WAELock)
        {
            if (!AutoEquipSettings.CurrentSettings.AutoSelectQuestRewards)
            {
                return;
            }

            int nbQuestRewards = WTGossip.NbQuestChoices;

            if (nbQuestRewards > 0 && QuestRewardGossipOpen)
            {
                cancelable.Cancel = true;

                List <WAEItem> itemRewards = new List <WAEItem>();
                for (int i = 1; i <= nbQuestRewards; i++)
                {
                    string itemLink = Lua.LuaDoString <string>($"return GetQuestItemLink(\"choice\", {i})");
                    itemRewards.Add(new WAEItem(itemLink, rewardSlot: i));
                }

                itemRewards = itemRewards.OrderByDescending(i => i.WeightScore).ToList();
                WAECharacterSheet.Scan();
                WAEContainers.Scan();
                WAEContainers.AllItems.AddRange(itemRewards);

                foreach (WAEItem item in itemRewards)
                {
                    if (item.ItemEquipLoc != "" && item.ItemSubType != "Bag")
                    {
                        // Weapons
                        if (WAEEnums.ItemSkillsDictionary.TryGetValue(item.ItemSubType, out SkillLine skillLine))
                        {
                            if (WAEEnums.TwoHanders.Contains(skillLine) ||
                                WAEEnums.OneHanders.Contains(skillLine) ||
                                item.ItemSubType == "Miscellaneous")
                            {
                                WAECharacterSheet.AutoEquipWeapons();
                                continue;
                            }
                        }

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

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

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

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

                ToolBox.Sleep(3000);
                if (QuestRewardReceived(itemRewards) == null)
                {
                    itemRewards = itemRewards.OrderByDescending(i => i.ItemSellPrice).ToList();
                    Lua.LuaDoString($"GetQuestReward({itemRewards.First().RewardSlot})");
                    ToolBox.Sleep(1000);
                    if (QuestRewardReceived(itemRewards) != null)
                    {
                        Logger.Log($"Selected quest reward {QuestRewardReceived(itemRewards).Name} because it has the highest sell value");
                    }
                }

                QuestRewardGossipOpen = false;
            }
        }
    }
Example #7
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");
        }