Thread Tools Display Modes
12-06-12, 10:18 AM   #1
Jarod24
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 66
Upgraded items and GetItemInfo()

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?

(edit: parsing tooltips to get the itemlevel isnt an option)
__________________
Author of IfThen, Links in Chat
 
12-06-12, 08:34 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Jarod24 View Post
(edit: parsing tooltips to get the itemlevel isnt an option)
Even if you're not displaying a tooltip, if you have an item ID you can always send it to a hidden tooltip and scan that.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
 
12-07-12, 12:13 AM   #3
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
You can pull the "upgraded item" information out of the hyperlink, it's the last number after a colon. Each upgrade type has its own ID kind of like the enchant IDs.

I generated a table of which IDs were for what but.. I don't have it any more. If I get around to it I'll try and do it again.

I can tell you they were all between 350 and 500.
 
12-07-12, 03:21 AM   #4
Jarod24
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 66
Originally Posted by semlar View Post
You can pull the "upgraded item" information out of the hyperlink, it's the last number after a colon. Each upgrade type has its own ID kind of like the enchant IDs.

I generated a table of which IDs were for what but.. I don't have it any more. If I get around to it I'll try and do it again.

I can tell you they were all between 350 and 500.
Yes i did see that. Looked like they're using a bitpattern of sorts, and i did find a very large list at wowwiki (i think). However that list wasnt up to date (wrath or cata used the 300 series of numbers afaik)
__________________
Author of IfThen, Links in Chat
 
12-07-12, 03:22 AM   #5
Jarod24
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 66
Originally Posted by Phanx View Post
Even if you're not displaying a tooltip, if you have an item ID you can always send it to a hidden tooltip and scan that.
Hmmm, hidden tooltip you say.
I'll look into that.
__________________
Author of IfThen, Links in Chat
 
12-07-12, 05:00 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Something like:

Code:
-- Construct your saarch pattern based on the existing global string:
local S_UPGRADE_LEVEL   = "^" .. gsub(ITEM_UPGRADE_TOOLTIP_FORMAT, "%%d", "(%%d+)")

-- Create the tooltip:
local scantip = CreateFrame("GameTooltip", "MyScanningTooltip", nil, "GameTooltipTemplate")
scantip:SetOwner(UIParent, "ANCHOR_NONE")

-- Create a function for simplicity's sake:
local function GetItemUpgradeLevel(itemLink)
    -- Pass the item link to the tooltip:
    scantip:SetHyperlink(itemLink)

    -- Scan the tooltip:
    for i = 2, scantip:NumLines() do -- Line 1 is always the name so you can skip it.
        local text = _G["MyScanningTooltipTextLeft"..i]:GetText()
        if text and text ~= "" then
            local currentUpgradeLevel, maxUpgradeLevel = strmatch(text, S_UPGRADE_LEVEL)
            if currentUpgradeLevel then
                return currentUpgradeLevel, maxUpgradeLevel
            end
        end
    end
end

-- Now you can just call the function to get the levels:
local currentUpgradeLevel, maxUpgradeLevel = GetItemUpgradeLevel(itemLink)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
 
12-07-12, 11:56 AM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Maybe this will help, I'm copying it here in case something happens to the original.
From Ro on http://us.battle.net/wow/en/forum/topic/7199032730#9:
Lua Code:
  1. function GetActualItemLevel(link)
  2.   local levelAdjust={ -- 11th item:id field and level adjustment
  3.     ["0"]=0,["1"]=8,["373"]=4,["374"]=8,["375"]=4,["376"]=4,
  4.     ["377"]=4,["379"]=4,["380"]=4,["445"]=0,["446"]=4,["447"]=8,
  5.     ["451"]=0,["452"]=8,["453"]=0,["454"]=4,["455"]=8,["456"]=0,
  6.     ["457"]=8,["458"]=0,["459"]=4,["460"]=8,["461"]=12,["462"]=16}
  7.   local baseLevel = select(4,GetItemInfo(link))
  8.   local upgrade = link:match(":(%d+)\124h%[")
  9.   if baseLevel and upgrade then
  10.     return baseLevel + levelAdjust[upgrade]
  11.   else
  12.     return baseLevel
  13.   end
  14. end
Probably less reliable than just pulling the item level straight out of the tooltip.

Last edited by semlar : 12-07-12 at 12:01 PM.
 
12-07-12, 02:14 PM   #8
Jarod24
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 66
In the end my solution was to simply scan the itemlevel from the tooltip.

http://www.wowwiki.com/UIOBJECT_GameTooltip was really helpful, as well as Phanx's example with regards to using patterns. That should make it work with localized versions of the game.

Credit to you Phanx in the latest version of IfThen
__________________
Author of IfThen, Links in Chat
 
12-07-12, 02:23 PM   #9
Jarod24
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 66
Originally Posted by semlar View Post
Maybe this will help, I'm copying it here in case something happens to the original.
From Ro on http://us.battle.net/wow/en/forum/topic/7199032730#9:
Lua Code:
  1. function GetActualItemLevel(link)
  2.   local levelAdjust={ -- 11th item:id field and level adjustment
  3.     ["0"]=0,["1"]=8,["373"]=4,["374"]=8,["375"]=4,["376"]=4,
  4.     ["377"]=4,["379"]=4,["380"]=4,["445"]=0,["446"]=4,["447"]=8,
  5.     ["451"]=0,["452"]=8,["453"]=0,["454"]=4,["455"]=8,["456"]=0,
  6.     ["457"]=8,["458"]=0,["459"]=4,["460"]=8,["461"]=12,["462"]=16}
  7.   local baseLevel = select(4,GetItemInfo(link))
  8.   local upgrade = link:match(":(%d+)\124h%[")
  9.   if baseLevel and upgrade then
  10.     return baseLevel + levelAdjust[upgrade]
  11.   else
  12.     return baseLevel
  13.   end
  14. end
Probably less reliable than just pulling the item level straight out of the tooltip.

Ok... wow... Having to do this amount of testing & work just to return the itemlevel tells me that Blizzard really need to get GetItemInfo() and GetItemStats() fixed so that they work as you should expect when passing in itemlinks to them.

It would reduce the overhead of lua code in addons as well as the need for tooltip scanning that should only go to improve the general performance of the game too (doing less is really, really efficient).
__________________
Author of IfThen, Links in Chat
 
 

WoWInterface » Site Forums » Archived Beta Forums » MoP Beta archived threads » Upgraded items and GetItemInfo()

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off