695 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			695 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
--DISPLAY EVERY FRAME SMH
 | 
						|
function()
 | 
						|
    --- CPU benchmarking ---
 | 
						|
    local start
 | 
						|
    local aura_env = aura_env
 | 
						|
    local Debug = aura_env.Debug
 | 
						|
    if Debug then
 | 
						|
        aura_env.count = aura_env.count or 1
 | 
						|
        aura_env.count = (aura_env.count + 1) % 600
 | 
						|
        start = debugprofilestop()
 | 
						|
    end
 | 
						|
 | 
						|
    -- Setting some aura_env to local variables to improve performance --
 | 
						|
    local ClassID = aura_env.ClassID
 | 
						|
    local SpecID = aura_env.SpecID
 | 
						|
    local AoE = aura_env.AoE
 | 
						|
    local Mode = aura_env.Mode
 | 
						|
    local ColorFunction = aura_env.Color
 | 
						|
    local Threshold = aura_env.Threshold
 | 
						|
    local BasicReductions = aura_env.BasicReductions
 | 
						|
 | 
						|
    -- Armor calulation // Armor scales differently depending on the enemy level, this makes sure is stays accurate --
 | 
						|
    local Armor = select(2, UnitArmor("player"))
 | 
						|
    Armor = 1 - C_PaperDollInfo.GetArmorEffectiveness(Armor, aura_env.TargetLevel) -- Gets the reduction percentage and makes it usable
 | 
						|
 | 
						|
    -- All Classes
 | 
						|
    local CurrentHealth = UnitHealth("player")
 | 
						|
    local MaxHealth = UnitHealthMax("player")
 | 
						|
    local Vers = 1 - (GetCombatRatingBonus(31) / 100)
 | 
						|
    local Avoid = 1
 | 
						|
    local ScanTarget = false
 | 
						|
    if AoE then
 | 
						|
        Avoid = 1 - (GetAvoidance() / 100)
 | 
						|
    end
 | 
						|
    local Elusive = 1
 | 
						|
    local StaggerP, StaggerM = 1, 1
 | 
						|
    local Absorbs = UnitGetTotalAbsorbs("player")
 | 
						|
    local AbsorbsP, AbsorbsM = Absorbs, Absorbs
 | 
						|
 | 
						|
    -- Initialize some variables --
 | 
						|
    local ClassDRP, ClassDRM = 1, 1
 | 
						|
    local PImmunity, MImmunity = 0, 0
 | 
						|
 | 
						|
    ----- General damage reduction buffs -----
 | 
						|
    local n = 1
 | 
						|
    local BuffID = select(10, UnitBuff("player", n))
 | 
						|
    while BuffID do
 | 
						|
        local Reduction = 1
 | 
						|
        local PhysicalReduction = 1
 | 
						|
        local MagicReduction = 1
 | 
						|
 | 
						|
        if BasicReductions[BuffID] then
 | 
						|
            ClassDRP = ClassDRP * BasicReductions[BuffID][1]
 | 
						|
            ClassDRM = ClassDRM * BasicReductions[BuffID][2]
 | 
						|
        end
 | 
						|
 | 
						|
        ---- More complex tracking ----
 | 
						|
 | 
						|
        local AMS, BloodS = 0, 0
 | 
						|
 | 
						|
        --- Death Knight ---
 | 
						|
        if BuffID == 48792 then
 | 
						|
            Reduction = 1 + (tonumber(select(18, UnitBuff("player", n)) or 0)) / 100 -- Icebound Fortitude // using plus since the tooltip returns a negative value
 | 
						|
 | 
						|
        elseif BuffID == 48707 then
 | 
						|
            AMS = (select(16, UnitBuff("player", n)) or 0) -- Anti-Magic Shell
 | 
						|
 | 
						|
        elseif BuffID == 77535 then
 | 
						|
            BloodS = (select(16, UnitBuff("player", n)) or 0) -- Blood Shield
 | 
						|
 | 
						|
            --- Demon Hunter ---
 | 
						|
        elseif BuffID == 212800 then
 | 
						|
            if IsPlayerSpell(205411) then Reduction = 0.50 -- Blur
 | 
						|
            else Reduction = 0.65 end
 | 
						|
 | 
						|
        elseif BuffID == 196555 then PImmunity = 1 -- Netherwalk
 | 
						|
 | 
						|
            --- Druid ---
 | 
						|
        elseif BuffID == 102342 then
 | 
						|
            Reduction = 1 + (tonumber(select(16, UnitBuff("player", n)) or 0)) / 100 -- Ironbark // using plus since the tooltip returns a negative value
 | 
						|
 | 
						|
            --- Hunter ---
 | 
						|
        elseif BuffID == 186265 then -- Aspect of the Turtle
 | 
						|
            PImmunity = 1
 | 
						|
            MImmunity = 1
 | 
						|
 | 
						|
            --- Mage ---
 | 
						|
        elseif BuffID == 45438 then -- Ice Block
 | 
						|
            PImmunity = 1
 | 
						|
            MImmunity = 1
 | 
						|
 | 
						|
            --- Monk ---
 | 
						|
        elseif BuffID == 261769 then
 | 
						|
            Reduction = 1 + (select(16, UnitBuff("player", n)) or 0) / 100 -- Inner Strength // using plus since the tooltip returns a negative value
 | 
						|
 | 
						|
        elseif BuffID == 115295 then
 | 
						|
            Absorbs = Absorbs - select(16, UnitBuff("player", n)) -- Guard // prevents Guard from counting as a normal absorb
 | 
						|
 | 
						|
            --- Paladin ---
 | 
						|
        elseif BuffID == 210320 then
 | 
						|
            Reduction = 1 + (tonumber(select(16, UnitBuff("player", n)) or 0)) / 100 -- Devotion Aura // using plus since the tooltip returns a negative value
 | 
						|
 | 
						|
        elseif BuffID == 1022 then PImmunity = 1 -- Blessing of Protection
 | 
						|
        elseif BuffID == 204018 then MImmunity = 1 -- Blessing of Spellwarding
 | 
						|
 | 
						|
        elseif BuffID == 188370 then
 | 
						|
            Reduction = 1 - (GetMasteryEffect() / 2.85) / 100 -- Consecration // May not be 100% accurate, but it's good enough for now
 | 
						|
            if IsEquippedItem(137047) then Reduction = Reduction * 0.96 end -- Consecration (Legendary Ring)
 | 
						|
 | 
						|
        elseif BuffID == 642 then -- Divine Shield
 | 
						|
            PImmunity = 1
 | 
						|
            MImmunity = 1
 | 
						|
 | 
						|
            --- Priest ---
 | 
						|
        elseif BuffID == 45242 then
 | 
						|
            Reduction = 1 - (select(3, UnitBuff("player", n)) or 0) * 15 / 100 -- Focused Will
 | 
						|
 | 
						|
        elseif BuffID == 139 then
 | 
						|
            if IsPlayerSpell(235189) and UnitBuff("player", n, nil, "player") then
 | 
						|
                Reduction = 0.90 -- Perseverance - Talent
 | 
						|
            end
 | 
						|
 | 
						|
            --- Rogue ---
 | 
						|
        elseif BuffID == 1966 then
 | 
						|
            if not AoE and IsPlayerSpell(79008)
 | 
						|
                then Elusive = 0.70 -- Elusiveness
 | 
						|
            else -- Feint
 | 
						|
                if AoE then Avoid = Avoid * 0.50 end
 | 
						|
            end
 | 
						|
        elseif BuffID == 31224 then MImmunity = 1 -- Cloak of Shadows
 | 
						|
 | 
						|
            --- Shaman ---
 | 
						|
        elseif BuffID == 260881 then
 | 
						|
            Reduction = 1 - (tonumber(select(3, UnitBuff("player", n)) or 0)) * 5 / 100 -- Ghost in the Mist - Talent
 | 
						|
 | 
						|
            --- Warlock ---
 | 
						|
 | 
						|
            --- Warrior ---
 | 
						|
        elseif BuffID == 184362 and IsPlayerSpell(208154) then -- Enrage
 | 
						|
            Reduction = 0.90 -- War Paint - Talent
 | 
						|
 | 
						|
        end
 | 
						|
 | 
						|
        AbsorbsP = Absorbs - AMS
 | 
						|
        AbsorbsM = Absorbs - BloodS
 | 
						|
 | 
						|
        ClassDRP = ClassDRP * Reduction * PhysicalReduction
 | 
						|
        ClassDRM = ClassDRM * Reduction * MagicReduction
 | 
						|
        n = n + 1
 | 
						|
        BuffID = select(10, UnitBuff("player", n))
 | 
						|
    end
 | 
						|
 | 
						|
    ----- Damage reductions with special calculations -----
 | 
						|
 | 
						|
    --- Death Knight ---
 | 
						|
    if ClassID == 6 then
 | 
						|
        local Necropolis = 1
 | 
						|
        if IsPlayerSpell(206967) then -- Will of the Necropolis - Talent
 | 
						|
            if CurrentHealth / MaxHealth < 0.35 then Necropolis = 0.65
 | 
						|
            end
 | 
						|
        end
 | 
						|
        ClassDRP = ClassDRP * Necropolis
 | 
						|
        ClassDRM = ClassDRM * Necropolis
 | 
						|
    end
 | 
						|
 | 
						|
    --- Demon Hunter ---
 | 
						|
    if ClassID == 12 then
 | 
						|
        local HavocDemWards = 1
 | 
						|
        local VengDemWards = 1
 | 
						|
        if SpecID == 1 then
 | 
						|
            HavocDemWards = 0.90 -- Demonic Wards - Passive
 | 
						|
        elseif SpecID == 2 then
 | 
						|
            VengDemWards = 0.90 -- Demonic Wards - Passive
 | 
						|
            ScanTarget = true
 | 
						|
        end
 | 
						|
 | 
						|
        ClassDRP = ClassDRP * VengDemWards
 | 
						|
        ClassDRM = ClassDRM * VengDemWards * HavocDemWards
 | 
						|
    end
 | 
						|
 | 
						|
    --- Druid ---
 | 
						|
    if ClassID == 11 then
 | 
						|
        local GuardA = 1
 | 
						|
        if IsEquippedItem(137015) and IsPlayerSpell(16931) then
 | 
						|
            GuardA = 0.895 -- Legendary chest
 | 
						|
        elseif IsPlayerSpell(16931) then
 | 
						|
            GuardA = 0.94 -- Thick Hide (Guardian Affinity)
 | 
						|
        end
 | 
						|
        if SpecID == 3 then
 | 
						|
            if IsPlayerSpell(204053) then
 | 
						|
                ScanTarget = true
 | 
						|
            end
 | 
						|
        end
 | 
						|
 | 
						|
        ClassDRP = ClassDRP * GuardA
 | 
						|
        ClassDRM = ClassDRM * GuardA
 | 
						|
    end
 | 
						|
 | 
						|
    --- Hunter ---
 | 
						|
    if ClassID == 3 then
 | 
						|
    end
 | 
						|
 | 
						|
    --- Mage ---
 | 
						|
    if ClassID == 8 then
 | 
						|
    end
 | 
						|
 | 
						|
    --- Monk ---
 | 
						|
    if ClassID == 10 then
 | 
						|
        if SpecID == 1 then
 | 
						|
            ScanTarget = true
 | 
						|
            -- Gets stagger agaist current target, if no target is found use base --
 | 
						|
            local StaggerBase, StaggerTarget = C_PaperDollInfo.GetStaggerPercentage("player")
 | 
						|
            if not StaggerTarget then StaggerTarget = StaggerBase end
 | 
						|
            StaggerM = StaggerTarget * 0.35
 | 
						|
            StaggerP = 1 - StaggerTarget / 100
 | 
						|
            StaggerM = 1 - StaggerM / 100
 | 
						|
 | 
						|
            -- Stagger cap --
 | 
						|
            local Stagger = UnitStagger("player") or 0 -- Calculate MaxHealth effective reduction for Stagger
 | 
						|
            local StaggerCapP = (CurrentHealth + AbsorbsP) / (CurrentHealth + AbsorbsP + 100 * MaxHealth - Stagger * 10)
 | 
						|
            local StaggerCapM = (CurrentHealth + AbsorbsM) / (CurrentHealth + AbsorbsM + 100 * MaxHealth - Stagger * 10)
 | 
						|
            if StaggerCapP < 0.01 then StaggerCapP = 0.01 end -- Stagger caps at 99%
 | 
						|
            if StaggerCapM < 0.01 then StaggerCapM = 0.01 end
 | 
						|
            if StaggerP < StaggerCapP then StaggerP = StaggerCapP end
 | 
						|
            if StaggerM < StaggerCapM then StaggerM = StaggerCapM end
 | 
						|
        end
 | 
						|
        if SpecID == 3 then
 | 
						|
            local Karma = 0
 | 
						|
            aura_env.GoodKarma = IsPlayerSpell(280195) -- Talent
 | 
						|
            Karma = aura_env.TouchOfKarma
 | 
						|
            Absorbs = Absorbs + Karma
 | 
						|
            AbsorbsP = AbsorbsP + Karma
 | 
						|
            AbsorbsM = AbsorbsM + Karma
 | 
						|
        end
 | 
						|
 | 
						|
        ClassDRP = ClassDRP * StaggerP
 | 
						|
        ClassDRM = ClassDRM * StaggerM
 | 
						|
    end
 | 
						|
 | 
						|
    --- Paladin ---
 | 
						|
    if ClassID == 2 then
 | 
						|
        local LastDefender = 1
 | 
						|
        if SpecID == 2 then -- Protection
 | 
						|
            LastDefender = 1 - (1 - 0.97 ^ aura_env.NameplateCounter)
 | 
						|
        end
 | 
						|
        ClassDRP = ClassDRP * LastDefender
 | 
						|
        ClassDRM = ClassDRM * LastDefender
 | 
						|
    end
 | 
						|
 | 
						|
    --- Priest ---
 | 
						|
    if ClassID == 5 then
 | 
						|
    end
 | 
						|
 | 
						|
    --- Rogue ---
 | 
						|
    if ClassID == 4 then
 | 
						|
    end
 | 
						|
 | 
						|
    --- Shaman ---
 | 
						|
    if ClassID == 7 then
 | 
						|
    end
 | 
						|
 | 
						|
    --- Warlock ---
 | 
						|
    if ClassID == 9 then
 | 
						|
        local SoulLink = 1
 | 
						|
        local DestructionMastery = 1
 | 
						|
        if SpecID == 2 then -- Soul Link passive for Demonology Warlocks
 | 
						|
            if UnitExists("pet") then
 | 
						|
                SoulLink = 0.80
 | 
						|
            end
 | 
						|
        elseif SpecID == 3 then
 | 
						|
            DestructionMastery = 1 - ((GetMasteryEffect() / 9) / 100) -- Destruction mastery effect
 | 
						|
        end
 | 
						|
 | 
						|
        ClassDRP = ClassDRP * SoulLink * DestructionMastery
 | 
						|
        ClassDRM = ClassDRM * SoulLink * DestructionMastery
 | 
						|
    end
 | 
						|
 | 
						|
    --- Warrior ---
 | 
						|
    if ClassID == 1 then
 | 
						|
        if SpecID == 3 then
 | 
						|
            ScanTarget = true
 | 
						|
        end
 | 
						|
 | 
						|
        ClassDRP = ClassDRP
 | 
						|
        ClassDRM = ClassDRM
 | 
						|
    end
 | 
						|
 | 
						|
    --- Miscellaneous ---
 | 
						|
    if aura_env.HighmountainTauren then
 | 
						|
        local Stamina = UnitStat("player", 3)
 | 
						|
        local RuggedTenacity = floor((Stamina * 0.0003 * 20) + 0.5)
 | 
						|
        Absorbs = Absorbs + RuggedTenacity
 | 
						|
    end
 | 
						|
 | 
						|
    --- Checking debuffs on target if needed ---
 | 
						|
    if ScanTarget then
 | 
						|
        local TD = 1
 | 
						|
        local DebuffID = select(10, UnitDebuff("target", TD))
 | 
						|
        while DebuffID do
 | 
						|
            local DebuffTarget = 1
 | 
						|
            local DebuffTargetP = 1
 | 
						|
            local DebuffTargetM = 1
 | 
						|
 | 
						|
            --- Demon Hunter ---
 | 
						|
            if DebuffID == 207744 and select(3, UnitDebuff("target", TD, nil, "player")) then
 | 
						|
                DebuffTarget = 0.60 -- Fiery Brand
 | 
						|
 | 
						|
            elseif DebuffID == 268178 and select(3, UnitDebuff("target", TD, nil, "player")) then
 | 
						|
                DebuffTarget = 0.94 -- Void Reaver -- Talent
 | 
						|
 | 
						|
                --- Druid ---
 | 
						|
            elseif DebuffID == 192090 and select(3, UnitDebuff("target", TD, nil, "player")) then
 | 
						|
                DebuffTarget = 1 - 0.02 * (select(3, UnitDebuff("target", TD, nil, "player")) or 0) -- Rend and Tear - Talent
 | 
						|
 | 
						|
                --- Monk ---
 | 
						|
            elseif DebuffID == 123725 then
 | 
						|
                DebuffTarget = 1 + 0.01 * (select(17, UnitDebuff("target", TD, nil, "player")) or 0) -- Breath of Fire // using plus since the tooltip returns a negative value
 | 
						|
 | 
						|
                --- Warrior ---
 | 
						|
            elseif DebuffID == 1160 and select(7, UnitDebuff("target", TD)) == "player" then
 | 
						|
                DebuffTarget = 0.80 -- Demoralizing Shout
 | 
						|
            end
 | 
						|
 | 
						|
            ClassDRP = ClassDRP * DebuffTarget * DebuffTargetP
 | 
						|
            ClassDRM = ClassDRM * DebuffTarget * DebuffTargetM
 | 
						|
            TD = TD + 1
 | 
						|
            DebuffID = select(10, UnitDebuff("target", TD))
 | 
						|
        end
 | 
						|
    end
 | 
						|
 | 
						|
    -- Damage taken modifiers --
 | 
						|
    local ReductionP = Vers * Avoid * ClassDRP * Armor * Elusive
 | 
						|
    local ReductionM = Vers * Avoid * ClassDRM * Elusive
 | 
						|
    -- CurrentHealth health and shields --
 | 
						|
    local EHP = (CurrentHealth + AbsorbsP) / ReductionP
 | 
						|
    local EHM = (CurrentHealth + AbsorbsM) / ReductionM
 | 
						|
 | 
						|
    -- Export pre-avoidance EHP, EHM and immunity status as global variables --
 | 
						|
    if aura_env.GlobalExport then
 | 
						|
        -- Calculate max effective health (no absorbs) --
 | 
						|
        local EHPMaxHealth = (MaxHealth + AbsorbsP) / ReductionP
 | 
						|
        local EHMMaxHealth = (MaxHealth + AbsorbsM) / ReductionM
 | 
						|
        -- Export to globals --
 | 
						|
        local Export = WA_ZELER_EH
 | 
						|
        Export.EHPMAX, Export.EHMMAX = EHPMaxHealth * Avoid * Elusive, EHMMaxHealth * Avoid * Elusive
 | 
						|
        Export.EHP, Export.EHM = EHP * Avoid * Elusive, EHM * Avoid * Elusive
 | 
						|
 | 
						|
        Export.REDP, Export.REDM = ReductionP / Avoid / Elusive, ReductionM / Avoid / Elusive
 | 
						|
        Export.ABS, Export.ABSP, Export.ABSM = Absorbs, AbsorbsP, AbsorbsM
 | 
						|
        Export.EHPIMMUNITY, Export.EHMIMMUNITY = PImmunity, MImmunity
 | 
						|
        Export.EHARMOR = Armor
 | 
						|
        Export.STAGGERP, Export.STAGGERM = StaggerP, StaggerM
 | 
						|
    end
 | 
						|
 | 
						|
    -- Formatting numbers --
 | 
						|
    local DivideP, DivideM = 1, 1
 | 
						|
    local ImportDecimal = aura_env.DisplayDecimals
 | 
						|
    local EHPdecimal, EHMdecimal = ImportDecimal, ImportDecimal
 | 
						|
    local letterP, letterM = "", ""
 | 
						|
    if EHP > 10 ^ 9 then
 | 
						|
        EHP = EHP / 10 ^ 9
 | 
						|
        DivideP = 10 ^ 9
 | 
						|
        letterP = "b"
 | 
						|
        EHPdecimal = 2
 | 
						|
    elseif EHP > 10 ^ 8 then
 | 
						|
        EHP = EHP / 10 ^ 6
 | 
						|
        DivideP = 10 ^ 6
 | 
						|
        letterP = "m"
 | 
						|
        EHPdecimal = 0
 | 
						|
    elseif EHP > 10 ^ 7 then
 | 
						|
        EHP = EHP / 10 ^ 6
 | 
						|
        DivideP = 10 ^ 6
 | 
						|
        letterP = "m"
 | 
						|
    elseif EHP > 10 ^ 6 then
 | 
						|
        EHP = EHP / 10 ^ 6
 | 
						|
        DivideP = 10 ^ 6
 | 
						|
        letterP = "m"
 | 
						|
        EHPdecimal = 2
 | 
						|
    elseif EHP > 10 ^ 5 then
 | 
						|
        EHP = EHP / 10 ^ 3
 | 
						|
        DivideP = 10 ^ 3
 | 
						|
        letterP = "k"
 | 
						|
        EHPdecimal = 0
 | 
						|
    elseif EHP > 10 ^ 4 then
 | 
						|
        EHP = EHP / 10 ^ 3
 | 
						|
        DivideP = 10 ^ 3
 | 
						|
        letterP = "k"
 | 
						|
    elseif EHP > 10 ^ 3 then
 | 
						|
        EHP = EHP / 10 ^ 3
 | 
						|
        DivideP = 10 ^ 3
 | 
						|
        letterP = "k"
 | 
						|
        EHPdecimal = 2
 | 
						|
    elseif EHP > -1 then
 | 
						|
        EHP = EHP / 1
 | 
						|
        DivideP = 1
 | 
						|
        EHPdecimal = 0
 | 
						|
    end
 | 
						|
 | 
						|
    if EHM > 10 ^ 9 then
 | 
						|
        EHM = EHM / 10 ^ 9
 | 
						|
        DivideM = 10 ^ 9
 | 
						|
        letterM = "b"
 | 
						|
        EHMdecimal = 2
 | 
						|
    elseif EHM > 10 ^ 8 then
 | 
						|
        EHM = EHM / 10 ^ 6
 | 
						|
        DivideM = 10 ^ 6
 | 
						|
        letterM = "m"
 | 
						|
        EHMdecimal = 0
 | 
						|
    elseif EHM > 10 ^ 7 then
 | 
						|
        EHM = EHM / 10 ^ 6
 | 
						|
        DivideM = 10 ^ 6
 | 
						|
        letterM = "m"
 | 
						|
    elseif EHM > 10 ^ 6 then
 | 
						|
        EHM = EHM / 10 ^ 6
 | 
						|
        DivideM = 10 ^ 6
 | 
						|
        letterM = "m"
 | 
						|
        EHMdecimal = 2
 | 
						|
    elseif EHM > 10 ^ 5 then
 | 
						|
        EHM = EHM / 10 ^ 3
 | 
						|
        DivideM = 10 ^ 3
 | 
						|
        letterM = "k"
 | 
						|
        EHMdecimal = 0
 | 
						|
    elseif EHM > 10 ^ 4 then
 | 
						|
        EHM = EHM / 10 ^ 3
 | 
						|
        DivideM = 10 ^ 3
 | 
						|
        letterM = "k"
 | 
						|
    elseif EHM > 10 ^ 3 then
 | 
						|
        EHM = EHM / 10 ^ 3
 | 
						|
        DivideM = 10 ^ 3
 | 
						|
        letterM = "k"
 | 
						|
        EHMdecimal = 2
 | 
						|
    elseif EHM > -1 then
 | 
						|
        EHM = EHM / 1
 | 
						|
        DivideM = 1
 | 
						|
        EHMdecimal = 0
 | 
						|
    end
 | 
						|
 | 
						|
    -- Format displayed text with appropriate colors --
 | 
						|
    local Color = ""
 | 
						|
    if Mode ~= "magic" then
 | 
						|
        for i = 1, 6 do
 | 
						|
            if EHP >= Threshold[1][i] / DivideP then Color = ColorFunction[i] end
 | 
						|
        end
 | 
						|
        if PImmunity == 1 then Color = ColorFunction[7] end
 | 
						|
        EHP = string.format("P:|c%s%." .. EHPdecimal .. "f" .. letterP .. "|r", Color, EHP)
 | 
						|
    else EHP = ""
 | 
						|
    end
 | 
						|
 | 
						|
    if Mode ~= "physical" then
 | 
						|
        for i = 1, 6 do
 | 
						|
            if EHM >= Threshold[2][i] / DivideM then Color = ColorFunction[i] end
 | 
						|
        end
 | 
						|
        if MImmunity == 1 then Color = ColorFunction[7] end
 | 
						|
        EHM = string.format("M:|c%s%." .. EHMdecimal .. "f" .. letterM .. "|r", Color, EHM)
 | 
						|
    else EHM = ""
 | 
						|
    end
 | 
						|
 | 
						|
    local separator = ""
 | 
						|
    if Mode == "both" and aura_env.Align == "horizontal" then separator = " | "
 | 
						|
    elseif Mode == "both" and aura_env.Align == "vertical" then separator = "\n" end
 | 
						|
 | 
						|
    --- CPU Benchmarking ---
 | 
						|
    if Debug then
 | 
						|
        aura_env.time = (aura_env.time or 0) + debugprofilestop() - start
 | 
						|
        if aura_env.count == 0 then
 | 
						|
            print(aura_env.time)
 | 
						|
            aura_env.time = 0
 | 
						|
        end
 | 
						|
        return "P: " .. ReductionP .. "\n" .. "M: " .. ReductionM
 | 
						|
    end
 | 
						|
 | 
						|
    return EHP .. separator .. EHM
 | 
						|
end
 | 
						|
 | 
						|
--CUSTOM TRIGGER
 | 
						|
function(t)
 | 
						|
    return t[1]
 | 
						|
end
 | 
						|
 | 
						|
--TRIGGER 1 - ALIVE
 | 
						|
 | 
						|
--ACTIVE_TALENT_GROUP_CHANGED
 | 
						|
function()
 | 
						|
    aura_env.SpecID = GetSpecialization()
 | 
						|
end
 | 
						|
 | 
						|
--COMBAT_LOG_EVENT_UNFILTERED
 | 
						|
function(event)
 | 
						|
    -- Original code from https://wago.io/B1M5OqeFb
 | 
						|
    if aura_env.ClassID == 10 and aura_env.SpecID == 3 then
 | 
						|
        local CLEU = {CombatLogGetCurrentEventInfo()}
 | 
						|
        local message = CLEU[2]
 | 
						|
        local destName = CLEU[9]
 | 
						|
        local Multiplier = 0.5
 | 
						|
        if aura_env.GoodKarma then
 | 
						|
            Multiplier = 1
 | 
						|
        end
 | 
						|
        if destName and UnitIsUnit("player", destName) then
 | 
						|
            if message == "SPELL_ABSORBED" then
 | 
						|
                local chk = CLEU[9]
 | 
						|
                local spellID, absorbed = 0, 0
 | 
						|
                if type(chk) == "number" then -- Spell
 | 
						|
                    spellID = CLEU[19]
 | 
						|
                    absorbed = CLEU[22]
 | 
						|
                else -- Swing
 | 
						|
                    spellID = CLEU[16]
 | 
						|
                    absorbed = CLEU[19]
 | 
						|
                end
 | 
						|
                if spellID == 122470 then
 | 
						|
                    aura_env.TouchOfKarma = math.max(aura_env.TouchOfKarma - absorbed, 0)
 | 
						|
                end
 | 
						|
            elseif message == "SPELL_AURA_APPLIED" then
 | 
						|
                local spellID = CLEU[12]
 | 
						|
                if spellID == 122470 then
 | 
						|
                    aura_env.maxValue = UnitHealthMax("player") * Multiplier
 | 
						|
                    aura_env.TouchOfKarma = aura_env.maxValue
 | 
						|
                end
 | 
						|
            elseif message == "SPELL_AURA_REMOVED" then
 | 
						|
                local spellID = CLEU[12]
 | 
						|
                if spellID == 122470 then
 | 
						|
                    aura_env.TouchOfKarma = 0
 | 
						|
                end
 | 
						|
            end
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
--PLAYER_TARGET_CHANGED,ENCOUNTER_START,INSTANCE_ENCOUNTER_ENGAGE_UNIT
 | 
						|
function()
 | 
						|
    local PlayerLevel = aura_env.PlayerLevel
 | 
						|
    local TargetLevel = PlayerLevel
 | 
						|
    if UnitExists("boss1") then
 | 
						|
        TargetLevel = UnitLevel("boss1")
 | 
						|
    elseif UnitExists("target") then
 | 
						|
        TargetLevel = UnitLevel("target")
 | 
						|
    end
 | 
						|
    if TargetLevel == -1 then -- Raid boss
 | 
						|
        TargetLevel = PlayerLevel + 3
 | 
						|
        -- elseif TargetLevel < aura_env.PlayerLevel then
 | 
						|
        --     TargetLevel = PlayerLevel -- Prevents the armor scaling from looking too strange. Currently disabled
 | 
						|
    end
 | 
						|
    aura_env.TargetLevel = TargetLevel
 | 
						|
end
 | 
						|
 | 
						|
--PLAYER_LEVEL_UP
 | 
						|
function(event, NewLevel)
 | 
						|
    aura_env.PlayerLevel = NewLevel
 | 
						|
end
 | 
						|
 | 
						|
--EVERY FRAME?? (For last defender - delet?)
 | 
						|
function()
 | 
						|
    if aura_env.ClassID == 2 and aura_env.SpecID == 2 then -- Enable for Protection Paladins only
 | 
						|
        if IsPlayerSpell(203791) then -- Last Defender - talent
 | 
						|
            local now = GetTime()
 | 
						|
            if now - aura_env.NameplateCheck >= 0.1 then -- Throttle
 | 
						|
                aura_env.NameplateCheck = now
 | 
						|
                local counter = 0
 | 
						|
                local i
 | 
						|
                for i = 1, 40 do
 | 
						|
                    local unit = "nameplate" .. i
 | 
						|
                    if UnitExists(unit) and not UnitIsFriend("player", unit) then
 | 
						|
                        if WeakAuras.GetRange(unit) < 8 then -- 8y range check
 | 
						|
                            counter = counter + 1
 | 
						|
                        end
 | 
						|
                    end
 | 
						|
                end
 | 
						|
                aura_env.NameplateCounter = counter
 | 
						|
            end
 | 
						|
        else aura_env.NameplateCounter = 0 -- Reset counter if the talent is not selected
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
--INIT-- Made by Zeler-Ravencrest EU, with great help from Stryer-Ravencrest EU
 | 
						|
aura_env.Mode = "both" -- Choose from "physical", "magic", "both" to change the value(s) displayed
 | 
						|
aura_env.Align = "vertical" -- Choose which alignment you want. "vertical" for vertical alignment, "horizontal" for horizontal alignment
 | 
						|
aura_env.AoE = true -- Enable avoidance with true and disable it with false
 | 
						|
aura_env.GlobalExport = true -- Enable export of certain variables as global variables for use in other weakauras
 | 
						|
aura_env.Debug = false -- Enable debug with true. It will then return the damage reduction multipliers
 | 
						|
local text = true -- Disable the 'P:' and the 'M:' with false
 | 
						|
aura_env.DisplayDecimals = 1 -- The number of decimals displayed
 | 
						|
 | 
						|
aura_env.PlayerLevel = UnitLevel("player")
 | 
						|
aura_env.TargetLevel = aura_env.PlayerLevel
 | 
						|
aura_env.TouchOfKarma = 0
 | 
						|
aura_env.GoodKarma = IsPlayerSpell(280195) -- Wind Walker Monk - Talent
 | 
						|
aura_env.HighmountainTauren = IsPlayerSpell(255659) -- Rugged Tenacity - Passive
 | 
						|
aura_env.NameplateCheck = 0 -- Protection Paladin - Last Defender - talent
 | 
						|
aura_env.NameplateCounter = 0 -- Protection Paladin - Last Defender - talent
 | 
						|
 | 
						|
-- Color values, the accepted values are from 0 to 255
 | 
						|
-- {red, green, blue}
 | 
						|
aura_env.Color = {
 | 
						|
    {0, 255, 0}, -- Lowest HP
 | 
						|
    {0, 255, 0},
 | 
						|
    {0, 255, 0},
 | 
						|
    {0, 255, 0},
 | 
						|
    {0, 255, 0},
 | 
						|
    {0, 255, 0}, -- Highest HP
 | 
						|
    {0, 255, 0}, -- Immunity color
 | 
						|
}
 | 
						|
 | 
						|
-- Thresholds at which the color changes (leave the first 0)
 | 
						|
aura_env.Threshold = {
 | 
						|
    {0, 1, 2, 3, 4, 5}, -- Physical EH
 | 
						|
    {0, 1, 2, 3, 4, 5}, -- Magic EH
 | 
						|
}
 | 
						|
 | 
						|
local function RGBtoHex(rgb)
 | 
						|
    return string.format("ff%02x%02x%02x", rgb[1], rgb[2], rgb[3])
 | 
						|
end
 | 
						|
 | 
						|
for i = 1, #aura_env.Color do
 | 
						|
    aura_env.Color[i] = RGBtoHex(aura_env.Color[i])
 | 
						|
end
 | 
						|
 | 
						|
-- Check player class and spec
 | 
						|
aura_env.ClassID = select(3, UnitClass("player"))
 | 
						|
aura_env.SpecID = GetSpecialization()
 | 
						|
 | 
						|
-- Class self-buffs: [Spell ID] = {Phys Reduction, Magic Reduction}
 | 
						|
aura_env.BasicReductions = {
 | 
						|
 | 
						|
    --- Death Knight ---
 | 
						|
    [194679] = {0.70, 0.70}, -- Rune Tap
 | 
						|
 | 
						|
    --- Demon Hunter ---
 | 
						|
 | 
						|
    --- Druid ---
 | 
						|
    [158792] = {0.91, 0.91}, -- Pulverize
 | 
						|
    [22812] = {0.80, 0.80}, -- Barkskin
 | 
						|
    [61336] = {0.50, 0.50}, -- Survival Instincts
 | 
						|
 | 
						|
    --- Hunter ---
 | 
						|
    [186265] = {0.70, 0.70}, -- Aspect of the Turtle
 | 
						|
    [264735] = {0.80, 0.80}, -- Survival of the Fittest
 | 
						|
 | 
						|
    --- Mage ---
 | 
						|
    [113862] = {0.40, 0.40}, -- Greater Invisibility
 | 
						|
    [235450] = {1, 0.85}, -- Prismatic Barrier
 | 
						|
 | 
						|
    --- Monk ---
 | 
						|
    [120954] = {0.80, 0.80}, -- Fortifying Brew (BrM)
 | 
						|
    [243435] = {0.80, 0.80}, -- Fortifying Brew (MW)
 | 
						|
    [122278] = {0.80, 0.80}, -- Dampen Harm, assumed at minimum reduction
 | 
						|
    [122783] = {1, 0.40}, -- Diffuse Magic
 | 
						|
    [115176] = {0.40, 0.40}, -- Zen Meditation
 | 
						|
 | 
						|
    --- Paladin ---
 | 
						|
    [498] = {0.80, 0.80}, -- Divine Protection
 | 
						|
    [31850] = {0.80, 0.80}, -- Ardent Defender
 | 
						|
    [205191] = {0.65, 1}, -- Eye for an Eye - talent
 | 
						|
    [86659] = {0.50, 0.50}, -- Guardian of Ancient Kings
 | 
						|
    [212641] = {0.50, 0.50}, -- Guardian of Ancient Kings - Glyph of the Queen
 | 
						|
    [183436] = {0.70, 0.70}, -- Retribution - passive
 | 
						|
    [6940] = {0.70, 0.70}, -- Blessing of Sacrifice
 | 
						|
    [204335] = {0.80, 0.80}, -- Aegis of Light - talent
 | 
						|
 | 
						|
    --- Priest ---
 | 
						|
    [47585] = {0.40, 0.40}, -- Dispersion
 | 
						|
    [193065] = {0.90, 0.90}, -- Masochism - talent
 | 
						|
    [232698] = {0.90, 1}, -- Shadowform
 | 
						|
    [33206] = {0.60, 0.60}, -- Pain Suppression
 | 
						|
    -- [194384] = {0.97, 0.97}, -- Leniece - talent -- Currently disabled due to being unable to track if the casting priest has the talent or not
 | 
						|
    [81782] = {0.75, 0.75}, -- Power Word: Barrier
 | 
						|
 | 
						|
    --- Rogue ---
 | 
						|
    [45182] = {0.15, 0.15}, -- Cheating Death - Cheat Death talent
 | 
						|
 | 
						|
    --- Shaman ---
 | 
						|
    [108271] = {0.60, 0.60}, -- Astral Shift
 | 
						|
    [98007] = {0.90, 0.90}, -- Spirit Link Totem
 | 
						|
 | 
						|
    --- Warlock ---
 | 
						|
    [104773] = {0.60, 0.60}, -- Unending Resolve
 | 
						|
 | 
						|
    --- Warrior ---
 | 
						|
    [197690] = {0.80, 0.80}, -- Defensive Stance
 | 
						|
    [118038] = {0.70, 0.70}, -- Die by the Sword
 | 
						|
    [184364] = {0.70, 0.70}, -- Enraged Regeneration
 | 
						|
    [871] = {0.60, 0.60}, -- Shield Wall
 | 
						|
    [23920] = {1, 0.80}, -- Spell Reflection
 | 
						|
    [223658] = {0.70, 0.70}, -- Safeguard
 | 
						|
 | 
						|
    --- Miscellaneous ---
 | 
						|
    [241836] = {0.95, 0.95}, -- Shadow of Celumbra
 | 
						|
    [65116] = {0.90, 1}, -- Stoneform
 | 
						|
    [211080] = {0.90, 0.90}, -- Comforting light (Court of Stars)
 | 
						|
    [273809] = {1.30, 1.30} -- Idol of Rage
 | 
						|
}
 | 
						|
 | 
						|
if aura_env.GlobalExport then
 | 
						|
    WA_ZELER_EH = {}
 | 
						|
end
 |