update some more (still needs more work)

This commit is contained in:
Crum
2018-12-13 14:51:37 -06:00
parent 7cdaf21377
commit 7dfe187aa7
37 changed files with 2018 additions and 1061 deletions
@@ -0,0 +1,123 @@
--By Elv, for E.
local ns = oUF
local oUF = ns.oUF
local UnitAffectingCombat = UnitAffectingCombat
local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax
local UnitExists = UnitExists
local frames, allFrames = {}, {}
local showStatus
local CheckForReset = function()
for frame, unit in pairs(allFrames) do
if frame.fadeInfo and frame.fadeInfo.reset then
frame:SetAlpha(1)
frame.fadeInfo.reset = nil
end
end
end
local FadeFramesInOut = function(fade, unit)
local E = unpack(ElvUI)
for frame, unit in pairs(frames) do
if not UnitExists(unit) then return end
if fade then
if frame:GetAlpha() ~= 1 or (frame.fadeInfo and frame.fadeInfo.endAlpha == 0) then
UIFrameFadeIn(frame, 0.15)
end
else
if frame:GetAlpha() ~= 0 then
UIFrameFadeOut(frame, 0.15)
frame.fadeInfo.finishedFunc = CheckForReset
else
showStatus = false;
return
end
end
end
if unit == "player" then
showStatus = fade
end
end
local Update = function(self, arg1, arg2)
if arg1 == "UNIT_HEALTH" and self and self.unit ~= arg2 then return end
if type(arg1) == "boolean" and not frames[self] then
return
end
local E = unpack(ElvUI)
if not frames[self] then
UIFrameFadeIn(self, 0.15)
self.fadeInfo.reset = true
return
end
local combat = UnitAffectingCombat("player")
local cur, max = UnitHealth("player"), UnitHealthMax("player")
local target = UnitExists("target")
if cur ~= max and showStatus ~= true then
FadeFramesInOut(true, frames[self])
elseif target and showStatus ~= true then
FadeFramesInOut(true, frames[self])
elseif arg1 == true and showStatus ~= true then
FadeFramesInOut(true, frames[self])
else
if combat and showStatus ~= true then
FadeFramesInOut(true, frames[self])
elseif not target and not combat and (cur == max) then
FadeFramesInOut(false, frames[self])
end
end
end
local Enable = function(self, unit)
if self.CombatFade then
frames[self] = self.unit
allFrames[self] = self.unit
if unit == "player" then
showStatus = false;
end
self:RegisterEvent("PLAYER_ENTERING_WORLD", Update)
self:RegisterEvent("PLAYER_REGEN_ENABLED", Update)
self:RegisterEvent("PLAYER_REGEN_DISABLED", Update)
self:RegisterEvent("PLAYER_TARGET_CHANGED", Update)
self:RegisterEvent("UNIT_HEALTH", Update)
self:RegisterEvent("UNIT_SPELLCAST_START", Update)
self:RegisterEvent("UNIT_SPELLCAST_STOP", Update)
self:RegisterEvent("UNIT_PORTRAIT_UPDATE", Update)
self:RegisterEvent("UNIT_MODEL_CHANGED", Update)
if not self.CombatFadeHooked then
HookScript(self, "OnEnter", function(self) Update(self, true) end)
HookScript(self, "OnLeave", function(self) Update(self, false) end)
self.CombatFadeHooked = true
end
return true
end
end
local Disable = function(self)
if(self.CombatFade) then
frames[self] = nil
Update(self)
self:UnregisterEvent("PLAYER_ENTERING_WORLD", Update)
self:UnregisterEvent("PLAYER_REGEN_ENABLED", Update)
self:UnregisterEvent("PLAYER_REGEN_DISABLED", Update)
self:UnregisterEvent("PLAYER_TARGET_CHANGED", Update)
self:UnregisterEvent("UNIT_HEALTH", Update)
self:UnregisterEvent("UNIT_SPELLCAST_START", Update)
self:UnregisterEvent("UNIT_SPELLCAST_STOP", Update)
self:UnregisterEvent("UNIT_PORTRAIT_UPDATE", Update)
self:UnregisterEvent("UNIT_MODEL_CHANGED", Update)
end
end
oUF:AddElement("CombatFade", Update, Enable, Disable)
@@ -0,0 +1,3 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="oUF_CombatFader.lua"/>
</Ui>
@@ -0,0 +1,110 @@
local ns = oUF
local oUF = ns.oUF
if not oUF then return end
local UnitAura = UnitAura
local UnitCanAssist = UnitCanAssist
local playerClass = select(2, UnitClass("player"))
local CanDispel = {
PRIEST = {Magic = true, Disease = true},
SHAMAN = {Poison = true, Disease = true},
PALADIN = {Magic = true, Poison = true, Disease = true},
MAGE = {Curse = true},
DRUID = {Curse = true, Poison = true}
}
local dispellist = CanDispel[playerClass] or {}
local origColors = {}
local origBorderColors = {}
local origPostUpdateAura = {}
local function GetDebuffType(unit, filter, filterTable)
if not unit or not UnitCanAssist("player", unit) then return nil end
local i = 1
while true do
local name, _, texture, _, debufftype = UnitAura(unit, i, "HARMFUL")
if not texture then break end
local filterSpell = filterTable[name]
if(filterTable and filterSpell and filterSpell.enable) then
return debufftype, texture, true, filterSpell.style, filterSpell.color
elseif(debufftype and (not filter or (filter and dispellist[debufftype]))) then
return debufftype, texture;
end
i = i + 1
end
end
local function Update(object, event, unit)
if(unit ~= object.unit) then return; end
local debuffType, texture, wasFiltered, style, color = GetDebuffType(unit, object.DebuffHighlightFilter, object.DebuffHighlightFilterTable);
if(wasFiltered) then
if(style == "GLOW" and object.DBHGlow) then
object.DBHGlow:Show();
object.DBHGlow:SetBackdropBorderColor(color.r, color.g, color.b);
elseif(object.DBHGlow) then
object.DBHGlow:Hide();
object.DebuffHighlight:SetVertexColor(color.r, color.g, color.b, color.a or object.DebuffHighlightAlpha or .5);
end
elseif(debuffType) then
color = DebuffTypeColor[debuffType];
if(object.DebuffHighlightBackdrop and object.DBHGlow) then
object.DBHGlow:Show();
object.DBHGlow:SetBackdropBorderColor(color.r, color.g, color.b);
elseif(object.DebuffHighlightUseTexture) then
object.DebuffHighlight:SetTexture(texture);
else
object.DebuffHighlight:SetVertexColor(color.r, color.g, color.b, object.DebuffHighlightAlpha or .5);
end
else
if(object.DBHGlow) then
object.DBHGlow:Hide();
end
if(object.DebuffHighlightUseTexture) then
object.DebuffHighlight:SetTexture(nil);
else
object.DebuffHighlight:SetVertexColor(0, 0, 0, 0);
end
end
if object.DebuffHighlight.PostUpdate then
object.DebuffHighlight:PostUpdate(object, debuffType, texture, wasFiltered, style, color)
end
end
local function Enable(object)
-- if we're not highlighting this unit return
if not object.DebuffHighlightBackdrop and not object.DebuffHighlight and not object.DBHGlow then
return
end
-- if we're filtering highlights and we're not of the dispelling type, return
if object.DebuffHighlightFilter and not CanDispel[playerClass] then
return
end
-- make sure aura scanning is active for this object
object:RegisterEvent("UNIT_AURA", Update)
return true
end
local function Disable(object)
object:UnregisterEvent("UNIT_AURA", Update)
if(object.DBHGlow) then
object.DBHGlow:Hide();
end
if(object.DebuffHighlight) then
local color = origColors[object];
if(color) then
object.DebuffHighlight:SetVertexColor(color.r, color.g, color.b, color.a);
end
end
end
oUF:AddElement("DebuffHighlight", Update, Enable, Disable)
@@ -0,0 +1,3 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="oUF_DebuffHighlight.lua"/>
</Ui>
@@ -0,0 +1,354 @@
--[[
Name: LibDruidMana-1.0
Revision: $Rev: 29 $
Author: Cameron Kenneth Knight (ckknight@gmail.com)
Inspired By: SmartyCat by Darravis
Website: http://www.wowace.com/
Description: A library to provide data on mana for druids in bear or cat form.
License: LGPL v2.1
]]
if(select(2, UnitClass("player")) ~= "DRUID") then return; end
local MAJOR_VERSION = "LibDruidMana-1.0"
local MINOR_VERSION = 90001 + tonumber(string.match("$Revision: 29 $", "%d+"))
local floor = math.floor
local GetManaRegen = GetManaRegen
local GetNumSpellTabs = GetNumSpellTabs
local GetSpellName = GetSpellName
local GetSpellTabInfo = GetSpellTabInfo
local GetSpellTexture = GetSpellTexture
local GetTime = GetTime
local UnitMana = UnitMana
local UnitManaMax = UnitManaMax
local UnitPowerType = UnitPowerType
local UnitStat = UnitStat
local lib, oldMinor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
if not lib then return end
local oldLib
if oldMinor then
oldLib = {}
for k, v in pairs(lib) do
oldLib[k] = v
lib[k] = nil
end
end
local regenMana, maxMana, currMana, currInt, fiveSecondRule
currMana, maxMana = 0, 0
local bearID, bearName, catName
-- frame for events and OnUpdate
local frame
if oldLib and oldLib.frame then
frame = oldLib.frame
frame:UnregisterAllEvents()
frame:SetScript("OnEvent", nil)
frame:SetScript("OnUpdate", nil)
for k in pairs(frame) do
if k ~= 0 then
frame[k] = nil
end
end
else
frame = CreateFrame("Frame", MAJOR_VERSION .. "_Frame")
end
lib.frame = frame
-- tooltip for scanning the mana cost for shapeshifting.
local tt
if oldLib and oldLib.tt then
tt = oldLib.tt
else
tt = CreateFrame("GameTooltip", MAJOR_VERSION .. "_Tooltip")
end
lib.tt = tt
if not tt.left then
tt.left = {}
tt.right = {}
end
for i = table.getn(tt.left) + 1, 30 do
local left, right = tt:CreateFontString(), tt:CreateFontString()
tt.left[i] = left
tt.right[i] = right
left:SetFontObject(GameFontNormal)
right:SetFontObject(GameFontNormal)
tt:AddFontStrings(left, right)
end
tt:SetOwner(UIParent, "ANCHOR_NONE")
-- set of functions to call when mana is updated
local registry = oldLib and oldLib.registry or {}
lib.registry = registry
local function getShapeshiftCost()
if not bearID then return 0 end
tt:ClearLines()
tt:SetSpell(bearID, "spell")
if not tt:IsOwned(UIParent) then
tt:SetOwner(UIParent, "ANCHOR_NONE")
end
local line = tt.left[2]:GetText()
if line then
line = tonumber(string.match(line, "(%d+)"))
end
return line or 0
end
frame:SetScript("OnEvent", function(...)
this[event](this, unpack(arg))
end)
local SetMax_time = nil
local UpdateMana_time = nil
local killFSR_time = nil
frame:SetScript("OnUpdate", function(this, elapsed)
local currentTime = GetTime()
if SetMax_time and SetMax_time <= currentTime then
SetMax_time = nil
this:SetMax()
end
if UpdateMana_time and UpdateMana_time <= currentTime then
UpdateMana_time = UpdateMana_time + 2
this:UpdateMana()
end
if killFSR_time and killFSR_time <= currentTime then
killFSR_time = nil
fiveSecondRule = false
end
end)
function frame:PLAYER_LOGIN()
self.PLAYER_LOGIN = nil
self:LEARNED_SPELL_IN_TAB()
self:RegisterEvent("UNIT_DISPLAYPOWER")
if UnitPowerType("player") == 0 then
self:UNIT_DISPLAYPOWER("player")
end
end
function frame:UNIT_DISPLAYPOWER(unit)
if unit ~= "player" or UnitPowerType("player") ~= 0 then return end
self:UnregisterEvent("UNIT_DISPLAYPOWER")
self.UNIT_DISPLAYPOWER = nil
maxMana = UnitManaMax("player")
currMana = UnitMana("player")
local _
_, currInt = UnitStat("player", 4)
self:RegisterEvent("UNIT_MANA")
self:RegisterEvent("UNIT_MAXMANA")
self:RegisterEvent("UNIT_INVENTORY_CHANGED")
self:RegisterEvent("PLAYER_AURAS_CHANGED")
self:RegisterEvent("LEARNED_SPELL_IN_TAB")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_LEAVING_WORLD")
self:RegisterEvent("COMBAT_TEXT_UPDATE")
self:Update()
end
function frame:PLAYER_ENTERING_WORLD()
if UnitPowerType("player") ~= 0 then
SetMax_time = GetTime() + 7
end
end
function frame:PLAYER_LEAVING_WORLD()
SetMax_time = nil
UpdateMana_time = nil
killFSR_time = nil
end
function frame:UNIT_MANA(unit)
if unit ~= "player" then return end
if UnitPowerType("player") == 0 then
currMana = UnitMana("player")
maxMana = UnitManaMax("player")
self:Update()
else
if regenMana and not UpdateMana_time then
-- Update mana every 2 seconds
UpdateMana_time = GetTime() + 2
self:UpdateMana()
end
-- if mana hasn't been updated for 7 seconds, set current mana to the max mana
SetMax_time = GetTime() + 7
end
end
function frame:UNIT_MAXMANA(unit)
if unit ~= "player" then return end
local _, int = UnitStat("player", 4)
if UnitPowerType("player") == 0 then
maxMana = UnitManaMax("player")
currMana = UnitMana("player")
currInt = int
elseif currInt ~= int then
-- int buff maybe
maxMana = maxMana + ((int - currInt) * 15)
currInt = int
if currMana > maxMana then
currMana = maxMana
end
end
self:Update()
end
frame.UNIT_INVENTORY_CHANGED = frame.UNIT_MAXMANA
function frame:PLAYER_AURAS_CHANGED()
-- possibly losing the bear/cat buff
if UnitPowerType("player") == 0 then
regenMana = false
SetMax_time = nil
UpdateMana_time = nil
killFSR_time = nil
currMana = UnitMana("player")
maxMana = UnitManaMax("player")
end
self:Update()
end
function frame:COMBAT_TEXT_UPDATE()
-- if the spell is cast for either bear or cat, deduct the cost.
-- we can't rely on UNIT_DISPLAYPOWER since you could switch from bear -> bear, never calling that, so we check the spellcast.
if (bearName and arg2 == bearName) or (catName and arg2 == catName) then
regenMana = true
fiveSecondRule = true
killFSR_time = GetTime() + 5
currMana = currMana - getShapeshiftCost()
end
end
function frame:LEARNED_SPELL_IN_TAB()
for i = 1, GetNumSpellTabs() do
local _, texture, offset, numSpells = GetSpellTabInfo(i)
-- the spell tab that shows the bear is the feral tree, gonna check for bear form and cat form, gleam important info
if string.find(texture, "Ability_Racial_BearForm") then
for j = offset + 1, offset + numSpells do
if string.find(GetSpellTexture(j, "spell"), "Ability_Racial_BearForm") then
bearID = j
bearName = GetSpellName(j, "spell")
elseif string.find(GetSpellTexture(j, "spell"), "Ability_Druid_CatForm") then
catName = GetSpellName(j, "spell")
end
end
break
end
end
end
function frame:UpdateMana()
print(this)
local regen, castingRegen = GetManaRegen()
if fiveSecondRule then
currMana = currMana + floor(castingRegen * 2 + 0.5)
else
currMana = currMana + floor(regen * 2 + 0.5)
end
if currMana >= maxMana then
currMana = maxMana
-- we're at max mana, no need for any more checking
SetMax_time = nil
UpdateMana_time = nil
killFSR_time = nil
end
self:Update()
end
function frame:SetMax()
currMana = maxMana
-- we're at max mana, no need for any more checking
SetMax_time = nil
UpdateMana_time = nil
killFSR_time = nil
self:Update()
end
local i = 0
local lastMaxMana, lastCurrMana = 0, 0
function frame:Update()
if lastMaxMana == maxMana and lastCurrMana == currMana then return end
lastMaxMana = maxMana
lastCurrMana = currMana
-- trigger event
for func in pairs(registry) do
local success, ret = pcall(func, currMana, maxMana)
if not success then
geterrorhandler()(ret)
end
end
end
-- if IsLoggedIn() then
frame:PLAYER_LOGIN()
-- else
-- frame:RegisterEvent("PLAYER_LOGIN")
-- end
function lib:GetCurrentMana()
return currMana
end
function lib:GetMaximumMana()
return maxMana
end
function lib:AddListener(tab, method)
local func
if type(tab) == "table" then
if type(method) ~= "string" then
error(format("Bad argument #3 to `AddListener'. Expected %q, got %q.", "string", type(method)), 2)
elseif type(tab[method]) ~= "function" then
error(format("Bad argument #3 to `AddListener'. Expected method, got %q.", type(tab[method])), 2)
end
func = function(...)
return tab[method](tab, unpack(arg))
end
elseif type(tab) == "function" then
func = tab
if method and type(method) ~= "string" then
method = true
end
else
error(format("Bad argument #2 to `AddListener'. Expected %q or %q, got %q.", "table", "function", type(tab)), 2)
end
registry[func] = method
end
function lib:RemoveListener(method)
if type(method) ~= "string" then
error(format("Bad argument #2 to `RemoveListener'. Expected %q, got %q.", "string", type(method)), 2)
end
for func, methodName in pairs(registry) do
if methodName == method then
registry[func] = nil
break
end
end
end
@@ -0,0 +1,3 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="LibDruidMana-1.0.lua"/>
</Ui>
@@ -0,0 +1,152 @@
if(select(2, UnitClass("player")) ~= "DRUID") then return; end
local ns = oUF
local oUF = ns.oUF
local LDM = LibStub("LibDruidMana-1.0")
local function UpdateColor(element, cur, max)
local parent = element.__owner
local r, g, b, t
if(element.colorClass) then
t = parent.colors.class['DRUID']
elseif(element.colorSmooth) then
r, g, b = parent.ColorGradient(cur, max, unpack(element.smoothGradient or parent.colors.smooth))
elseif(element.colorPower) then
t = parent.colors.power[0]
end
if(t) then
r, g, b = t[1], t[2], t[3]
end
if(b) then
element:SetStatusBarColor(r, g, b)
local bg = element.bg
if(bg) then
local mu = bg.multiplier or 1
bg:SetVertexColor(r * mu, g * mu, b * mu)
end
end
end
local function Update(self, event, unit, currMana, maxMana)
if(unit ~= 'player') then return end
local element = self.DruidAltMana
if(element.PreUpdate) then element:PreUpdate(unit) end
local cur, max = currMana, maxMana
if not (cur and max) then
cur, max = LDM:GetCurrentMana(), LDM:GetMaximumMana()
end
element:SetMinMaxValues(0, max)
element:SetValue(cur)
element:UpdateColor(cur, max)
if(element.PostUpdate) then
return element:PostUpdate(unit, cur, max, event)
end
end
local function Path(self, ...)
return (self.DruidAltMana.Override or Update) (self, unpack(arg))
end
local function ElementEnable(self)
self:RegisterEvent("UNIT_MANA", Path)
self:RegisterEvent("UNIT_MAXMANA", Path)
self.DruidAltMana:Show()
if self.DruidAltMana.PostUpdateVisibility then
self.DruidAltMana:PostUpdateVisibility(true, not self.DruidAltMana.isEnabled)
end
self.DruidAltMana.isEnabled = true
Path(self, 'ElementEnable', 'player', UnitPowerType("player", 0))
end
local function ElementDisable(self)
self:UnregisterEvent("UNIT_MANA", Path)
self:UnregisterEvent("UNIT_MAXMANA", Path)
self.DruidAltMana:Hide()
if self.DruidAltMana.PostUpdateVisibility then
self.DruidAltMana:PostUpdateVisibility(false, self.DruidAltMana.isEnabled)
end
self.DruidAltMana.isEnabled = nil
Path(self, 'ElementDisable', 'player', UnitPowerType("player", 0))
end
local function Visibility(self, event, unit)
local shouldEnable
if UnitPowerType("player") ~= 0 then
shouldEnable = true
end
if(shouldEnable) then
ElementEnable(self)
else
ElementDisable(self)
end
end
local function VisibilityPath(self, ...)
return (self.DruidAltMana.OverrideVisibility or Visibility) (self, unpack(arg))
end
local function ForceUpdate(element)
return VisibilityPath(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self, unit)
local element = self.DruidAltMana
if(element and unit == 'player') then
element.__owner = self
element.ForceUpdate = ForceUpdate
LDM:AddListener(function(currMana, maxMana)
Update(self, "Listener", "player", currMana, maxMana)
end, "oUF_DruidMana")
self:RegisterEvent('PLAYER_LOGIN', VisibilityPath) -- need?
self:RegisterEvent('PLAYER_ENTERING_WORLD', VisibilityPath)
self:RegisterEvent('UPDATE_SHAPESHIFT_FORM', VisibilityPath) -- need?
self:RegisterEvent('UNIT_DISPLAYPOWER', VisibilityPath)
if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then
element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
end
if(not element.UpdateColor) then
element.UpdateColor = UpdateColor
end
return true
end
end
local function Disable(self)
local element = self.DruidAltMana
if(element) then
ElementDisable(self)
LDM:RemoveListener("oUF_DruidMana")
self:UnregisterEvent('PLAYER_LOGIN', VisibilityPath) -- need?
self:UnregisterEvent('PLAYER_ENTERING_WORLD', VisibilityPath)
self:UnregisterEvent('UPDATE_SHAPESHIFT_FORM', VisibilityPath) -- need?
self:UnregisterEvent('UNIT_DISPLAYPOWER', VisibilityPath)
end
end
oUF:AddElement("DruidAltMana", VisibilityPath, Enable, Disable)
@@ -0,0 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Include file="LibDruidMana-1.0\LibDruidMana-1.0.xml"/>
<Script file="oUF_DruidMana.lua"/>
</Ui>
@@ -1,4 +1,8 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Include file="oUF_RaidDebuffs\oUF_RaidDebuffs.xml"/>
<Include file="oUF_DruidMana\oUF_DruidMana.xml"/>
<Include file="oUF_DebuffHighlight\oUF_DebuffHighlight.xml"/>
<Include file="oUF_Smooth\oUF_Smooth.xml"/>
<Include file="oUF_CombatFader\oUF_CombatFader.xml"/>
<Include file="oUF_GPS\oUF_GPS.xml"/>
</Ui>
@@ -0,0 +1,263 @@
local ns = oUF
local oUF = ns.oUF
local pairs, type = pairs, type
local format = string.format
local floor = math.floor
local GetSpellInfo = GetSpellInfo
local GetTime = GetTime
local UnitDebuff = UnitAura
local addon = {}
ns.oUF_RaidDebuffs = addon
oUF_RaidDebuffs = ns.oUF_RaidDebuffs
if(not _G.oUF_RaidDebuffs) then
_G.oUF_RaidDebuffs = addon
end
local debuff_data = {}
addon.DebuffData = debuff_data
addon.ShowDispellableDebuff = true
addon.FilterDispellableDebuff = true
addon.priority = 10
local function add(spell, priority, stackThreshold)
if(spell) then
debuff_data[spell] = {
priority = (addon.priority + priority),
stackThreshold = (stackThreshold or 0)
}
end
end
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
}
else
if(t[spell].enable) then
add(spell, t[spell].priority, t[spell].stackThreshold)
end
end
end
end
function addon:ResetDebuffData()
wipe(debuff_data)
end
local DispellColor = {
['Magic'] = {.2, .6, 1},
['Curse'] = {.6, 0, 1},
['Disease'] = {.6, .4, 0},
['Poison'] = {0, .6, 0}
}
local DispellPriority = {
['Magic'] = 4,
['Curse'] = 3,
['Disease'] = 2,
['Poison'] = 1
}
local DispellFilter
do
local dispellClasses = {
['PRIEST'] = {
['Magic'] = true,
['Disease'] = true
},
['SHAMAN'] = {
['Poison'] = true,
['Disease'] = true
},
['PALADIN'] = {
['Poison'] = true,
['Magic'] = true,
['Disease'] = true
},
['MAGE'] = {
['Curse'] = true
},
['DRUID'] = {
['Curse'] = true,
['Poison'] = true
}
}
DispellFilter = dispellClasses[select(2, UnitClass('player'))] or {}
end
local function formatTime(s)
if(s > 60) then
return format('%dm', s/60), string.mod(s, 60)
elseif(s < 1) then
return format('%.1f', s), s - floor(s)
else
return format('%d', s), s - floor(s)
end
end
local function onUpdate(self, elapsed)
self.elapsed = (self.elapsed or 0) + elapsed
if self.elapsed >= 0.1 then
local _, _, _, _, _, _, timeLeft = UnitDebuff(self.__owner.unit, self.index, "HARMFUL")
if timeLeft and timeLeft > 0 then
self.time:SetText(formatTime(timeLeft))
else
self:SetScript('OnUpdate', nil)
self.time:Hide()
end
self.elapsed = 0
end
end
local function UpdateDebuff(self, name, icon, count, debuffType, duration, endTime, stackThreshold)
local element = self.RaidDebuffs
if(name and (count >= stackThreshold)) then
element.icon:SetTexture(icon)
element.icon:Show()
element.duration = duration
if(element.count) then
if(count and count > 1) then
element.count:SetText(count)
element.count:Show()
else
element.count:SetText('')
element.count:Hide()
end
end
if(element.time) then
if(duration and duration > 0 and endTime) then
element:SetScript('OnUpdate', onUpdate)
element.time:Show()
else
element:SetScript('OnUpdate', nil)
element.time:Hide()
end
end
if(element.cd) then
if(duration and duration > 0 and endTime) then
element.cd:SetCooldown(GetTime() - (endTime - duration), duration)
element.cd:Show()
else
element.cd:Hide()
end
end
local c = DispellColor[debuffType] or ElvUI[1].media.bordercolor
element:SetBackdropBorderColor(c[1], c[2], c[3])
element:Show()
else
element:Hide()
element.index = nil
end
end
local function Update(self, event, unit)
if(not unit or self.unit ~= unit) then return end
local element = self.RaidDebuffs
local _, name, icon, count, debuffType, duration, expirationTime
local _name, _icon, _count, _dtype, _duration, _endTime
local _priority, priority = 0, 0
local _stackThreshold = 0
for i = 1, 40 do
name, _, icon, count, debuffType, duration, expirationTime = UnitDebuff(unit, i, "HARMFUL")
if not (name and icon) then break end
if(addon.ShowDispellableDebuff and (element.showDispellableDebuff ~= false) and debuffType) then
if(addon.FilterDispellableDebuff) then
DispellPriority[debuffType] = (DispellPriority[debuffType] or 0) + addon.priority
priority = DispellFilter[debuffType] and DispellPriority[debuffType] or 0
if(priority == 0) then
debuffType = nil
end
else
priority = DispellPriority[debuffType] or 0
end
if(priority > _priority) then
_priority, _name, _icon, _count, _dtype, _duration, _endTime = priority, name, icon, count, debuffType, duration, expirationTime
element.index = i
end
end
priority = debuff_data[name] and debuff_data[name].priority
if(priority and (priority > _priority)) then
_priority, _name, _icon, _count, _dtype, _duration, _endTime = priority, name, icon, count, debuffType, duration, expirationTime
element.index = i
end
end
if(element.forceShow) then
_name, _, _icon = GetSpellInfo(26993)
_count, _dtype, _duration, _endTime, _stackThreshold = 5, 'Magic', 0, 60, 0
end
if(_name and _icon) then
_stackThreshold = debuff_data[_name] and debuff_data[_name].stackThreshold or _stackThreshold
end
UpdateDebuff(self, _name, _icon, _count, _dtype, _duration, _endTime, _stackThreshold)
--Reset the DispellPriority
DispellPriority = {
['Magic'] = 4,
['Curse'] = 3,
['Disease'] = 2,
['Poison'] = 1
}
end
local function Path(self, ...)
--[[ Override: RaidDebuffs.Override(self, event, ...)
Used to completely override the element's update process.
* self - the parent object
* event - the event triggering the update (string)
* ... - the arguments accompanying the event (string)
--]]
return (self.RaidDebuffs.Override or Update) (self, unpack(arg))
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
local element = self.RaidDebuffs
if(element) then
element.__owner = self
element.ForceUpdate = ForceUpdate
self:RegisterEvent('UNIT_AURA', Update)
return true
end
end
local function Disable(self)
local element = self.RaidDebuffs
if(element) then
element:Hide()
self:UnregisterEvent('UNIT_AURA', Update)
end
end
oUF:AddElement('RaidDebuffs', Update, Enable, Disable)
@@ -0,0 +1,3 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="oUF_RaidDebuffs.lua"/>
</Ui>