Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Version: 1.2
- This is based on "AffDots Mage r3" and has been modified by Hendrikto to contain fixes to make the module work properly for Arcane Mages.
- Nothing has been changed except for what is clearly indicated in the source code. I don't take credit for any code I have not written myself.
- The module was originally developed by "Xab3r".
- 1.0:
- + added:
- + Rune of Power tracking
- + Mastery: Mana Adept tracking
- 1.1:
- + fixed:
- + Mastery will now be ignored for non Arcane Mages
- 1.2:
- + changed:
- + Dot strength will be calculated on every Combat Log Event to track Mana Adept more accurately
- ]]
- local o
- local me, spec
- local protect = 1
- local timer, throttle = 0, 0.1
- local dot_damage, targets = AffDots.dot_damage, AffDots.targets
- local dot_damage_ext = { }
- local durSaved = { }
- local dot_ticks = { }
- function onUpdate(self,elapsed)
- timer = timer + elapsed;
- if timer >= throttle then
- for k,v in pairs(AffDots.track) do
- AffDots.track[k].update(AffDots.track[k])
- AffDots:FrameDraw(AffDots.track[k])
- end
- if o.tidyplates.enable and TidyPlates then AffDots:Tidy() end
- timer = 0
- end
- end
- local dotSpells = {
- lb =
- {
- Id = 44457,
- Info = GetSpellInfo(44457),
- InitialTicksCount = 4,
- InitialDuration = 12,
- RawTickDmg = function ( spd)
- return 1072+spd*0.8036
- end,
- ExistsInCurrentSpec = function()
- local _,_,_,_,selected = GetTalentInfo(14)
- return selected
- end
- }, -- Living Bomb
- nt =
- {
- Id = 114923,
- Info = GetSpellInfo(114923),
- InitialTicksCount = 12,
- InitialDuration = 12,
- RawTickDmg = function ( spd)
- return 325+spd*0.2436
- end,
- ExistsInCurrentSpec = function()
- local _,_,_,_,selected = GetTalentInfo(13)
- return selected
- end
- }, -- Nether Tempest
- }
- local buffSpells = {
- invocationBuff = {Id = 116257, Info = GetSpellInfo(116257), Dmg = 0.15},
- ropBuff = {Id = 116011, Info = GetSpellInfo(116011), Dmg = 0.15} -- Hendrikto: fixed RoP
- }
- local function GetDmgBuffsUpdate()
- local dmg_buff = 1
- for k,v in pairs(buffSpells) do
- local auraInfo = UnitBuff("player", v.Info, nil)
- if (auraInfo) then dmg_buff = dmg_buff + v.Dmg end
- end
- if spec == 1 then dmg_buff = dmg_buff + ((GetMasteryEffect() / 100) * (UnitMana("Player") / UnitManaMax("Player"))) end -- Hendrikto: fixed Mana Adept
- --print("DmgBuff "..dmg_buff)
- return dmg_buff
- end
- local function Round(num) return math.floor(num+.5) end
- local function SecondsRound(num)
- if num > 2 then return math.floor(num+.5)
- else return math.floor(num*10+.5)/10 end
- end
- function AffDots:FindColor(GUID,time_left,spell,pandemic)
- if not targets[GUID..spell] or not dot_damage[spell] then
- return 7
- end
- local current = dot_damage[spell][1]
- local on_target = targets[GUID..spell][1]
- if on_target < current then color = 1
- elseif on_target == current then color = 2
- elseif on_target > current then color = 6
- end
- return color
- end
- AffDots.Update = {
- dot = function(f)
- local guid = UnitGUID(f.target)
- local _,_,_,_,_,duration,expires = UnitDebuff(f.target,f.name,f.rank,"player")
- if duration and guid and targets[guid..f.spell] then
- if(math.abs(expires-f.timer)>1) then
- f.datanew.expires = expires
- f.datanew.duration = duration
- f.datanew.setcd = true
- f.timer = expires
- end
- f.datanew.color = o["color"..AffDots:FindColor(guid,expires - GetTime(),f.spell,f.pandemic)]
- f.datanew.tick = targets[guid..f.spell][3]
- f.datanew.t2 = SecondsRound(f.timer-GetTime())
- local spellText = Round(dot_damage[f.spell][1]*100/targets[guid..f.spell][1]).."%"
- f.datanew.t1 = spellText
- else
- f.datanew.color = o.color7
- f.datanew.t1 = 0
- f.datanew.t2 = ""
- f.datanew.tick = 0
- f.timer = 0
- f.datanew.hidecd = true
- end
- end,
- }
- local GetDotDmgFunc = function()
- haste, crit, spd = UnitSpellHaste("player"), GetSpellCritChance(6), GetSpellBonusDamage(6)
- if crit > 100 then crit = 100 end
- critDamageBonus = (1+crit/100)
- dmgBuff = GetDmgBuffsUpdate()
- for k,v in pairs(dotSpells) do
- tick_every = v.InitialTicksCount/(1+(haste/100))
- ticks = Round(v.InitialDuration/tick_every)
- duration = ticks * tick_every
- dmgPerTick = v.RawTickDmg(spd)
- totalDamage = dmgPerTick*ticks*critDamageBonus*dmgBuff
- dps = Round(totalDamage/duration)
- dot_damage[v.Id] = {dps, tick_every, duration, ticks}
- --print( string.format("%s: dmg=%f; perTick=%f",v.Info, totalDamage, dmgPerTick))
- end
- end
- local function GetDotDur(arg1)
- local spellname = GetSpellInfo(arg1)
- local duration = select(6, UnitAura("target", spellname, nil, "PLAYER|HARMFUL")) or 0
- local expiration = select(7, UnitAura("target", spellname, nil, "PLAYER|HARMFUL")) or GetTime()
- local testtime = expiration-duration
- return duration, expiration, testtime
- end
- local function GetDotTicks(spellID, destGUID)
- if dot_ticks[destGUID..""..spellID] and dot_ticks[destGUID..""..spellID] == 0 then
- return true
- else
- return false
- end
- end
- local function RemoveDotTic(spellID, destGUID)
- if dot_ticks[destGUID..""..spellID] and dot_ticks[destGUID..""..spellID] > 0 then
- dot_ticks[destGUID..""..spellID] = dot_ticks[destGUID..""..spellID] - 1
- end
- end
- local CombatLogFunc = function(_,_,_,event_type,_,source_GUID,_,_,_,dest_GUID,_,_,_, ...)
- spellId = select(1, ...)
- --[[ Hendrikto: fixed Mana Adept
- if dest_GUID == UnitGUID("player") and spellId == 137590 then
- AffDots:GetDotDmg()
- end
- --]]
- AffDots:GetDotDmg() -- Hendrikto: fixed Mana Adept
- if source_GUID ~= me then return end
- local spellMustBeProcessed = false
- for k,v in pairs(dotSpells) do
- if v.Id == spellId then
- spellMustBeProcessed = true
- break
- end
- end
- if event_type == "SPELL_SUMMON" then
- saGUID[dest_GUID] = me
- end
- if (spellMustBeProcessed) then
- if (event_type == "SPELL_AURA_APPLIED" or (event_type == "SPELL_AURA_REFRESH" and GetTime() - protect > 0.5)) then
- if UnitGUID("target") == dest_GUID then
- durSaved[dest_GUID..spellId] = { select(2, GetDotDur(spellId)), GetSpellBonusDamage(6), GetDmgBuffsUpdate() }
- else
- durSaved[dest_GUID..spellId] = { dot_damage[spellId][2] , GetSpellBonusDamage(6), GetDmgBuffsUpdate() }
- end
- targets[dest_GUID..spellId] = {dot_damage[spellId][1],GetTime(),dot_damage[spellId][2]}
- dot_ticks[dest_GUID..spellId] = dot_damage[spellId][4]
- elseif event_type == "SPELL_DAMAGE" then
- protect = GetTime()
- elseif event_type == "SPELL_PERIODIC_DAMAGE" then
- RemoveDotTic(spellId, dest_GUID)
- end
- end
- end
- function AffDots:InitSpec()
- AffDots:ReleaseFrames()
- wipe(AffDots.track)
- AffDots.execute_percent = 0
- local index = 0
- for k,v in pairs(dotSpells) do
- if (v.ExistsInCurrentSpec()) then
- AffDots:Track( v.Id, AffDots.Update.dot, "target", v.InitialDuration, 0, index, true)
- index = index + 1
- end
- end
- AffDots:InitFrames()
- end
- function AffDots:InitClass()
- AffDots:RegisterEvent("PLAYER_TALENT_UPDATE", "InitClass")
- me = UnitGUID("player")
- o = self.db.profile
- AffDots:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
- AffDots:UnregisterEvent("COMBAT_RATING_UPDATE")
- AffDots:UnregisterEvent("SPELL_POWER_CHANGED")
- AffDots:UnregisterEvent("UNIT_STATS")
- AffDots:UnregisterEvent("PLAYER_DAMAGE_DONE_MODS")
- AffDots:UnregisterEvent("PLAYER_REGEN_ENABLED")
- AffDots:UnregisterEvent("PLAYER_REGEN_DISABLED")
- AffDots:UnregisterEvent("PLAYER_FOCUS_CHANGED")
- AffDots:UnregisterEvent("MODIFIER_STATE_CHANGED")
- AffDotsTarget:SetScript("OnUpdate", nil)
- AffDotsTarget:Hide(); AffDotsFocus:Hide(); AffDotsBurst:Hide()
- spec = GetSpecialization() or ""
- o = self.db.profile
- AffDots.GetDotDmg = GetDotDmgFunc
- AffDots.CombatLog = CombatLogFunc
- AffDots:GetDotDmg()
- AffDots:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED", "CombatLog")
- --[[ Hendrikto: fixed Mana Adept
- AffDots:RegisterEvent("COMBAT_RATING_UPDATE", "GetDotDmg")
- AffDots:RegisterEvent("SPELL_POWER_CHANGED", "GetDotDmg")
- AffDots:RegisterEvent("UNIT_STATS", "GetDotDmg")
- AffDots:RegisterEvent("PLAYER_DAMAGE_DONE_MODS", "GetDotDmg")
- AffDots:RegisterEvent("UNIT_SPELL_HASTE", "GetDotDmg")
- AffDots:RegisterEvent("PLAYER_AURAS_CHANGED", "GetDotDmg")
- --]]
- AffDots:RegisterEvent("PLAYER_REGEN_ENABLED")
- AffDots:RegisterEvent("PLAYER_REGEN_DISABLED")
- AffDots:RegisterEvent("PLAYER_FOCUS_CHANGED")
- AffDots:RegisterEvent("MODIFIER_STATE_CHANGED")
- AffDotsTarget:SetScript("OnUpdate", onUpdate)
- AffDots:InitSpec()
- end
- function AffDots:GetSpecOptions(spec)
- if string.match(spec,"MAGE") then
- self.options.args.spec.name = "Mage"
- self.options.args.spec.args = {
- spacer1 = {
- order = 1,type = "description",name="You are "..spec, width="full",
- },
- }
- AffDots:InitClass()
- else
- self.options.args.spec.name = "Specialization"
- self.options.args.spec.args = {
- spacer1 = {
- order = 1,type = "description",name="You are not mage", width="full",
- },
- }
- end
- end
- function AffDots:OnEnable()
- AffDots:InitClass()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement