WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Tracking my spell casts and fails (https://www.wowinterface.com/forums/showthread.php?t=58659)

Walkerbo 03-30-21 04:09 PM

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?

Fizzlemizz 03-30-21 04:56 PM

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


Walkerbo 03-30-21 05:32 PM

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?

Fizzlemizz 03-30-21 05:39 PM

Isn't 146739 the aura that gets applied with corruption?

Walkerbo 03-30-21 05:50 PM

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


All times are GMT -6. The time now is 06:47 PM.

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