Mercurial > wow > ouroloot
comparison bossmods.lua @ 42:4f1e71f62776
Handle moving from one instance kill/loot into a new instance, and then getting loot from trash in the new instance before seeing any bosses.
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Fri, 13 Jan 2012 01:12:36 +0000 |
| parents | d929c40cdb09 |
| children | fcc0d0ff5832 |
comparison
equal
deleted
inserted
replaced
| 41:d6b8858c1b64 | 42:4f1e71f62776 |
|---|---|
| 1 local addon = select(2,...) | 1 local addon = select(2,...) |
| 2 | 2 |
| 3 --[[ | 3 --[==[ |
| 4 Here's the control flow: | 4 Here's the control flow: |
| 5 (1) This file or another addon calls :register_boss_mod("Foo",register[,unregister]) | 5 (1) This file or another addon calls |
| 6 addon:register_boss_mod("Foo",register[,unregister]) | |
| 6 (2) When OL decides it's time to register with a boss mod, it calls | 7 (2) When OL decides it's time to register with a boss mod, it calls |
| 7 register (addon, addon_do_boss) | 8 register (addon, addon_do_boss) |
| 8 which should do whatever's needed. This may happen more than once, if OL | 9 which should do whatever's needed. This may happen more than once, if OL |
| 9 is turned on/off, etc. | 10 is turned on/off, etc. It should return a true value if successful. |
| 10 (2b) If a boss mod is already in place, | 11 (2b) If a boss mod is already in place, |
| 11 unregister (addon) | 12 unregister (addon) |
| 12 will be called first, if such a function was given at the start. | 13 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 (3) When the boss mod triggers a callback, this code should call |
| 14 addon_do_boss (.....) | 15 addon_do_boss (.....) |
| 19 - The callback for (3) must check if OL is appropriately active. | 20 - The callback for (3) must check if OL is appropriately active. |
| 20 | 21 |
| 21 ------ Constants | 22 ------ Constants |
| 22 ------ Globals | 23 ------ Globals |
| 23 ------ Deadly Boss Mods | 24 ------ Deadly Boss Mods |
| 24 ]] | 25 ]==] |
| 25 | 26 |
| 26 ------ Constants | 27 ------ Constants |
| 27 | 28 |
| 28 ------ Globals | 29 ------ Globals |
| 29 local flib = LibStub("LibFarmbuyer") | 30 local flib = LibStub("LibFarmbuyer") |
| 40 local addon_do_boss | 41 local addon_do_boss |
| 41 | 42 |
| 42 | 43 |
| 43 ------ Deadly Boss Mods | 44 ------ Deadly Boss Mods |
| 44 do | 45 do |
| 46 local DBM | |
| 45 local location | 47 local location |
| 48 local real_loadmod | |
| 49 -- When zoning into a raid instance not seen this session, make sure | |
| 50 -- we don't report a previous raid instance as current location. DBM | |
| 51 -- has no callback event for this, so we do a small hook instead. | |
| 52 local function resetting_loadmod (...) | |
| 53 addon.latest_instance = nil | |
| 54 return real_loadmod(...) | |
| 55 end | |
| 56 | |
| 46 local function DBMBossCallback (self, reason, mod, ...) | 57 local function DBMBossCallback (self, reason, mod, ...) |
| 47 if (not self.rebroadcast) and (not self.enabled) then return end | 58 if (not self.rebroadcast) and (not self.enabled) then return end |
| 48 | 59 |
| 49 local name | 60 local name |
| 50 if mod.combatInfo and mod.combatInfo.name then | 61 if mod.combatInfo and mod.combatInfo.name then |
| 54 else | 65 else |
| 55 name = "Unknown Boss" | 66 name = "Unknown Boss" |
| 56 end | 67 end |
| 57 | 68 |
| 58 local it = location or self.instance_tag() | 69 local it = location or self.instance_tag() |
| 70 self.latest_instance = it | |
| 59 location = nil | 71 location = nil |
| 60 | 72 |
| 61 local duration = 0 | 73 local duration = 0 |
| 62 if mod.combatInfo and mod.combatInfo.pull then | 74 if mod.combatInfo and mod.combatInfo.pull then |
| 63 duration = math.floor (GetTime() - mod.combatInfo.pull) | 75 duration = math.floor (GetTime() - mod.combatInfo.pull) |
| 78 end | 90 end |
| 79 | 91 |
| 80 local function callback(...) DBMBossCallback(addon,...) end | 92 local function callback(...) DBMBossCallback(addon,...) end |
| 81 | 93 |
| 82 local function _registerDBM (self, OL_boss_worker) | 94 local function _registerDBM (self, OL_boss_worker) |
| 83 if _G.DBM then | 95 DBM = _G.DBM |
| 96 if DBM then | |
| 84 local rev = tonumber(DBM.Revision) or 0 | 97 local rev = tonumber(DBM.Revision) or 0 |
| 85 if rev < 1503 then | 98 if rev < 1503 then |
| 86 self.status_text = "|cffff1010Deadly Boss Mods must be version 1.26 or newer to work with Ouro Loot.|r" | 99 self.status_text = "|cffff1010Deadly Boss Mods must be version 1.26 or newer to work with Ouro Loot.|r" |
| 87 return | 100 return |
| 88 end | 101 end |
| 89 addon_do_boss = OL_boss_worker | 102 addon_do_boss = OL_boss_worker |
| 90 local r = _G.DBM:RegisterCallback("kill", callback) | 103 local r = DBM:RegisterCallback("kill", callback) |
| 91 _G.DBM:RegisterCallback("wipe", callback) | 104 DBM:RegisterCallback("wipe", callback) |
| 92 _G.DBM:RegisterCallback("pull", function() location = self.instance_tag() end) | 105 DBM:RegisterCallback("pull", function() location = self.instance_tag() end) |
| 106 real_loadmod = DBM.LoadMod | |
| 107 DBM.LoadMod = resetting_loadmod | |
| 93 return r > 0 | 108 return r > 0 |
| 94 else | 109 else |
| 95 self.status_text = "|cffff1010Ouro Loot cannot find Deadly Boss Mods, loot will not be grouped by boss.|r" | 110 self.status_text = "|cffff1010Ouro Loot cannot find Deadly Boss Mods, loot will not be grouped by boss.|r" |
| 96 end | 111 end |
| 97 end | 112 end |
| 98 | 113 |
| 99 addon:register_boss_mod ("DBM", _registerDBM) | 114 local function _unregisterDBM (self) |
| 115 self.latest_instance = nil | |
| 116 DBM.LoadMod = real_loadmod | |
| 117 end | |
| 118 | |
| 119 addon:register_boss_mod ("DBM", _registerDBM, _unregisterDBM) | |
| 100 end -- DBM tie-ins | 120 end -- DBM tie-ins |
| 101 | 121 |
| 102 | 122 |
| 103 -- DXE, BigWigs, etc, need to be researched for this too | 123 -- DXE, BigWigs, etc, need to be researched for this too |
| 104 | 124 |
