Is there a better (more efficient) way for a Taunt resist notify addon? It seems to me that parsing every single combat log event is a bit wasteful. Forgive me of my ignorance :(
TauntResist = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0")
function TauntResist:OnEnable()
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
function TauntResist:COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, ...)
if( event=="SPELL_MISSED" and sourceName==UnitName("player") ) then
local spellId, spellName, spellSchool, missType = select(1, ...)
if (spellName == "Taunt" or spellName == "Growl" or spellName == "Challenging Roar" or spellName == "Challenging Shout") then
if missType == "RESIST" then
-- Taunt resist on BrownBear.
SendChatMessage(spellName.." resist on "..destName..".", "YELL");
elseif missType == "EVADE" then
-- Taunt on BrownBear failed! Evading on John.
SendChatMessage(spellName.." on "..destName.." failed! Evading on "..UnitName("targettarget")..".", "YELL");
end
end
end
end
While it would be better to allow us to register for only the combat events we actually care about, calling a simple if statement on every combat event is still many times better than having to parse every combat event by localization. There really isn't a need at all for a parserlib anymore except for the combat events not yet moved to the new system (Rep gain, Experience, etc...). Unless you just want one that puts the event data into a table, but that is really trivial and probably should just be done by the addons that want that.
In your case there isn't a lot that can be made more efficiently than what you have, since you only care about one event type. You could potentially change from using names and use the GUID's and UnitGUID() instead. When you start caring about multiple events you can use a lookup table and some of the combat log constants to filter things out easier. Here's an simplified example of what I have done to filter Proximo for only enemy deaths (and if anyone has found better ways, I'm all ears):
--combat log locals
Proximo.COMBAT_EVENTS = {
["UNIT_DIED"] = true,
["UNIT_DESTROYED"] = true,
}
local COMBAT_EVENTS = Proximo.COMBAT_EVENTS
local CombatLog_Object_IsA = CombatLog_Object_IsA
local COMBATLOG_OBJECT_NONE = COMBATLOG_OBJECT_NONE
local COMBATLOG_FILTER_HOSTILE_PLAYERS = COMBATLOG_FILTER_HOSTILE_PLAYERS
...
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
...
function Proximo:COMBAT_LOG_EVENT_UNFILTERED(arg1, timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, ...)
--check for events we care about
if not COMBAT_EVENTS[event] then return end
--see if its to an enemy
local toEnemyPlayer
if (destName and not CombatLog_Object_IsA(destFlags, COMBATLOG_OBJECT_NONE) ) then
toEnemyPlayer = CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_HOSTILE_PLAYERS)
end
--if not from a event type we care about, then end
if not toEnemyPlayer then return end
if...(other events)
elseif event == "UNIT_DIED" or event == "UNIT_DESTROYED" then
...
end
end
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Is there a better (more efficient) way for a Taunt resist notify addon? It seems to me that parsing every single combat log event is a bit wasteful. Forgive me of my ignorance :(
tho the idea is intriguing what can be done wtih CBH and a new parser lib ...
In your case there isn't a lot that can be made more efficiently than what you have, since you only care about one event type. You could potentially change from using names and use the GUID's and UnitGUID() instead. When you start caring about multiple events you can use a lookup table and some of the combat log constants to filter things out easier. Here's an simplified example of what I have done to filter Proximo for only enemy deaths (and if anyone has found better ways, I'm all ears):