I have a coding question about my new addon.
Basically, i'm trying to write an addon that tells you about your interrupt spells.
these three are what this addon supposed to do.
It pops up a message whenever you actually interrupt enemy's spells.
If you fail to interrupt enemy's spells (immune,absorb,etc), it pops up a failure message with cooldown duration of the spell you failed with.
If you cast an interrupt spell than is still on its cooldown, it pops up a message to show you the remaining cooldown duration of the spell.
and here is my code.
Lua Code:
-- Spell List
local spellData = {
-- Class Spells
[2139] = { -- Counterspell
cooldown = 24,
--texture = "Interface\\Icons\\spell_frost_iceshock",
},
[1766] = { -- Kick
cooldown = 15,
},
[47528] = { -- Mind Freeze
cooldown = 15,
},
[6522] = { -- Pummel
cooldown = 15,
},
[96231] = { -- Rebuke
cooldown = 15,
},
[80964] = { -- Skull Bash (Bear Form)
cooldown = 15,
},
[80965] = { -- Skull Bash (Cat Form)
cooldown = 15,
},
[57994] = { -- Wind Shear
cooldown = 12,
},
[34490] = { -- Silencing Shot
cooldown = 20,
},
[15487] = { -- Silence (Priest)
cooldown = 45,
},
[47476] = { -- Strangulate
cooldown = 120,
},
--[108194] = { -- Asphyxiate
-- cooldown = 20,
--},
[116705] = { -- Spear Hand Strike
cooldown = 15,
},
-- Racials
[28730] = { -- Arcane Torrent (Mana)
cooldown = 120,
},
[50613] = { -- Arcane Torrent (Runic Power)
cooldown = 120,
},
[80483] = { -- Arcane Torrent (Focus)
cooldown = 120,
},
[129597] = { -- Arcane Torrent (Chi)
cooldown = 120,
},
[25046] = { -- Arcane Torrent (Energy)
cooldown = 120,
},
[69179] = { -- Arcane Torrent (Rage)
cooldown = 120,
},
}
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
eventFrame:SetScript("OnEvent", function(self, event, timestap, combatEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellID, spellName, spellSchool, extraSpellID, extraSpellName, ...)
if sourceName ~= UnitName("Player") then
return
end
-- Messages
local fChat = GetSpellLink(spellID).." has failed to interrupt !!! "..spell.cooldown.."s CD"
local sChat = GetSpellLink(spellID).." > "..destName.."'s "..GetSpellLink(extraSpellID)
if combatEvent == "SPELL_CAST_SUCCESS" then
local spell = spellData[spellID]
if not spell then
return
end
if combatEvent == "SPELL_AURA_APPLIED" then
SendChatMessage(sChat,"Say")
end
if combatEvent == "SPELL_INTERRUPT" then
SendChatMessage(sChat,"Say")
end
SendChatMessage(fChat,"Say")
end
if combatEvent == "SPELL_CAST_MISSED" then
local spell = spellData[spellID]
if not spell then
return
end
SendChatMessage(fChat,"Say")
end
-- Remaining Time Message
if combatEvent == "SPELL_CAST_FAILED" then
local spell = spellData[spellID]
if not spell then
return
end
if IsSpellInRange(spellName,"Target") == 1 or spellName == "Arcane Torrent" then
local xt,yt,zt = GetSpellCooldown(spellID)
local cdt = (xt + yt) - GetTime()
if zt ~= 0 then
SendChatMessage(GetSpellLink(spellID).."'s CD has "..(ceil(cdt*10)/10).."s left","Say")
end
end
end
end)
I noticed that when you are supposed to only get a message for either spell_aura_applied or spell_interrupt, you also get a spell_cast_success message
like,
[Kick] has failed to interrupt !!! 15s CD
[Kick] > Mage's [Frost Bolt]
I want to know if you can ignore the cast_success message whenever you get either aura_applied or cast_interrupt message.
Also, if there is a way to fix this addon to make it work better, please help me to do so. I am a newb and this is my very first addon