View Single Post
10-08-12, 04:03 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
In that case, just remove that entire SPELL_CAST_SUCCESS block. That event fires when the spell finishes casting, no matter if it took effect on the target or not. I would also suggest havint the spell check before the other conditionals since no matter what event type is triggered, you'd want to exit if it's a spell you want to exclude.

This is what I have in mind:
Lua Code:
  1. --  Spell List
  2. local spellData = {
  3.  
  4. --  Class Spells
  5.  
  6.     [2139] = { -- Counterspell
  7.         cooldown = 24,
  8. --      texture = "Interface\\Icons\\spell_frost_iceshock",
  9.     },
  10.     [1766] = { -- Kick
  11.         cooldown = 15,
  12.     },
  13.     [47528] = { -- Mind Freeze
  14.         cooldown = 15,
  15.     },
  16.     [6522] = { -- Pummel
  17.         cooldown = 15,
  18.     },
  19.     [96231] = { -- Rebuke
  20.         cooldown = 15,
  21.     },
  22.     [80964] = { -- Skull Bash (Bear Form)
  23.         cooldown = 15,
  24.     },
  25.     [80965] = { -- Skull Bash (Cat Form)
  26.         cooldown = 15,
  27.     },
  28.     [57994] = { -- Wind Shear
  29.         cooldown = 12,
  30.     },
  31.     [34490] = { -- Silencing Shot
  32.         cooldown = 20,
  33.     },
  34.     [15487] = { -- Silence (Priest)
  35.         cooldown = 45,
  36.     },
  37.     [47476] = { -- Strangulate
  38.         cooldown = 120,
  39.     },
  40. --  [108194] = { -- Asphyxiate
  41. --      cooldown = 20,
  42. --  },
  43.     [116705] = { -- Spear Hand Strike
  44.         cooldown = 15,
  45.     },
  46.  
  47. --  Racials
  48.  
  49.     [28730] = { -- Arcane Torrent (Mana)
  50.         cooldown = 120,
  51.     },
  52.     [50613] = { -- Arcane Torrent (Runic Power)
  53.         cooldown = 120,
  54.     },
  55.     [80483] = { -- Arcane Torrent (Focus)
  56.         cooldown = 120,
  57.     },
  58.     [129597] = { -- Arcane Torrent (Chi)
  59.         cooldown = 120,
  60.     },
  61.     [25046] = { -- Arcane Torrent (Energy)
  62.         cooldown = 120,
  63.     },
  64.     [69179] = { -- Arcane Torrent (Rage)
  65.         cooldown = 120,
  66.     },
  67. }
  68.  
  69. local eventFrame = CreateFrame("Frame")
  70. eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  71. eventFrame:SetScript("OnEvent", function(self,event, _, combatEvent, _, sourceGUID, _, _, _, _, destName, _, _, spellID, spellName, _, extraSpellID)
  72.  
  73. --  Only allow player and specific spells we handle
  74.     local spell=spellData[spellID]
  75.     if sourceGUID ~= UnitGUID("Player") or not spell then
  76.         return
  77.     end
  78.  
  79. --  Success/Fail Messages
  80.     if combatEvent == "SPELL_INTERRUPT" then
  81.         SendChatMessage(format("%s > %s's %s",GetSpellLink(spellID),destName,GetSpellLink(extraSpellID)),"Say")
  82.     elseif combatEvent == "SPELL_CAST_MISSED" then
  83.         SendChatMessage(format("%s has failed to interrupt !!!  %.0fs CD",GetSpellLink(spellID),spell.cooldown),"Say")
  84.     elseif combatEvent == "SPELL_CAST_FAILED" then
  85. --      Remaining Time Message
  86.         local start, duration, enabled = GetSpellCooldown(spellID)
  87.         if enabled==1 and duration>0 then
  88.             SendChatMessage(format("%s's CD has %0.1fs left", GetSpellLink(spellID), (start + duration) - GetTime()), "Say")
  89.         end
  90.     end
  91. end)

Note, I shortened the code a bit, renamed the variables receiving GetSpellCooldown()'s returns to conform with Blizzard's Add-On Development Policy regarding obfuscation, and cleaned up the event handler's parameters. The unused handler parameters have been renamed to the variable _ , which even though it's considered in Lua as just another variable, it's commonly used for this and is easier to distinguish as a value that isn't important.

EDIT: Removed the condition for SPELL_AURA_APPLIED since in some cases, it may cause spaming when using an AoE ability like Arcane Torrent. This will also fix some cases of success messages sending twice.

Note, SPELL_CAST_FAILED should also be considered for possible spam as some players may "mash" the ability when trying to cast it.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 10-08-12 at 04:13 PM.
  Reply With Quote