Commit 43d251fd authored by Tukz's avatar Tukz
Browse files

Update oUF_RaidDebuffs.lua

parent 27b27852
local T, C, L = select(2, ...):unpack()
local _, ns = ...
local oUF = ns.oUF or oUF
local addon = {}
local _G = _G
local addon = {}
ns.oUF_RaidDebuffs = addon
oUF_RaidDebuffs = ns.oUF_RaidDebuffs
_G.oUF_RaidDebuffs = ns.oUF_RaidDebuffs
if not _G.oUF_RaidDebuffs then
_G.oUF_RaidDebuffs = addon
end
local debuff_data = {}
local format, floor = format, floor
local type, pairs, wipe = type, pairs, wipe
local GetActiveSpecGroup = GetActiveSpecGroup
local GetSpecialization = GetSpecialization
local GetSpellInfo = GetSpellInfo
local GetTime = GetTime
local UnitAura = UnitAura
local UnitCanAttack = UnitCanAttack
local UnitIsCharmed = UnitIsCharmed
local debuff_data = {}
addon.DebuffData = debuff_data
addon.ShowDispellableDebuff = true
addon.FilterDispellableDebuff = true
......@@ -36,11 +44,7 @@ function addon:RegisterDebuffs(t)
for spell, value in pairs(t) do
if type(t[spell]) == 'boolean' then
local oldValue = t[spell]
t[spell] = {
['enable'] = oldValue,
['priority'] = 0,
['stackThreshold'] = 0
}
t[spell] = { enable = oldValue, priority = 0, stackThreshold = 0 }
else
if t[spell].enable then
add(spell, t[spell].priority, t[spell].stackThreshold)
......@@ -76,47 +80,100 @@ do
['Disease'] = true,
},
['SHAMAN'] = {
['Poison'] = true,
['Disease'] = true,
['Magic'] = false,
['Curse'] = true,
},
['PALADIN'] = {
['Poison'] = true,
['Magic'] = true,
['Magic'] = false,
['Disease'] = true,
},
['DRUID'] = {
['Magic'] = false,
['Curse'] = true,
['Poison'] = true,
['Disease'] = false,
},
['MAGE'] = {
['Curse'] = true,
['MONK'] = {
['Magic'] = false,
['Disease'] = true,
['Poison'] = true,
},
}
DispellFilter = dispellClasses[select(2, UnitClass('player'))] or {}
end
local function CheckTalentTree(tree)
local activeGroup = GetActiveSpecGroup()
if activeGroup and GetSpecialization(false, false, activeGroup) then
return tree == GetSpecialization(false, false, activeGroup)
end
end
local playerClass = select(2, UnitClass('player'))
local function CheckSpec(self, event, levels)
-- Not interested in gained points from leveling
if event == "CHARACTER_POINTS_CHANGED" and levels > 0 then return end
--Check for certain talents to see if we can dispel magic or not
if playerClass == "PALADIN" then
if CheckTalentTree(1) then
DispellFilter.Magic = true
else
DispellFilter.Magic = false
end
elseif playerClass == "SHAMAN" then
if CheckTalentTree(3) then
DispellFilter.Magic = true
else
DispellFilter.Magic = false
end
elseif playerClass == "DRUID" then
if CheckTalentTree(4) then
DispellFilter.Magic = true
else
DispellFilter.Magic = false
end
elseif playerClass == "MONK" then
if CheckTalentTree(2) then
DispellFilter.Magic = true
else
DispellFilter.Magic = false
end
end
end
local function formatTime(s)
if s > 60 then
return format('%dm', s/60), s%60
elseif s < 1 then
return format("%.1f", s), s - floor(s)
else
return format('%d', s), s - floor(s)
end
end
local abs = math.abs
local function OnUpdate(self, elapsed)
self.elapsed = (self.elapsed or 0) + elapsed
if (self.elapsed >= 0.1) then
if self.elapsed >= 0.1 then
local timeLeft = self.endTime - GetTime()
if (timeLeft > 0) then
local text = T.FormatTime(timeLeft)
if self.reverse then timeLeft = abs((self.endTime - GetTime()) - self.duration) end
if timeLeft > 0 then
local text = formatTime(timeLeft)
self.time:SetText(text)
else
self:SetScript('OnUpdate', nil)
self.time:Hide()
end
self.elapsed = 0
end
end
local function UpdateDebuff(self, name, icon, count, debuffType, duration, endTime, spellId, stackThreshold)
local f = self.RaidDebuffs
if name and (count >= stackThreshold) then
f.icon:SetTexture(icon)
f.icon:Show()
......@@ -154,7 +211,12 @@ local function UpdateDebuff(self, name, icon, count, debuffType, duration, endTi
end
local c = DispellColor[debuffType] or DispellColor.none
f.Backdrop:SetBorderColor(c[1], c[2], c[3])
if f.Backdrop then
f.Backdrop:SetBorderColor(c[1], c[2], c[3])
else
f:SetBackdropBorderColor(c[1], c[2], c[3])
end
f:Show()
else
......@@ -164,7 +226,7 @@ end
local function Update(self, event, unit)
if unit ~= self.unit then return end
local _name, _icon, _count, _dtype, _duration, _endTime, _spellId
local _name, _icon, _count, _dtype, _duration, _endTime, _spellId, _
local _priority, priority = 0, 0
local _stackThreshold = 0
......@@ -176,11 +238,11 @@ local function Update(self, event, unit)
for i = 1, 40 do
local name, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId, canApplyAura, isBossDebuff = UnitAura(unit, i, 'HARMFUL')
if (not name) then break end
--we coudln't dispell if the unit its charmed, or its not friendly
if addon.ShowDispellableDebuff and (self.RaidDebuffs.showDispellableDebuff ~= false) and debuffType and (not isCharmed) and (not canAttack) then
if addon.FilterDispellableDebuff then
DispellPriority[debuffType] = (DispellPriority[debuffType] or 0) + addon.priority --Make Dispell buffs on top of Boss Debuffs
priority = DispellFilter[debuffType] and DispellPriority[debuffType] or 0
......@@ -197,7 +259,6 @@ local function Update(self, event, unit)
end
local debuff
if self.RaidDebuffs.onlyMatchSpellID then
debuff = debuff_data[spellId]
else
......@@ -209,14 +270,13 @@ local function Update(self, event, unit)
end
priority = debuff and debuff.priority
if priority and (priority > _priority) then
if priority and not self.RaidDebuffs.BlackList[spellId] and (priority > _priority) then
_priority, _name, _icon, _count, _dtype, _duration, _endTime, _spellId = priority, name, icon, count, debuffType, duration, expirationTime, spellId
end
end
if self.RaidDebuffs.forceShow then
_spellId = 6788
_spellId = 47540
_name, _, _icon = GetSpellInfo(_spellId)
_count, _dtype, _duration, _endTime, _stackThreshold = 5, 'Magic', 0, 60, 0
end
......@@ -226,11 +286,26 @@ local function Update(self, event, unit)
end
UpdateDebuff(self, _name, _icon, _count, _dtype, _duration, _endTime, _spellId, _stackThreshold)
--Reset the DispellPriority
DispellPriority['Magic'] = 4
DispellPriority['Curse'] = 3
DispellPriority['Disease'] = 2
DispellPriority['Poison'] = 1
end
local function Enable(self)
if self.RaidDebuffs then
self:RegisterEvent("PLAYER_TALENT_UPDATE", CheckSpec, true)
self:RegisterEvent("CHARACTER_POINTS_CHANGED", CheckSpec, true)
self:RegisterEvent('UNIT_AURA', Update)
self.RaidDebuffs.BlackList = {
[105171] = true, -- Deep Corruption
[108220] = true, -- Deep Corruption
[116095] = true, -- Disable, Slow
[137637] = true, -- Warbringer, Slow
}
return true
end
......@@ -238,10 +313,12 @@ end
local function Disable(self)
if self.RaidDebuffs then
self:UnregisterEvent("PLAYER_TALENT_UPDATE", CheckSpec, true)
self:UnregisterEvent("CHARACTER_POINTS_CHANGED", CheckSpec, true)
self:UnregisterEvent('UNIT_AURA', Update)
self.RaidDebuffs:Hide()
end
end
oUF:AddElement('RaidDebuffs', Update, Enable, Disable)
oUF:AddElement('RaidDebuffs', Update, Enable, Disable)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment