Files
wow-weakauras/Complete Projects/BFA/Ignor Pain ALERT.lua
2024-08-24 22:43:07 +02:00

79 lines
3.3 KiB
Lua

--UNIT_AURA:player UNIT_POWER_UPDATE:player
function(e, ...)
if e == "UNIT_AURA" then
if aura_env.UnitBuffC("Ignore Pain") then
local expTime = math.floor((select(6, aura_env.UnitBuffC("Ignore Pain")) * 100))
local ctime = math.floor((GetTime() * 100))
if ctime + 1200 == expTime then aura_env.absorb = select(16, aura_env.UnitBuffC("Ignore Pain")) end
end
elseif e == "UNIT_POWER_UPDATE" then
local rage = UnitPower("player")
local time = GetTime()
if rage < 40 then
aura_env.region:Hide()
return false
elseif rage >= 40 and rage < 90 and not aura_env.UnitBuffC("player", "Ignore Pain") then
aura_env.region:SetIcon(GetSpellTexture("Ignore Pain"))
aura_env.region:SetOffset(128, 200)
aura_env.region:SetGlow(true)
aura_env.region:Color(1, 1, 1, 1)
aura_env.region:Show()
return true
elseif rage >= 40 and rage < 90 and aura_env.UnitBuffC("player", "Ignore Pain") then
local absorb = select(16, aura_env.UnitBuffC("player", "Ignore Pain")) or 0
local expTime = select(6, aura_env.UnitBuffC("player", "Ignore Pain")) or 0
if absorb > 0 and expTime > 0 then
if expTime - time <= 3 then
aura_env.region:SetIcon(GetSpellTexture("Ignore Pain"))
aura_env.region:SetOffset(128, 200)
aura_env.region:SetGlow(false)
aura_env.region:Color(1, 1, 1, 1)
aura_env.region:Show()
return true
elseif absorb <= 0.2 * aura_env.absorb then
aura_env.region:SetIcon(GetSpellTexture("Ignore Pain"))
aura_env.region:SetOffset(128, 200)
aura_env.region:SetGlow(false)
aura_env.region:Color(1, 1, 1, 1)
aura_env.region:Show()
return true
else
aura_env.region:Hide()
return false
end
end
elseif rage >= 90 and not aura_env.UnitBuffC("player", "Shield Block") then
aura_env.region:SetIcon(GetSpellTexture("Shield Block"))
aura_env.region:SetOffset(-128, 200)
aura_env.region:SetGlow(false)
aura_env.region:Color(1, 1, 1, 0.33)
aura_env.region:Show()
return true
elseif rage >= 90 and aura_env.UnitBuffC("player", "Shield Block") then
aura_env.region:SetIcon(GetSpellTexture("Ignore Pain"))
aura_env.region:SetOffset(128, 200)
aura_env.region:SetGlow(false)
aura_env.region:Color(1, 1, 1, 0.5)
aura_env.region:Show()
return true
else
aura_env.region:Hide()()
return false
end
end
end
--INIT
aura_env.absorb = 0
aura_env.UnitBuffC = function(unit, spell)
for i = 1, 40 do
local name = UnitBuff(unit, i)
if name then
if name == spell then
return UnitBuff(unit, i)
end
else
return nil
end
end
end