Thread Tools Display Modes
Today, 01:51 PM   #1
Saint-Ange
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 18
Question Getting the gear item level

Hello,

Is there an other way to get a gear item level (armor/weapon/Jewelry) other than GetItemLink(bagId, slotIndex) and retrieve the SubType?

I'd like to get the crafting rank from armor/weapon/Jewelry no matter if looted or crafted, so I've made a table (00 are placeholders till I get the SubType) :

Code:
data.itemLevelToRankAndQuality = {
   -- level 1 to 14, rank 1
   { level = {00, 00, 00, 00, 00}, rank = 1, quality = 1 }, -- White (Normal)
   { level = {00, 00, 00, 00, 00}, rank = 1, quality = 2 }, -- Green (Fine)
   { level = {00, 00, 00, 00, 00}, rank = 1, quality = 3 }, -- Blue (Superior)
   { level = {00, 00, 00, 00, 00}, rank = 1, quality = 4 }, -- Purple (Epic)
   { level = {00, 00, 00, 00, 00}, rank = 1, quality = 5 }, -- Gold (Legendary)
   -- level 16 to 24, rank 2
   { level = {00, 00, 00, 00, 00}, rank = 2, quality = 1 }, -- White
   { level = {00, 00, 00, 00, 00}, rank = 2, quality = 2 }, -- Green
   { level = {00, 00, 00, 00, 00}, rank = 2, quality = 3 }, -- Blue
   { level = {00, 00, 00, 00, 00}, rank = 2, quality = 4 }, -- Purple
   { level = {00, 00, 00, 00, 00}, rank = 2, quality = 5 }, -- Gold
   -- level 26 to 34, rank 3
   { level = {29, 00, 00, 00, 00}, rank = 3, quality = 1 }, -- White
   { level = {32, 00, 00, 00, 00}, rank = 3, quality = 2 }, -- Green
   { level = {35, 00, 00, 00, 00}, rank = 3, quality = 3 }, -- Blue
   { level = {00, 00, 00, 00, 00}, rank = 3, quality = 4 }, -- Purple
   { level = {00, 00, 00, 00, 00}, rank = 3, quality = 5 }, -- Gold
   -- level 36 to 44, rank 4
   { level = {00, 00, 00, 00, 00}, rank = 4, quality = 1 }, -- White
   { level = {00, 00, 00, 00, 00}, rank = 4, quality = 2 }, -- Green
   { level = {00, 00, 00, 00, 00}, rank = 4, quality = 3 }, -- Blue
   { level = {00, 00, 00, 00, 00}, rank = 4, quality = 4 }, -- Purple
   { level = {00, 00, 00, 00, 00}, rank = 4, quality = 5 }, -- Gold
   -- level 46 to 54, rank 5
   { level = {00, 00, 00, 00, 00}, rank = 5, quality = 1 }, -- White
   { level = {00, 00, 00, 00, 00}, rank = 5, quality = 2 }, -- Green
   { level = {00, 00, 00, 00, 00}, rank = 5, quality = 3 }, -- Blue
   { level = {00, 00, 00, 00, 00}, rank = 5, quality = 4 }, -- Purple
   { level = {00, 00, 00, 00, 00}, rank = 5, quality = 5 }, -- Gold
   -- CP 10 to 30, rank 6
   { level = {00, 00, 00}, rank = 6, quality = 1 }, -- White
   { level = {00, 00, 00}, rank = 6, quality = 2 }, -- Green
   { level = {00, 00, 00}, rank = 6, quality = 3 }, -- Blue
   { level = {00, 00, 00}, rank = 6, quality = 4 }, -- Purple
   { level = {00, 00, 00}, rank = 6, quality = 5 }, -- Gold
   -- CP 40 to 60, rank 7
   { level = {00, 00, 00}, rank = 7, quality = 1 }, -- White
   { level = {00, 00, 00}, rank = 7, quality = 2 }, -- Green
   { level = {00, 00, 00}, rank = 7, quality = 3 }, -- Blue
   { level = {00, 00, 00}, rank = 7, quality = 4 }, -- Purple
   { level = {00, 00, 00}, rank = 7, quality = 5 }, -- Gold
   -- CP 70 to 80, rank 8
   { level = {00, 00}, rank = 8, quality = 1 }, -- White
   { level = {00, 00}, rank = 8, quality = 2 }, -- Green
   { level = {00, 00}, rank = 8, quality = 3 }, -- Blue
   { level = {00, 00}, rank = 8, quality = 4 }, -- Purple
   { level = {00, 00}, rank = 8, quality = 5 }, -- Gold
   -- CP 90 to 140, rank 9
   { level = {00, 00, 00, 00, 00, 70}, rank = 9, quality = 1 }, -- White
   { level = {00, 00, 00, 00, 00, 76}, rank = 9, quality = 2 }, -- Green
   { level = {00, 00, 00, 00, 00, 79}, rank = 9, quality = 3 }, -- Blue
   { level = {00, 00, 00, 00, 00, 00}, rank = 9, quality = 4 }, -- Purple
   { level = {00, 00, 00, 00, 00, 00}, rank = 9, quality = 5 }, -- Gold
   -- CP 150 to 160, rank 10
   { level = {74, 75}, rank = 10, quality = 1 }, -- White
   { level = {00, 78}, rank = 10, quality = 2 }, -- Green
   { level = {00, 81}, rank = 10, quality = 3 }, -- Blue
   { level = {00, 83}, rank = 10, quality = 4 }, -- Purple
   { level = {00, 86}, rank = 10, quality = 5 }, -- Gold
}
.. hence me asking here if there's a better way

Last edited by Saint-Ange : Today at 01:52 PM. Reason: typo
  Reply With Quote
Today, 02:26 PM   #2
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 417
It's not clear what information you have. Where is this item and why can you not use GetItemLink? There's multiple ways and reasons to get the level and quality, and various reasons why a table or similar might be required, but you haven't given enough information for us to say what to use.
  Reply With Quote
Today, 02:49 PM   #3
Saint-Ange
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 18
Originally Posted by Dolgubon View Post
It's not clear what information you have. Where is this item and why can you not use GetItemLink? There's multiple ways and reasons to get the level and quality, and various reasons why a table or similar might be required, but you haven't given enough information for us to say what to use.
I want to retrieve the crafting rank of a gear item on EVENT_INVENTORY_SINGLE_SLOT_UPDATE though if I understood well itemLink does not contain that information hence me mapping the subType to displayed level on the tooltip.
  Reply With Quote
Today, 03:10 PM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,165
The crafting rank is nothing that's in the itemlink directly as it is level dependent afaik
So what you need would be a lookup table for GetItemLinkRequiredLevel(itemLink) and hardcode the needed crafting ranks.
Like smithing "iron" rank 1 = item levels 1 to 14
and so on

Unless vanilla UI code shows you how ZOs does it to show the level text "1 to 14" at the crafting tables UI?
Did you search that control and how it's text is build in vanilla code?
ZO_SmithingTopLevelCreationPanelMaterialListSelectedLabel
https://github.com/esoui/esoui/blob/...hared.lua#L305
Looks like the rank texts is in data.patternName, so check how it get's there and maybe it's using some API.
I think it's this line:
https://github.com/esoui/esoui/blob/...hared.lua#L876
Code:
 local patternName, baseName, _, numMaterials, numTraitsRequired, numTraitsKnown, resultingItemFilterType = GetSmithingPatternInfo(patternIndex)

But the quality is in the itenlink so no need to hardcode anything for that, unless your addon would need that somehow...

Last edited by Baertram : Today at 03:17 PM.
  Reply With Quote
Today, 03:52 PM   #5
Saint-Ange
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 18
Originally Posted by Baertram View Post
The crafting rank is nothing that's in the itemlink directly as it is level dependent afaik
So what you need would be a lookup table for GetItemLinkRequiredLevel(itemLink) and hardcode the needed crafting ranks.
Like smithing "iron" rank 1 = item levels 1 to 14
and so on

Unless vanilla UI code shows you how ZOs does it to show the level text "1 to 14" at the crafting tables UI?
Did you search that control and how it's text is build in vanilla code?
ZO_SmithingTopLevelCreationPanelMaterialListSelectedLabel
https://github.com/esoui/esoui/blob/...hared.lua#L305
Looks like the rank texts is in data.patternName, so check how it get's there and maybe it's using some API.
I think it's this line:
https://github.com/esoui/esoui/blob/...hared.lua#L876
Code:
 local patternName, baseName, _, numMaterials, numTraitsRequired, numTraitsKnown, resultingItemFilterType = GetSmithingPatternInfo(patternIndex)

But the quality is in the itenlink so no need to hardcode anything for that, unless your addon would need that somehow...
ok I tried again with GetItemLinkRequiredLevel(itemLink) and of course I get the .. level but what about the CP level, how do I get that?

Also I have checked your links but I haven't got the level yet, it's all giberish to me :°
  Reply With Quote
Today, 05:08 PM   #6
Saint-Ange
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 18
I found a way to retrieve the CP and Level at my level in lua. it's not getting the crafting rank directly from a gear item but this will do :

Code:
function addon.OnInventorySlotUpdate(event, bagId, slotIndex)
   local itemLink = GetItemLink(bagId, slotIndex)
	local requiredLevel = GetItemLinkRequiredLevel(itemLink)
	local requiredCP = GetItemLinkRequiredChampionPoints(itemLink)
	
	-- Determine which value to use
	if requiredCP > 0 then
		-- If CP is required (level 50 items)
		d(string.format("Required Champion Points: %d", requiredCP))
	elseif requiredLevel > 0 then
		-- If the level is between 1 and 50, use the required level
		d(string.format("Required Level: %d", requiredLevel))
	end
end
at least the code will be much smaller.

Still, thanks for taking the time to answer me Baertram and Dolgubon

Last edited by Saint-Ange : Today at 05:11 PM.
  Reply With Quote
Today, 05:13 PM   #7
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 417
What are you referring to by 'subtype'?
As baertram mentions, the level displayed in an item's tooltip is not the same as the level of material needed to craft it. (And, indeed, you cannot craft e.g. lvl 5 items, but you can loot lvl 5 items)
Additionally, jewelry has a different material 'level' progression.

Let's start with the level required to equip an item. (Aka, what's in the tooltip/item link)
There is GetItemLinkRequiredChampionPoints which will tell you how much CP is required to equip it, or just GetItemRequiredChampionPoints if you have the bag location.


This will get you the level of the gear, but it's very difficult to go from that to the type of item required to craft it. There's two cases situations: At a crafting station, and not at a crafting station.

There's also LibLazyCrafting which you could use to help out, and depending on your use case, it might just be simpler to use LLC overall.
At a crafting station
You don't need any lookup tables, though one can be useful to avoid needing to do loops. You'd probably want to use GetSmithingPatternMaterialItemInfo(luaindex patternIndex, luaindex materialIndex)
You don't care about pattern index here, so just pass in 1 for that.
Material index is weirder though, it would more accurately be named craftLevelIndex or something like that.

1 -> Lvl 1 item
2 -> Lvl 4 item
3 -> Lvl 6 item
etc.
It'll tell you what level for a given index, what material for the index, etc. At 8 (except for jewelry) it'll swap to the second tier of material. You can loop through this with each individual material index, but it's going to be easier to just have a hardcoded table of the material breakpoints. Once you have a material index you can use GetSmithingPatternMaterialItemLink which will give you the item link. Do note that this only works for the crafting type of the station you're currently at.
Not at a crafting station
This case sucks.
You do not have those aforementioned API functions. They won't work, including the one that Baertram mentioned. You'll need to hardcode a bunch of stuff, starting with the ItemIds (or just item links I guess) for the materials. You can find those at line 1428 in Smithing.lua in LibLazyCrafting. From there, you could get the flavour text and search in that for the levels. Or you could hardcode the levels that each one corresponds to.

LibLazyCrafting:
This is still admittedly a kind of circuitous route, but it'll give you the item link of the material needed to craft an item. (Don't worry, this won't actually craft the item)Also, craftingTypeIndex -> This should be whatever type of station is needed to craft the item. e.g. CRAFTING_TYPE_BLACKSMITHING for heavy armour
Code:
local llc = LibLazyCrafting:AddRequestingAddon("ExampleAddonName", false, function() end)
local request = llc:CraftSmithingItemByLevel(1, isChampionLevel, level, 1, 0, false, craftingTypeIndex, 0, 1, false, "temporary")
local craftingRequirements = llc:CompileRequirements(request)
for itemId, amount in pairs(craftingRequirements) do
local materials = {[ITEMTYPE_BLACKSMITHING_MATERIAL]=1,[ITEMTYPE_CLOTHIER_MATERIAL]=1,
[ITEMTYPE_JEWELRYCRAFTING_MATERIAL]=1,
[ITEMTYPE_WOODWORKING_MATERIAL]=1}
 if materials[GetItemLinkItemType(llc:getItemLinkFromItemId(itemId))] then
   -- this is the crafting material
   llc:cancelItemByReference("temporary")
   return llc:getItemLinkFromItemId(itemId)
  end

Last edited by Dolgubon : Today at 05:19 PM.
  Reply With Quote
Today, 05:25 PM   #8
Saint-Ange
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 18
Originally Posted by Dolgubon View Post
Warning: Spoiler
Sorry, I haven't been clear enough : from a gear item I want to know what rank of refined materials its deconstruction will yield.
  Reply With Quote
Today, 07:01 PM   #9
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 417
Originally Posted by Saint-Ange View Post
Sorry, I haven't been clear enough : from a gear item I want to know what rank of refined materials its deconstruction will yield.
That's the same thing, actually. If it would take iron ingots to craft, deconstruction will give back iron ingots. So you should still be able to use the same methods
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Getting the gear item level


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