Thread Tools Display Modes
10-19-11, 12:12 AM   #1
Safturento
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 13
Finding the duration of Weapon Enchants

Is there any way to find the duration of weapon enchants? I'm making status bar timers for my buffs, but I'm unable to do so for the weapon enchant due to the lack of a Max value for the status bar. Does anyone know a clever workaround to get a duration value for your weapon enchants? (GetWeaponEnchantInfo only returns expiration)
  Reply With Quote
10-19-11, 12:16 AM   #2
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Safturento View Post
Is there any way to find the duration of weapon enchants? I'm making status bar timers for my buffs, but I'm unable to do so for the weapon enchant due to the lack of a Max value for the status bar. Does anyone know a clever workaround to get a duration value for your weapon enchants? (GetWeaponEnchantInfo only returns expiration)
Not sure if there is a way. May need to code in a table of known enchants and their durations.
  Reply With Quote
10-19-11, 12:38 AM   #3
Safturento
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 13
I don't even see that being possible, due to the fact that GetWeaponEnchantInfo doesn't even return the name or spell ID of the enchant. >.<
  Reply With Quote
10-19-11, 12:41 AM   #4
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Safturento View Post
I don't even see that being possible, due to the fact that GetWeaponEnchantInfo doesn't even return the name or spell ID of the enchant. >.<
Hmm, very true. Oh well

Ahh, but wait! All you'd have to do is have a list of weapon enchants, and upon detecting an active enchant do a loop through UnitAura to find which enchant is active. A little convoluted, but could work.


Rogue poisons: (all 60mins)
2892
3775
5237
6947
10918
21835

Shaman Enchants (all 30mins if I recall):
Windfury = 8232
Rockbiter = 8017
Flametongue = 8024
Frostbrand = 8033
Earthliving = 51730

Last edited by Nibelheim : 10-19-11 at 12:49 AM.
  Reply With Quote
10-19-11, 12:45 AM   #5
Safturento
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 13
I wish, UnitAura doesn't check for weapon enchants. ._.
  Reply With Quote
10-19-11, 12:53 AM   #6
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Safturento View Post
I wish, UnitAura doesn't check for weapon enchants. ._.
Damn, it doesn't. Ack!

Edit: I have a better idea! Brb, researching.

There might be a way to set the tooltip to a particular inventory slot item with the info from GetInventoryItemLink("player", 16/17). If this can be done, then you'll be able to search the tooltip for an active enchant. I know there's a GameTooltip:GetItem(), and an OnTooltipSetItem event for the GameTooltip, but not sure how to set it. Maybe you can't even set it manually. Oh well. Interesting nonetheless.

Last edited by Nibelheim : 10-19-11 at 01:06 AM.
  Reply With Quote
10-19-11, 12:59 AM   #7
Safturento
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 13
The only possible way I could think of doing this would be to make an OnEvent script that finds in the combat log when you enchant the weapon, with what, and on what weapon. Then it would have to figure out which slot that weapon is in, somehow insert that number into some crazy horrible disaster of a table blizzard is using to hold the information on weapon enchants, and then hook a securefunc to GetEnchantWeaponInfo to make it also return (can you even hook a function to return additional information?) the duration. At that point, I don't care about my status bars anymore.. lmao

edit: I'm going to bed before my head explodes.. >.>
  Reply With Quote
10-19-11, 01:16 AM   #8
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
GameTooltip:SetInventoryItem("player", 16) -- main hand
GameTooltip:SetInventoryItem("player", 17) -- off hand

Now, let's see if I can read it's text.

Hmm, oh well. Maybe not possible.

Last edited by Nibelheim : 10-19-11 at 01:48 AM.
  Reply With Quote
10-19-11, 06:39 AM   #9
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
For my ProcWatch I used a db and stored duration as durationMax if it was bigger than the previous value.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
10-19-11, 03:40 PM   #10
Barjack
A Black Drake
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 89
Even if you see the enchant happen and set that as the "max" for your bar (which actually isn't as easy as it sounds due to the delayed update of durations with fresh enchants), as soon as a player logs in with an already-enchanted weapon you will suddenly get an enchant with a "max" of 12 mins 32 sec or whatever was left when they logged in.

The best thing to do is probably just use your own list of names/IDs and durations as given above. Other than shaman and rogue enchants, fishing enchants are either 10 or 60 minutes, Venomhide Poison is 5 minutes, and most other enchants (various oils and sharpening stones) are usually 60 minutes as well (which is probably a good default for unknown enchants).

To actually get the name of the enchant, though, you'll probably need to scan tooltips after seeing enchants on the weapons with GetWeaponEnchantInfo. The combat log won't work if the player reloads or relogs with the enchant already active. You can use UNIT_INVENTORY_CHANGED to check for enchants being applied (also fires during login), but keep in mind that the info returned from GetWeaponEnchantInfo isn't correct immediately after that, but may take up to a second or two to be correct. Things that will often be wrong include the duration of the enchant, and also the name of the enchant if you scan the tooltip immediately. It's unfortunately quite complicated.

Last edited by Barjack : 10-19-11 at 03:47 PM.
  Reply With Quote
10-19-11, 04:18 PM   #11
Safturento
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 13
I find it kind of ridiculous that Blizzard would make a great function to get all sorts of information on buffs and debuffs, but decides to leave Weapon Enchants out of the loop. It just seems like it would be so much easier for them to just add it to the GetWeaponEnchantInfo function than for all of us to go through all of these complicated work arounds. =\
  Reply With Quote
10-19-11, 06:38 PM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
What I do for the timer bars in ShinyBuffs is use the time remaining compared with when the addon first sees the weapon buff (be that when it is applied or when your session begins).

/edit: scratch that... I just remembered that I gave up on that and just keep the bar full like they're timeless while the duration text counts down...


You guys should put this here: http://www.wowinterface.com/forums/f...splay.php?f=15
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh


Last edited by Seerah : 10-19-11 at 06:41 PM.
  Reply With Quote
10-19-11, 07:30 PM   #13
Safturento
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 13
Originally Posted by Seerah View Post
Done: http://www.wowinterface.com/forums/s...191#post246191
  Reply With Quote
10-19-11, 09:36 PM   #14
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Originally Posted by Barjack View Post
Even if you see the enchant happen and set that as the "max" for your bar (which actually isn't as easy as it sounds due to the delayed update of durations with fresh enchants), as soon as a player logs in with an already-enchanted weapon you will suddenly get an enchant with a "max" of 12 mins 32 sec or whatever was left when they logged in.
With db I mean a table stored in SV So it is only wrong when you install the addon with an enchant active until you refrest it.
Originally Posted by Barjack View Post
The best thing to do is probably just use your own list of names/IDs and durations as given above. Other than shaman and rogue enchants, fishing enchants are either 10 or 60 minutes, Venomhide Poison is 5 minutes, and most other enchants (various oils and sharpening stones) are usually 60 minutes as well (which is probably a good default for unknown enchants).
That requires to have a db with correct values predefined. Too much work
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
10-20-11, 08:33 AM   #15
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
Hello

See the code in the RDX addon.

Check the file RDX\Metadata\WeaponsBuffs.lua
Contains the list of all enchantbuff with the max durations.
Use spellid, so it works with US, FR, DE


Check the file RDX\RosterMgr\Core.lua

RDXDAL.registerBuffWeapon(spellid, duration, icon)
Line 201: This function is used to register an enchant duration

duration, icon = RDXDAL.getBuffWeaponInfo(name)
Line 214: This function is used to get an enchant duration base on the name

buffname, buffrank, bufftex, idslot = scanHand(hand)
Line 230: This function will scan your hand and return the name of the enchant, base on a tooltip scan. hand is "MainHandSlot", "SecondaryHandSlot", "RangedSlot"

RDXDAL.LoadWeaponsBuff()
Line 268 This function returns all informations
Returns:
hasMainHandEnchant, mainHandBuffName, mainHandBuffRank, mainHandCharges, mainHandBuffStart, mainHandBuffDur, mainHandTex, mainHandBuffTex, mainHandSlot,

hasOffHandEnchant, offHandBuffName, offHandBuffRank, offHandCharges, offHandBuffStart, offHandBuffDur, offHandTex, offHandBuffTex, offHandSlot,

hasThrownEnchant, thrownBuffName, thrownBuffRank, thrownCharges, thrownBuffStart, thrownBuffDur, thrownTex, thrownBuffTex, thrownSlot;

This code will also work with the coming rangeslot.
RDX code is opensource, free for use.

Best regards
Sigg
__________________
RDX manager
Sigg
  Reply With Quote
10-20-11, 09:31 AM   #16
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
You can make a custom tooltip for your addon, with it you can on certain events check with GetWeaponEnchantInfo() then if you need to check a weapon, use the tooltip and :SetInventoryItem("player", slot), then parse each line and line:match("^(.+) %((%d+) (%D+)%)$") the returned values should be the name, duration and the min/sec suffix label.

You now have a way to extract enchant data and with GetWeaponEnchantInfo()'s help get the duration of that enchant. If you call it properly when the buff is applied, you can cache the duration it has into the savedvariables!

You can later scan the tooltip when needed and refer to the already saved value, this way you can show a bar on the screen even if you just login or reload the UI.
  Reply With Quote
10-20-11, 10:34 AM   #17
Safturento
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 13
Sig, I love you; your code works flawlessly. Thank you, proper credits will be given.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Finding the duration of Weapon Enchants


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