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
 
12-07-12, 10:38 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
If you're using the tooltip scanning method, I'd recommend keeping a cache of items you've previously scanned, so you don't scan them again. Store them in a table with the item links as keys and the levels as values, and then have GetItemUpgradeLevel return the stored value if it exists, or if not, set the value before returning it so it's cached for next time.
__________________
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-13-12, 01:51 PM   #11
d07.RiV
A Defias Bandit
Join Date: Jun 2011
Posts: 3
Hi,
I'm using a workaround that is pretty crude but is accurate except for rounding issues. Its simply scaling stats proportional to spellpower on caster weapons; I wonder if the actual scales used in the game are anywhere in client data.

lua Code:
  1. local spTable = {
  2.   [458] = 4914,
  3.   [463] = 5152,
  4.   [466] = 5293,
  5.   [470] = 5496,
  6.   [471] = 5550,
  7.   [474] = 5704,
  8.   [476] = 5812,
  9.   [478] = 5920,
  10.   [480] = 6032,
  11.   [483] = 6206,
  12.   [484] = 6261,
  13.   [487] = 6441,
  14.   [489] = 6564,
  15.   [490] = 6628,
  16.   [491] = 6685,
  17.   [493] = 6812,
  18.   [494] = 6879,
  19.   [496] = 7007,
  20.   [497] = 7071,
  21.   [498] = 7140,
  22.   [500] = 7272,
  23.   [501] = 7337,
  24.   [502] = 7408,
  25.   [503] = 7478,
  26.   [504] = 7548,
  27.   [505] = 7619,
  28.   [506] = 7688,
  29.   [507] = 7761,
  30.   [508] = 7836,
  31.   [509] = 7907,
  32.   [510] = 7980,
  33.   [511] = 8054,
  34.   [512] = 8132,
  35.   [513] = 8206,
  36.   [514] = 8286,
  37.   [515] = 8364,
  38.   [516] = 8441,
  39.   [517] = 8518,
  40.   [518] = 8603,
  41.   [519] = 8680,
  42.   [520] = 8761,
  43.   [521] = 8841,
  44.   [524] = 9093,
  45.   [525] = 9179,
  46.   [528] = 9439,
  47.   [532] = 9797,
  48. }
  49. local upTable = {
  50.   [1]   =  8, -- 1/1
  51.   [373] =  4, -- 1/2
  52.   [374] =  8, -- 2/2
  53.   [375] =  4, -- 1/3
  54.   [376] =  4, -- 2/3
  55.   [377] =  4, -- 3/3
  56.   [379] =  4, -- 1/2
  57.   [380] =  4, -- 2/2
  58.   [445] =  0, -- 0/2
  59.   [446] =  4, -- 1/2
  60.   [447] =  8, -- 2/2
  61.   [451] =  0, -- 0/1
  62.   [452] =  8, -- 1/1
  63.   [453] =  0, -- 0/2
  64.   [454] =  4, -- 1/2
  65.   [455] =  8, -- 2/2
  66.   [456] =  0, -- 0/1
  67.   [457] =  8, -- 1/1
  68.   [458] =  0, -- 0/4
  69.   [459] =  4, -- 1/4
  70.   [460] =  8, -- 2/4
  71.   [461] = 12, -- 3/4
  72.   [462] = 16, -- 4/4
  73. }
  74. function GetItemStatsUp(link, table)
  75.   local result = GetItemStats(link, table)
  76.   if not result then
  77.     return result
  78.   end
  79.   local id = tonumber (link:match ("item:%d+:%d+:%d+:%d+:%d+:%d+:%-?%d+:%-?%d+:%d+:%d+:(%d+)"))
  80.   local _, _, _, iLvl = GetItemInfo(link)
  81.   iLvl = iLvl or 0
  82.   if iLvl >= 458 and upTable[id] then
  83.     local iLvl2 = iLvl + upTable[id]
  84.     if iLvl2 > iLvl and spTable[iLvl] and spTable[iLvl2] then
  85.       for k, v in pairs(result) do
  86.         if tonumber(v) then
  87.           result[k] = math.floor(tonumber(v) * spTable[iLvl2] / spTable[iLvl] + 0.5)
  88.         end
  89.       end
  90.     end
  91.   end
  92.   return result
  93. end
 
01-06-13, 05:53 AM   #12
Mirroar
A Defias Bandit
 
Mirroar's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 3
I did a bit of spreadsheet magic to approximate the spellpower values you were using into an exponential function - https://docs.google.com/spreadsheet/...2hwaFBwUEVmLXc

So you could do something like this instead of using your spellpower table:
Lua Code:
  1. local exp, mult = 1.00936754973658, 68.6945347210951
  2. local spellpower = mult * (exp ^ iLvl)
The error should be pretty small (a max of 4 points of spellpower with the given values, so < 0.1%) and you have the added benefits of it working for item levels not in your table.

Edit: Tested ingame and seems to be working pretty well.
The only exception I found so far was armor, which seems to scale differently. I have a Sixteen-Fanged Crown, upgraded once. It has 3208 unupgraded armor and 3250 after the upgrade, scaling it like the other stats yields 3330 armor...

Last edited by Mirroar : 01-06-13 at 10:14 AM.
 
05-29-13, 01:29 PM   #13
d07.RiV
A Defias Bandit
Join Date: Jun 2011
Posts: 3
I'll try to bring back this discussion - with the new patch, upgraded stats now compensate for sockets (which aren't upgraded, obviously), so the formula changes.

Since item data now appears to be stored client-side (Item-sparse.db2), you can get stat allocation and socket multipliers for every item, so the formula is something like this:
Code:
statAfterUpgrade = (statBeforeUpgrade + socketMultiplier * 160) * upgradeFactor - socketMultiplier * 160
I'm getting upgradeFactor from weapon damage data (ItemDamageTwoHand.dbc), and it seems to work fine except for rounding issues (maybe if I find out how to use stat allocation values I'd get it right).

Anyway, the obvious problem is that socketMultiplier is not available in lua code, and there's no general rule to calculate it - e.g. if some items have 1 for primary stat and 0.5 for both secondary stats, some would have 1 for primary, and 0.25/0.75 for secondary (assuming 2 sockets).

By the way, here's the new upgrade id to item level table:
Lua Code:
  1. local upTable = {
  2.   [1]   =  8, -- 1/1
  3.   [373] =  4, -- 1/2
  4.   [374] =  8, -- 2/2
  5.   [375] =  4, -- 1/3
  6.   [376] =  4, -- 2/3
  7.   [377] =  4, -- 3/3
  8.   [378] =  7, -- 1/1
  9.   [379] =  4, -- 1/2
  10.   [380] =  4, -- 2/2
  11.   [445] =  0, -- 0/2
  12.   [446] =  4, -- 1/2
  13.   [447] =  8, -- 2/2
  14.   [451] =  0, -- 0/1
  15.   [452] =  8, -- 1/1
  16.   [453] =  0, -- 0/2
  17.   [454] =  4, -- 1/2
  18.   [455] =  8, -- 2/2
  19.   [456] =  0, -- 0/1
  20.   [457] =  8, -- 1/1
  21.   [458] =  0, -- 0/4
  22.   [459] =  4, -- 1/4
  23.   [460] =  8, -- 2/4
  24.   [461] = 12, -- 3/4
  25.   [462] = 16, -- 4/4
  26.   [465] =  0, -- 0/2
  27.   [466] =  4, -- 1/2
  28.   [467] =  8, -- 2/2
  29.   [468] =  0, -- 0/4
  30.   [469] =  4, -- 1/4
  31.   [470] =  8, -- 2/4
  32.   [471] = 12, -- 3/4
  33.   [472] = 16, -- 4/4
  34.   [476] =  0, -- ?
  35.   [479] =  0, -- ?
  36. }
 
05-29-13, 01:53 PM   #14
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Mirroar View Post
I did a bit of spreadsheet magic to approximate the spellpower values you were using into an exponential function - https://docs.google.com/spreadsheet/...2hwaFBwUEVmLXc

So you could do something like this instead of using your spellpower table:
Lua Code:
  1. local exp, mult = 1.00936754973658, 68.6945347210951
  2. local spellpower = mult * (exp ^ iLvl)
The error should be pretty small (a max of 4 points of spellpower with the given values, so < 0.1%) and you have the added benefits of it working for item levels not in your table.
Maybe something was added/substracted to the base of the exponentiation or afterwards? Does blue ever respond to these type of questions?

[offtopic]Mirroar, when can we expect a TopFit update for 5.3 please [/offtopic]
 
05-29-13, 02:01 PM   #15
d07.RiV
A Defias Bandit
Join Date: Jun 2011
Posts: 3
Edit: found the formulas that gives the precise results. The general scaling formula is 15% every 15 levels, but the exact values are found in RandPropPoints.dbc, for every item level there are 15=5x3 values for different slot types/item qualities. Item data has two extra values for every stat: stat allocation and socket multiplier. Item allocation is in 1/10000ths of the value obtained from RandPropPoints.dbc, and gives the value of the stat before socket penalty. Subtracting (socketMul * 160) from this value gives the exact value of the stat, and makes it easy to calculate stats for different iLevels. 160 comes from gtItemSocketCostPerLevel.dbc, though its always 160 for upgradeable items.

Last edited by d07.RiV : 06-03-13 at 02:17 AM.
 
09-16-13, 08:21 PM   #16
scotepi
A Defias Bandit
Join Date: Dec 2005
Posts: 2
Any updates on this? I'm using Ro's version but I no longer play and don't want to have to keep updating my code every patch. The current table I used is below for 5.4

Lua Code:
  1. -- 5.4
  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.         ["465"]=0,["466"]=4,["467"]=8,["469"]=4,["470"]=8,["471"]=12,
  8.         ["472"]=16,["491"]=0,["492"]=4,["493"]=8,["494"]=4,["495"]=8,
  9.         ["496"]=8,["497"]=12,["498"]=16,
  10.     }
 
09-17-13, 08:31 PM   #17
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
I've been using LibItemUpgradeInfo-1.0 for my !SyLevel addon.

The libarary has also been updated for the changes in 5.4
 
 

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