WoWInterface - View Single Post - Upgraded items and GetItemInfo()
View Single Post
12-07-12, 02:23 PM   #9
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