Mercurial > wow > ouroloot
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 1:822b6ca3ef89 | 2:fe437e761ef8 |
|---|---|
| 1 local addon = select(2,...) | |
| 2 | |
| 3 --[[ | |
| 4 Here's the control flow: | |
| 5 (1) This file or another addon calls :register_boss_mod("Foo",register[,unregister]) | |
| 6 (2) When OL decides it's time to register with a boss mod, it calls | |
| 7 register (addon, addon_do_boss) | |
| 8 which should do whatever's needed. This may happen more than once, if OL | |
| 9 is turned on/off, etc. | |
| 10 (2b) If a boss mod is already in place, | |
| 11 unregister (addon) | |
| 12 will be called first, if such a function was given at the start. | |
| 13 (3) When the boss mod triggers a callback, this code should call | |
| 14 addon_do_boss (.....) | |
| 15 with the crapton of data passed as in the DBM-related code below. | |
| 16 | |
| 17 NOTA BENE: | |
| 18 - 'register' will not be called multiple times in a row for the same boss mod. | |
| 19 - The callback for (3) must check if OL is appropriately active. | |
| 20 | |
| 21 ------ Constants | |
| 22 ------ Locals | |
| 23 ------ Deadly Boss Mods | |
| 24 ]] | |
| 25 | |
| 26 ------ Constants | |
| 27 | |
| 28 ------ Locals | |
| 29 local flib = LibStub("LibFarmbuyer") | |
| 30 local pprint, tabledump = addon.pprint, flib.tabledump | |
| 31 | |
| 32 -- Lua | |
| 33 local pairs, ipairs, tinsert, tremove, tonumber = pairs, ipairs, table.insert, table.remove, tonumber | |
| 34 | |
| 35 -- WoW | |
| 36 local GetRaidRosterInfo = GetRaidRosterInfo | |
| 37 | |
| 38 -- OL | |
| 39 local addon_do_boss | |
| 40 | |
| 41 | |
| 42 ------ Deadly Boss Mods | |
| 43 do | |
| 44 local location | |
| 45 local function DBMBossCallback (self, reason, mod, ...) | |
| 46 if (not self.rebroadcast) and (not self.enabled) then return end | |
| 47 | |
| 48 local name | |
| 49 if mod.combatInfo and mod.combatInfo.name then | |
| 50 name = mod.combatInfo.name | |
| 51 elseif mod.id then | |
| 52 name = mod.id | |
| 53 else | |
| 54 name = "Unknown Boss" | |
| 55 end | |
| 56 | |
| 57 local it = location or self.instance_tag() | |
| 58 location = nil | |
| 59 | |
| 60 local duration = 0 | |
| 61 if mod.combatInfo and mod.combatInfo.pull then | |
| 62 duration = math.floor (GetTime() - mod.combatInfo.pull) | |
| 63 end | |
| 64 | |
| 65 -- attendance: maybe put people in groups 6,7,8 into a "backup/standby" | |
| 66 -- list? probably too specific to guild practices. | |
| 67 local raiders = {} | |
| 68 for i = 1, GetNumRaidMembers() do | |
| 69 tinsert(raiders, (GetRaidRosterInfo(i))) | |
| 70 end | |
| 71 table.sort(raiders) | |
| 72 | |
| 73 return addon_do_boss (self, reason, name, it, duration, raiders) | |
| 74 end | |
| 75 | |
| 76 local function callback(...) DBMBossCallback(addon,...) end | |
| 77 | |
| 78 local function _registerDBM (self, OL_boss_worker) | |
| 79 if _G.DBM then | |
| 80 local rev = tonumber(DBM.Revision) or 0 | |
| 81 if rev < 1503 then | |
| 82 self.status_text = "|cffff1010Deadly Boss Mods must be version 1.26 or newer to work with Ouro Loot.|r" | |
| 83 return | |
| 84 end | |
| 85 addon_do_boss = OL_boss_worker | |
| 86 local r = _G.DBM:RegisterCallback("kill", callback) | |
| 87 _G.DBM:RegisterCallback("wipe", callback) | |
| 88 _G.DBM:RegisterCallback("pull", function() location = self.instance_tag() end) | |
| 89 return r > 0 | |
| 90 else | |
| 91 self.status_text = "|cffff1010Ouro Loot cannot find Deadly Boss Mods, loot will not be grouped by boss.|r" | |
| 92 end | |
| 93 end | |
| 94 | |
| 95 addon:register_boss_mod ("DBM", _registerDBM) | |
| 96 end -- DBM tie-ins | |
| 97 | |
| 98 | |
| 99 -- DXE, BigWigs, etc, need to be researched for this too | |
| 100 | |
| 101 -- vim:noet |
