WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Detect start of Disenchant (https://www.wowinterface.com/forums/showthread.php?t=42026)

Gregity 12-07-11 02:02 PM

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

Gazmik 12-07-11 03:16 PM

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.

Vlad 12-07-11 03:48 PM

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? :)

Phanx 12-07-11 08:21 PM

Quote:

Originally Posted by Gazmik (Post 248907)
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.

Gregity 12-08-11 01:53 AM

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


All times are GMT -6. The time now is 03:15 PM.

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