Quantcast
spellId, COMBAT_LOG_EVENT_UNFILTERED - WoWInterface
Thread Tools Display Modes
12-14-16, 05:30 AM   #1
Xiaowei
A Defias Bandit
Join Date: Nov 2016
Posts: 2
spellId, COMBAT_LOG_EVENT_UNFILTERED

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:
  1. local Enlightener = CreateFrame('FRAME')
  2. Enlightener:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  3. Enlightener:SetScript('OnEvent', function(self, event, ...)
  4.  
  5.   local event = select(2, ...)
  6.   local sourceGUID = select(4, ...)
  7.   local destGUID = select(8, ...)
  8.   local spellId = select(12, ...)
  9.   local extraSpellId = select(15, ...) -- 'missType' for '_MISSED'
  10.  
  11.   if sourceGUID == UnitGUID('player') or sourceGUID == UnitGUID('pet') then
  12.     -- Interrupted
  13.     if event == 'SPELL_INTERRUPT' then
  14.       UIErrorsFrame:AddMessage('Interrupted: '..GetSpellInfo(extraSpellId), 1, 1, 0)
  15.  
  16.     -- Dispelled
  17.     elseif event == 'SPELL_DISPEL' then
  18.       UIErrorsFrame:AddMessage('Dispelled: '..GetSpellInfo(extraSpellId), 1, 1, 0)
  19.  
  20.     -- Stolen
  21.     elseif event == 'SPELL_STOLEN' then
  22.       UIErrorsFrame:AddMessage('Stolen: '..GetSpellInfo(extraSpellId), 1, 1, 0)
  23.  
  24.     -- Experimental: Grounded
  25.     elseif event == 'SPELL_DAMAGE'
  26.     and spellId == 204336 then -- Shaman: Grounding Totem
  27.       UIErrorsFrame:AddMessage('Grounded: '..GetSpellInfo(spellId), 1, 1, 0)
  28.       PlaySoundFile('Interface\\AddOns\\Enlightener\\Alert.ogg', 'Master')
  29.  
  30.     -- Evaded
  31.     elseif event == 'SPELL_MISSED' and extraSpellId == 'EVADE' then
  32.       UIErrorsFrame:AddMessage('Evaded: '..GetSpellInfo(spellId), 1, 1, 0)
  33.       PlaySoundFile('Interface\\AddOns\\Enlightener\\Alert.ogg', 'Master')
  34.  
  35.     -- Immune
  36.     elseif event == 'SPELL_MISSED' and extraSpellId == 'IMMUNE'
  37.     and spellId ~= 43265 -- Death Knight: Death and Decay
  38.     and spellId ~= 26573 -- Paladin: Consecration
  39.     and spellId ~= 6343 then -- Warrior: Thunder Clap
  40.       UIErrorsFrame:AddMessage('Immune: '..GetSpellInfo(spellId), 1, 1, 0)
  41.       PlaySoundFile('Interface\\AddOns\\Enlightener\\Alert.ogg', 'Master')
  42.  
  43.     -- Experimental: Shattered
  44.     elseif event == 'SPELL_MISSED' and extraSpellId == 'IMMUNE'
  45.     and spellId == 65941 then -- Warrior: Shattering Throw
  46.       UIErrorsFrame:AddMessage('Shattered', 1, 1, 0)
  47.  
  48.     -- Experimental: Reflected
  49.     elseif event == 'SPELL_MISSED' and extraSpellId == 'REFLECT' and destGUID == UnitGUID('player') then
  50.       UIErrorsFrame:AddMessage('Reflected: '..GetSpellInfo(spellId), 1, 1, 0)
  51.     end
  52.   end
  53. end)
  Reply With Quote
12-14-16, 07:02 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,092
There can be many versions of the same spell in the game database. You need to insert some debug code printing out what SpellIDs are getting past your checks. Once you find the IDs getting through and block them, you can remove the debug code.
__________________
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)
  Reply With Quote
12-14-16, 07:45 AM   #3
Xiaowei
A Defias Bandit
Join Date: Nov 2016
Posts: 2
Thanks for your input. I did not know about that. I have added some code to test and verify.

Do you have any tips in terms of limiting the amount of events that can occur at once?
  Reply With Quote
12-14-16, 09:20 AM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,203
Originally Posted by Xiaowei View Post
Do you have any tips in terms of limiting the amount of events that can occur at once?
You can use AceBucket-3.0 https://www.wowace.com/projects/ace3...ace-bucket-3-0
  Reply With Quote
12-14-16, 06:23 PM   #5
Eternal_Lynx
An Aku'mai Servant
 
Eternal_Lynx's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 31
For throttling, there's a lib-free approach: store that timestamp (eg. GetTime()) whenever a message is sent/sound effect is played, then calculate elapsed time from last recorded timestamp, if it's shorter than your desired interval, return.
__________________
Moo'. Are you happy now?
  Reply With Quote
12-15-16, 02:56 AM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,092
An addon like this isn't really suited for caching events for later processing. As the alerts only trigger from the player doing stuff, the amount of actual actions it takes versus the event firing is slim. As an alert addon, you need your info immediately, not seconds later. Your code is far from optimized, but it a decent start for what needs done.

One thing I would do is implement an internal message cooldown so it doesn't spam the user when using an AoE that misses, evades, etc. There are a lot of these and the list is changing all the time. The optimizations I would do first is cache the player and pet GUIDs so you're not calling UnitEvent() constantly. Combine the local assignment and move away from using select(). Look into nesting similar conditions together in your if blocks so the CPU isn't stuck comparing stuff you already checked over and over previously. Get rid of GetSpellInfo(), the spell name in either use is provided in the args, use them instead.
__________________
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 : 12-15-16 at 03:04 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » spellId, COMBAT_LOG_EVENT_UNFILTERED

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off