-- For general use, I wouldn't recommend obsessively upvaluing every
-- global but it is worth doing for situations like CLEU or OnUpdate
-- where you are accessing them extremely often.
local bit_band = bit.band
local COMBATLOG_OBJECT_CONTROL_PLAYER = COMBATLOG_OBJECT_CONTROL_PLAYER
-- GUIDs are not available when the main chunk executes, so you have to
-- wait and fill this in once the combat log starts running.
local frame_cleu = CreateFrame("FRAME", "remgankframe_cleu")
-- There's no need to define your event handler function separately and
-- then set it as the OnEvent script. You can just define the function
-- right in the SetScript call.
frame_cleu:SetScript("OnEvent", function(self, event, timeStamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, prefixParam1, prefixParam2, dummyparam, suffixParam1, suffixParam2)
-- Fill in the playerGUID variable here if needed.
if not playerGUID then
playerGUID = UnitGUID("player")
-- Since these first two conditions apply no matter which event is
-- firing, check them first.
if destGUID == playerGUID and bit_band(sourceGUID, COMBATLOG_OBJECT_CONTROL_PLAYER) == COMBATLOG_OBJECT_CONTROL_PLAYER then
if event == "SWING_DAMAGE" then
-- Nest checks inside each other instead of using and, so
-- that if any check matches (eg. it is this event, but not
-- the right prefix) the code doesn't keep checking other
-- things that obviously can never match.
if prefixParam2 > 0 then
print(string_format("[%s] killed [%s] with %s Melee overkill %s", sourceName, destName, prefixParam1, suffixParam2))
elseif event == "SPELL_DAMAGE" or event == "SPELL_PERIODIC_DAMAGE" or event == "RANGE_DAMAGE" then
if suffixParam2 > 0 then
print(string_format("[%s] killed [%s] with %s damage of %s overkill %s", sourceName, destName, suffixParam1, GetSpellLink(prefixParam1), suffixParam2))
-- a sample line when an enemy player killed me
-- [name] killed [me] with 65762 damage of [Combustione dell'Ombra] overkill 48472