My add-on enlightens the user when certain events occur. It has difficulties matching the
spellId for
-- Immune as it triggers even when
spellId is one of the three excluded.
There is no doubt if
spellId indeed returns an ID, since
UIErrorsFrame:AddMessage has no difficulties returning the spell name through
GetSpellInfo.
What have I done wrong here? I am lost completely.
On a completely unrelated note, I would also like to implement some sort of safety limit that will ensure that events cannot trigger many times at the same time as this could occur in rare circumstances. Any tips on how to achieve this?
Lua Code:
local Enlightener = CreateFrame('FRAME')
Enlightener:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
Enlightener:SetScript('OnEvent', function(self, event, ...)
local event = select(2, ...)
local sourceGUID = select(4, ...)
local destGUID = select(8, ...)
local spellId = select(12, ...)
local extraSpellId = select(15, ...) -- 'missType' for '_MISSED'
if sourceGUID == UnitGUID('player') or sourceGUID == UnitGUID('pet') then
-- Interrupted
if event == 'SPELL_INTERRUPT' then
UIErrorsFrame:AddMessage('Interrupted: '..GetSpellInfo(extraSpellId), 1, 1, 0)
-- Dispelled
elseif event == 'SPELL_DISPEL' then
UIErrorsFrame:AddMessage('Dispelled: '..GetSpellInfo(extraSpellId), 1, 1, 0)
-- Stolen
elseif event == 'SPELL_STOLEN' then
UIErrorsFrame:AddMessage('Stolen: '..GetSpellInfo(extraSpellId), 1, 1, 0)
-- Experimental: Grounded
elseif event == 'SPELL_DAMAGE'
and spellId == 204336 then -- Shaman: Grounding Totem
UIErrorsFrame:AddMessage('Grounded: '..GetSpellInfo(spellId), 1, 1, 0)
PlaySoundFile('Interface\\AddOns\\Enlightener\\Alert.ogg', 'Master')
-- Evaded
elseif event == 'SPELL_MISSED' and extraSpellId == 'EVADE' then
UIErrorsFrame:AddMessage('Evaded: '..GetSpellInfo(spellId), 1, 1, 0)
PlaySoundFile('Interface\\AddOns\\Enlightener\\Alert.ogg', 'Master')
-- Immune
elseif event == 'SPELL_MISSED' and extraSpellId == 'IMMUNE'
and spellId ~= 43265 -- Death Knight: Death and Decay
and spellId ~= 26573 -- Paladin: Consecration
and spellId ~= 6343 then -- Warrior: Thunder Clap
UIErrorsFrame:AddMessage('Immune: '..GetSpellInfo(spellId), 1, 1, 0)
PlaySoundFile('Interface\\AddOns\\Enlightener\\Alert.ogg', 'Master')
-- Experimental: Shattered
elseif event == 'SPELL_MISSED' and extraSpellId == 'IMMUNE'
and spellId == 65941 then -- Warrior: Shattering Throw
UIErrorsFrame:AddMessage('Shattered', 1, 1, 0)
-- Experimental: Reflected
elseif event == 'SPELL_MISSED' and extraSpellId == 'REFLECT' and destGUID == UnitGUID('player') then
UIErrorsFrame:AddMessage('Reflected: '..GetSpellInfo(spellId), 1, 1, 0)
end
end
end)