View Single Post
10-30-14, 12:07 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That's not really a hack, though it is a bit inefficient. You really only need to keep track of the unique ID for the cast. Assuming that the relevant UNIT_SPELLCAST_INTERRUPTED event always fires after the UNIT_SPELLCAST_SUCCEEDED event for your Pummel, something like this is fairly straightforward and should get the job done:

Code:
local pummelCast

local f = CreateFrame("Frame")
f:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", "player")
f:RegisterUnitEvent("UNIT_SPELLCAST_INTERRUPTED", "target")

f:SetScript("OnEvent", function(self, event, ...)
     if event == "UNIT_SPELLCAST_SUCCEEDED" then
          -- You cast Pummel
          local _, _, _, _, _, _, _, castID, interruptible = UnitCastingInfo("target")
          if castID and interruptible then
               pummelCast = castID
          else
               castID = nil
          end
     else
          -- Your target's spellcast was interrupted
          local _, _, _, castID, spellID = ...
          if castID = pummelCast then
              print("Interrupted", GetSpellLink(spellID))
          end
          knownCastID = nil
     end
end)
If you're using Pummel on units other than your target, you'll need to make some minor modifications to avoid using a hardcoded "target" unit, but you don't need to keep track of the target between events, because two units won't ever share a castID.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote