Rework auto loot
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
-- LOOT_READY
|
||||
function(e)
|
||||
local lootInfo = GetLootInfo()
|
||||
aura_env.filterService:run(lootInfo)
|
||||
print(aura_env.filterService)
|
||||
aura_env.FilterService.Run(lootInfo)
|
||||
CloseLoot()
|
||||
end
|
||||
|
@@ -3,85 +3,86 @@ if not WeakAurasSaved then WeakAurasSaved = {} end
|
||||
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
||||
if not WeakAurasSaved.Cyka.ItemCache then WeakAurasSaved.Cyka.ItemCache = {} end
|
||||
|
||||
-- make blood of sargeras filter
|
||||
-- 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
|
||||
---@param slot number
|
||||
---@return string
|
||||
local function getItemLink(slot)
|
||||
aura_env.debugLog("getItemLink " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return "" end
|
||||
return GetLootSlotLink(slot)
|
||||
end
|
||||
---@param slot number
|
||||
---@return string
|
||||
local function getItemName(slot)
|
||||
aura_env.debugLog("getItemName " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return "" end
|
||||
return select(2, GetLootSlotInfo(slot))
|
||||
end
|
||||
---@param slot number
|
||||
---@return string
|
||||
local function getItemType(slot)
|
||||
aura_env.debugLog("getItemType " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return "" end
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(6, GetItemInfo(itemLink))
|
||||
end
|
||||
---@param slot number
|
||||
---@return string
|
||||
local function getItemSubtype(slot)
|
||||
aura_env.debugLog("getItemSubtype " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return "" end
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(7, GetItemInfo(itemLink))
|
||||
end
|
||||
---@param slot number
|
||||
---@return number
|
||||
local function getItemLevel(slot)
|
||||
aura_env.debugLog("getItemLevel " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return 0 end
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(4, GetItemInfo(itemLink))
|
||||
end
|
||||
---The vendor price in copper, or 0 for items that cannot be sold
|
||||
---@param slot number
|
||||
---@return number
|
||||
local function getItemValue(slot)
|
||||
aura_env.debugLog("getItemValue " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return 0 end
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(11, GetItemInfo(itemLink))
|
||||
end
|
||||
---@param slot number
|
||||
---@return number
|
||||
local function getItemQuantity(slot)
|
||||
aura_env.debugLog("getItemQuantity " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return 0 end
|
||||
return select(3, GetLootSlotInfo(slot))
|
||||
end
|
||||
---@param slot number
|
||||
---@return Enum.ItemQuality
|
||||
local function getItemQuality(slot)
|
||||
aura_env.debugLog("getItemQuality " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return Enum.ItemQuality.Poor end
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(3, GetItemInfo(itemLink))
|
||||
end
|
||||
---@param slot number
|
||||
---@return string
|
||||
local function getItemEquipLocation(slot)
|
||||
aura_env.debugLog("getItemEquipLocation " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return "" end
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(9, GetItemInfo(itemLink))
|
||||
end
|
||||
---@param slot number
|
||||
---@return number
|
||||
local function getItemIcon(slot)
|
||||
aura_env.debugLog("getItemIcon " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return 0 end
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(10, GetItemInfo(itemLink))
|
||||
end
|
||||
---@param slot number
|
||||
---@return number
|
||||
local function getBindType(slot)
|
||||
aura_env.debugLog("getBindType " .. tostring(slot))
|
||||
if (slot == nil) then return nil end
|
||||
if slot == nil then return 0 end
|
||||
local itemLink = getItemLink(slot)
|
||||
if (itemLink == nil) then return nil end
|
||||
return select(14, GetItemInfo(itemLink)) or 0
|
||||
return select(14, GetItemInfo(itemLink))
|
||||
end
|
||||
|
||||
|
||||
---@param slot number
|
||||
---@return nil
|
||||
local doLoot = function(slot)
|
||||
aura_env.debugLog("Looting slot: " .. tostring(slot))
|
||||
LootSlot(slot)
|
||||
|
||||
local itemIcon = getItemIcon(slot) or 134400
|
||||
@@ -97,367 +98,319 @@ local doLoot = function(slot)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local goldFilter = {
|
||||
enabled = true,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Gold filter; slot: " .. tostring(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
|
||||
aura_env.debugLog("Gold filter fail " .. tostring(itemName))
|
||||
end
|
||||
end
|
||||
}
|
||||
local orderResourcesFilter = {
|
||||
enabled = true,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Resource filter; slot: " .. tostring(slot))
|
||||
local itemName = getItemName(slot)
|
||||
if (itemName and itemName:match("Order Resources")) then
|
||||
aura_env.debugLog("Order resource filter pass")
|
||||
return true
|
||||
end
|
||||
aura_env.debugLog("Order resource filter fail " .. tostring(itemName))
|
||||
end
|
||||
end
|
||||
}
|
||||
local mountFilter = {
|
||||
enabled = true,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Mount filter; slot: " .. tostring(slot))
|
||||
local itemType = getItemType(slot)
|
||||
if (itemType and itemType == "Mount") then
|
||||
aura_env.debugLog("Mount filter pass")
|
||||
return true
|
||||
end
|
||||
aura_env.debugLog("Mount filter fail " .. tostring(itemType))
|
||||
end
|
||||
end
|
||||
}
|
||||
local ilvlFilter = {
|
||||
enabled = true,
|
||||
ilvlThreshold = 700,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("ILvl filter; slot: " .. tostring(slot))
|
||||
local itemLevel = getItemLevel(slot)
|
||||
if (itemLevel and itemLevel > self.ilvlThreshold) then
|
||||
aura_env.debugLog("Item level filter pass")
|
||||
return true
|
||||
end
|
||||
aura_env.debugLog("Item level filter fail " .. tostring(itemLevel))
|
||||
end
|
||||
end
|
||||
}
|
||||
local professionFilter = {
|
||||
enabled = true,
|
||||
herbs = true,
|
||||
cloth = true,
|
||||
ore = false,
|
||||
leather = false,
|
||||
cooking = true,
|
||||
inscription = true,
|
||||
enchanting = true,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Profession filter; slot: " .. tostring(slot))
|
||||
local itemType = getItemType(slot)
|
||||
local itemSubtype = getItemSubtype(slot)
|
||||
if (itemType and itemType == "Tradeskill") then
|
||||
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)
|
||||
or (itemSubtype == "Inscription" and self.inscription)
|
||||
or (itemSubtype == "Enchanting" and self.enchanting)) then
|
||||
aura_env.debugLog("Profession filter pass")
|
||||
return true
|
||||
end
|
||||
end
|
||||
aura_env.debugLog("Profession filter fail " .. tostring(itemType) .. " " .. tostring(itemSubtype))
|
||||
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: " .. tostring(slot))
|
||||
local itemValue = getItemValue(slot)
|
||||
|
||||
if (self.applyThresholdToItemStack) then
|
||||
local itemQuantity = getItemQuantity(slot)
|
||||
aura_env.debugLog("There exist " .. tostring(itemQuantity) .. " items in slot " .. tostring(slot))
|
||||
itemValue = itemValue * itemQuantity
|
||||
end
|
||||
|
||||
if (itemValue and itemValue > self.valueThreshold) then
|
||||
aura_env.debugLog("Value filter pass")
|
||||
return true
|
||||
end
|
||||
aura_env.debugLog("Value filter fail " .. tostring(itemValue))
|
||||
end
|
||||
end
|
||||
}
|
||||
local greyValueFilter = {
|
||||
enabled = true,
|
||||
-- Set threshold to 0 to loot all greys
|
||||
valueThreshold = 4 * 100 * 100,
|
||||
applyThresholdToItemStack = false,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Grey value filter; slot: " .. tostring(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 " .. tostring(itemQuantity) .. " items in slot " .. tostring(slot))
|
||||
itemValue = itemValue * itemQuantity
|
||||
end
|
||||
|
||||
if (itemValue and itemValue > self.valueThreshold) then
|
||||
aura_env.debugLog("Grey value filter pass")
|
||||
return true
|
||||
end
|
||||
aura_env.debugLog("Grey value filter fail " .. tostring(itemValue))
|
||||
end
|
||||
aura_env.debugLog("Grey value filter fail " .. tostring(itemQuality))
|
||||
end
|
||||
end
|
||||
}
|
||||
local questItemFilter = {
|
||||
enabled = true,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Quest item filter; slot: " .. tostring(slot))
|
||||
local itemType = getItemType(slot)
|
||||
local itemSubtype = getItemSubtype(slot)
|
||||
if (itemType and itemSubtype and itemType == "Quest" and itemSubtype == "Quest") then
|
||||
aura_env.debugLog("Quest item filter pass")
|
||||
return true
|
||||
end
|
||||
aura_env.debugLog("Quest item filter fails " .. tostring(itemType) .. " " .. tostring(itemSubtype))
|
||||
end
|
||||
end
|
||||
}
|
||||
local classGearFilter = {
|
||||
enabled = true,
|
||||
ilvlThreshold = 800,
|
||||
qualityThreshold = 2,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("BoE filter; slot: " .. tostring(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
|
||||
aura_env.debugLog("Class gear filter fails " .. tostring(itemType) .. " " .. tostring(itemEquipLoc))
|
||||
end
|
||||
end
|
||||
}
|
||||
local azeriteFilter = {
|
||||
enabled = true,
|
||||
ilvlThreshold = 800,
|
||||
qualityThreshold = 2,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Azerite filter; slot: " .. tostring(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
|
||||
aura_env.debugLog("Azerite filter fails " .. tostring(itemType) .. " " .. tostring(itemSubtype) .. " " .. tostring(itemQuality))
|
||||
end
|
||||
end
|
||||
}
|
||||
local arguniteFilter = {
|
||||
enabled = true,
|
||||
qualityThreshold = 1,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Argunite filter; slot: " .. tostring(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
|
||||
aura_env.debugLog("Argunite filter failed " .. tostring(itemName) .. " " .. tostring(itemQuality))
|
||||
end
|
||||
end
|
||||
}
|
||||
local ancientManaFilter = {
|
||||
enabled = true,
|
||||
qualityThreshold = 1,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Ancient mana filter; slot: " .. tostring(slot))
|
||||
local itemName = getItemName(slot)
|
||||
if (itemName and itemName:match("Ancient Mana")) then
|
||||
aura_env.debugLog("Ancient mana filter pass")
|
||||
return true
|
||||
end
|
||||
aura_env.debugLog("Ancient mana filter fail " .. tostring(itemName))
|
||||
end
|
||||
end
|
||||
}
|
||||
local reicpeFilter = {
|
||||
enabled = true,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Recipe filter; slot: " .. tostring(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
|
||||
aura_env.debugLog("Recipe filter fail " .. tostring(itemName))
|
||||
end
|
||||
end
|
||||
}
|
||||
local bloodOfSargerasFilter = {
|
||||
enabled = true,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Blood of Sargeras filter; slot: " .. tostring(slot))
|
||||
local itemName = getItemName(slot)
|
||||
if (itemName and itemName:match("Sargeras")) then
|
||||
aura_env.debugLog("Blood of Sargeras filter pass")
|
||||
return true
|
||||
end
|
||||
aura_env.debugLog("Blood of Sargeras filter fail " .. tostring(itemName))
|
||||
end
|
||||
end
|
||||
}
|
||||
local bloodhunerQuarryFilter = {
|
||||
enabled = true,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("Bloodhunter's Quarry filter; slot: " .. tostring(slot))
|
||||
local itemName = getItemName(slot)
|
||||
if (itemName and itemName:match("Bloodhunter")) then
|
||||
aura_env.debugLog("Bloodhunter's Quarry filter pass")
|
||||
return true
|
||||
end
|
||||
aura_env.debugLog("Bloodhunter's Quarry filter fail " .. tostring(itemName))
|
||||
end
|
||||
end
|
||||
}
|
||||
local boeFilter = {
|
||||
enabled = true,
|
||||
ilvlThreshold = 800,
|
||||
qualityThreshold = 1,
|
||||
filter = function(self, slot)
|
||||
if (self.enabled) then
|
||||
aura_env.debugLog("BoE filter; slot: " .. tostring(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 bindType = getBindType(slot)
|
||||
|
||||
if (itemLevel and itemQuality and bindType and itemLevel > self.ilvlThreshold and itemQuality > self.qualityThreshold and bindType == 1) then
|
||||
aura_env.debugLog("BoE filter pass")
|
||||
return true
|
||||
end
|
||||
end
|
||||
aura_env.debugLog("BoE filter fails " .. tostring(itemType) .. " " .. tostring(itemEquipLoc))
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
aura_env.filterService = {
|
||||
filters = {
|
||||
goldFilter,
|
||||
orderResourcesFilter,
|
||||
mountFilter,
|
||||
ilvlFilter,
|
||||
professionFilter,
|
||||
valueFilter,
|
||||
greyValueFilter,
|
||||
questItemFilter,
|
||||
classGearFilter,
|
||||
azeriteFilter,
|
||||
arguniteFilter,
|
||||
ancientManaFilter,
|
||||
reicpeFilter,
|
||||
bloodOfSargerasFilter,
|
||||
boeFilter,
|
||||
bloodhunerQuarryFilter,
|
||||
},
|
||||
slotsToLoot = {},
|
||||
run = function(self, lootInfo)
|
||||
self.slotsToLoot = {}
|
||||
for slot, item in pairs(lootInfo) do
|
||||
aura_env.debugLog("Loot slot: " .. tostring(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
|
||||
---@class Filter
|
||||
---@field enabled boolean
|
||||
---@field requires table<string, fun(slot: number): string|number|boolean> | nil
|
||||
---@field filter fun(slot: number, provided: table<string, string|number|boolean>): boolean
|
||||
Filter = {
|
||||
---@param enabled boolean
|
||||
---@param requires table<string, fun(slot: number): string|number|boolean> | nil
|
||||
---@param filter fun(slot: number, provided: table<string, string|number|boolean>): boolean
|
||||
---@return Filter
|
||||
new = function(enabled, requires, filter)
|
||||
local self = setmetatable({}, {
|
||||
__index = Filter
|
||||
})
|
||||
self.enabled = enabled
|
||||
self.requires = requires
|
||||
self.filter = filter
|
||||
return self
|
||||
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
|
||||
|
||||
---@param self Filter
|
||||
---@param slot number
|
||||
---@return boolean
|
||||
Run = function(self, slot)
|
||||
---@type table<string, string|number|boolean>
|
||||
local provided = {}
|
||||
if self.requires then
|
||||
for k, v in pairs(self.requires) do
|
||||
provided[k] = v(slot)
|
||||
end
|
||||
end
|
||||
return self.filter(slot, provided)
|
||||
end
|
||||
}
|
||||
|
||||
aura_env.debugLog = function(obj)
|
||||
if (debug) then
|
||||
print(GetTime())
|
||||
DevTools_Dump(obj)
|
||||
print()
|
||||
local goldFilter = Filter.new(true,
|
||||
{ ["name"] = getItemName },
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if string.find(provided.name, "Gold") or
|
||||
string.find(provided.name, "Silver") or
|
||||
string.find(provided.name, "Copper") then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local orderResourcesFilter = Filter.new(true,
|
||||
{ ["name"] = getItemName },
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if string.find(provided.name, "Order Resources") then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local mountFilter = Filter.new(true,
|
||||
{ ["type"] = getItemType },
|
||||
function(slot, provided)
|
||||
---@cast provided { type: string }
|
||||
if provided.type == "Mount" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local ilvlFilter = Filter.new(true,
|
||||
{ ["ilvl"] = getItemLevel },
|
||||
function(slot, provided)
|
||||
---@cast provided { ilvl: number }
|
||||
if provided.ilvl and provided.ilvl > 800 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local professionFilter = Filter.new(true,
|
||||
{
|
||||
["type"] = getItemType,
|
||||
["subtype"] = getItemSubtype
|
||||
},
|
||||
function(slot, provided)
|
||||
---@cast provided { type: string, subtype: string }
|
||||
|
||||
local enabled = {
|
||||
["Herb"] = true,
|
||||
["Leather"] = true,
|
||||
["Cloth"] = true,
|
||||
["Ore"] = false,
|
||||
["Cooking"] = true,
|
||||
["Inscription"] = true,
|
||||
["Enchanting"] = true,
|
||||
}
|
||||
|
||||
if provided.type == "Tradeskill" then
|
||||
if enabled[provided.subtype] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local valueFilter = Filter.new(true,
|
||||
{
|
||||
["value"] = getItemValue,
|
||||
["quantity"] = getItemQuality
|
||||
},
|
||||
function(slot, provided)
|
||||
---@cast provided { value: number, quantity: number }
|
||||
|
||||
local valueThreshold = 35 * 100 * 100
|
||||
local applyValueTostack = false
|
||||
|
||||
local value = provided.value
|
||||
if applyValueTostack then value = value * provided.quantity end
|
||||
|
||||
if value > valueThreshold then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local greyValueFilter = Filter.new(true,
|
||||
{
|
||||
["quality"] = getItemQuality,
|
||||
["value"] = getItemValue,
|
||||
["quantity"] = getItemQuantity
|
||||
},
|
||||
function(slot, provided)
|
||||
---@cast provided { quality: number, value: number, quantity: number }
|
||||
|
||||
local valueThreshold = 4 * 100 * 100
|
||||
local applyValueTostack = false
|
||||
|
||||
if provided.quality == 0 then
|
||||
local value = provided.value
|
||||
if applyValueTostack then value = value * provided.quantity end
|
||||
|
||||
if value > valueThreshold then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local questItemFilter = Filter.new(true,
|
||||
{
|
||||
["type"] = getItemType,
|
||||
["subtype"] = getItemSubtype
|
||||
},
|
||||
function(slot, provided)
|
||||
---@cast provided { type: string, subtype: string }
|
||||
if provided.type == "Quest" and provided.subtype == "Quest" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local classGearFilter = Filter.new(true,
|
||||
{
|
||||
["ilvl"] = getItemLevel,
|
||||
["quality"] = getItemQuality,
|
||||
["type"] = getItemType,
|
||||
["subtype"] = getItemSubtype,
|
||||
["equiploc"] = getItemEquipLocation
|
||||
},
|
||||
function(slot, provided)
|
||||
---@cast provided { ilvl: number, quality: number, type: string, subtype: string, equiploc: string }
|
||||
|
||||
local ilvlThreshold = 800
|
||||
local qualityThreshold = 2
|
||||
|
||||
local isEquippable = aura_env.skills[select(3, UnitClass("player"))][provided.subtype] == 1
|
||||
|
||||
if isEquippable and provided.ilvl > ilvlThreshold and provided.quality > qualityThreshold then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local arguniteFilter = Filter.new(true,
|
||||
{
|
||||
["name"] = getItemName,
|
||||
["quality"] = getItemQuality
|
||||
},
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string, quality: number }
|
||||
if string.find(provided.name, "Argunite") and provided.quality > 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local ancientManaFilter = Filter.new(true,
|
||||
{ ["name"] = getItemName },
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if string.find(provided.name, "Ancient Mana") then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local reicpeFilter = Filter.new(false,
|
||||
{ ["name"] = getItemName },
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if string.find(provided.name, "Recipe") or string.find(provided.name, "Technique") then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local bloodOfSargerasFilter = Filter.new(true,
|
||||
{ ["name"] = getItemName },
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if provided.name == "Blood of Sargeras" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local bloodhunerQuarryFilter = Filter.new(true,
|
||||
{ ["name"] = getItemName },
|
||||
function(slot, provided)
|
||||
---@cast provided { name: string }
|
||||
if provided.name == "Bloodhunter's Quarry" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
local boeFilter = Filter.new(true,
|
||||
{
|
||||
["ilvl"] = getItemLevel,
|
||||
["type"] = getItemType,
|
||||
["quality"] = getItemQuality,
|
||||
["equiploc"] = getItemEquipLocation,
|
||||
["bindtype"] = getBindType
|
||||
},
|
||||
function(slot, provided)
|
||||
---@cast provided { ilvl: number, type: string, quality: number, equiploc: string, bindtype: number }
|
||||
|
||||
local ilvlThreshold = 800
|
||||
local qualityThreshold = 1
|
||||
|
||||
local itemType = provided.type
|
||||
local itemEquipLoc = provided.equiploc
|
||||
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 = provided.ilvl
|
||||
local itemQuality = provided.quality
|
||||
local bindType = provided.bindtype
|
||||
|
||||
if itemLevel > ilvlThreshold and itemQuality > qualityThreshold and bindType == 1 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end)
|
||||
|
||||
-- local azeriteFilter = {
|
||||
-- enabled = true,
|
||||
-- ilvlThreshold = 800,
|
||||
-- qualityThreshold = 2,
|
||||
-- filter = function(self, slot)
|
||||
-- if self.enabled the
|
||||
-- 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 the
|
||||
-- return true
|
||||
-- en
|
||||
-- tostring(itemType) .. " " .. tostring(itemSubtype) .. " " .. tostring(itemQuality))
|
||||
-- end
|
||||
-- end
|
||||
-- }
|
||||
|
||||
|
||||
---@type table<Filter>
|
||||
local filters = {
|
||||
goldFilter,
|
||||
orderResourcesFilter,
|
||||
mountFilter,
|
||||
ilvlFilter,
|
||||
professionFilter,
|
||||
valueFilter,
|
||||
greyValueFilter,
|
||||
questItemFilter,
|
||||
classGearFilter,
|
||||
arguniteFilter,
|
||||
ancientManaFilter,
|
||||
reicpeFilter,
|
||||
bloodOfSargerasFilter,
|
||||
boeFilter,
|
||||
bloodhunerQuarryFilter,
|
||||
}
|
||||
|
||||
---@class FilterService
|
||||
aura_env.FilterService = {
|
||||
---@param lootInfo table<number>
|
||||
Run = function(lootInfo)
|
||||
---@type table<number>
|
||||
local slotsToLoot = {}
|
||||
for slot, item in pairs(lootInfo) do
|
||||
for _, filter in pairs(filters) do
|
||||
if filter:Run(slot) then
|
||||
slotsToLoot[#slotsToLoot + 1] = slot
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
aura_env.FilterService.doLoot(slotsToLoot)
|
||||
end,
|
||||
|
||||
doLoot = function(slots)
|
||||
for i = #slots, 1, -1 do
|
||||
doLoot(slots[i])
|
||||
end
|
||||
end
|
||||
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
||||
if not WeakAurasSaved.Cyka.Log then WeakAurasSaved.Cyka.Log = {} end
|
||||
if not WeakAurasSaved.Cyka.Log.AutoLoot then WeakAurasSaved.Cyka.Log.AutoLoot = {} end
|
||||
WeakAurasSaved.Cyka.Log.AutoLoot[#WeakAurasSaved.Cyka.Log.AutoLoot + 1] = obj
|
||||
end
|
||||
}
|
||||
|
||||
aura_env.skills = {
|
||||
--Warrior
|
||||
@@ -770,4 +723,4 @@ aura_env.qualityColors = {
|
||||
"\124cffff8000", -- Legendary
|
||||
"\124cffe6cc80", -- Artifact
|
||||
"\124cff00ccff", -- Heirloom
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ function(allstates, e)
|
||||
if CanMerchantRepair() == true then RepairAllItems() end
|
||||
|
||||
for container = 0, 4 do
|
||||
for slot = 1, GetContainerNumSlots(container) do
|
||||
for slot = 1, C_Container.GetContainerNumSlots(container) do
|
||||
aura_env.filterService:run(container, slot)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user