diff --git a/Ele_GUI.lua b/Ele_GUI.lua index 9dfbbfe..4b2f794 100755 --- a/Ele_GUI.lua +++ b/Ele_GUI.lua @@ -622,12 +622,12 @@ function Elementarist:CreateGUI() t:SetText("") Elementarist.textList["debuff"] = t - local debuffCooldownFrame = CreateFrame("Cooldown","$parent_debuffcooldown", ElementaristDebuffTrackerFrame, "CooldownFrameTemplate") - debuffCooldownFrame:SetHeight(50) - debuffCooldownFrame:SetWidth(50) - debuffCooldownFrame:ClearAllPoints() - debuffCooldownFrame:SetPoint("TOPLEFT", Elementarist.debuffTracker, "TOPLEFT", 0, 0) - Elementarist.debuffCooldownFrame["main"] = debuffCooldownFrame + local auraCooldownFrame = CreateFrame("Cooldown","$parent_debuffcooldown", ElementaristDebuffTrackerFrame, "CooldownFrameTemplate") + auraCooldownFrame:SetHeight(50) + auraCooldownFrame:SetWidth(50) + auraCooldownFrame:ClearAllPoints() + auraCooldownFrame:SetPoint("TOPLEFT", Elementarist.debuffTracker, "TOPLEFT", 0, 0) + Elementarist.auraCooldownFrame["main"] = auraCooldownFrame for i=1,10,1 do local debuffTracker_cd = CreateFrame("Frame","$parent_debuff_" .. tostring(i), ElementaristDebuffTrackerFrame) @@ -641,12 +641,12 @@ function Elementarist:CreateGUI() debuffTracker_cd.texture = t Elementarist.textureList["debuff_" .. tostring(i)] = t - local debuffCooldownFrame = CreateFrame("Cooldown" ,"$parent_debuffcooldown_" .. tostring(i), ElementaristDebuffTrackerFrame, "CooldownFrameTemplate") - debuffCooldownFrame:SetHeight(25) - debuffCooldownFrame:SetWidth(25) - debuffCooldownFrame:ClearAllPoints() - debuffCooldownFrame:SetPoint("TOPLEFT", 50 + ( 25 * ( math.floor( (i - 1) / 2) ) ), - (25 * ( (i - 1) % 2) ) ) - Elementarist.debuffCooldownFrame["mini_" .. tostring(i)] = debuffCooldownFrame + local auraCooldownFrame = CreateFrame("Cooldown" ,"$parent_debuffcooldown_" .. tostring(i), ElementaristDebuffTrackerFrame, "CooldownFrameTemplate") + auraCooldownFrame:SetHeight(25) + auraCooldownFrame:SetWidth(25) + auraCooldownFrame:ClearAllPoints() + auraCooldownFrame:SetPoint("TOPLEFT", 50 + ( 25 * ( math.floor( (i - 1) / 2) ) ), - (25 * ( (i - 1) % 2) ) ) + Elementarist.auraCooldownFrame["mini_" .. tostring(i)] = auraCooldownFrame end local shieldTracker = CreateFrame("Frame","ElementaristShieldTrackerFrame",UIParent) diff --git a/Elementarist.lua b/Elementarist.lua index 8147d69..484ef0e 100755 --- a/Elementarist.lua +++ b/Elementarist.lua @@ -14,19 +14,18 @@ Elementarist.playerGUID = UnitGUID("player") Elementarist.targetGUID = nil Elementarist.spellHaste = GetCombatRatingBonus(20) Elementarist.timeSinceLastUpdate = 0 -Elementarist.debuffTrackerUpdate = 0 +Elementarist.AuraTrackerUpdate = 0 Elementarist.shieldTrackerUpdate = 0 Elementarist.spellPower = GetSpellBonusDamage(4); -- nature spell bonus Elementarist.lastBaseGCD = 1.5 Elementarist.lastShockCD = 6 -Elementarist.fsCount = 0 Elementarist.person = { ["foeCount"] = 0, ["friendCount"] = 0, ["friend"] = {}, ["foe"] = {} } -Elementarist.debuffCooldowns = {} +Elementarist.auraCooldowns = {} Elementarist.lastPersonTablePurged = 0.0; Elementarist.configPanel = nil Elementarist.prevDB = {} @@ -42,7 +41,9 @@ Elementarist.SFHistory = { ["int"] = nil } Elementarist.talent = "" +Elementarist.role = "" Elementarist.talentUnsure = true +Elementarist.callbacks = {}; Elementarist.tier6Talent = nil Elementarist.lastSpell = nil Elementarist.CustomIDs = { @@ -83,12 +84,8 @@ Elementarist.SpellList = { -- debuff ["Unleashed Fury"] = GetSpellInfo(118470), } -Elementarist.debuffCooldownFrame = { - ["main"] = nil, - ["mini_1"] = nil, - ["mini_2"] = nil, - ["mini_3"] = nil, - ["mini_4"] = nil +Elementarist.auraCooldownFrame = { + ["main"] = nil } Elementarist.textureList = { ["next"] = nil, @@ -97,10 +94,6 @@ Elementarist.textureList = { ["misc"] = nil, ["int"] = nil, ["debuff"] = nil, - ["debuff_1"] = nil, - ["debuff_2"] = nil, - ["debuff_3"] = nil, - ["debuff_4"] = nil, ["shield"] = nil } @@ -313,6 +306,7 @@ function Elementarist:detectTalent() if (talent ~= "") and (talent ~= Elementarist.talent) then if ((Elementarist.modules[talent]) and (Elementarist[talent].Initialize)) then + Elementarist.callbacks = {}; Elementarist[talent]:Initialize(); end; Elementarist.talent = talent; @@ -345,15 +339,15 @@ function Elementarist:RemoveFromTables(guid) Elementarist.person["foeCount"] = Elementarist.person["foeCount"] - 1 Elementarist:Debug('Enemy died:', Elementarist.person["foeCount"] .. " " .. guid) end - if (Elementarist.debuffCooldowns[guid]) then - Elementarist.debuffCooldowns[guid]=nil - Elementarist:UpdateDebuffTracker() + if (Elementarist.auraCooldowns[guid]) then + Elementarist.auraCooldowns[guid]=nil + Elementarist:UpdateAuraTracker() end end function Elementarist:PurgeDebuffTable() - Elementarist.debuffCooldowns = {} - Elementarist:UpdateDebuffTracker() + Elementarist.auraCooldowns = {} + Elementarist:UpdateAuraTracker() end function Elementarist:PurgePersonTable() @@ -431,8 +425,8 @@ end function Elementarist.events.COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, srcGUID, srcName, srcFlags, srcRaidFlags, dstGUID, dstName, dstFlags, dstRaidFlags, spellId, spellName, spellSchool, damage, ...) if Elementarist.isEnabled() then if srcName == Elementarist.playerName then - if (event=="SPELL_PERIODIC_DAMAGE") and (spellName==Elementarist.SpellList["Flame Shock"]) and (Elementarist.debuffCooldowns[dstGUID]) then - Elementarist.debuffCooldowns[dstGUID]["action"] = GetTime() + if (srcGUID == Elementarist.playerGUID) and (spellName==Elementarist.trackAura) and (Elementarist.auraCooldowns[dstGUID]) then + Elementarist.auraCooldowns[dstGUID]["action"] = GetTime() end if (event=="SPELL_CAST_START") then Elementarist.SFHistory.spell = nil @@ -443,7 +437,22 @@ function Elementarist.events.COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideC -- calculate DPS if (event=="SPELL_CAST_SUCCESS") then Elementarist.lastSpell = spellName + -- aura track if needed + if (spellName == Elementarist.trackAura) then + -- this spell needs to be tracked in aura tracker + if (dstGUID) and (not Elementarist.auraCooldowns[dstGUID]) then + Elementarist.auraCooldowns[dstGUID] = {} + end + Elementarist.auraCooldowns[dstGUID]["start"] = GetTime() + Elementarist.auraCooldowns[dstGUID]["duration"] = Elementarist.trackDuration; + Elementarist.auraCooldowns[dstGUID]["action"] = GetTime() + end; end + -- main Aura track if neede + if (Elementarist.callbacks.COMBAT_LOG) then + Elementarist.callbacks:COMBAT_LOG(event,spellName,srcGUID,dstGUID); + end; + -- Caculate DPS on the target if ((event=="SPELL_DAMAGE") or (event=="SPELL_PERIODIC_DAMAGE")) then if (not Elementarist.DPSTable[dstGUID]) then Elementarist.DPSTable[dstGUID] = { @@ -570,51 +579,59 @@ function Elementarist:UpdateShieldTracker() end end -function Elementarist:UpdateDebuffTracker() - local name, _, icon, _, _, d, e = Elementarist:hasDeBuff("target",Elementarist.SpellList["Flame Shock"],"player") - local tguid = UnitGUID("target") +function Elementarist:UpdateAuraTracker() + if (not Elementarist.trackAura) then + return; + end; + local name,tguid,icon,d,e; + if (not Elementarist.callbacks.COMBAT_LOG) then + name, _, icon, _, _, d, e = Elementarist:hasAura("target",Elementarist.trackAura,"player",Elementarist.trackFilter) + tguid = UnitGUID("target"); + end; - Elementarist.debuffTrackerUpdate = GetTime() + Elementarist.AuraTrackerUpdate = GetTime() if (name) then - if (tguid) and (not Elementarist.debuffCooldowns[tguid]) then - Elementarist.debuffCooldowns[tguid] = {} + if (tguid) and (not Elementarist.auraCooldowns[tguid]) then + Elementarist.auraCooldowns[tguid] = {} end - Elementarist.debuffCooldowns[tguid]["start"] = e-d - Elementarist.debuffCooldowns[tguid]["duration"] = d - Elementarist.debuffCooldowns[tguid]["action"] = GetTime() + Elementarist.auraCooldowns[tguid]["start"] = e-d + Elementarist.auraCooldowns[tguid]["duration"] = d + Elementarist.auraCooldowns[tguid]["action"] = GetTime() else - _, _, icon = GetSpellInfo(Elementarist.SpellList["Flame Shock"]) + _, _, icon = GetSpellInfo(Elementarist.trackAura) end -- update mini frames local m = 1 - for i,v in pairs(Elementarist.debuffCooldowns) do - if ( (v["start"] + v["duration"]) > GetTime() ) and (i ~= tguid) and (m <= 10) and (v["action"]>GetTime() - 4) then - Elementarist:SetTexture(Elementarist.textureList["debuff_" .. tostring(m)],icon) - Elementarist.debuffCooldownFrame["mini_" .. tostring(m)]:SetCooldown( v["start"], v["duration"]) - m = m + 1 - end + for i,v in pairs(Elementarist.auraCooldowns) do + if (i ~= "0") then + if ( (v["start"] + v["duration"]) > GetTime() ) and (i ~= tguid) and (m <= 10) and (v["action"]>GetTime() - 4) then + Elementarist:SetTexture(Elementarist.textureList["debuff_" .. tostring(m)],icon) + Elementarist.auraCooldownFrame["mini_" .. tostring(m)]:SetCooldown( v["start"], v["duration"]) + m = m + 1 + end + end; end for i=m,10,1 do Elementarist:SetTexture(Elementarist.textureList["debuff_" .. tostring(m)],"") - Elementarist.debuffCooldownFrame["mini_" .. tostring(m)]:SetCooldown( 0, 0) + Elementarist.auraCooldownFrame["mini_" .. tostring(m)]:SetCooldown( 0, 0) end -- update main frame - if (name) then - Elementarist:SetTexture(Elementarist.textureList["debuff"],icon) - if (not Elementarist.OmniCC) then - Elementarist.textList["debuff"]:SetText(format('%.1f', (e - GetTime()))) + if (Elementarist.callbacks.COMBAT_LOG == nil) then + if (name) then + Elementarist:SetTexture(Elementarist.textureList["debuff"],icon) + if (not Elementarist.OmniCC) then + Elementarist.textList["debuff"]:SetText(format('%.1f', (e - GetTime()))) + end + Elementarist.auraCooldownFrame["main"]:SetCooldown( e-d, d) + else + Elementarist:SetTexture(Elementarist.textureList["debuff"],"") + Elementarist.textList["debuff"]:SetText("") + Elementarist.auraCooldownFrame["main"]:SetCooldown(0, 0) + m = m - 1 end - Elementarist.debuffCooldownFrame["main"]:SetCooldown( e-d, d) - else - Elementarist:SetTexture(Elementarist.textureList["debuff"],"") - Elementarist.textList["debuff"]:SetText("") - Elementarist.debuffCooldownFrame["main"]:SetCooldown(0, 0) - m = m - 1 - end - - Elementarist.fsCount = m + end; end function Elementarist:GetSpellCooldownRemaining(spell) @@ -626,10 +643,24 @@ function Elementarist:GetSpellCooldownRemaining(spell) return d end -function Elementarist:hasAura(unit, spellName, casterUnit) +function Elementarist:hasGlyph(glyph) + local i, _, enabled, glyphSpellID; + + for i = 1, NUM_GLYPH_SLOTS do + enabled, _, _, glyphSpellID = GetGlyphSocketInfo(i); + if ( enabled ) then + if (glyph == GetSpellInfo( glyphSpellID ) ) then + return true; + end + end + end + return false; +end + +function Elementarist:hasAura(unit, spellName, casterUnit, filter) local i = 1; while true do - local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitAura(unit, i); + local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitAura(unit, i, filter); if not name then break; end @@ -765,7 +796,7 @@ function Elementarist:DecideSpells() return end - if guid == nil then + if (guid == nil) and (Elementarist.role == "DPS") then Elementarist:SetTexture(Elementarist.textureList["next"],"") Elementarist:SetTexture(Elementarist.textureList["next1"],"") Elementarist:SetTexture(Elementarist.textureList["next2"],"") @@ -774,7 +805,7 @@ function Elementarist:DecideSpells() return end - if (UnitHealth("target") == 0) then + if (UnitHealth("target") == 0) and (Elementarist.role == "DPS") then Elementarist:SetTexture(Elementarist.textureList["next"],"") Elementarist:SetTexture(Elementarist.textureList["next1"],"") Elementarist:SetTexture(Elementarist.textureList["next2"],"") @@ -843,12 +874,12 @@ function Elementarist:OnUpdate(elapsed) Elementarist:DecideSpells() end if (not ElementaristDB.debuffdisabled) then - Elementarist.debuffTrackerUpdate = Elementarist.debuffTrackerUpdate + elapsed + Elementarist.AuraTrackerUpdate = Elementarist.AuraTrackerUpdate + elapsed if ( - ((Elementarist.OmniCC) and (Elementarist.debuffTrackerUpdate >= 1)) or - ((not Elementarist.OmniCC) and (Elementarist.debuffTrackerUpdate >= 1)) + ((Elementarist.OmniCC) and (Elementarist.AuraTrackerUpdate >= 1)) or + ((not Elementarist.OmniCC) and (Elementarist.AuraTrackerUpdate >= 1)) ) then - Elementarist:UpdateDebuffTracker() + Elementarist:UpdateAuraTracker() end end if (not ElementaristDB.shielddisabled) then diff --git a/modules/elemental.lua b/modules/elemental.lua index d92a1f6..e99471d 100755 --- a/modules/elemental.lua +++ b/modules/elemental.lua @@ -3,6 +3,19 @@ local L = Elementarist.Locals; Elementarist:RegisterModule("elemental"); Elementarist.elemental = { + Initialize = function(self) + Elementarist:LoadSpells({ + ["Glyph of Flame Shock"] = GetSpellInfo(55447) + }); + + Elementarist.role = "DPS"; + Elementarist.trackAura = Elementarist.SpellList["Flame Shock"]; + Elementarist.trackFilter = "PLAYER|HARMFUL"; + Elementarist.trackDuration = 24; + if (Elementarist:hasGlyph(Elementarist.SpellList["Glyph of Flame Shock"])) then + Elementarist.trackDuration = Elementarist.trackDuration * 1.25; + end + end; NextSpell = function(self,timeshift,exspell1,exspell2) local guid = UnitGUID("target") local currentTime = GetTime() diff --git a/modules/restoration.lua b/modules/restoration.lua index be209b9..586f27b 100755 --- a/modules/restoration.lua +++ b/modules/restoration.lua @@ -11,12 +11,103 @@ Elementarist.restoration = { ["Riptide"] = GetSpellInfo(61295), ["Earthliving Weapon"] = GetSpellInfo(51730), ["Water Shield"] = GetSpellInfo(52127), - ["Tidal Waves"] = GetSpellInfo(53390) + ["Tidal Waves"] = GetSpellInfo(53390), + + ["Flask of Falling Leaves"] = GetSpellInfo(105693), + ["Healing Stream Totem"] = GetSpellInfo(5394), + ["Earth Shield"] = GetSpellInfo(974), + ["Healing Rain"] = GetSpellInfo(73921), + ["Healing Tide Totem"] = GetSpellInfo(108280), + ["Spirit Link Totem"] = GetSpellInfo(98008), }); - + Elementarist.role = "heal"; + Elementarist.trackAura = Elementarist.SpellList["Riptide"]; + Elementarist.trackFilter = "PLAYER|HELPFUL"; + Elementarist.trackDuration = 18; + Elementarist.callbacks = { + ["COMBAT_LOG"] = function(self,event,spellName,srcGUID,dstGUID) + if (spellName == Elementarist.SpellList["Earth Shield"]) then + if (srcGUID == Elementarist.playerGUID) then + if (not Elementarist.auraCooldowns["0"]) then + Elementarist.auraCooldowns["0"] = {} + end; + if (event=="SPELL_CAST_SUCCESS") then + Elementarist.auraCooldowns["0"].charges = 9; + Elementarist:SetTexture(Elementarist.textureList["debuff"],select(3, GetSpellInfo(Elementarist.SpellList["Earth Shield"]))); + Elementarist.textureList["debuff"]:Show(); + end; + if (event=="SPELL_HEAL") and (Elementarist.auraCooldowns["0"]) and (Elementarist.auraCooldowns["0"].charges) then + Elementarist.auraCooldowns["0"].charges = Elementarist.auraCooldowns["0"].charges - 1; + end; + if (Elementarist.auraCooldowns["0"]) and (Elementarist.auraCooldowns["0"].charges) then + Elementarist.textList['debuff']:SetText( Elementarist.auraCooldowns["0"].charges ); + end; + if (event=="SPELL_AURA_REMOVED") then + Elementarist.auraCooldowns["0"] = {}; + Elementarist:SetTexture(Elementarist.textureList["debuff"],""); + Elementarist.textList['debuff']:SetText(""); + end; + end; + end; + end; + }; end; NextSpell = function(self,timeshift,exspell1,exspell2) + local i, count, e; + + if (not timeshift) then + timeshift = 0 + end + + -- Earth Shield, if not known + if (not Elementarist.auraCooldowns["0"]) or (not Elementarist.auraCooldowns["0"].charges) or (Elementarist.auraCooldowns["0"].charges == 0) then + if (exspell1 ~= Elementarist.SpellList["Earth Shield"]) and (exspell2 ~= Elementarist.SpellList["Earth Shield"]) then + return Elementarist.SpellList["Earth Shield"]; + end; + end; + + -- Riptide, if found on noone + if (not Elementarist.auraCooldowns["0"]) or (not Elementarist.auraCooldowns["0"].charges) or (Elementarist.auraCooldowns["0"].charges == 0) then + if (exspell1 ~= Elementarist.SpellList["Riptide"]) and (exspell2 ~= Elementarist.SpellList["Riptide"]) then + count = 0; + for i in pairs(Elementarist.auraCooldowns) do + if (i ~= "0") then + count = count + 1; + end; + end; + if (count == 0) then + e = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Riptide"]) + if (e-timeshift <= 0) then + return Elementarist.SpellList["Riptide"]; + end + end; + end; + end; + + -- Healing Rain + if (exspell1 ~= Elementarist.SpellList["Healing Rain"]) and (exspell2 ~= Elementarist.SpellList["Healing Rain"]) then + e = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Healing Rain"]); + if (e-timeshift <= 0) then + return Elementarist.SpellList["Healing Rain"]; + end; + end; + + -- Healing Tide Totem + if (exspell1 ~= Elementarist.SpellList["Healing Tide Totem"]) and (exspell2 ~= Elementarist.SpellList["Healing Tide Totem"]) then + e = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Healing Tide Totem"]); + if (e-timeshift <= 0) then + return Elementarist.SpellList["Healing Tide Totem"]; + end; + end; + + -- Spirit Link Totem + if (exspell1 ~= Elementarist.SpellList["Spirit Link Totem"]) and (exspell2 ~= Elementarist.SpellList["Spirit Link Totem"]) then + e = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Spirit Link Totem"]); + if (e-timeshift <= 0) then + return Elementarist.SpellList["Spirit Link Totem"]; + end; + end; return "" end; @@ -26,10 +117,7 @@ Elementarist.restoration = { -- Alchemy Flask of Enhancement if GetItemCount(Elementarist.CustomIDs["Alchemist's Flask Item"]) ~= 0 then - name = Elementarist:hasBuff("player", Elementarist.SpellList["Flask of the Warm Sun"]); - if (name == nil) then - name = Elementarist:hasBuff("player", Elementarist.SpellList["Flask of the Draconic Mind"]); - end + name = Elementarist:hasBuff("player", Elementarist.SpellList["Flask of Falling Leaves"]); if (name == nil) then name, _, _, _, _, _, expirationTime = Elementarist:hasBuff("player", Elementarist.SpellList["Alchemist's Flask"], false, Elementarist.CustomIDs["Alchemist's Flask Spell"]); if (name == nil) or (expirationTime < 2) then @@ -41,7 +129,7 @@ Elementarist.restoration = { end end - -- Flametongue weapon + -- Earthliving weapon if Elementarist:SpellAvailable(Elementarist.SpellList["Earthliving Weapon"]) then local hasMainHandEnchant, mainHandExpiration, _, _, _, _ = GetWeaponEnchantInfo() if (hasMainHandEnchant == nil) or ((mainHandExpiration / 60000) < 1) then @@ -57,6 +145,24 @@ Elementarist.restoration = { end end + -- Healing Stream Totem + if Elementarist:SpellAvailable(Elementarist.SpellList["Healing Stream Totem"]) then + local haveWaterTotem,waterTotemName,_,_ = GetTotemInfo(3) + if (waterTotemName == "") then + -- no water totem + return Elementarist.SpellList["Healing Stream Totem"] + end + end + + -- Searing Totem + if Elementarist:SpellAvailable(Elementarist.SpellList["Searing Totem"]) then + local haveFireTotem,fireTotemName,_,_ = GetTotemInfo(1) + if (fireTotemName == "") then + -- no fire totem + return Elementarist.SpellList["Searing Totem"] + end + end + return "" end; IntSpell = function(self)