update LibDruidMana-1.0

This commit is contained in:
Crum
2018-12-14 22:45:07 -06:00
parent 7dfe187aa7
commit 5c9ec9c3c3
@@ -84,6 +84,16 @@ tt:SetOwner(UIParent, "ANCHOR_NONE")
local registry = oldLib and oldLib.registry or {} local registry = oldLib and oldLib.registry or {}
lib.registry = registry lib.registry = registry
local function GetManaRegen()
local base, spirit = UnitStat("player", 5)
local currMana, maxMana = UnitMana("player"), UnitManaMax("player")
local regen = ((spirit / 5) - 15)
local castingRegen = min(currMana + regen, maxMana)
return regen, castingRegen
end
local function getShapeshiftCost() local function getShapeshiftCost()
if not bearID then return 0 end if not bearID then return 0 end
@@ -110,7 +120,7 @@ local SetMax_time = nil
local UpdateMana_time = nil local UpdateMana_time = nil
local killFSR_time = nil local killFSR_time = nil
frame:SetScript("OnUpdate", function(this, elapsed) frame:SetScript("OnUpdate", function()
local currentTime = GetTime() local currentTime = GetTime()
if SetMax_time and SetMax_time <= currentTime then if SetMax_time and SetMax_time <= currentTime then
SetMax_time = nil SetMax_time = nil
@@ -138,8 +148,8 @@ function frame:PLAYER_LOGIN()
end end
end end
function frame:UNIT_DISPLAYPOWER(unit) function frame:UNIT_DISPLAYPOWER()
if unit ~= "player" or UnitPowerType("player") ~= 0 then return end if arg1 ~= "player" or UnitPowerType("player") ~= 0 then return end
self:UnregisterEvent("UNIT_DISPLAYPOWER") self:UnregisterEvent("UNIT_DISPLAYPOWER")
self.UNIT_DISPLAYPOWER = nil self.UNIT_DISPLAYPOWER = nil
@@ -173,8 +183,8 @@ function frame:PLAYER_LEAVING_WORLD()
killFSR_time = nil killFSR_time = nil
end end
function frame:UNIT_MANA(unit) function frame:UNIT_MANA()
if unit ~= "player" then return end if arg1 ~= "player" then return end
if UnitPowerType("player") == 0 then if UnitPowerType("player") == 0 then
currMana = UnitMana("player") currMana = UnitMana("player")
@@ -191,8 +201,8 @@ function frame:UNIT_MANA(unit)
end end
end end
function frame:UNIT_MAXMANA(unit) function frame:UNIT_MAXMANA()
if unit ~= "player" then return end if arg1 ~= "player" then return end
local _, int = UnitStat("player", 4) local _, int = UnitStat("player", 4)
if UnitPowerType("player") == 0 then if UnitPowerType("player") == 0 then
@@ -256,7 +266,6 @@ function frame:LEARNED_SPELL_IN_TAB()
end end
function frame:UpdateMana() function frame:UpdateMana()
print(this)
local regen, castingRegen = GetManaRegen() local regen, castingRegen = GetManaRegen()
if fiveSecondRule then if fiveSecondRule then
currMana = currMana + floor(castingRegen * 2 + 0.5) currMana = currMana + floor(castingRegen * 2 + 0.5)
@@ -303,11 +312,7 @@ function frame:Update()
end end
end end
-- if IsLoggedIn() then frame:PLAYER_LOGIN()
frame:PLAYER_LOGIN()
-- else
-- frame:RegisterEvent("PLAYER_LOGIN")
-- end
function lib:GetCurrentMana() function lib:GetCurrentMana()
return currMana return currMana