Quantcast

ADDED: After 1000 kills, will now display an achievement-like notice about it (support for Glamour).

F16Gaming [12-01-11 - 02:58]
ADDED: After 1000 kills, will now display an achievement-like notice about it (support for Glamour).
Filename
KillTrack.lua
diff --git a/KillTrack.lua b/KillTrack.lua
index d4627e3..8a288c0 100644
--- a/KillTrack.lua
+++ b/KillTrack.lua
@@ -97,7 +97,7 @@ end
 function KT:AddKill(id, name)
 	name = name or "<No Name>"
 	if type(self.Global.MOBS[id]) ~= "table" then
-		self.Global.MOBS[id] = { Name = name, Kills = 0 }
+		self.Global.MOBS[id] = { Name = name, Kills = 0, AchievCount = 0 }
 		self:Msg(("Created new entry for %q"):format(name))
 	end
 	self.Global.MOBS[id].Kills = self.Global.MOBS[id].Kills + 1
@@ -109,6 +109,18 @@ function KT:AddKill(id, name)
 	if self.Global.PRINTKILLS then
 		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)
+		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)
+		if self.Global.MOBS[id].AchievCount > achievCount then
+			self:KillAlert(self.Global.MOBS[id])
+		end
+	end
 end

 function KT:GetKills(id)
@@ -154,6 +166,31 @@ function KT:Msg(msg)
 	DEFAULT_CHAT_FRAME:AddMessage("\124cff00FF00[KillTrack]\124r " .. msg)
 end

+function KT:KillAlert(mob)
+	local data = {
+		Text = ("%d kills on %s!"):format(mob.Kills, mob.Name),
+		Title = "Kill Record!",
+		bTitle = "Congratulations!",
+		Icon = "Interface\\Icons\\ABILITY_Deathwing_Bloodcorruption_Death",
+		FrameStyle = "GuildAchievement"
+	}
+	if IsAddOnLoaded("Glamour") then
+		GlamourShowAlert(500, data)
+	else
+		RaidNotice_AddMessage(RaidBossEmoteFrame, data.Text, ChatTypeInfo["SYSTEM"])
+		RaidNotice_AddMessage(RaidBossEmoteFrame, data.Text, ChatTypeInfo["SYSTEM"])
+	end
+end
+
+function KT:GetMob(id)
+	for k,v in pairs(self.Global.MOBS) do
+		if type(v) == "table" and (tostring(k) == tostring(id) or v.Name == id) then
+			return v, self.CharGlobal.MOBS[k]
+		end
+	end
+	return false, nil
+end
+
 function KT:GetSortedMobTable(mode)
 	if not tonumber(mode) then mode = self.Sort.Desc end
 	if mode < 0 or mode > 7 then mode = self.Sort.Desc end
@@ -246,9 +283,3 @@ for k,_ in pairs(KT.Events) do
 end

 KT.Frame:SetScript("OnEvent", function(_, event, ...) KT:OnEvent(_, event, ...) end)
-
--------------------
--- DISPLAY FRAME --
--------------------
-
---KT.Display = CreateFrame("Frame")