Thread Tools Display Modes
12-07-11, 02:02 PM   #1
Gregity
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 54
Detect start of Disenchant

Hi, I'm looking for a way to detect a disenchant or sell action and be able to stop it in some cases.

I want to make an addon that will check the item being disenchanted or sold to see if it belongs to an equipment set. If it does, print a message that the item belongs to equipment set <name> and cancel the disenchant or sell.

I've lost gear before due to this and I'd like to stop it from happening.

I try to be careful when I do disenchant and sell, but I've blown it in the past and would like to at least get a warning that I'm about to do something I might regret.

I've poked around the API lists, but don't see anything that I can use for disenchant.

Thanks,
-g
  Reply With Quote
12-07-11, 03:16 PM   #2
Gazmik
A Cobalt Mageweaver
 
Gazmik's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 245
I do this in my Disenchant Predictor addon so I can make sure that the mats resulting from a disenchant match the predictions. You're welcome to check out the code there, but here's the gist of it:

1. Hook the OnClick handlers for both container buttons and inventory buttons so you can catch which item got clicked and remember it for the next step.

2. In UNIT_SPELLCAST_START, check to see if the spell being cast is Disenchant. (Note that you can do this in a locale-independent way if you start with the spellID for Disenchant and look up its name.) If it is, the item you clicked before is the one getting disenchanted.

This probably isn't the best way -- it doesn't catch disenchants that were set up by secure button attributes (as in mods like Breakables) or macros that "/cast disenchant" and then "/use" an item (by name or location). But it handles the most common case well.
__________________
Gazmik Fizzwidget's UI Addons: www.fizzwidget.com
  Reply With Quote
12-07-11, 03:48 PM   #3
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
By default an item owned by a set has "Used by set: ..." or similar tag, so you see what sets the item is used in, so you could really just check for that line in the tooltip, check GlobalStrings for what it's exactly written as and parse the tooltip when you mouseover an item while having the dissenchant spell "on the cursor ready to select something" or?
  Reply With Quote
12-07-11, 08:21 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Gazmik View Post
Note that you can do this in a locale-independent way if you start with the spellID for Disenchant and look up its name.
You actually don't even need to do that; since WoW 4.0 the UNIT_SPELLCAST_START event fires with a 5th argument containing the spellID of the spell being cast. Simply check if that spellID matches the spellID for Disenchant.
  Reply With Quote
12-08-11, 01:53 AM   #5
Gregity
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 54
I'll be playing around with the ideas here. There is much I'm going to need to learn. Thanks for the ideas so I can investigate how I might make it work.
-g
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Detect start of Disenchant


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