Thread Tools Display Modes
04-21-06, 09:15 AM   #1
Nyrine
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 23
Detecting spell casting

Hi,

I'm writing an addon, and I need to be able to count genuine spells cast by the player.

Currently, i'm hooking into :

CHAT_MSG_SPELL_SELF_DAMAGE
CHAT_MSG_SPELL_SELF_BUFF

And this works fine - to a point.

These events also fire if certain items proc, or spell effects work etc., and I would like to discount these.

For example :

I have Windfury up, and it goes off, this triggers the CHAT_MSG_SPELL_SELF_BUFF event.

The drain life effect on my shield goes off, this triggers both CHAT_MSG_SPELL_SELF_BUFF and CHAT_MSG_SPELL_SELF_DAMAGE

Is there a way to determine which are genuine spells cast by a player vs which are procs ?

EDIT : I did think of maybe trying to see if the global cooldown timer was active, but some spells genuinely cast by a player (long heals f/ex) have a casttime loinger than the cooldown, so by the time the spell goes off and fires the event, the cooldown timer has already reset.

I'd prefer not to have to have a list of proc effects and skip those !

Thanks for any help =)

EDIT2: Seems a different set of search criteria would have helped. Reading this post :http://www.wowinterface.com/forums/s...ead.php?t=4009 suggests that the SPELLCAST_STOP event may work - I'll give that a go !

Last edited by Nyrine : 04-21-06 at 10:58 AM.
  Reply With Quote
04-21-06, 11:01 AM   #2
Esamynn
Featured Artist
Premium Member
Featured
Join Date: Jan 2005
Posts: 395
Have you tried playing around with

SPELLCAST_CHANNEL_START
SPELLCAST_CHANNEL_STOP
SPELLCAST_CHANNEL_UPDATE
SPELLCAST_DELAYED
SPELLCAST_FAILED
SPELLCAST_INTERRUPTED
SPELLCAST_START
SPELLCAST_STOP

I don't know if any of the non-CHANNEL events fire prior to a channelling bar starting, but certainly for all other spells the following should work:

Monitor the SPELLCAST_STOP and SPELLCAST_FAILED events.

Whenever SPELLCAST_FAILED fires set a "dirty" flag

Whenever SPELLCAST_STOP fires and the dirty flag is NOT set, the player has sucessfully cast a spell. If the "dirty" flag is set, the spellcast failed. Don't forget to CLEAR the dirty flag every time this event fires.


Also see:

http://www.wowwiki.com/HOWTO:_Detect...nt_Cast_Spells
  Reply With Quote
04-21-06, 12:17 PM   #3
Nyrine
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 23
OK - got this working (mostly) - thanks !

This is using ACE, so I do :

Code:
self:RegisterEvent("SPELLCAST_INTERRUPTED", "SO_INT")
self:RegisterEvent("SPELLCAST_STOP", "SO_INC")
self.spellsuccess = 0
Then I have :

Code:
SO_INT = function(self)
	if (self.spellsuccess == 1) then
		self.charData.so_cnt = self.charData.so_cnt-1
		self:Update()
	end
	self.spellsuccess = 0
end

SO_INC = function(self)
	self.charData.so_cnt = self.charData.so_cnt+1
	self.spellsuccess = 1
	self:Update()
end
This works mostly, but SO_INC still fires for First Aid, which isnt really a 'spell' as such !

Last edited by Nyrine : 04-21-06 at 01:22 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Detecting spell casting


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