Rework auto loot
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
-- LOOT_READY
|
-- LOOT_READY
|
||||||
function(e)
|
function(e)
|
||||||
local lootInfo = GetLootInfo()
|
local lootInfo = GetLootInfo()
|
||||||
aura_env.filterService:run(lootInfo)
|
print(aura_env.filterService)
|
||||||
|
aura_env.FilterService.Run(lootInfo)
|
||||||
CloseLoot()
|
CloseLoot()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,85 +3,86 @@ if not WeakAurasSaved then WeakAurasSaved = {} end
|
|||||||
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
||||||
if not WeakAurasSaved.Cyka.ItemCache then WeakAurasSaved.Cyka.ItemCache = {} end
|
if not WeakAurasSaved.Cyka.ItemCache then WeakAurasSaved.Cyka.ItemCache = {} end
|
||||||
|
|
||||||
-- make blood of sargeras filter
|
---@param slot number
|
||||||
-- itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType,itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType,expacID, setID, isCraftingReagent = GetItemInfo(slot)
|
---@return string
|
||||||
-- lootIcon, lootName, lootQuantity, currencyID, lootQuality, locked, isQuestItem, questID, isActive = GetLootSlotInfo(slot)
|
|
||||||
-- Link sometimes does not work
|
|
||||||
local function getItemLink(slot)
|
local function getItemLink(slot)
|
||||||
aura_env.debugLog("getItemLink " .. tostring(slot))
|
if slot == nil then return "" end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
return GetLootSlotLink(slot)
|
return GetLootSlotLink(slot)
|
||||||
end
|
end
|
||||||
|
---@param slot number
|
||||||
|
---@return string
|
||||||
local function getItemName(slot)
|
local function getItemName(slot)
|
||||||
aura_env.debugLog("getItemName " .. tostring(slot))
|
if slot == nil then return "" end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
return select(2, GetLootSlotInfo(slot))
|
return select(2, GetLootSlotInfo(slot))
|
||||||
end
|
end
|
||||||
|
---@param slot number
|
||||||
|
---@return string
|
||||||
local function getItemType(slot)
|
local function getItemType(slot)
|
||||||
aura_env.debugLog("getItemType " .. tostring(slot))
|
if slot == nil then return "" end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
local itemLink = getItemLink(slot)
|
local itemLink = getItemLink(slot)
|
||||||
if (itemLink == nil) then return nil end
|
|
||||||
return select(6, GetItemInfo(itemLink))
|
return select(6, GetItemInfo(itemLink))
|
||||||
end
|
end
|
||||||
|
---@param slot number
|
||||||
|
---@return string
|
||||||
local function getItemSubtype(slot)
|
local function getItemSubtype(slot)
|
||||||
aura_env.debugLog("getItemSubtype " .. tostring(slot))
|
if slot == nil then return "" end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
local itemLink = getItemLink(slot)
|
local itemLink = getItemLink(slot)
|
||||||
if (itemLink == nil) then return nil end
|
|
||||||
return select(7, GetItemInfo(itemLink))
|
return select(7, GetItemInfo(itemLink))
|
||||||
end
|
end
|
||||||
|
---@param slot number
|
||||||
|
---@return number
|
||||||
local function getItemLevel(slot)
|
local function getItemLevel(slot)
|
||||||
aura_env.debugLog("getItemLevel " .. tostring(slot))
|
if slot == nil then return 0 end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
local itemLink = getItemLink(slot)
|
local itemLink = getItemLink(slot)
|
||||||
if (itemLink == nil) then return nil end
|
|
||||||
return select(4, GetItemInfo(itemLink))
|
return select(4, GetItemInfo(itemLink))
|
||||||
end
|
end
|
||||||
|
---The vendor price in copper, or 0 for items that cannot be sold
|
||||||
|
---@param slot number
|
||||||
|
---@return number
|
||||||
local function getItemValue(slot)
|
local function getItemValue(slot)
|
||||||
aura_env.debugLog("getItemValue " .. tostring(slot))
|
if slot == nil then return 0 end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
local itemLink = getItemLink(slot)
|
local itemLink = getItemLink(slot)
|
||||||
if (itemLink == nil) then return nil end
|
|
||||||
return select(11, GetItemInfo(itemLink))
|
return select(11, GetItemInfo(itemLink))
|
||||||
end
|
end
|
||||||
|
---@param slot number
|
||||||
|
---@return number
|
||||||
local function getItemQuantity(slot)
|
local function getItemQuantity(slot)
|
||||||
aura_env.debugLog("getItemQuantity " .. tostring(slot))
|
if slot == nil then return 0 end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
return select(3, GetLootSlotInfo(slot))
|
return select(3, GetLootSlotInfo(slot))
|
||||||
end
|
end
|
||||||
|
---@param slot number
|
||||||
|
---@return Enum.ItemQuality
|
||||||
local function getItemQuality(slot)
|
local function getItemQuality(slot)
|
||||||
aura_env.debugLog("getItemQuality " .. tostring(slot))
|
if slot == nil then return Enum.ItemQuality.Poor end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
local itemLink = getItemLink(slot)
|
local itemLink = getItemLink(slot)
|
||||||
if (itemLink == nil) then return nil end
|
|
||||||
return select(3, GetItemInfo(itemLink))
|
return select(3, GetItemInfo(itemLink))
|
||||||
end
|
end
|
||||||
|
---@param slot number
|
||||||
|
---@return string
|
||||||
local function getItemEquipLocation(slot)
|
local function getItemEquipLocation(slot)
|
||||||
aura_env.debugLog("getItemEquipLocation " .. tostring(slot))
|
if slot == nil then return "" end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
local itemLink = getItemLink(slot)
|
local itemLink = getItemLink(slot)
|
||||||
if (itemLink == nil) then return nil end
|
|
||||||
return select(9, GetItemInfo(itemLink))
|
return select(9, GetItemInfo(itemLink))
|
||||||
end
|
end
|
||||||
|
---@param slot number
|
||||||
|
---@return number
|
||||||
local function getItemIcon(slot)
|
local function getItemIcon(slot)
|
||||||
aura_env.debugLog("getItemIcon " .. tostring(slot))
|
if slot == nil then return 0 end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
local itemLink = getItemLink(slot)
|
local itemLink = getItemLink(slot)
|
||||||
if (itemLink == nil) then return nil end
|
|
||||||
return select(10, GetItemInfo(itemLink))
|
return select(10, GetItemInfo(itemLink))
|
||||||
end
|
end
|
||||||
|
---@param slot number
|
||||||
|
---@return number
|
||||||
local function getBindType(slot)
|
local function getBindType(slot)
|
||||||
aura_env.debugLog("getBindType " .. tostring(slot))
|
if slot == nil then return 0 end
|
||||||
if (slot == nil) then return nil end
|
|
||||||
local itemLink = getItemLink(slot)
|
local itemLink = getItemLink(slot)
|
||||||
if (itemLink == nil) then return nil end
|
return select(14, GetItemInfo(itemLink))
|
||||||
return select(14, GetItemInfo(itemLink)) or 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param slot number
|
||||||
|
---@return nil
|
||||||
local doLoot = function(slot)
|
local doLoot = function(slot)
|
||||||
aura_env.debugLog("Looting slot: " .. tostring(slot))
|
|
||||||
LootSlot(slot)
|
LootSlot(slot)
|
||||||
|
|
||||||
local itemIcon = getItemIcon(slot) or 134400
|
local itemIcon = getItemIcon(slot) or 134400
|
||||||
@@ -97,312 +98,278 @@ local doLoot = function(slot)
|
|||||||
end
|
end
|
||||||
end
|
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,
|
||||||
|
|
||||||
local goldFilter = {
|
---@param self Filter
|
||||||
enabled = true,
|
---@param slot number
|
||||||
filter = function(self, slot)
|
---@return boolean
|
||||||
if (self.enabled) then
|
Run = function(self, slot)
|
||||||
aura_env.debugLog("Gold filter; slot: " .. tostring(slot))
|
---@type table<string, string|number|boolean>
|
||||||
local itemName = getItemName(slot)
|
local provided = {}
|
||||||
-- I guess it does not support OR in regex?
|
if self.requires then
|
||||||
-- itemName:match("%d+ ((Gold)|(Silver)|(Copper))")
|
for k, v in pairs(self.requires) do
|
||||||
if (itemname and itemName:match("%d+ Gold") or itemName:match("%d+ Silver") or itemName:match("%d+ Copper")) then
|
provided[k] = v(slot)
|
||||||
aura_env.debugLog("Gold filter pass")
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
aura_env.debugLog("Gold filter fail " .. tostring(itemName))
|
|
||||||
end
|
end
|
||||||
|
return self.filter(slot, provided)
|
||||||
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 goldFilter = Filter.new(true,
|
||||||
local itemQuantity = getItemQuantity(slot)
|
{ ["name"] = getItemName },
|
||||||
aura_env.debugLog("There exist " .. tostring(itemQuantity) .. " items in slot " .. tostring(slot))
|
function(slot, provided)
|
||||||
itemValue = itemValue * itemQuantity
|
---@cast provided { name: string }
|
||||||
end
|
if string.find(provided.name, "Gold") or
|
||||||
|
string.find(provided.name, "Silver") or
|
||||||
if (itemValue and itemValue > self.valueThreshold) then
|
string.find(provided.name, "Copper") then
|
||||||
aura_env.debugLog("Value filter pass")
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
aura_env.debugLog("Value filter fail " .. tostring(itemValue))
|
return false
|
||||||
end
|
end)
|
||||||
end
|
local orderResourcesFilter = Filter.new(true,
|
||||||
}
|
{ ["name"] = getItemName },
|
||||||
local greyValueFilter = {
|
function(slot, provided)
|
||||||
enabled = true,
|
---@cast provided { name: string }
|
||||||
-- Set threshold to 0 to loot all greys
|
if string.find(provided.name, "Order Resources") then
|
||||||
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
|
return true
|
||||||
end
|
end
|
||||||
aura_env.debugLog("Grey value filter fail " .. tostring(itemValue))
|
return false
|
||||||
end
|
end)
|
||||||
aura_env.debugLog("Grey value filter fail " .. tostring(itemQuality))
|
local mountFilter = Filter.new(true,
|
||||||
end
|
{ ["type"] = getItemType },
|
||||||
end
|
function(slot, provided)
|
||||||
}
|
---@cast provided { type: string }
|
||||||
local questItemFilter = {
|
if provided.type == "Mount" then
|
||||||
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
|
return true
|
||||||
end
|
end
|
||||||
aura_env.debugLog("Quest item filter fails " .. tostring(itemType) .. " " .. tostring(itemSubtype))
|
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
|
||||||
end
|
end
|
||||||
}
|
return false
|
||||||
local classGearFilter = {
|
end)
|
||||||
enabled = true,
|
local valueFilter = Filter.new(true,
|
||||||
ilvlThreshold = 800,
|
{
|
||||||
qualityThreshold = 2,
|
["value"] = getItemValue,
|
||||||
filter = function(self, slot)
|
["quantity"] = getItemQuality
|
||||||
if (self.enabled) then
|
},
|
||||||
aura_env.debugLog("BoE filter; slot: " .. tostring(slot))
|
function(slot, provided)
|
||||||
local itemType = getItemType(slot)
|
---@cast provided { value: number, quantity: number }
|
||||||
local itemEquipLoc = getItemEquipLocation(slot)
|
|
||||||
|
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"
|
if (itemType == "Armor"
|
||||||
or itemType == "Weapon"
|
or itemType == "Weapon"
|
||||||
or itemEquipLoc == "INVTYPE_FINGER"
|
or itemEquipLoc == "INVTYPE_FINGER"
|
||||||
or itemEquipLoc == "INVTYPE_TRINKET"
|
or itemEquipLoc == "INVTYPE_TRINKET"
|
||||||
or itemEquipLoc == "INVTYPE_CLOAK"
|
or itemEquipLoc == "INVTYPE_CLOAK"
|
||||||
or itemEquipLoc == "INVTYPE_NECK") then
|
or itemEquipLoc == "INVTYPE_NECK") then
|
||||||
local itemLevel = getItemLevel(slot)
|
local itemLevel = provided.ilvl
|
||||||
local itemQuality = getItemQuality(slot)
|
local itemQuality = provided.quality
|
||||||
local isEquippable = aura_env.skills[select(3, UnitClass("player"))][subtype] == 1
|
local bindType = provided.bindtype
|
||||||
|
|
||||||
if (isEquippable and itemLevel > self.ilvlThreshold and itemQuality > self.qualityThreshold) then
|
if itemLevel > ilvlThreshold and itemQuality > qualityThreshold and bindType == 1 then
|
||||||
aura_env.debugLog("Class gear filter pass")
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
aura_env.debugLog("Class gear filter fails " .. tostring(itemType) .. " " .. tostring(itemEquipLoc))
|
return false
|
||||||
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: " .. 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
|
-- local azeriteFilter = {
|
||||||
aura_env.debugLog("BoE filter pass")
|
-- enabled = true,
|
||||||
return true
|
-- ilvlThreshold = 800,
|
||||||
end
|
-- qualityThreshold = 2,
|
||||||
end
|
-- filter = function(self, slot)
|
||||||
aura_env.debugLog("BoE filter fails " .. tostring(itemType) .. " " .. tostring(itemEquipLoc))
|
-- if self.enabled the
|
||||||
end
|
-- local itemType = getItemType(slot)
|
||||||
end
|
-- 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
|
||||||
|
-- }
|
||||||
|
|
||||||
aura_env.filterService = {
|
|
||||||
filters = {
|
---@type table<Filter>
|
||||||
|
local filters = {
|
||||||
goldFilter,
|
goldFilter,
|
||||||
orderResourcesFilter,
|
orderResourcesFilter,
|
||||||
mountFilter,
|
mountFilter,
|
||||||
@@ -412,53 +379,39 @@ aura_env.filterService = {
|
|||||||
greyValueFilter,
|
greyValueFilter,
|
||||||
questItemFilter,
|
questItemFilter,
|
||||||
classGearFilter,
|
classGearFilter,
|
||||||
azeriteFilter,
|
|
||||||
arguniteFilter,
|
arguniteFilter,
|
||||||
ancientManaFilter,
|
ancientManaFilter,
|
||||||
reicpeFilter,
|
reicpeFilter,
|
||||||
bloodOfSargerasFilter,
|
bloodOfSargerasFilter,
|
||||||
boeFilter,
|
boeFilter,
|
||||||
bloodhunerQuarryFilter,
|
bloodhunerQuarryFilter,
|
||||||
},
|
}
|
||||||
slotsToLoot = {},
|
|
||||||
run = function(self, lootInfo)
|
---@class FilterService
|
||||||
self.slotsToLoot = {}
|
aura_env.FilterService = {
|
||||||
|
---@param lootInfo table<number>
|
||||||
|
Run = function(lootInfo)
|
||||||
|
---@type table<number>
|
||||||
|
local slotsToLoot = {}
|
||||||
for slot, item in pairs(lootInfo) do
|
for slot, item in pairs(lootInfo) do
|
||||||
aura_env.debugLog("Loot slot: " .. tostring(slot) .. " " .. item.item)
|
for _, filter in pairs(filters) do
|
||||||
self:runFilters(slot)
|
if filter:Run(slot) then
|
||||||
|
slotsToLoot[#slotsToLoot + 1] = slot
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
aura_env.debugLog("Slots to loot: " .. #self.slotsToLoot)
|
aura_env.FilterService.doLoot(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,
|
end,
|
||||||
runFilters = function(self, slot)
|
|
||||||
for k, filter in pairs(self.filters) do
|
doLoot = function(slots)
|
||||||
if (filter:filter(slot)) then
|
for i = #slots, 1, -1 do
|
||||||
-- 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
|
doLoot(slots[i])
|
||||||
self.slotsToLoot[#self.slotsToLoot + 1] = slot
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
aura_env.debugLog = function(obj)
|
|
||||||
if (debug) then
|
|
||||||
print(GetTime())
|
|
||||||
DevTools_Dump(obj)
|
|
||||||
print()
|
|
||||||
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 = {
|
aura_env.skills = {
|
||||||
--Warrior
|
--Warrior
|
||||||
[1] = {
|
[1] = {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ function(allstates, e)
|
|||||||
if CanMerchantRepair() == true then RepairAllItems() end
|
if CanMerchantRepair() == true then RepairAllItems() end
|
||||||
|
|
||||||
for container = 0, 4 do
|
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)
|
aura_env.filterService:run(container, slot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user