local debug = false if not WeakAurasSaved then WeakAurasSaved = {} end if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end if not WeakAurasSaved.Cyka.ItemCache then WeakAurasSaved.Cyka.ItemCache = {} end -- itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType,itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType,expacID, setID, isCraftingReagent = GetItemInfo(slot) -- lootIcon, lootName, lootQuantity, currencyID, lootQuality, locked, isQuestItem, questID, isActive = GetLootSlotInfo(slot) -- Link sometimes does not work local function getItemLink(slot) if (slot == nil) then return nil end return GetLootSlotLink(slot) end local function getItemName(slot) if (slot == nil) then return nil end return select(2, GetLootSlotInfo(slot)) end local function getItemType(slot) if (slot == nil) then return nil end local itemLink = getItemLink(slot) if (itemLink == nil) then return nil end return select(6, GetItemInfo(itemLink)) end local function getItemSubtype(slot) if (slot == nil) then return nil end local itemLink = getItemLink(slot) if (itemLink == nil) then return nil end return select(7, GetItemInfo(itemLink)) end local function getItemLevel(slot) if (slot == nil) then return nil end local itemLink = getItemLink(slot) if (itemLink == nil) then return nil end return select(4, GetItemInfo(itemLink)) end local function getItemValue(slot) if (slot == nil) then return nil end local itemLink = getItemLink(slot) if (itemLink == nil) then return nil end return select(11, GetItemInfo(itemLink)) end local function getItemQuantity(slot) if (slot == nil) then return nil end return select(3, GetLootSlotInfo(slot)) end local function getItemQuality(slot) if (slot == nil) then return nil end local itemLink = getItemLink(slot) if (itemLink == nil) then return nil end return select(3, GetItemInfo(itemLink)) end local function getItemEquipLocation(slot) if (slot == nil) then return nil end local itemLink = getItemLink(slot) if (itemLink == nil) then return nil end return select(9, GetItemInfo(itemLink)) end local function getItemIcon(slot) if (slot == nil) then return nil end local itemLink = getItemLink(slot) if (itemLink == nil) then return nil end return select(10, GetItemInfo(itemLink)) end local doLoot = function(slot) aura_env.debugLog("Looting slot: " .. slot) LootSlot(slot) local itemIcon = getItemIcon(slot) or 134400 local itemName = getItemName(slot) or "Unknown" itemName = itemName:gsub("\n", ", ") local itemQuality = getItemQuality(slot) or 0 if not WeakAurasSaved.Cyka.ItemCache[itemName] then WeakAurasSaved.Cyka.ItemCache[itemName] = { icon = itemIcon, quality = itemQuality, } end end local goldFilter = { enabled = true, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Gold filter; slot: " .. slot) local itemName = getItemName(slot) -- I guess it does not support OR in regex? -- itemName:match("%d+ ((Gold)|(Silver)|(Copper))") if (itemname and itemName:match("%d+ Gold") or itemName:match("%d+ Silver") or itemName:match("%d+ Copper")) then aura_env.debugLog("Gold filter pass") return true end end end } local orderResourcesFilter = { enabled = true, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Resource filter; slot: " .. slot) local itemName = getItemName(slot) if (itemName and itemName:match("Order Resources")) then aura_env.debugLog("Order resource filter pass") return true end end end } local mountFilter = { enabled = true, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Mount filter; slot: " .. slot) local itemType = getItemType(slot) if (itemType and itemType == "Mount") then aura_env.debugLog("Mount filter pass") return true end end end } local ilvlFilter = { enabled = true, ilvlThreshold = 880, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("ILvl filter; slot: " .. slot) local itemLevel = getItemLevel(slot) if (itemLevel and itemLevel > self.ilvlThreshold) then aura_env.debugLog("Item level filter pass") return true end end end } local professionFilter = { enabled = true, herbs = true, cloth = false, ore = false, leather = false, cooking = true, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Profession filter; slot: " .. slot) local itemType = getItemType(slot) if (itemType and itemType == "Tradeskill") then local itemSubtype = getItemSubtype(slot) if (itemSubtype and (itemSubtype == "Herb" and self.herbs) or (itemSubtype == "Leather" and self.leather) or (itemSubtype == "Cloth" and self.cloth) or (itemSubtype == "Ore" and self.ore) or (itemSubtype == "Cooking" and self.cooking)) then aura_env.debugLog("Profession filter pass") return true end end end end } local valueFilter = { enabled = true, valueThreshold = 35 * 100 * 100, applyThresholdToItemStack = false, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Value filter; slot: " .. slot) local itemValue = getItemValue(slot) if (self.applyThresholdToItemStack) then local itemQuantity = getItemQuantity(slot) aura_env.debugLog("There exist " .. itemQuantity .. " items in slot " .. slot) itemValue = itemValue * itemQuantity end if (itemValue and itemValue > self.valueThreshold) then aura_env.debugLog("Value filter pass") return true end end end } local greyValueFilter = { enabled = true, -- Set threshold to 0 to loot all greys valueThreshold = 5 * 100 * 100, applyThresholdToItemStack = false, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Grey value filter; slot: " .. slot) local itemQuality = getItemQuality(slot) if (itemQuality and itemQuality > 0) then local itemValue = getItemValue(slot) if (self.applyThresholdToItemStack) then local itemQuantity = getItemQuantity(slot) aura_env.debugLog("There exist " .. itemQuantity .. " items in slot " .. slot) itemValue = itemValue * itemQuantity end if (itemValue and itemValue > self.valueThreshold) then aura_env.debugLog("Grey value filter pass") return true end end end end } local questItemFilter = { enabled = true, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Quest item filter; slot: " .. slot) local itemType = getItemType(slot) local itemSubtype = getItemSubtype(slot) if (itemType and itemSubtype and itemType == itemSubtype == "Quest") then aura_env.debugLog("Quest item filter pass") return true end end end } local classGearFilter = { enabled = true, ilvlThreshold = 800, qualityThreshold = 2, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Class gear filter; slot: " .. slot) local itemType = getItemType(slot) local itemEquipLoc = getItemEquipLocation(slot) if (itemType == "Armor" or itemType == "Weapon" or itemEquipLoc == "INVTYPE_FINGER" or itemEquipLoc == "INVTYPE_TRINKET" or itemEquipLoc == "INVTYPE_CLOAK" or itemEquipLoc == "INVTYPE_NECK") then local itemLevel = getItemLevel(slot) local itemQuality = getItemQuality(slot) local isEquippable = aura_env.skills[select(3, UnitClass("player"))][subtype] == 1 if (isEquippable and itemLevel > self.ilvlThreshold and itemQuality > self.qualityThreshold) then aura_env.debugLog("Class gear filter pass") return true end end end end } local azeriteFilter = { enabled = true, ilvlThreshold = 800, qualityThreshold = 2, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Azerite filter; slot: " .. slot) local itemType = getItemType(slot) local itemSubtype = getItemSubtype(slot) local itemQuality = getItemQuality(slot) if (itemType and itemSubtype and itemQuality and itemType == "Consumable" and itemSubtype == "Other" and itemQuality > 1) then aura_env.debugLog("Azerite filter pass") return true end end end } local arguniteFilter = { enabled = true, qualityThreshold = 1, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Argunite filter; slot: " .. slot) local itemName = getItemName(slot) local itemQuality = getItemQuality(slot) if (itemName and itemQuality and itemName:match("Argunite") and itemQuality > self.qualityThreshold) then aura_env.debugLog("Argunite filter pass") return true end end end } local ancientManaFilter = { enabled = true, qualityThreshold = 1, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Ancient mana filter; slot: " .. slot) local itemName = getItemName(slot) if (itemName and itemName:match("Ancient Mana")) then aura_env.debugLog("Ancient mana filter pass") return true end end end } local reicpeFilter = { enabled = true, filter = function(self, slot) if (self.enabled) then aura_env.debugLog("Recipe filter; slot: " .. slot) local itemName = getItemName(slot) if (itemName and (itemName:match("Recipe") or itemName:match("Technique"))) then aura_env.debugLog("Recipe filter pass") return true end end end } aura_env.filterService = { filters = { goldFilter, orderResourcesFilter, mountFilter, ilvlFilter, professionFilter, valueFilter, greyValueFilter, questItemFilter, classGearFilter, azeriteFilter, arguniteFilter, ancientManaFilter, reicpeFilter, }, slotsToLoot = {}, run = function(self, lootInfo) self.slotsToLoot = {} for slot, item in pairs(lootInfo) do aura_env.debugLog("Loot slot: " .. slot .. " " .. item.item) self:runFilters(slot) end aura_env.debugLog("Slots to loot: " .. #self.slotsToLoot) aura_env.debugLog(self.slotsToLoot) for i = #self.slotsToLoot, 1, -1 do local slot = self.slotsToLoot[i] aura_env.debugLog("Looting slot (iterator): " .. slot) doLoot(slot) end end, runFilters = function(self, slot) for k, filter in pairs(self.filters) do if (filter:filter(slot)) then -- Might be good to, instead of just adding slot to a list, add an object with info about the item and the slot containing it so each filter can dictate the item name and icon self.slotsToLoot[#self.slotsToLoot + 1] = slot return end end end } aura_env.debugLog = function(obj) if (debug) then print(GetTime()) DevTools_Dump(obj) print() end end aura_env.skills = { --Warrior [1] = { --Armor Skills ["Cloth"] = 0, ["Leather"] = 0, ["Mail"] = 0, ["Plate"] = 1, ["Shields"] = 1, --Weapon Skills ["One-Handed Axes"] = 1, ["Two-Handed Axes"] = 1, ["Bows"] = 1, ["Guns"] = 1, ["One-Handed Maces"] = 1, ["Two-Handed Maces"] = 1, ["Polearms"] = 1, ["One-Handed Swords"] = 1, ["Two-Handed Swords"] = 1, ["Warglaives"] = 1, ["Staves"] = 1, ["Fist Weapons"] = 1, ["Daggers"] = 1, ["Crossbows"] = 1, ["Wands"] = 0, }, --Paladin [2] = { --Armor Skills ["Cloth"] = 0, ["Leather"] = 0, ["Mail"] = 0, ["Plate"] = 1, ["Shields"] = 1, --Weapon Skills ["One-Handed Axes"] = 1, ["Two-Handed Axes"] = 1, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 1, ["Two-Handed Maces"] = 1, ["Polearms"] = 1, ["One-Handed Swords"] = 1, ["Two-Handed Swords"] = 1, ["Warglaives"] = 0, ["Staves"] = 0, ["Fist Weapons"] = 0, ["Daggers"] = 0, ["Crossbows"] = 0, ["Wands"] = 0, }, --Hunter [3] = { --Armor Skills ["Cloth"] = 0, ["Leather"] = 0, ["Mail"] = 1, ["Plate"] = 0, ["Shields"] = 0, --Weapon Skills ["One-Handed Axes"] = 1, ["Two-Handed Axes"] = 1, ["Bows"] = 1, ["Guns"] = 1, ["One-Handed Maces"] = 0, ["Two-Handed Maces"] = 0, ["Polearms"] = 1, ["One-Handed Swords"] = 1, ["Two-Handed Swords"] = 1, ["Warglaives"] = 0, ["Staves"] = 1, ["Fist Weapons"] = 1, ["Daggers"] = 1, ["Crossbows"] = 1, ["Wands"] = 0, }, --Rogue [4] = { --Armor Skills ["Cloth"] = 0, ["Leather"] = 1, ["Mail"] = 0, ["Plate"] = 0, ["Shields"] = 0, --Weapon Skills ["One-Handed Axes"] = 1, ["Two-Handed Axes"] = 0, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 1, ["Two-Handed Maces"] = 0, ["Polearms"] = 0, ["One-Handed Swords"] = 1, ["Two-Handed Swords"] = 0, ["Warglaives"] = 0, ["Staves"] = 0, ["Fist Weapons"] = 1, ["Daggers"] = 1, ["Crossbows"] = 0, ["Wands"] = 0, }, --Priest [5] = { --Armor Skills ["Cloth"] = 1, ["Leather"] = 0, ["Mail"] = 0, ["Plate"] = 0, ["Shields"] = 0, --Weapon Skills ["One-Handed Axes"] = 0, ["Two-Handed Axes"] = 0, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 1, ["Two-Handed Maces"] = 0, ["Polearms"] = 0, ["One-Handed Swords"] = 0, ["Two-Handed Swords"] = 0, ["Warglaives"] = 0, ["Staves"] = 1, ["Fist Weapons"] = 0, ["Daggers"] = 1, ["Crossbows"] = 0, ["Wands"] = 1, }, --Death Knight [6] = { --Armor Skills ["Cloth"] = 0, ["Leather"] = 0, ["Mail"] = 0, ["Plate"] = 1, ["Shields"] = 0, --Weapon Skills ["One-Handed Axes"] = 1, ["Two-Handed Axes"] = 1, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 1, ["Two-Handed Maces"] = 1, ["Polearms"] = 1, ["One-Handed Swords"] = 1, ["Two-Handed Swords"] = 1, ["Warglaives"] = 0, ["Staves"] = 0, ["Fist Weapons"] = 0, ["Daggers"] = 0, ["Crossbows"] = 0, ["Wands"] = 0, }, --Shaman [7] = { --Armor Skills ["Cloth"] = 0, ["Leather"] = 0, ["Mail"] = 1, ["Plate"] = 0, ["Shields"] = 1, --Weapon Skills ["One-Handed Axes"] = 1, ["Two-Handed Axes"] = 0, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 1, ["Two-Handed Maces"] = 0, ["Polearms"] = 0, ["One-Handed Swords"] = 0, ["Two-Handed Swords"] = 0, ["Warglaives"] = 0, ["Staves"] = 1, ["Fist Weapons"] = 1, ["Daggers"] = 1, ["Crossbows"] = 0, ["Wands"] = 0, }, --Mage [8] = { --Armor Skills ["Cloth"] = 1, ["Leather"] = 0, ["Mail"] = 0, ["Plate"] = 0, ["Shields"] = 0, --Weapon Skills ["One-Handed Axes"] = 0, ["Two-Handed Axes"] = 0, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 0, ["Two-Handed Maces"] = 0, ["Polearms"] = 0, ["One-Handed Swords"] = 1, ["Two-Handed Swords"] = 0, ["Warglaives"] = 0, ["Staves"] = 1, ["Fist Weapons"] = 0, ["Daggers"] = 1, ["Crossbows"] = 0, ["Wands"] = 1, }, --Warlock [9] = { --Armor Skills ["Cloth"] = 1, ["Leather"] = 0, ["Mail"] = 0, ["Plate"] = 0, ["Shields"] = 0, --Weapon Skills ["One-Handed Axes"] = 0, ["Two-Handed Axes"] = 0, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 0, ["Two-Handed Maces"] = 0, ["Polearms"] = 0, ["One-Handed Swords"] = 1, ["Two-Handed Swords"] = 0, ["Warglaives"] = 0, ["Staves"] = 1, ["Fist Weapons"] = 0, ["Daggers"] = 1, ["Crossbows"] = 0, ["Wands"] = 1, }, --Monk [10] = { --Armor Skills ["Cloth"] = 0, ["Leather"] = 1, ["Mail"] = 0, ["Plate"] = 1, ["Shields"] = 1, --Weapon Skills ["One-Handed Axes"] = 1, ["Two-Handed Axes"] = 0, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 1, ["Two-Handed Maces"] = 0, ["Polearms"] = 1, ["One-Handed Swords"] = 1, ["Two-Handed Swords"] = 0, ["Warglaives"] = 0, ["Staves"] = 1, ["Fist Weapons"] = 1, ["Daggers"] = 0, ["Crossbows"] = 0, ["Wands"] = 0, }, --Druid [11] = { --Armor Skills ["Cloth"] = 0, ["Leather"] = 1, ["Mail"] = 0, ["Plate"] = 0, ["Shields"] = 0, --Weapon Skills ["One-Handed Axes"] = 0, ["Two-Handed Axes"] = 0, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 1, ["Two-Handed Maces"] = 0, ["Polearms"] = 1, ["One-Handed Swords"] = 0, ["Two-Handed Swords"] = 0, ["Warglaives"] = 0, ["Staves"] = 1, ["Fist Weapons"] = 1, ["Daggers"] = 1, ["Crossbows"] = 0, ["Wands"] = 0, }, --Demon Hunter [12] = { --Armor Skills ["Cloth"] = 0, ["Leather"] = 1, ["Mail"] = 0, ["Plate"] = 0, ["Shields"] = 0, --Weapon Skills ["One-Handed Axes"] = 1, ["Two-Handed Axes"] = 0, ["Bows"] = 0, ["Guns"] = 0, ["One-Handed Maces"] = 0, ["Two-Handed Maces"] = 0, ["Polearms"] = 0, ["One-Handed Swords"] = 1, ["Two-Handed Swords"] = 0, ["Warglaives"] = 1, ["Staves"] = 0, ["Fist Weapons"] = 1, ["Daggers"] = 0, ["Crossbows"] = 0, ["Wands"] = 0, }, } aura_env.qualityColors = { "\124cff9d9d9d", -- Poor "\124cffffffff", -- Common "\124cff1eff00", -- Uncommon "\124cff0070dd", -- Rare "\124cffa335ee", -- Epic "\124cffff8000", -- Legendary "\124cffe6cc80", -- Artifact "\124cff00ccff", -- Heirloom }