Thread Tools Display Modes
02-24-11, 07:07 PM   #1
skitspam
A Defias Bandit
Join Date: Feb 2011
Posts: 3
COMBAT_LOG_EVENT_UNFILTERED help!

Hello!
I am currently trying to make a simple addon which is supposed to get the name of the unit who killed another specific unit.

I have tried to use the COMBAT_LOG_EVENT_UNFILTERED event with the event UNIT_DIED to get the sourceName, but it always returns nil.


Code:
local frame = CreateFrame("FRAME", "MyAddonFrame");
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
function eventHandler(self, event, ...)

	if(event=="COMBAT_LOG_EVENT_UNFILTERED") then
		local time, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags=...
		if(event=="UNIT_DIED")then
			if(destName=="theUnit")then
				print(sourceName.." killed "..destName)
			end
		end
	end
end
Is there any way to get the sourceName by using this combatlog event? Or can I get the name in any other way?
  Reply With Quote
02-24-11, 07:29 PM   #2
Nobgul
A Molten Giant
 
Nobgul's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 693
Depending on what you are going to use this for. The only thing I can think of is.
Use UNIT_HEALTH If it is <0 then the unit is dead find the killing blow or spell then save the name of the person who delt it in a table for later use?
__________________
[SIGPIC][/SIGPIC]
  Reply With Quote
02-24-11, 07:37 PM   #3
Nobgul
A Molten Giant
 
Nobgul's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 693
Also check out UNITGUID.

It may be a way to grab the players name.
__________________
[SIGPIC][/SIGPIC]
  Reply With Quote
02-24-11, 08:18 PM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
UNIT_DIED doesn't show who killed it
Code:
UNIT_DIED,0x0000000000000000,nil,0x80000000,0xF130AF290001BAC9,"Blight Beast",0xa48
You could check for overkill events though:
Lua Code:
  1. local function OnEvent(self, event, ...)
  2.    local _, subevent, _, sourceName, _, _, destName, _, prefixParam1, prefixParam2, _, suffixParam1, suffixParam2 = ...
  3.  
  4.    if (subevent == "SPELL_DAMAGE" or subevent == "SPELL_PERIODIC_DAMAGE" or subevent == "RANGE_DAMAGE") and suffixParam2 > 0 then
  5.       print("["..sourceName.."] killed ["..destName.."] with "..suffixParam1.." "..GetSpellLink(prefixParam1))
  6.    elseif subevent == "SWING_DAMAGE" and prefixParam2 > 0 then
  7.       print("["..sourceName.."] killed ["..destName.."] with "..prefixParam1.." Melee")
  8.    end
  9. end
  10.  
  11. local f = CreateFrame("Frame")
  12. f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  13. f:SetScript("OnEvent", OnEvent)
This example won't account for multiple timed killing blows on the same unit ..

btw I'm not actually using any format(), but I know I should ><

Last edited by Ketho : 02-24-11 at 08:22 PM.
  Reply With Quote
02-25-11, 01:31 AM   #5
skitspam
A Defias Bandit
Join Date: Feb 2011
Posts: 3
Originally Posted by Ketho View Post
UNIT_DIED doesn't show who killed it
Code:
UNIT_DIED,0x0000000000000000,nil,0x80000000,0xF130AF290001BAC9,"Blight Beast",0xa48
You could check for overkill events though:
Lua Code:
  1. local function OnEvent(self, event, ...)
  2.    local _, subevent, _, sourceName, _, _, destName, _, prefixParam1, prefixParam2, _, suffixParam1, suffixParam2 = ...
  3.  
  4.    if (subevent == "SPELL_DAMAGE" or subevent == "SPELL_PERIODIC_DAMAGE" or subevent == "RANGE_DAMAGE") and suffixParam2 > 0 then
  5.       print("["..sourceName.."] killed ["..destName.."] with "..suffixParam1.." "..GetSpellLink(prefixParam1))
  6.    elseif subevent == "SWING_DAMAGE" and prefixParam2 > 0 then
  7.       print("["..sourceName.."] killed ["..destName.."] with "..prefixParam1.." Melee")
  8.    end
  9. end
  10.  
  11. local f = CreateFrame("Frame")
  12. f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  13. f:SetScript("OnEvent", OnEvent)
This example won't account for multiple timed killing blows on the same unit ..

btw I'm not actually using any format(), but I know I should ><

Yea. This works the way I want it to!
Thanks for the fast answer!
  Reply With Quote
02-25-11, 01:46 PM   #6
skitspam
A Defias Bandit
Join Date: Feb 2011
Posts: 3
Actually, I recieved alot of errors because of comparing a nil value with a number (the suffixParam2), but it was easily avoidable by first checking whether the value is nil or not.

Code:
if(suffixParam2~=nil)then
	DoStuff()
end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » COMBAT_LOG_EVENT_UNFILTERED help!

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