Skip to content

Commit

Permalink
improve DR functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Schaka committed Jul 29, 2016
1 parent 664b03f commit 51227d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 45 deletions.
13 changes: 3 additions & 10 deletions Gladdy.lua
Expand Up @@ -628,11 +628,9 @@ function Gladdy:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventType, sourceG
local Auras = Gladdy.modules.Auras
local aura = Auras.auras[spellName]

local factor = self:Call("Diminishings", "Gain", destUnit, spellName)

if (aura and aura.priority >= (Auras.frames[destUnit].priority or 0)) then
local auraIcon = select(3, GetSpellInfo(spellID))
local auraExpTime = aura.duration / (factor or 1)
local auraExpTime = aura.duration

self:SendMessage("AURA_GAIN", destUnit, spellName, auraIcon, auraExpTime, aura.priority)
button.spells[spellName] = t
Expand All @@ -647,13 +645,10 @@ function Gladdy:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventType, sourceG
local Auras = Gladdy.modules.Auras
local aura = Auras.auras[spellName]

self:Call("Diminishings", "Fade", destUnit, spellName)
local factor = self:Call("Diminishings", "Gain", destUnit, spellName)

if (aura and aura.priority >= (Auras.frames[destUnit].priority or 0)) then
local auraIcon = select(3, GetSpellInfo(spellID))
local auraExpTime = aura.duration / (factor or 1)

local auraExpTime = aura.duration
self:SendMessage("AURA_GAIN", destUnit, spellName, auraIcon, auraExpTime, aura.priority)
button.spells[spellName] = t
end
Expand All @@ -664,8 +659,6 @@ function Gladdy:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventType, sourceG

self:AuraFade(destUnit, spellName)

self:Call("Diminishings", "Fade", destUnit, spellName)

local Auras = Gladdy.modules.Auras
if (spellName == Auras.frames[destUnit].name) then
self:SendMessage("AURA_FADE", destUnit)
Expand Down
53 changes: 18 additions & 35 deletions Modules/Diminishings.lua
Expand Up @@ -10,7 +10,7 @@ local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local Diminishings = Gladdy:NewModule("Diminishings", nil, {
drFontColor = {r = 1, g = 1, b = 0, a = 1},
drFontSize = 10,
drFontSize = 20,
drCooldownPos = "LEFT",
drIconSize = 30,
})
Expand All @@ -34,12 +34,13 @@ local function StyleActionButton(f)
normalTex:SetVertexColor(1, 1, 1, 1)
end

function Diminishings:OnEvent(event, ...)
self[event](self, ...)
end

function Diminishings:Initialise()
self.frames = {}

self.text = {"1/2", "1/4", "0" }

self.spells = {}
self.spells = {}
self.icons = {}

local spells = self:GetDRList()
Expand All @@ -50,8 +51,18 @@ function Diminishings:Initialise()
end

self:RegisterMessage("UNIT_DEATH", "ResetUnit")
self:SetScript("OnEvent", Diminishings.OnEvent)
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end

function Diminishings:COMBAT_LOG_EVENT_UNFILTERED(...)
local timestamp, eventType, sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,spellID,spellName,spellSchool,auraType = select ( 1 , ... );
local destUnit = Gladdy.guids[destGUID]
if eventType == "SPELL_AURA_REMOVED" and destUnit then
self:Fade(destUnit, spellName)
end
end

function Diminishings:CreateFrame(unit)
local drFrame = CreateFrame("Frame", nil, Gladdy.buttons[unit])

Expand Down Expand Up @@ -183,42 +194,26 @@ function Diminishings:Test(unit)

for i = 1, 4 do
local spell = GetSpellInfo(spells[i])
self:Gain(unit, spell)
self:Fade(unit, spell)
end
end

function Diminishings:Gain(unit, spell)
local drFrame = self.frames[unit]
local dr = self.spells[spell]
if (not drFrame or not dr) then return end

if (not drFrame.tracked[dr]) then
drFrame.tracked[dr] = 0
end

drFrame.tracked[dr] = drFrame.tracked[dr] + 1

return drFrame.tracked[dr]
function testdr()
Diminishings:Fade("arena1", GetSpellInfo(118));
end

function Diminishings:Fade(unit, spell)
local drFrame = self.frames[unit]
local dr = self.spells[spell]
if (not drFrame or not dr) then return end

local factor = drFrame.tracked[dr]
if (factor ~= nil and factor >= 4) then return end

for i = 1, 16 do
local icon = drFrame["icon" .. i]
if (not icon.active or (icon.dr and icon.dr == dr)) then
icon.dr = dr
icon.factor = factor
icon.timeLeft = 15
icon.cooldown:SetCooldown(GetTime(), 15)
icon.texture:SetTexture(self.icons[spell])
icon.text:SetText(self.text[factor])
icon.active = true

self:Positionate(unit)
Expand Down Expand Up @@ -259,17 +254,6 @@ function Diminishings:Positionate(unit)
end
end

function Diminishings:GetFactor(unit, spell)
local drFrame = self.frames[unit]
if (not drFrame) then return end

local dr = self.spells[spell]

if (dr and drFrame.tracked[dr]) then
return drFrame.tracked[dr]
end
end

local function option(params)
local defaults = {
get = function(info)
Expand Down Expand Up @@ -399,7 +383,6 @@ function Diminishings:GetDRList()
[30283] = "stun", -- Shadowfury
[6358] = "fear", -- Seduction (Succubus)
[5484] = "fear", -- Howl of Terror
[31117] = "silence", -- Unstable Affliction

-- WARRIOR
[12809] = "stun", -- Concussion Blow
Expand Down

0 comments on commit 51227d5

Please sign in to comment.