Quantcast

Added new feature to immediate frame: Tracking number of kills

F16Gaming [01-17-13 - 18:26]
Added new feature to immediate frame: Tracking number of kills
Filename
Command.lua
KillTrack.lua
README.md
diff --git a/Command.lua b/Command.lua
index ccd3cee..08ee272 100644
--- a/Command.lua
+++ b/Command.lua
@@ -166,7 +166,20 @@ C:Register({"time", "timer"}, function(args)
 	KT.TimerFrame:Start(s, m, h)
 end)

-C:Register({"immediate", "imm", "i"}, function(args) KT.Immediate:Show() end)
+C:Register({"immediate", "imm", "i"}, function(args)
+	if #args < 1 then
+		KT.Immediate:Show()
+	elseif args[1]:match("^t") then
+		local threshold = tonumber(args[2])
+		if #args < 2 then
+			KT:Msg("Usage: immediate threshold <threshold>")
+			KT:Msg("E.g: /kt immediate threshold 50")
+			KT:Msg("    Notice will be shown on every 50th kill when immediate frame is active")
+		else
+			KT:SetImmediateThreshold(threshold)
+		end
+	end
+end)

 C:Register({"threshold"}, function(args)
 	if #args <= 0 then
diff --git a/KillTrack.lua b/KillTrack.lua
index 71bd053..6c68983 100644
--- a/KillTrack.lua
+++ b/KillTrack.lua
@@ -47,6 +47,8 @@ local KT = KillTrack

 local KTT = KillTrack_Tools

+local IMMEDIATE_THRESHOLD_SOUND = "PVPTHROUGHQUEUE"
+
 local FirstDamage = {} -- Tracks first damage to a mob registered by CLEU
 local LastDamage = {} -- Tracks whoever did the most recent damage to a mob
 local DamageValid = {} -- Determines if mob is tapped by player/group
@@ -117,6 +119,9 @@ function KT.Events.ADDON_LOADED(self, ...)
 	if type(self.Global.IMMEDIATE.POSITION) ~= "table" then
 		self.Global.IMMEDIATE.POSITION = {}
 	end
+	if type(self.Global.IMMEDIATE.THRESHOLD) ~= "number" then
+		self.Global.IMMEDIATE.THRESHOLD = 0
+	end
 	if type(self.Global.BROKER) ~= "table" then
 		self.Global.BROKER = {}
 	end
@@ -244,6 +249,18 @@ function KT:SetThreshold(threshold)
 	KT:Msg(("New kill notice (achievement) threshold set to %d."):format(threshold))
 end

+function KT:SetImmediateThreshold(threshold)
+	if type(threshold) ~= "number" then
+		error("KillTrack.SetImmediateThreshold: Argument #1 (threshold) must be of type 'number'")
+	end
+	self.Global.IMMEDIATE.THRESHOLD = threshold
+	if threshold > 0 then
+		KT:Msg(("New immediate threshold set to %d."):format(threshold))
+	else
+		KT:Msg("Immediate threshold disabled.")
+	end
+end
+
 function KT:ToggleCountMode()
 	self.Global.COUNT_GROUP = not self.Global.COUNT_GROUP
 	if self.Global.COUNT_GROUP then
@@ -271,6 +288,11 @@ function KT:AddKill(id, name)
 	self:AddSessionKill(name)
 	if self.Immediate.Active then
 		self.Immediate:AddKill()
+		if self.Global.IMMEDIATE.THRESHOLD > 0 and self.Immediate.Kills % self.Global.IMMEDIATE.THRESHOLD == 0 then
+			PlaySound("RaidWarning")
+			PlaySound("PVPTHROUGHQUEUE")
+			RaidNotice_AddMessage(RaidWarningFrame, ("%d KILLS!"):format(self.Immediate.Kills), ChatTypeInfo["SYSTEM"])
+		end
 	end
 	if type(self.Global.MOBS[id].AchievCount) ~= "number" then
 		self.Global.MOBS[id].AchievCount = floor(self.Global.MOBS[id].Kills / self.Global.ACHIEV_THRESHOLD)
diff --git a/README.md b/README.md
index d2c1fa1..7e7f127 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,17 @@ Immediate Frame

 By using the command /kt immediate (or /kt i for short), you will get a small frame that shows you how many kills you've made since running the command. This can be useful for times when you need to kill a certain number of mobs, but do not wish to reset your session statistics. Simply run /kt i and it will track how many kills you do until you close it, reopening the frame will reset the count.

+With the command **/kt immediate threshold \<threshold\>**, where **\<threshold\>** is a number, the addon will display a message on screen and play sound each time you kill that many creatures.
+
+E.g: You open the immediate frame with **/kt i** and then set the threshold to 10 with **/kt i threshold 10**. Now each time you score 10 kills (10, 20, 30 et.c) you will see a message and hear a sound to notify you of this event. This can be useful when you need to score a certain number of kills for whatever reason (quests, item procs...).
+
+If you have some addon tracking procs or similar you could call this from Lua with something like:
+
+  KillTrack.Immediate:Show()
+  KillTrack:SetImmediateThreshold(someThreshold)
+
+To automatically start tracking.
+
 Feedback
 --------