ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Wish List (https://www.esoui.com/forums/forumdisplay.php?f=177)
-   -   [implemented] get enchantment from equipment itemlink (https://www.esoui.com/forums/showthread.php?t=8106)

sirinsidiator 10/13/18 11:05 AM

[implemented] 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.

ZOS_ChipHilseberg 10/15/18 03:54 PM

We can add GetItemLinkEnchantSearchCategoryType(itemlink) - search category.

Kyoma 10/15/18 04:07 PM

Any objections to still get a way to retrieve this enchant id from an item link?

sirinsidiator 10/15/18 04:41 PM

Quote:

Originally Posted by ZOS_ChipHilseberg (Post 36318)
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.

ZOS_ChipHilseberg 10/17/18 07:43 AM

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.

sirinsidiator 10/17/18 08:35 AM

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?

ZOS_ChipHilseberg 10/17/18 08:37 AM

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.

Kyoma 10/17/18 08:58 AM

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?

sirinsidiator 10/17/18 09:10 AM

Quote:

Originally Posted by ZOS_ChipHilseberg (Post 36326)
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? :confused:

ZOS_ChipHilseberg 10/17/18 01:16 PM

Quote:

Originally Posted by Kyoma (Post 36327)
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.

ZOS_ChipHilseberg 10/17/18 01:20 PM

Quote:

Originally Posted by sirinsidiator (Post 36328)
Ok. But in that case, how do I know the enchant quality? :confused:

You want the required level and the quality of the applied enchant?

sirinsidiator 10/17/18 01:44 PM

Quote:

Originally Posted by ZOS_ChipHilseberg (Post 36330)
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?

ZOS_ChipHilseberg 10/17/18 03:44 PM

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.

sirinsidiator 10/18/18 06:08 AM

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.


All times are GMT -6. The time now is 04:54 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI