View Single Post
03-30-21, 04:09 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
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