diff bossmods.lua @ 2:fe437e761ef8

More safety checks for itemfilter validity. Factor out DBM callbacks into semi-generalized boss mod registration (todo: selection gui).
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 22 Apr 2011 01:34:47 +0000
parents
children df3e27edbd60
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bossmods.lua	Fri Apr 22 01:34:47 2011 +0000
@@ -0,0 +1,101 @@
+local addon = select(2,...)
+
+--[[
+Here's the control flow:
+(1) This file or another addon calls :register_boss_mod("Foo",register[,unregister])
+(2) When OL decides it's time to register with a boss mod, it calls
+       register (addon, addon_do_boss)
+    which should do whatever's needed.  This may happen more than once, if OL
+    is turned on/off, etc.
+(2b) If a boss mod is already in place,
+       unregister (addon)
+    will be called first, if such a function was given at the start.
+(3) When the boss mod triggers a callback, this code should call
+       addon_do_boss (.....)
+    with the crapton of data passed as in the DBM-related code below.
+
+NOTA BENE:
+- 'register' will not be called multiple times in a row for the same boss mod.
+- The callback for (3) must check if OL is appropriately active.
+
+------ Constants
+------ Locals
+------ Deadly Boss Mods
+]]
+
+------ Constants
+
+------ Locals
+local flib = LibStub("LibFarmbuyer")
+local pprint, tabledump = addon.pprint, flib.tabledump
+
+-- Lua
+local pairs, ipairs, tinsert, tremove, tonumber = pairs, ipairs, table.insert, table.remove, tonumber
+
+-- WoW
+local GetRaidRosterInfo = GetRaidRosterInfo
+
+-- OL
+local addon_do_boss 
+
+
+------ Deadly Boss Mods
+do
+	local location
+	local function DBMBossCallback (self, reason, mod, ...)
+		if (not self.rebroadcast) and (not self.enabled) then return end
+
+		local name
+		if mod.combatInfo and mod.combatInfo.name then
+			name = mod.combatInfo.name
+		elseif mod.id then
+			name = mod.id
+		else
+			name = "Unknown Boss"
+		end
+
+		local it = location or self.instance_tag()
+		location = nil
+
+		local duration = 0
+		if mod.combatInfo and mod.combatInfo.pull then
+			duration = math.floor (GetTime() - mod.combatInfo.pull)
+		end
+
+		-- attendance:  maybe put people in groups 6,7,8 into a "backup/standby"
+		-- list?  probably too specific to guild practices.
+		local raiders = {}
+		for i = 1, GetNumRaidMembers() do
+			tinsert(raiders, (GetRaidRosterInfo(i)))
+		end
+		table.sort(raiders)
+
+		return addon_do_boss (self, reason, name, it, duration, raiders)
+	end
+
+	local function callback(...) DBMBossCallback(addon,...) end
+
+	local function _registerDBM (self, OL_boss_worker)
+		if _G.DBM then
+			local rev = tonumber(DBM.Revision) or 0
+			if rev < 1503 then
+				self.status_text = "|cffff1010Deadly Boss Mods must be version 1.26 or newer to work with Ouro Loot.|r"
+				return
+			end
+			addon_do_boss = OL_boss_worker
+			local r = _G.DBM:RegisterCallback("kill", callback)
+					  _G.DBM:RegisterCallback("wipe", callback)
+					  _G.DBM:RegisterCallback("pull", function() location = self.instance_tag() end)
+			return r > 0
+		else
+			self.status_text = "|cffff1010Ouro Loot cannot find Deadly Boss Mods, loot will not be grouped by boss.|r"
+		end
+	end
+
+	addon:register_boss_mod ("DBM", _registerDBM)
+end  -- DBM tie-ins
+
+
+-- DXE, BigWigs, etc, need to be researched for this too
+
+-- vim:noet