Quantcast

Resto fixes and code optimalizations.

Taracque [12-10-12 - 06:42]
Resto fixes and code optimalizations.
Filename
Elementarist.lua
modules/restoration.lua
diff --git a/Elementarist.lua b/Elementarist.lua
index 484ef0e..7b0ab5c 100755
--- a/Elementarist.lua
+++ b/Elementarist.lua
@@ -243,7 +243,7 @@ end;

 function Elementarist:CallModule( funcName, ... )
 	if (Elementarist.modules[Elementarist.talent]) and (Elementarist[Elementarist.talent]) and (Elementarist[Elementarist.talent][funcName]) then
-		return Elementarist[Elementarist.talent][funcName](...);
+		return Elementarist[Elementarist.talent][funcName](self,...);
 	end;
 	return false;
 end;
@@ -346,7 +346,14 @@ function Elementarist:RemoveFromTables(guid)
 end

 function Elementarist:PurgeDebuffTable()
-	Elementarist.auraCooldowns = {}
+	if (Elementarist.auraCooldowns["0"]) then
+		local tmp = Elementarist.auraCooldowns["0"];
+		Elementarist.auraCooldowns = {
+			["0"] = tmp
+		};
+	else
+		Elementarist.auraCooldowns = {};
+	end;
 	Elementarist:UpdateAuraTracker()
 end

@@ -605,11 +612,15 @@ function Elementarist:UpdateAuraTracker()
 	local m = 1
 	for i,v in pairs(Elementarist.auraCooldowns) do
 		if (i ~= "0") then
-			if ( (v["start"] + v["duration"]) > GetTime() ) and (i ~= tguid) and (m <= 10) and (v["action"]>GetTime() - 4) then
-				Elementarist:SetTexture(Elementarist.textureList["debuff_" .. tostring(m)],icon)
-				Elementarist.auraCooldownFrame["mini_" .. tostring(m)]:SetCooldown( v["start"], v["duration"])
-				m = m + 1
-			end
+			if (not v["start"]) then
+				v = {}
+			else
+				if ( (v["start"] + v["duration"]) > GetTime() ) and (i ~= tguid) and (m <= 10) and (v["action"]>GetTime() - 4) then
+					Elementarist:SetTexture(Elementarist.textureList["debuff_" .. tostring(m)],icon)
+					Elementarist.auraCooldownFrame["mini_" .. tostring(m)]:SetCooldown( v["start"], v["duration"])
+					m = m + 1
+				end
+			end;
 		end;
 	end
 	for i=m,10,1 do
@@ -737,27 +748,15 @@ function Elementarist:SpellAvailable(spell)
 end

 function Elementarist:NextSpell(...)
-	if (Elementarist[Elementarist.talent]) and (Elementarist[Elementarist.talent].NextSpell ~= nil) then
-		return Elementarist[Elementarist.talent]:NextSpell(...)
-	end
-
-	return ""
+	return Elementarist:CallModule("NextSpell", ...);
 end

 function Elementarist:MiscSpell(...)
-	if (Elementarist[Elementarist.talent]) and (Elementarist[Elementarist.talent].MiscSpell ~= nil) then
-		return Elementarist[Elementarist.talent]:MiscSpell(...)
-	end
-
-	return ""
+	return Elementarist:CallModule("MiscSpell", ...);
 end

 function Elementarist:IntSpell(...)
-	if (Elementarist[Elementarist.talent]) and (Elementarist[Elementarist.talent].IntSpell ~= nil) then
-		return Elementarist[Elementarist.talent]:IntSpell(...)
-	end
-
-	return ""
+	return Elementarist:CallModule("IntSpell", ...);
 end

 function Elementarist:FlashSpell(spell,spelltype)
@@ -875,19 +874,13 @@ function Elementarist:OnUpdate(elapsed)
 		end
 		if (not ElementaristDB.debuffdisabled) then
 			Elementarist.AuraTrackerUpdate = Elementarist.AuraTrackerUpdate + elapsed
-			if (
-				((Elementarist.OmniCC) and (Elementarist.AuraTrackerUpdate >= 1)) or
-				((not Elementarist.OmniCC) and (Elementarist.AuraTrackerUpdate >= 1))
-			) then
+			if (Elementarist.AuraTrackerUpdate >= 1) then
 				Elementarist:UpdateAuraTracker()
 			end
 		end
 		if (not ElementaristDB.shielddisabled) then
 			Elementarist.shieldTrackerUpdate = Elementarist.shieldTrackerUpdate + elapsed
-			if (
-				((Elementarist.OmniCC) and (Elementarist.shieldTrackerUpdate >= 1)) or
-				((not Elementarist.OmniCC) and (Elementarist.shieldTrackerUpdate >= 1))
-			) then
+			if (Elementarist.shieldTrackerUpdate >= 1) then
 				Elementarist:UpdateShieldTracker()
 			end
 		end
diff --git a/modules/restoration.lua b/modules/restoration.lua
index 586f27b..9492d37 100755
--- a/modules/restoration.lua
+++ b/modules/restoration.lua
@@ -26,18 +26,34 @@ Elementarist.restoration = {
 		Elementarist.trackDuration = 18;
 		Elementarist.callbacks = {
 			["COMBAT_LOG"] = function(self,event,spellName,srcGUID,dstGUID)
-				if (spellName == Elementarist.SpellList["Earth Shield"]) then
+				if (Elementarist.auraCooldowns["0"]) and (Elementarist.auraCooldowns["0"].seen) and ((GetTime() - Elementarist.auraCooldowns["0"].seen)> 60 ) then
+					Elementarist.auraCooldowns["0"] = {};
+					Elementarist:SetTexture(Elementarist.textureList["debuff"],"");
+					Elementarist.textList['debuff']:SetText("");
+				end;
+				if (spellName == Elementarist.SpellList["Riptide"]) then
+					if (event=="SPELL_AURA_REMOVED") then
+						Elementarist.auraCooldowns[dstGUID] = {};
+					end;
+				end;
+				if (Elementarist.auraCooldowns["0"]) and (Elementarist.auraCooldowns["0"].guid) and (dstGUID == Elementarist.auraCooldowns["0"].guid) then
+					Elementarist.auraCooldowns["0"].seend = GetTime();
+				end;
+				if (spellName == Elementarist.SpellList["Earth Shield"]) then
 					if (srcGUID == Elementarist.playerGUID) then
 						if (not Elementarist.auraCooldowns["0"]) then
 							Elementarist.auraCooldowns["0"] = {}
 						end;
 						if (event=="SPELL_CAST_SUCCESS") then
 							Elementarist.auraCooldowns["0"].charges = 9;
+							Elementarist.auraCooldowns["0"].guid = dstGUID;
+							Elementarist.auraCooldowns["0"].seend = GetTime();
 							Elementarist:SetTexture(Elementarist.textureList["debuff"],select(3, GetSpellInfo(Elementarist.SpellList["Earth Shield"])));
 							Elementarist.textureList["debuff"]:Show();
 						end;
 						if (event=="SPELL_HEAL") and (Elementarist.auraCooldowns["0"]) and (Elementarist.auraCooldowns["0"].charges) then
 							Elementarist.auraCooldowns["0"].charges = Elementarist.auraCooldowns["0"].charges - 1;
+							Elementarist.auraCooldowns["0"].seend = GetTime();
 						end;
 						if (Elementarist.auraCooldowns["0"]) and (Elementarist.auraCooldowns["0"].charges) then
 							Elementarist.textList['debuff']:SetText( Elementarist.auraCooldowns["0"].charges );
@@ -111,6 +127,7 @@ Elementarist.restoration = {

 		return ""
 	end;
+
 	MiscSpell = function(self)
 		local d, e
 		local name, expirationTime, _
@@ -149,8 +166,10 @@ Elementarist.restoration = {
 		if Elementarist:SpellAvailable(Elementarist.SpellList["Healing Stream Totem"]) then
 			local haveWaterTotem,waterTotemName,_,_ = GetTotemInfo(3)
 			if (waterTotemName == "") then
-				-- no water totem
-				return Elementarist.SpellList["Healing Stream Totem"]
+				e = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Healing Stream Totem"]);
+				if (e < 1) then
+					return Elementarist.SpellList["Healing Stream Totem"];
+				end;
 			end
 		end