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;
            }
        }
    }
Beispiel #2
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");
        }