diff --git a/ls_UI/core/utils.lua b/ls_UI/core/utils.lua index cdb21bb6..0a4927dc 100644 --- a/ls_UI/core/utils.lua +++ b/ls_UI/core/utils.lua @@ -485,72 +485,11 @@ do end end - do - local ARMOR_SLOTS = {1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} - local X2_INVTYPES = { - INVTYPE_2HWEAPON = true, - INVTYPE_RANGEDRIGHT = true, - INVTYPE_RANGED = true, - } - local X2_EXCEPTIONS = { - [2] = 19, -- wands, use INVTYPE_RANGEDRIGHT, but are 1H - } - - function E:GetUnitAverageItemLevel(unit) - if UnitIsUnit(unit, "player") then - return m_floor(select(2, GetAverageItemLevel())) - else - local isOK, total, link = true, 0 - - -- Armour - for _, id in next, ARMOR_SLOTS do - link = GetInventoryItemLink(unit, id) - if link then - local cur = GetDetailedItemLevelInfo(link) - if cur and cur > 0 then - total = total + cur - end - elseif GetInventoryItemTexture(unit, id) then - isOK = false - end - end - - -- Main hand - local mainItemLevel, mainQuality, mainEquipLoc, mainItemClass, mainItemSubClass, _ = 0 - link = GetInventoryItemLink(unit, 16) - if link then - mainItemLevel = GetDetailedItemLevelInfo(link) - _, _, mainQuality, _, _, _, _, _, mainEquipLoc, _, _, mainItemClass, mainItemSubClass = GetItemInfo(link) - elseif GetInventoryItemTexture(unit, 16) then - isOK = false - end - - -- Off hand - local offItemLevel, offEquipLoc = 0 - link = GetInventoryItemLink(unit, 17) - if link then - offItemLevel = GetDetailedItemLevelInfo(link) - _, _, _, _, _, _, _, _, offEquipLoc = GetItemInfo(link) - elseif GetInventoryItemTexture(unit, 17) then - isOK = false - end - - if mainQuality == 6 or (not offEquipLoc and X2_INVTYPES[mainEquipLoc] and X2_EXCEPTIONS[mainItemClass] ~= mainItemSubClass and GetInspectSpecialization(unit) ~= 72) then - mainItemLevel = m_max(mainItemLevel, offItemLevel) - total = total + mainItemLevel * 2 - else - total = total + mainItemLevel + offItemLevel - end - - -- at the beginning of an arena match no info might be available, - -- so despite having equipped gear a person may appear naked - if total == 0 then - isOK = false - end - - -- print("|cffffd200" .. UnitName(unit) .. "|r", "total:", total, "cur:", m_floor(total / 16), isOK and "|cff11ff11SUCCESS!|r" or "|cffff1111FAIL!|r") - return isOK and m_floor(total / 16) - end + function E:GetUnitAverageItemLevel(unit) + if UnitIsUnit(unit, "player") then + return m_floor(select(2, GetAverageItemLevel())) + else + return C_PaperDollInfo.GetInspectItemLevel(unit) end end