UNIT_SPELLCAST_START behavior?

Got a problem that may be a bug. But I’ve been burned enough to know that bugs often turn out to be my own error. So, here goes.

I have an addon that uses UNIT_SPELLCAST_START to notify a player when a mob begins a cast. If the spell is interruptible the addon displays a notification to the screen so the player can interrupt the mob. This works fine … sort of.

Curiously, when I test the addon against the rogue wizards (at the Stone Cairn lake in Elwynn Forest) the UNIT_SPELLCAST_START event fires twice! When I test it against other caster mobs (e.g., the geomancers near the Jasperlode mine) the event fires only once … as expected.

Any thoughts?

Which game version? In retail you get the event re-occuring because they chain cast their spell.

If not that, is the duplicate comming from the same unit?

Thanks, Fizz. The version is retail and I took care to eliminate any other casters in the vicinity. I’ve tested this against other casters and the addon works as I would expect.

Cheers,

My test (below ), single frame, single event, simple print, shows they appear to be working as intended so it’s a bit hard to try and diagnose without any code.

local f = CreateFrame("Frame")
f:RegisterEvent("UNIT_SPELLCAST_START")
f:SetScript("OnEvent", function(self, event, ...)
	local unit, spellGUID, spellID = ...
	print("|cffffff00frame|r", self, "\n|cffffff00unit|r", unit, "\n|cffffff00unitGUID|r", spellGUID, "\n|cffffff00unitspellID|r", spellID)
end)

Here’s my code that exhibits the behavior described above:

if event == "UNIT_SPELLCAST_START" then
        local casterId = arg1      
        local targetId = nil
        local playerName = UnitName("Player")
        local targetName = nil

        if casterId ~= nil then
            targetId = casterId .. "target"
            casterName = UnitName( casterId )
            targetName = UnitName( targetId )
            if targetName == playerName then
                targetName = "you!"
            end
        end

        local interruptible = false
        local spellName, _, _, _, _, _, _, notInterruptible, spellId = UnitCastingInfo( casterId )
        if interruptible then
            local s = nil
            if targetName == nil then
                s = sprintf("%s, %s\n", casterName, spellName )
            else        
                s = sprintf("%s, %s, %s\n", casterName, spellName, targetName )
            end
            UIErrorsFrame:AddMessage(s, 1.0, 1.0, 0.0, 1, 10 )
        end
        return
    end

FYI, the event (UNIT_SPELLCAST_START) only fires twice when caster is a rogue wizard at stone cairn lake. There is another rogue wizard in a camp near the Jasperlode mine that, when casting, only triggers the event once - as it should.

Cheers,

It looks to me like you might have an easier time of it parsing the Combat Log Event Unfiltered (called the CLEU).

https://wowpedia.fandom.com/wiki/COMBAT_LOG_EVENT

That carries a payload that has much of what you’re looking for in it - should simplify the code a bit and make it easier to find the problem.

I’m wondering if this code is what’s actually triggering whatever you’re seeing:

local interruptible = false
local spellName, _, _, _, _, _, _, notInterruptible, spellId = UnitCastingInfo( casterId )
if interruptible then
    ...
end

you’re assigning/checking interruptible but using notInterruptible as the return value of UnitCastingInfo() ie. interruptible will always be false!

My testing has been on the island at Stone Cairn.

you’re assigning/checking interruptible but using notInterruptible as the return value of UnitCastingInfo() ie. interruptible will always be false!

Good catch. Off to stone cairn to see if it fixes things.

Cheers,

The code provided should never report an interruptable spell so I imagine a duplicate would be out of the question. Which leads to the probablility of the problem being elsewhere (in your code or another addon entirely??).

Maybe a test addon still active?

Well, I’ve given up for now. Instead, I added a flag that prevents the code from executing the handler twice in the “same” interrupt. I will get back to it, however.

As to other addons, the code is developed and tested with no other addons active.

Thanks and I’m sure I’ll have more issues once I get some other tasks accomplished.