Quantcast WoWInterface - View Single Post - Best way to determine who killed me
View Single Post
11-25-12, 06:06 PM   #1
A Cobalt Mageweaver
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 232
Best way to determine who killed me

Hi all,
I'd like to improve my ganklist addon to offer the possibility to show a frame with the name of the char that killed you to easily add to the db.

So I begin to study a little bit the combat log.

The best way I found to determine who killed me is something like this pseudo sample code:

Lua Code:
  1. --- other code above
  2. local playerName = UnitName("player");
  3. local type = ""
  4. local typeMask = 0x00F
  6. local function eventHandler_cleu(self, event, ...)
  7.     local timeStamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, prefixParam1, prefixParam2, dummyparam, suffixParam1, suffixParam2 = ...
  9.         -- bit.band(tonumber(sourceGUID:sub(1,5)),typeMask) = 0 Player, 3-4 NPC
  11.         if destName == playerName and bit.band(tonumber(sourceGUID:sub(1,5)),typeMask) == 0 and (event == "SPELL_DAMAGE" or event == "SPELL_PERIODIC_DAMAGE" or event == "RANGE_DAMAGE") and suffixParam2 > 0  then
  12.             print(type .. " ["..sourceName.."] killed ["..destName.."] with "..suffixParam1.." damage of ".. GetSpellLink(prefixParam1) .. " overkill " .. suffixParam2)   
  13.         elseif destName == playerName and bit.band(tonumber(sourceGUID:sub(1,5)),typeMask) == 0 and event == "SWING_DAMAGE" and prefixParam2 > 0 then
  14.             print(type .." ["..sourceName.."] killed ["..destName.."] with "..prefixParam1.." Melee, overkill " .. suffixParam2 )
  15.         end        
  17.         -- a sample line when an enemy player killed me
  18.         -- [name] killed [me] with 65762 damage of [Combustione dell'Ombra] overkill 48472
  19.     end
  22. local frame_cleu = CreateFrame("FRAME", "remgankframe_cleu")
  23. frame_cleu:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  24. frame_cleu:SetScript("OnEvent", eventHandler_cleu)
  26. --- other code not show...

Some questions now:

1) As noted in another thread the UNIT_DIED subevent not contain all the information about the src of the damage so I think I can't use it. So is this the best way ( check the overkill ) ?

2) May I use the CLE not CLEU ? I have not understand so much the differences but if in the first there are only events related to me probably is more efficent than the second and for what I need is the same.

3) I am a little bit scared about the so many conditions to parsing of the die event ... if it is my name related (destName), if I am not in a bg/arena, if the srcName is a Player, if this player is an Enemy (this could be omitted I think), if the there is an overkill so I am died by spell or it was a melee ... etc :-) . But I think I can't summarize them all :-)

Thanks all for attention.
  Reply With Quote