Watch for party kills

This snippet is written to watch for npcs that your party is killing and report who scored the killing blow to your chat frame. Specifically it is meant to watch for kills of Shoveltusk Stags, but could be customized to watch for any specific mob id.

Snippet

if not DeathFrame then
   CreateFrame("Frame", "DeathFrame", UIParent)
end

local function isShoveltusk(guid)
   local type = tonumber(guid:sub(3, 5), 16)
   local npc = bit.band(type, 0x00f) == 3
   if npc then
      local mobid = tonumber(guid:sub(8, 12), 16)
      if mobid == 23691 then
         return true         
      end
   end
end

DeathFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
DeathFrame:SetScript("OnEvent", function(self, event, ...)
      local combatEvent = select(2, ...)
      if combatEvent == "PARTY_KILL" then
         local sourceName = select(4, ...)
         local destGUID = select(6, ...)
         if isShoveltusk (destGUID) then
            print(sourceName .. " has killed a Shoveltusk Stag!")
         end
      end
end)
Posted by jnwhiteh at Mon, 27 Apr 2009 10:46:51 +0000