Quantcast

ADDED: User can now specify the threshold for when kill notices are shown.

F16Gaming [12-01-11 - 13:54]
ADDED: User can now specify the threshold for when kill notices are shown.
Filename
Command.lua
KillTrack.lua
diff --git a/Command.lua b/Command.lua
index e6daf95..89fc768 100644
--- a/Command.lua
+++ b/Command.lua
@@ -74,6 +74,7 @@ C:Register("__DEFAULT__", function(args)
 	KT:Msg("/kt purge [treshold] - Open dialog to purge entries, specifiying a treshold here is optional.")
 	KT:Msg("/kt reset - Clear the mob database.")
 	KT:Msg("/kt time - Track kills within specified time.")
+	KT:Msg("/kt treshold <treshold> - Set treshold for kill record notices to show.")
 	KT:Msg("/kt - Displays this help message.")
 end)

@@ -163,6 +164,21 @@ C:Register({"time", "timer"}, function(args)
 	KT.TimerFrame:Start(s, m, h)
 end)

+C:Register({"treshold"}, function(args)
+	if #args <= 0 then
+		KT:Msg("Usage: treshold <treshold>")
+		KT:Msg("E.g: /kt treshold 100")
+		KT:Msg("    Notice will be shown on every 100th kill.")
+		return
+	end
+	local t = tonumber(args[1])
+	if t then
+		KT:SetTreshold(t)
+	else
+		KT:Msg("Argument must be a number.")
+	end
+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 8a288c0..0bed3ec 100644
--- a/KillTrack.lua
+++ b/KillTrack.lua
@@ -60,6 +60,9 @@ function KT.Events.ADDON_LOADED(self, ...)
 	if type(self.Global.PRINTKILLS) ~= "boolean" then
 		self.Global.PRINTKILLS = true
 	end
+	if type(self.Global.ACHIEV_TRESHOLD) ~= "number" then
+		self.Global.ACHIEV_TRESHOLD = 1000
+	end
 	if type(self.Global.MOBS) ~= "table" then
 		self.Global.MOBS = {}
 	end
@@ -94,6 +97,14 @@ function KT.Events.UPDATE_MOUSEOVER_UNIT(self, ...)
 	GameTooltip:Show()
 end

+function KT:SetTreshold(treshold)
+	if type(treshold) ~= "number" then
+		error("KillTrack.SetTreshold: Argument #1 (treshold) must be of type 'number'")
+	end
+	self.Global.ACHIEV_TRESHOLD = treshold
+	KT:Msg(("New kill notice (achievement) treshold set to %d."):format(treshold))
+end
+
 function KT:AddKill(id, name)
 	name = name or "<No Name>"
 	if type(self.Global.MOBS[id]) ~= "table" then
@@ -110,13 +121,13 @@ function KT:AddKill(id, name)
 		self:Msg(("Updated %q, new kill count: %d. Kill count on this character: %d"):format(name, self.Global.MOBS[id].Kills, self.CharGlobal.MOBS[id].Kills))
 	end
 	if type(self.Global.MOBS[id].AchievCount) ~= "number" then
-		self.Global.MOBS[id].AchievCount = floor(self.Global.MOBS[id].Kills / 1000)
+		self.Global.MOBS[id].AchievCount = floor(self.Global.MOBS[id].Kills / self.Global.ACHIEV_TRESHOLD)
 		if self.Global.MOBS[id].AchievCount >= 1 then
 			self:KillAlert(self.Global.MOBS[id])
 		end
 	else
 		local achievCount = self.Global.MOBS[id].AchievCount
-		self.Global.MOBS[id].AchievCount = floor(self.Global.MOBS[id].Kills / 1000)
+		self.Global.MOBS[id].AchievCount = floor(self.Global.MOBS[id].Kills / self.Global.ACHIEV_TRESHOLD)
 		if self.Global.MOBS[id].AchievCount > achievCount then
 			self:KillAlert(self.Global.MOBS[id])
 		end
@@ -175,6 +186,10 @@ function KT:KillAlert(mob)
 		FrameStyle = "GuildAchievement"
 	}
 	if IsAddOnLoaded("Glamour") then
+		if not GlamourShowAlert then
+			KT:Msg("ERROR: GlamourShowAlert == nil! Notify AddOn developer.")
+			return
+		end
 		GlamourShowAlert(500, data)
 	else
 		RaidNotice_AddMessage(RaidBossEmoteFrame, data.Text, ChatTypeInfo["SYSTEM"])