Quantcast
Tracking my spell casts and fails - WoWInterface
Thread Tools Display Modes
03-30-21, 04:09 PM   #1
Walkerbo
A Flamescale Wyrmkin
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 143
Tracking my spell casts and fails

Hi all

I need to track the player, (and the player only), spell casts, so I am tracking the different Spell Cast events.

The UNIT_SPELLCAST_SENT event is the only one that returns the unit casting the spell, however this returns regardless of whether the cast goes off or not, (eg; casting Health Funnel cannot be cast on a pet that is already full health).

I thought I could track UNIT_SPELLCAST_FAILED, UNIT_SPELLCAST_STOP and UNIT_SPELLCAST_SUCCEEDED yet these fire on any spell cast by others in the same group/instance/raid so I cannot guarantee that it is my spell that fails, stops or succeeds.

I have further problems that when I get multiple returns from the one spell cast, ( eg I cast agony and I get two returns).

Corruption returns multiples for two different spell IDs, (146739, 172), even though the spell cast sent is only for the 172 spell ID.

Here is my event tracking chunk;
Lua Code:
  1. elseif event == "UNIT_SPELLCAST_SENT" then
  2.             unit, target, _, spellID = ...
  3.             spellName = GetSpellInfo(spellID)
  4.             print("|cffAAD372 UNIT_SPELLCAST_SENT - unit, spellID, spellName - ", unit, spellID, spellName) -- debug --
  5.  
  6.  
  7. elseif event == "UNIT_SPELLCAST_FAILED" then
  8.             _, _, spellID = ...
  9.             spellName = GetSpellInfo(spellID)
  10.             print("|cff3FC7EB UNIT_SPELLCAST_FAILED - spellID, spellName - ", spellID, spellName) -- debug --
  11.  
  12.  
  13. elseif event == "UNIT_SPELLCAST_START" then
  14.             _, _, spellID = ...
  15.             spellName = GetSpellInfo(spellID)
  16.             print("|cffF48CBA UNIT_SPELLCAST_START - spellID, spellName - ", spellID, spellName) -- debug --
  17.  
  18.  
  19. elseif event == "UNIT_SPELLCAST_STOP" then
  20.             _, _, spellID = ...
  21.             spellName = GetSpellInfo(spellID)
  22.             print("|cffFF7C0A UNIT_SPELLCAST_STOP - spellID, spellName - ", spellID, spellName) -- debug --
  23.  
  24.  
  25. elseif event == "UNIT_SPELLCAST_SUCCEEDED" then
  26.             _, _, spellID = ...
  27.             spellName = GetSpellInfo(spellID)
  28.            print("|cffFFF468 UNIT_SPELLCAST_SUCCEEDED - spellID, spellName - ", spellID, spellName) -- debug --

Here is a gif of the returns for each event that I am tracking;


Is there a way that I can reliably track only my spell casts and only my spell cast successes?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
03-30-21, 04:56 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,439
The first parameter in the payload for UNIT_xxx events is the unit that is the target of the event

Code:
local unit , x, x = ...
if unit == "player" then
   -- you started casting, sent the cast, failed at casting, stopped casting or got the job done.
end
In your code, "UNIT_SPELLCAST_SENT is the only event where you check for the unit
Code:
local function OnEvent(self, event, ...)
	local unit, arg2, arg3, arg4 = ...
	if unit ~= "player" then
		return
	end
	if event == "zzz"  then
		if arg2 == yyy then
			-- whatever for event zzz
		end
	elseif event == "ddd" then
		if arg3 == nnn then
			-- whatever for event ddd
		end
	end
end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-30-21 at 05:07 PM.
  Reply With Quote
03-30-21, 05:32 PM   #3
Walkerbo
A Flamescale Wyrmkin
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 143
Thx Fizzlemizz

I thought that the first return was the unit I was targeting, not the unit casting the spell; thanks for pointing this one out to me.

The issue with the corruption spell still confuses me;
When I cast Corruption the spellID is 172, yet the success event returns two events, spellID 172 as well as the extra spellID 146739.

The annoying part is both of the spellIDs both comeback as player, so effectively I am getting two successes for the one cast.

I guess that there are multiple Corruption spells that have different spellIDs yet the one I cast is 172 so why do I get the second success of the spell I did not cast?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
03-30-21, 05:39 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,439
Isn't 146739 the aura that gets applied with corruption?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-30-21, 05:50 PM   #5
Walkerbo
A Flamescale Wyrmkin
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 143
Smile

Hey Fizzlemizz

Yes, you are right it is the buff.

To ensure I am only testing the spellID I cast I have now saved the spellID on cast and test that against the success spellID, to ensure I capture the right return.

Once again you have saved me.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Tracking my spell casts and fails

Thread Tools
Display Modes

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