Quantcast [open] get enchantment from equipment itemlink - ESOUI
Thread Tools Display Modes
10/13/18, 11:05 AM   #1
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,140
[open] get enchantment from equipment itemlink

I just noticed that there is no proper way to get the applied enchantment of an item. Right now there is only a function GetItemLinkEnchantInfo which returns true if the enchantment has charges and the localized name and description. If possible I'd like to have an additional return (or a separate function) which gives me the itemlink for the applied glyph.

From what I have seen the itemlink already contains the glyph id and quality for items enchanted by the player, but loot that is dropped in the world seems to use some sort of default enchantment which is not specified there (enchantment item id is 0), so I cannot just build the link myself.

For my use case I need a way to get the ENCHANTMENT_SEARCH_CATEGORY_* from an item link, so if GetItemLinkEnchantInfo returned that in addition, it would be even easier for me.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.

Last edited by sirinsidiator : 10/13/18 at 11:25 AM.
  Reply With Quote
10/15/18, 03:54 PM   #2
ZOS_ChipHilseberg
ZOS Staff!
Premium Member
Yes this person is from ZeniMax!
Join Date: Oct 2014
Posts: 539
We can add GetItemLinkEnchantSearchCategoryType(itemlink) - search category.
  Reply With Quote
10/15/18, 04:07 PM   #3
Kyoma
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 71
Any objections to still get a way to retrieve this enchant id from an item link?
  Reply With Quote
10/15/18, 04:41 PM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,140
Originally Posted by ZOS_ChipHilseberg View Post
We can add GetItemLinkEnchantSearchCategoryType(itemlink) - search category.
That would be very helpful. For now I made a workaround:

Lua Code:
  1. local ENCHANT_CATEGORY_BY_HEADER = {}
  2. do
  3.     local SAMPLE_GLYPH_ITEM_LINK_TEMPLATE = "|H1:item:%d:366:50:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h"
  4.  
  5.     local enchantCategorySampleGlyphItemId = {
  6.         -- weapons
  7.         [ENCHANTMENT_SEARCH_CATEGORY_FIERY_WEAPON] = 26848,
  8.         [ENCHANTMENT_SEARCH_CATEGORY_FROZEN_WEAPON] = 5365,
  9.         [ENCHANTMENT_SEARCH_CATEGORY_CHARGED_WEAPON] = 26844,
  10.         [ENCHANTMENT_SEARCH_CATEGORY_POISONED_WEAPON] = 26587,
  11.         [ENCHANTMENT_SEARCH_CATEGORY_BEFOULED_WEAPON] = 26841,
  12.         [ENCHANTMENT_SEARCH_CATEGORY_DAMAGE_HEALTH] = 45869,
  13.         [ENCHANTMENT_SEARCH_CATEGORY_BERSERKER] = 54484,
  14.         [ENCHANTMENT_SEARCH_CATEGORY_REDUCE_POWER] = 26591,
  15.         [ENCHANTMENT_SEARCH_CATEGORY_DAMAGE_SHIELD] = 5366,
  16.         [ENCHANTMENT_SEARCH_CATEGORY_REDUCE_ARMOR] = 26845,
  17.         [ENCHANTMENT_SEARCH_CATEGORY_ABSORB_MAGICKA] = 45868,
  18.         [ENCHANTMENT_SEARCH_CATEGORY_ABSORB_HEALTH] = 43573,
  19.         [ENCHANTMENT_SEARCH_CATEGORY_ABSORB_STAMINA] = 45867,
  20.         -- prismatic 68344
  21.  
  22.         -- armor
  23.         [ENCHANTMENT_SEARCH_CATEGORY_MAGICKA] = 26582,
  24.         [ENCHANTMENT_SEARCH_CATEGORY_HEALTH] = 26580,
  25.         [ENCHANTMENT_SEARCH_CATEGORY_STAMINA] = 26588,
  26.         -- prismatic 68343
  27.  
  28.         -- jewelry
  29.         [ENCHANTMENT_SEARCH_CATEGORY_FIRE_RESISTANT] = 26849,
  30.         [ENCHANTMENT_SEARCH_CATEGORY_FROST_RESISTANT] = 5364,
  31.         [ENCHANTMENT_SEARCH_CATEGORY_SHOCK_RESISTANT] = 43570,
  32.         [ENCHANTMENT_SEARCH_CATEGORY_POISON_RESISTANT] = 26586,
  33.         [ENCHANTMENT_SEARCH_CATEGORY_DISEASE_RESISTANT] = 26847,
  34.         [ENCHANTMENT_SEARCH_CATEGORY_DECREASE_SPELL_DAMAGE] = 45886,
  35.         [ENCHANTMENT_SEARCH_CATEGORY_DECREASE_PHYSICAL_DAMAGE] = 45885,
  36.         [ENCHANTMENT_SEARCH_CATEGORY_INCREASE_SPELL_DAMAGE] = 45884,
  37.         [ENCHANTMENT_SEARCH_CATEGORY_INCREASE_PHYSICAL_DAMAGE] = 45883,
  38.         [ENCHANTMENT_SEARCH_CATEGORY_INCREASE_BASH_DAMAGE] = 45872,
  39.         [ENCHANTMENT_SEARCH_CATEGORY_INCREASE_POTION_EFFECTIVENESS] = 45874,
  40.         [ENCHANTMENT_SEARCH_CATEGORY_REDUCE_POTION_COOLDOWN] = 45875,
  41.         [ENCHANTMENT_SEARCH_CATEGORY_REDUCE_SPELL_COST] = 45870,
  42.         [ENCHANTMENT_SEARCH_CATEGORY_REDUCE_FEAT_COST] = 45871,
  43.         [ENCHANTMENT_SEARCH_CATEGORY_REDUCE_BLOCK_AND_BASH] = 45873,
  44.         [ENCHANTMENT_SEARCH_CATEGORY_MAGICKA_REGEN] = 26583,
  45.         [ENCHANTMENT_SEARCH_CATEGORY_HEALTH_REGEN] = 26581,
  46.         [ENCHANTMENT_SEARCH_CATEGORY_STAMINA_REGEN] = 26589,
  47.     }
  48.  
  49.     for category, id in pairs(enchantCategorySampleGlyphItemId) do
  50.         local _, enchantHeader = GetItemLinkEnchantInfo(SAMPLE_GLYPH_ITEM_LINK_TEMPLATE:format(id))
  51.         ENCHANT_CATEGORY_BY_HEADER[enchantHeader] = category
  52.     end
  53. end
  54.  
  55. local function GetItemLinkEnchantSearchCategoryType(itemLink)
  56.     local _, enchantHeader = GetItemLinkEnchantInfo(itemLink)
  57.     if(enchantHeader ~= "") then
  58.         return ENCHANT_CATEGORY_BY_HEADER[enchantHeader] or ENCHANTMENT_SEARCH_CATEGORY_OTHER
  59.     end
  60.     return nil
  61. end

I also noticed there are no enchant search categories for the prismatic glyphs. They show up in ENCHANTMENT_SEARCH_CATEGORY_OTHER at the moment and since the ability altering equipment no longer uses enchantments, it would probably make sense to remove the "other" category in favor of two new ones for the prismatic glyphs.

And I agree with what Kyoma said. A way to get the default glyph on dropped equipment would still be nice for other use cases.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
10/17/18, 07:43 AM   #5
ZOS_ChipHilseberg
ZOS Staff!
Premium Member
Yes this person is from ZeniMax!
Join Date: Oct 2014
Posts: 539
We added:

GetItemLinkDefaultEnchantId
GetItemLinkAppliedEnchantId
GetItemLinkFinalEnchantId

GetEnchantSearchCategoryType
GetEnchantProcAbilityId

We'll see if we have time to do the data work required to split those enchantments out.
  Reply With Quote
10/17/18, 08:35 AM   #6
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,140
That sounds great! Thanks a lot!

Just wondering, does GetItemLinkFinalEnchantId return some new kind of enchant id? If so, how would one get a glyph itemlink from this id?
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
10/17/18, 08:37 AM   #7
ZOS_ChipHilseberg
ZOS Staff!
Premium Member
Yes this person is from ZeniMax!
Join Date: Oct 2014
Posts: 539
Final is Applied if it exists, otherwise Default.

This returns an enchant id. You want a glyph item that has that enchant id as its default enchant id.
  Reply With Quote
10/17/18, 08:58 AM   #8
Kyoma
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 71
Hurray \o/

Question: When an enchant is applied to something that had a default enchant, will it remain retrievable with the default function or will it return 0 from that point on?

Last edited by Kyoma : 10/17/18 at 09:00 AM.
  Reply With Quote
10/17/18, 09:10 AM   #9
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,140
Originally Posted by ZOS_ChipHilseberg View Post
Final is Applied if it exists, otherwise Default.

This returns an enchant id. You want a glyph item that has that enchant id as its default enchant id.
Ok. But in that case, how do I know the enchant quality?
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
10/17/18, 01:16 PM   #10
ZOS_ChipHilseberg
ZOS Staff!
Premium Member
Yes this person is from ZeniMax!
Join Date: Oct 2014
Posts: 539
Originally Posted by Kyoma View Post
Hurray \o/

Question: When an enchant is applied to something that had a default enchant, will it remain retrievable with the default function or will it return 0 from that point on?
It will remain retrievable.
  Reply With Quote
10/17/18, 01:20 PM   #11
ZOS_ChipHilseberg
ZOS Staff!
Premium Member
Yes this person is from ZeniMax!
Join Date: Oct 2014
Posts: 539
Originally Posted by sirinsidiator View Post
Ok. But in that case, how do I know the enchant quality?
You want the required level and the quality of the applied enchant?

Last edited by ZOS_ChipHilseberg : 10/17/18 at 01:32 PM.
  Reply With Quote
10/17/18, 01:44 PM   #12
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,140
Originally Posted by ZOS_ChipHilseberg View Post
You want the required level and the quality of the applied enchant?
Maybe I am just misunderstanding, but I was thinking about getting the item link for the default, applied and final enchant so I can use it with all the other itemlink methods we already have. From what I know, we need the itemId (=enchantId?) and the quality to build that:

Lua Code:
  1. local enchantId = GetItemLinkDefaultEnchantId(armorItemLink)
  2. local searchCategory = GetEnchantSearchCategoryType(enchantId)
  3. local procAbilityId = GetEnchantProcAbilityId(enchantId)
  4. local glyphItemLink = string.format("|H1:item:%d:%d:50:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", enchantId, missing)

Maybe you could just change the methods to give us the link, like this:
Lua Code:
  1. local glyphItemLink = GetItemLinkDefaultEnchantLink(armorItemLink)
  2. local enchantId = GetItemLinkItemId(glyphItemLink)
  3. local searchCategory = GetEnchantSearchCategoryType(enchantId)
  4. local procAbilityId = GetEnchantProcAbilityId(enchantId)

Or maybe I am just mistaken?
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
10/17/18, 03:44 PM   #13
ZOS_ChipHilseberg
ZOS Staff!
Premium Member
Yes this person is from ZeniMax!
Join Date: Oct 2014
Posts: 539
You are mistaken. There is no item for a default enchant. Its power is based off of the item quality and level. Applied enchants do have an item. You can find those by searching through all items and finding one with a matching default enchant id. Their power is based off of the enchant item's quality and level.
  Reply With Quote
10/18/18, 06:08 AM   #14
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,140
Ok. I was just confused because the items I tested with did show that the default enchant corresponds to a glyph with the same level and quality as the item.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote

ESOUI » Developer Discussions » Wish List » [open] get enchantment from equipment itemlink

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