--WeakAurasSaved.HoTP 3.0
--TRIGGER
function()
    return true
end

--ICON --Trigger for scripts
function()
    WeakAurasSaved.HoTP.percentageHealth = aura_env.round((UnitHealth("player") / UnitHealthMax("player")) * 100, 0)
    WeakAurasSaved.HoTP.currentHealth = UnitHealth("player")
    WeakAurasSaved.HoTP.missingHealthPercentage = aura_env.round(((UnitHealthMax("player") - UnitHealth("player")) / UnitHealthMax("player")) * 100, 2)
    WeakAurasSaved.HoTP.missingHealth = UnitHealthMax("player") - UnitHealth("player")
    local healingMultiplier = 1.
    local versa = GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_DONE)
    healingMultiplier = healingMultiplier + (healingMultiplier * (WeakAurasSaved.HoTP.traitLevel * WeakAurasSaved.HoTP.traitEffectiveness))
    healingMultiplier = healingMultiplier + (healingMultiplier * (versa / 100))
    for k, v in pairs(WeakAurasSaved.HoTP.Buffs) do
        if UnitBuff("player", k) ~= nil then
            healingMultiplier = healingMultiplier + (healingMultiplier * v)
        end
    end
    local talent = select(10, GetTalentInfoByID(22430))
    if talent == true then
        healingMultiplier = healingMultiplier + (healingMultiplier * 0.3)
    end
    WeakAurasSaved.HoTP.hotpRelativeHeal = 0.3 * healingMultiplier --How much % hotp heals disregarding missing health
    WeakAurasSaved.HoTP.hotpAbsoluteRelativeHeal = WeakAurasSaved.HoTP.hotpRelativeHeal * WeakAurasSaved.HoTP.missingHealthPercentage --How much % hp hotp will heal regarding missing health
    WeakAurasSaved.HoTP.hotpAbsoluteHeal = aura_env.round(WeakAurasSaved.HoTP.hotpRelativeHeal * WeakAurasSaved.HoTP.missingHealth, 0)
    WeakAurasSaved.HoTP.newApsoluteHealth = aura_env.round(WeakAurasSaved.HoTP.currentHealth + WeakAurasSaved.HoTP.hotpAbsoluteHeal, 0)
    WeakAurasSaved.HoTP.newRelativeHealth = aura_env.round(WeakAurasSaved.HoTP.percentageHealth + WeakAurasSaved.HoTP.hotpAbsoluteRelativeHeal, 0)
end

--DURATION
function()
    return WeakAurasSaved.HoTP.percentageHealth, 100, 1
end

--NAME
function()
    return WeakAurasSaved.HoTP.percentageHealth .. " " .. WeakAurasSaved.HoTP.newRelativeHealth .. " +" .. aura_env.round(WeakAurasSaved.HoTP.hotpAbsoluteRelativeHeal, 0)
end

--DISPLAY
function()
    return ("%.0fk / %.0fk"):format(UnitHealth("player") / 1000, UnitHealthMax("player") / 1000);
end

--INIT
aura_env.round = function(var, n)
    if (n) then
        var = math.floor((var * 10 ^ n) + 0.5) / (10 ^ n)
    else
        var = math.floor(var + 0.5)
    end
    return var
end
WeakAurasSaved.HoTP =
{
    ["Buffs"] =
    {
        ["Consecration"] = 0.3,
        ["Avenging Wrath"] = 0.35,
        ["Chains of Thrayn"] = 0.5,
        ["Ilterendi, Crown Jewel of Silvermoon"] = 0.15,
    },
    ["traitLevel"] = 7,
    ["traitEffectiveness"] = 0.06,
    ["percentageHealth"] = 0,
    ["currentHealth"] = 0,
    ["hotpRelativeHeal"] = 0,
    ["hotpAbsoluteRelativeHeal"] = 0,
    ["hotpAbsoluteHeal"] = 0,
    ["newApsoluteHealth"] = 0,
    ["newRelativeHealth"] = 0,
    ["missingHealth"] = 0,
    ["missingHealthPercentage"] = 0,
}
