View Single Post
10-08-12, 11:15 AM   #1
Mayoren
A Defias Bandit
Join Date: Oct 2012
Posts: 3
I have a coding question about my new addon.

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:
  1. -- Spell List
  2.  
  3. local spellData = {
  4.  
  5.     -- Class Spells
  6.  
  7.     [2139] = { -- Counterspell
  8.         cooldown = 24,
  9.         --texture = "Interface\\Icons\\spell_frost_iceshock",
  10.     },
  11.     [1766] = { -- Kick
  12.         cooldown = 15,
  13.     },
  14.     [47528] = { -- Mind Freeze
  15.         cooldown = 15,
  16.     },
  17.     [6522] = { -- Pummel
  18.         cooldown = 15,
  19.     },
  20.     [96231] = { -- Rebuke
  21.         cooldown = 15,
  22.     },
  23.     [80964] = { -- Skull Bash (Bear Form)
  24.         cooldown = 15,
  25.     },
  26.     [80965] = { -- Skull Bash (Cat Form)
  27.         cooldown = 15,
  28.     },
  29.     [57994] = { -- Wind Shear
  30.         cooldown = 12,
  31.     },
  32.     [34490] = { -- Silencing Shot
  33.         cooldown = 20,
  34.     },
  35.     [15487] = { -- Silence (Priest)
  36.         cooldown = 45,
  37.     },
  38.     [47476] = { -- Strangulate
  39.         cooldown = 120,
  40.     },
  41.     --[108194] = { -- Asphyxiate
  42.     --  cooldown = 20,
  43.     --},
  44.     [116705] = { -- Spear Hand Strike
  45.         cooldown = 15,
  46.     },
  47.  
  48.     -- Racials
  49.  
  50.     [28730] = { -- Arcane Torrent (Mana)
  51.         cooldown = 120,
  52.     },
  53.     [50613] = { -- Arcane Torrent (Runic Power)
  54.         cooldown = 120,
  55.     },
  56.     [80483] = { -- Arcane Torrent (Focus)
  57.         cooldown = 120,
  58.     },
  59.     [129597] = { -- Arcane Torrent (Chi)
  60.         cooldown = 120,
  61.     },
  62.     [25046] = { -- Arcane Torrent (Energy)
  63.         cooldown = 120,
  64.     },
  65.     [69179] = { -- Arcane Torrent (Rage)
  66.         cooldown = 120,
  67.     },
  68. }
  69.  
  70.  
  71. local eventFrame = CreateFrame("Frame")
  72.  
  73. eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  74.  
  75. eventFrame:SetScript("OnEvent", function(self, event, timestap, combatEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellID, spellName, spellSchool, extraSpellID, extraSpellName, ...)
  76.    
  77.    
  78.     if sourceName ~= UnitName("Player") then
  79.         return
  80.     end
  81.  
  82. -- Messages
  83.    
  84.    
  85.     local fChat = GetSpellLink(spellID).." has failed to interrupt !!!  "..spell.cooldown.."s CD"
  86.     local sChat = GetSpellLink(spellID).." > "..destName.."'s "..GetSpellLink(extraSpellID)
  87.  
  88.    
  89.     if combatEvent == "SPELL_CAST_SUCCESS" then
  90.         local spell = spellData[spellID]
  91.         if not spell then
  92.             return
  93.         end
  94.  
  95.         if combatEvent == "SPELL_AURA_APPLIED" then
  96.         SendChatMessage(sChat,"Say")
  97.         end
  98.        
  99.         if combatEvent == "SPELL_INTERRUPT" then
  100.         SendChatMessage(sChat,"Say")
  101.         end
  102.        
  103.         SendChatMessage(fChat,"Say")
  104.     end
  105.            
  106.     if combatEvent == "SPELL_CAST_MISSED" then
  107.         local spell = spellData[spellID]
  108.             if not spell then
  109.         return
  110.         end
  111.         SendChatMessage(fChat,"Say")
  112.     end
  113.    
  114.    
  115. -- Remaining Time Message
  116.  
  117.     if combatEvent == "SPELL_CAST_FAILED" then
  118.         local spell = spellData[spellID]
  119.             if not spell then
  120.                 return
  121.             end
  122.         if IsSpellInRange(spellName,"Target") == 1 or spellName == "Arcane Torrent" then
  123.             local xt,yt,zt = GetSpellCooldown(spellID)
  124.             local cdt = (xt + yt) - GetTime()
  125.             if zt ~= 0 then
  126.             SendChatMessage(GetSpellLink(spellID).."'s CD has "..(ceil(cdt*10)/10).."s left","Say")
  127.             end
  128.         end
  129.     end
  130. 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
  Reply With Quote