I'm having an issue when getting the itemlevel values of specific items for the player or whatever you are /inspecting and the item has been upgraded (the feature added in patch 5.1).

Using GetAverageItemLevel() is not an option here since that only returns the values for what the player is currently wearing and will not work with /inspected players.

If you call GetItemInfo() or GetItemStats() they will just return the base itemlevel and stats for the item even if you use a itemlink for your specfically upgraded/enchanted/gemmed item.

Example:

Code:

function foo()
--lookup the players mainhand weapon (slotid==16)
local slot = 16;
local _, itemBasic = GetItemInfo( GetInventoryItemID("player", slot) ); --get the basic itemlink just using itemID
local itemUpgraded = GetInventoryItemLink("player", slot); --get the itemlink for the specific item that the player has equipped with enchants, gems, upgrades, everything.
print("basic:"..itemBasic);
print("upgraded:"..itemUpgraded);
--if you just compare the two links you see that their info is different, and clicking on them they show different info.
local infoBasic = GetItemInfo(itemBasic);
local infoUpgraded = GetItemInfo(itemUpgraded);
--these two will return the exact same results even tho the itemlink-data isnt the exact same
local statBasic = GetItemStats(itemBasic);
local statUpgraded = GetItemStats(itemUpgraded);
--these two will also return the exact same results even tho the itemlink's are not the same
local delta = GetItemStatDelta(itemBasic, itemUpgraded);
--this will return an empty table; presumably it thinks the items are identical aswell.
return itemBasic, itemUpgraded, infoBasic, infoUpgraded, statBasic, statUpgraded, delta;
end

I have been looking into the Blizzard_ItemUpgradeUI.lua and PaperDollFrame.lua for ideas on how to solve this but it seems that whomever coded that did not think of non-UI options, (functions like GetItemUpgradeItemInfo() do not accept input arguments but instead is hardcoded to only return stats for the item currently placed in the upgrade-UI).

In my head, the fact that GetItemStats() and GetItemInfo() returns the same data for 2 different links is a bug that Blizzard should fix (but how likely is that to happen). Yes; the link is refering to the same itemID, but it should consider enchants, gems, reforge, upgrades and so on.

So; Anyone got a suggestion for how to get the correct itemlevel for items, or is there no way to get this done?