AbsorbBarConfig = {}
AbsorbBar = {}
local AbsorbBarAddon = CreateFrame("Frame", "AbsorbBarAddon", UIParent)
local DefaultConfig = {}
local RegisteredEvents = {}
AbsorbBarAddon:SetScript("OnEvent", function (self, event, ...) if (RegisteredEvents[event]) then return RegisteredEvents[event](self, event, ...) end end)
local ORGINAL_AMOUNT = 0
local CURRENT_AMOUNT = 0
local REMOVED_AMOUNT = 0
local ORGINAL_AMOUNT2 = 0
local CURRENT_AMOUNT2 = 0
local AbsorbBar_MyGUID =0;
local AbsorbBarClass = "";
local AB_SS = 'Sacred Shield'
local AB_SB = 'Shield Barrier';
local AB_PWS = 'Power Word: Shield';
local AB_DA = 'Divine Aegis';
local AB_IB = 'Ice Barrier';
local AB_MS = 'Mana Shield';
local AB_MW = 'Mage Ward'
local AB_BB = 'Blazing Barrier';
local AB_SF = 'Sacrifice';
local AB_SPS = 'Spirit Shell';
local pattern = "[aA]bsorb%a* (%d+) [^d]?%a*%s?damage" ; -- [1]
local mylocale;
local IB_Current, IB_Total, MS_Current, MS_Total, MW_Current, MW_Total, BB_Current, BB_Total = 0,0,0,0,0,0,0,0 -- MAGE
local PWS_Current, PWS_Total, DA_Current, DA_Total, SPS_Current,SPS_tmp, SPS_Total = 0,0,0,0,0,0,0 -- PRIEST
local SB_Current,SB_Total = 0,0 --Warrior
local SS_Current,SS_Total = 0,0 --Paladin
function RegisteredEvents:ADDON_LOADED(event, addon, ...)
local _
AbsorbBarClass,_ = UnitClass("player");
if (
AbsorbBarClass ~= "Priest" and
AbsorbBarClass ~= "Mage" and
AbsorbBarClass ~= "Warlock" and
AbsorbBarClass ~= "Warrior" and
AbsorbBarClass ~= "Paladin"
) then
return -- disable addon of other classes
end
if (addon == "AbsorbBar") then
SLASH_ABAR1 = '/abar'
SlashCmdList["ABAR"] = function (msg, editbox)
AbsorbBar.SlashCmdHandler(msg, editbox)
end
setmetatable(AbsorbBarConfig, {__index = DefaultConfig})
AbsorbBarUI.CreateEnergyBar()
AbsorbBarUI.CreateConfigMenu()
print("AbsorbBar " .. GetAddOnMetadata("AbsorbBar","Version") .. " Loaded. /abar for options" )
end
end
function RegisteredEvents:PLAYER_LOGIN(event)
local _
AbsorbBarClass,_ = UnitClass("player");
if (
AbsorbBarClass ~= "Priest" and
AbsorbBarClass ~= "Mage" and
AbsorbBarClass ~= "Warlock" and
AbsorbBarClass ~= "Warrior" and
AbsorbBarClass ~= "Paladin"
) then
return -- disable addon of other classes
end
AbsorbBar_MyGUID = UnitGUID("player");
mylocale = GetLocale();
AbsorbBar.Lang();
--print(" UnitGUID " ..UnitGUID("player"))
AbsorbBar.UpdateBar()
-- show config panel at load
--InterfaceOptionsFrame_OpenToCategory("AbsorbBar")
end
function RegisteredEvents:UNIT_AURA(arg1, arg2)
--print ("---")
--print (arg1) -- UNIT_AURA
--print (arg2) -- Player
local _
-- MAGE
if AbsorbBarClass == "Mage" and arg2 == "player" then
_, _, _, _, _, _, _, _, _, _, _, _, _, _,IB_Current = UnitBuff("Player", AB_IB)
_, _, _, _, _, _, _, _, _, _, _, _, _, _,MS_Current = UnitBuff("Player", AB_MS)
if (IB_Current ~= nil ) then -- ice bar
if (IB_Current >= IB_Total) then
IB_Total = IB_Current
end
else
IB_Total = 0
IB_Current = 0
end
if (MS_Current ~= nil ) then -- mana shield
if (MS_Current >= MS_Total) then
MS_Total = MS_Current
end
else
MS_Total = 0
MS_Current = 0
end
if (MW_Current ~= nil ) then -- mage ward
if (MW_Current >= MW_Total) then
MW_Total = MW_Current
end
else
MW_Total = 0
MW_Current = 0
end
if (BB_Current ~= nil ) then -- Blazing barrier
if (BB_Current >= BB_Total) then
BB_Total = BB_Current
end
else
BB_Total = 0
BB_Current = 0
end
CURRENT_AMOUNT2 = 0
ORGINAL_AMOUNT2 = 0
if IB_Total ~= nil and IB_Current ~= nil then
CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + IB_Current
ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + IB_Total
end
if MS_Total ~= nil and MS_Current ~= nil then
CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + MS_Current
ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + MS_Total
end
if MW_Total ~= nil and MW_Current ~= nil then
CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + MW_Current
ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + MW_Total
end
if BB_Total ~= nil and BB_Current ~= nil then
CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + BB_Current
ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + BB_Total
end
AbsorbBar.UpdateBar()
return
end
-- PRIEST
if AbsorbBarClass == "Priest" and arg2 == "player" then
_, _, _, _, _, _, _, _, _, _, _, _, _, _,PWS_Current = UnitBuff("Player", AB_PWS)
_, _, _, _, _, _, _, _, _, _, _, _, _, _,DA_Current = UnitBuff("Player", AB_DA)
SPS_Current =getspiritshield()
if (PWS_Current ~= nil ) then -- Power word shield
if (PWS_Current >= PWS_Total) then
PWS_Total = PWS_Current
end
else
PWS_Total = 0
PWS_Current = 0
end
if (DA_Current ~= nil ) then -- Divine Aegis
if (DA_Current >= DA_Total) then
DA_Total = DA_Current
end
else
DA_Total = 0
DA_Current = 0
end
if (SPS_Current ~= nil ) then -- Divine Aegis
if (SPS_Current >= SPS_Total) then
SPS_Total = SPS_Current
end
else
SPS_Total = 0
SPS_Current = 0
end
CURRENT_AMOUNT2 = 0
ORGINAL_AMOUNT2 = 0
if PWS_Total ~= nil and PWS_Current ~= nil then
CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + PWS_Current
ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + PWS_Total
end
if DA_Total ~= nil and DA_Current ~= nil then
CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + DA_Current
ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + DA_Total
end
if SPS_Total ~= nil and SPS_Current ~= nil then
CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + SPS_Current
ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + SPS_Total
end
AbsorbBar.UpdateBar()
return
end
--Paladin
if AbsorbBarClass == "Paladin" and arg2 == "player" then
_, _, _, _, _, _, _, _, _, _, _, _, _, _,SS_Current = UnitBuff("Player", AB_SS)
if (SS_Current ~= nil ) then -- Sacred Shield
if (SS_Current >= SS_Total) then
SS_Total = SS_Current
end
else
SS_Total = 0
SS_Current = 0
end
CURRENT_AMOUNT2 = 0
ORGINAL_AMOUNT2 = 0
if SS_Total ~= nil and SS_Current ~= nil then
CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + SS_Current
ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + SS_Total
end
AbsorbBar.UpdateBar()
return
end
-- Warrior
if AbsorbBarClass == "Warrior" and arg2 == "player" then
_, _, _, _, _, _, _, _, _, _, _, _, _, _,SB_Current = UnitBuff("Player", AB_SB)
if (SB_Current ~= nil ) then -- Shield Barrier
if (SB_Current >= SB_Total) then
SB_Total = SB_Current
end
else
SB_Total = 0
SB_Current = 0
end
CURRENT_AMOUNT2 = 0
ORGINAL_AMOUNT2 = 0
if SB_Total ~= nil and SB_Current ~= nil then
CURRENT_AMOUNT2 = CURRENT_AMOUNT2 + SB_Current
ORGINAL_AMOUNT2 = ORGINAL_AMOUNT2 + SB_Total
end
AbsorbBar.UpdateBar()
return
end
end