LibItemUpgradeInfo-1.0

LibItemUpgradeInfo-1.0 provides information about item upgrades applied to items.


Functions

:GetUpgradeID(itemString)

Arguments

itemString
String - An itemLink or itemString denoting the item

Returns

upgradeID
Number - The upgrade ID (possibly 0), or nil if the input is invalid or does not contain upgrade info


:GetCurrentUpgrade(id)

Returns the current upgrade level of the item, e.g. 1 for a 1/2 item.

Arguments

id
Number - The upgrade ID of the item (obtained via GetUpgradeID())

Returns

upgradeLevel
Number - The current upgrade level of the item, or nil if the item cannot be upgraded


:GetMaximumUpgrade(id)

Returns the maximum upgrade level of the item, e.g. 2 for a 1/2 item.

Arguments

id
Number - The upgrade ID of the item (obtained via GetUpgradeID())

Returns

upgradeLevel
Number - The maximum upgrade level of the item, or nil if the item cannot be upgraded


:GetItemLevelUpgrade(id)

Returns the item level increase that this upgrade is worth, e.g. 4 for a 1/2 item or 8 for a 2/2 item.

Arguments

id
Number - The upgrade ID of the item (obtained via GetUpgradeID())

Returns

ilvlDelta
Number - The item level increase of the item, or 0 if the item cannot be or has not been upgraded


:GetItemUpgradeInfo(itemString)

Returns the current upgrade level, maximum upgrade level, and item level increase for an item.

Arguments

itemString
String - An itemLink or itemString denoting the item

Returns

nil if the item is invalid or cannot be upgraded, otherwise:

curUpgradeLevel
Number - The current upgrade level of the item
maxUpgradeLevel
Number - The maximum upgrade level of the item
lvlDelta
Number - The item level increase of the item


:GetHeirloomTrueLevel(itemString)

Returns the true item level for an heirloom.

Arguments

itemString
String - An itemLink or itemString denoting the item

Returns

ilvl
Number - The true item level of the item, or nil if the input is invalid
isTrue
Boolean - true if the returned item level is the "true" item level of an heirloom, or false if the item was not an heirloom or some error occurred while scanning the tooltip.


:GetUpgradedItemLevel(itemString)

Returns the true item level of the item, including upgrades and heirlooms.

Arguments

itemString
String - An itemLink or itemString denoting the item

Returns

ilvl
Number - The true item level of the item, or nil if the input is invalid

Example

local ItemUpgradeInfo = LibStub("LibItemUpgradeInfo-1.0")
local item = GetInventoryItemLink("player", 1)
local id = ItemUpgradeInfo:GetUpgradeID(item)
local upgrade = ItemUpgradeInfo:GetCurrentUpgrade(id)
if upgrade then
	local max = ItemUpgradeInfo:GetMaximumUpgrade(id)
	local delta = ItemUpgradeInfo:GetItemLevelUpgrade(id)
	local ilvl = ItemUpgradeInfo:GetUpgradedItemLevel(item)
	DEFAULT_CHAT_FRAME:AddMessage(("%s %d/%d (+%d -> %d)"):format(item, upgrade, max, delta, ilvl))
else
	DEFAULT_CHAT_FRAME:AddMessage(item .. " cannot be upgraded")
end

Same code using the GetItemUpgradeInfo() convenience function:

local ItemUpgradeInfo = LibStub("LibItemUpgradeInfo-1.0")
local item = GetInventoryItemLink("player", 1)
local upgrade, max, delta = ItemUpgradeInfo:GetItemUpgradeInfo(item)
if upgrade then
	local ilvl = ItemUpgradeInfo:GetUpgradedItemLevel(item)
	DEFAULT_CHAT_FRAME:AddMessage(("%s %d/%d (+%d -> %d)"):format(item, upgrade, max, delta, ilvl))
else
	DEFAULT_CHAT_FRAME:AddMessage(item .. " cannot be upgraded")
end

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of eridius eridius Nov 29, 2014 at 20:59 UTC - 0 likes

    @olzenkhaw: Go

    I really don't want to maintain a database of Garrosh heirlooms. Beyond that, what you're suggesting will only work for Garrosh heirlooms and won't work for any others. The tooltip approach that I implemented should work for all heirlooms.

  • Avatar of olzenkhaw olzenkhaw Nov 29, 2014 at 09:54 UTC - 0 likes

    <<reply 2407652>>

    U don need to scan the tooltip to get the item level of Garrosh heirloom.
    Below is the heirloom id and respective ilvl based on player's level. (3 = normal, 2 = heroic, 1 = mythic)

    local GarroshBoA = {
        [3] = {105679,105673,105677,105672,105678,105671,105675,105670,105674,105680},
        [2] = {104405,104403,104406,104404,104401,104400,104402,104399,104409,104407},
        [1] = {105692,105686,105690,105685,105691,105684,105688,105683,105687,105693},
    }

    local GarroshBoAScaling = {
            ----        M,  H,   N
        [90] = {582,569,556},
        [91] = {586,574,562},
        [92] = {590,579,569},
        [93] = {593,584,575},
        [94] = {597,589,582},
        [95] = {601,595,588},
        [96] = {605,600,594},
        [97] = {609,605,601},
        [98] = {612,610,607},
        [99] = {616,615,614},
        [100] = {620,620,620},
    }

    function GarroshBoAItemLevel(itemID, unitid)
        local itemLevel=0;
        local m,n;
        local sw=false;
        for m = 1,3 do
            for n = 1, 10 do
                if GarroshBoA[m][n] == tonumber(itemID) then
                    itemLevel = GarroshBoAScaling[UnitLevel(unitid)][m];
                    sw=true;
                    break;
                end
            end
            if sw then break end
        end
        return itemLevel;
    end

    formula for the item level is:
    [level 90 item level based on difficulity] + (620 - [level 90 item level based on difficulity]) / 10 * (player's level - 90)

    For example:
    mythic garrosh wep on lvl 90 is 582,
    so the item level on lvl 98 is 582 + (620 - 582) / 10 * (98 - 90) = 612.4 = 612

    Last edited Nov 29, 2014 by olzenkhaw
  • Avatar of eridius eridius Nov 29, 2014 at 09:23 UTC - 0 likes

    @JayCanuck: Go

    I just pushed out an update, v1.0.8, that handles heirlooms.

  • Avatar of eridius eridius Nov 28, 2014 at 21:05 UTC - 0 likes

    @JayCanuck: Go

    I looked into this a couple of days ago. It seems that Garrosh Heirlooms report their item level as being the ilvl they count as when at the minimum. Bonus IDs don't seem to play into it. As near as I can figure, the only way to get the "real" item level is to either build a database of all known heirlooms and their level ranges so the current ilvl can be calculated, or to scan a tooltip to get the "current" ilvl every time.

    It may be worth implementing the tooltip approach. We could at least cache each combination of (itemid, playerlevel) and the resulting itemlevel that maps to.

  • Avatar of JayCanuck JayCanuck Nov 28, 2014 at 16:24 UTC - 0 likes

    I can confirm Garrosh heirloom item levels aren't reporting correctly. I suspect the BonusID fields added in 6.0.2 might be to blame, but that's just speculation.

  • Avatar of Innovindil Innovindil Nov 17, 2014 at 22:25 UTC - 0 likes

    Garrosh Heirlooms do not appear to be updating with their iLvL scaling. Any ideas on how to fix it?

    Not a huge deal ... but my OCD kicks in every so often lol.

    Thanks again for this awesome addon.

  • Avatar of eridius eridius Oct 17, 2014 at 08:01 UTC - 0 likes

    @scotepi: Go

    Thanks for the note, I just pushed v1.0.7 which should work with WoW 6.0.

  • Avatar of scotepi scotepi Oct 16, 2014 at 01:04 UTC - 0 likes

    Any ETA on an 6.0 update? One of my users has this for the fixed regex

    function lib:GetUpgradeID(itemString)
    	return tonumber(itemString:match(":(%d+):%d+:%d+\124h%["))
    end
    
    Last edited Oct 16, 2014 by scotepi
  • Avatar of eridius eridius Sep 18, 2013 at 03:20 UTC - 0 likes

    @suicidalkatt: Go

    That's completely useless. The upgrade information is stored as one of the components of the itemLink. If you don't have an itemLink, then you have no upgrade info. GetItemInfo() isn't smart enough either to give you the base (un-upgraded) version of the item; an itemLink produced that way has no upgrade information at all.

  • Avatar of suicidalkatt suicidalkatt Sep 18, 2013 at 02:59 UTC - 0 likes

    My point about being able to use itemID or itemName within the API functions to easily cut a corner to be able to get item upgrade info without having to find the item link within users addon code.

    A very simple function like this can get the required information within the library for the user:

    local function GetItemLink(input)
    	local output
    	if GetItemInfo(input) ~= nil then
    		output = select(2,GetItemInfo(input))
    	end	
    	if output then return output end
    end
    
    Last edited Sep 18, 2013 by suicidalkatt