Quantcast

Mob counting fixed, added a toggle for count mode.

F16Gaming [12-12-11 - 18:56]
Mob counting fixed, added a toggle for count mode.

FIXED: Mob kills done by raid members should now count, just like party kills.
ADDED: Now has two modes: "Count all group kills" and "Count only your own kills". This can be toggled with /kt countmode.
Filename
Command.lua
KillTrack.lua
diff --git a/Command.lua b/Command.lua
index b800cb6..52fd8da 100644
--- a/Command.lua
+++ b/Command.lua
@@ -75,6 +75,7 @@ C:Register("__DEFAULT__", function(args)
 	KT:Msg("/kt reset - Clear the mob database.")
 	KT:Msg("/kt time - Track kills within specified time.")
 	KT:Msg("/kt threshold <threshold> - Set threshold for kill record notices to show.")
+	KT:Msg("/kt countmode - Toggle between counting group killing blows or your killing blows only.")
 	KT:Msg("/kt - Displays this help message.")
 end)

@@ -179,6 +180,10 @@ C:Register({"threshold"}, function(args)
 	end
 end)

+C:Register({"countmode", "cm", "count", "counttype", "changecount", "switchcount"}, function(args)
+	KT:ToggleCountMode()
+end)
+
 for i,v in ipairs(C.Slash) do
 	_G["SLASH_" .. KT.Name:upper() .. i] = "/" .. v
 end
diff --git a/KillTrack.lua b/KillTrack.lua
index fd91a23..333937e 100644
--- a/KillTrack.lua
+++ b/KillTrack.lua
@@ -63,6 +63,9 @@ function KT.Events.ADDON_LOADED(self, ...)
 	if type(self.Global.ACHIEV_THRESHOLD) ~= "number" then
 		self.Global.ACHIEV_THRESHOLD = 1000
 	end
+	if type(self.Global.COUNT_GROUP) ~= "boolean" then
+		self.Global.COUNT_GROUP = false
+	end
 	if type(self.Global.MOBS) ~= "table" then
 		self.Global.MOBS = {}
 	end
@@ -78,7 +81,16 @@ end

 function KT.Events.COMBAT_LOG_EVENT_UNFILTERED(self, ...)
 	local event = (select(2, ...))
-	if event ~= "PARTY_KILL" then return end
+	if event ~= "UNIT_DIED" then return end
+	-- Perform solo/group checks
+	local source = tostring((select(5, ...)))
+	local pass
+	if self.Global.COUNT_GROUP then
+		pass = self:IsInGroup(source)
+	else
+		pass = UnitName("player") == source
+	end
+	if not pass then return end
 	local id = KTT:GUIDToID((select(8, ...)))
 	local name = tostring((select(9, ...)))
 	if id == 0 then return end
@@ -97,6 +109,13 @@ function KT.Events.UPDATE_MOUSEOVER_UNIT(self, ...)
 	GameTooltip:Show()
 end

+function KT:IsInGroup(unit)
+	if unit == UnitName("player") then return true end
+	if UnitInParty(unit) then return true end
+	if UnitInRaid(unit) then return true end
+	return false
+end
+
 function KT:SetThreshold(threshold)
 	if type(threshold) ~= "number" then
 		error("KillTrack.SetThreshold: Argument #1 (threshold) must be of type 'number'")
@@ -106,6 +125,15 @@ function KT:SetThreshold(threshold)
 	KT:Msg(("New kill notice (achievement) threshold set to %d."):format(threshold))
 end

+function KT:ToggleCountMode()
+	self.Global.COUNT_GROUP = not self.Global.COUNT_GROUP
+	if self.Global.COUNT_GROUP then
+		KT:Msg("Now counting kills for every player in the group (party/raid)!")
+	else
+		KT:Msg("Now counting your own killing blows ONLY.")
+	end
+end
+
 function KT:AddKill(id, name)
 	name = name or "<No Name>"
 	if type(self.Global.MOBS[id]) ~= "table" then