Quantcast

Handle Eclipse in the state machine when crossing the zero threshold.

Johnny C. Lam [12-09-13 - 02:14]
Handle Eclipse in the state machine when crossing the zero threshold.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1248 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleEclipse.lua
diff --git a/OvaleEclipse.lua b/OvaleEclipse.lua
index 82c68d2..9d80aaa 100644
--- a/OvaleEclipse.lua
+++ b/OvaleEclipse.lua
@@ -188,6 +188,14 @@ function OvaleEclipse:ApplySpellAfterCast(state, spellId, targetGUID, startCast,
 			-- Only adjust Eclipse energy if the spell moves the Eclipse bar in the right direction.
 			if (direction <= 0 and energy < 0) or (direction >= 0 and energy > 0) then
 				eclipse = eclipse + energy
+
+				-- Crossing zero energy removes the corresponding Eclipse state.
+				if direction < 0 and eclipse <= 0 then
+					state:RemoveAuraOnGUID(self_guid, SOLAR_ECLIPSE, "HELPFUL", true, endCast)
+				elseif direction > 0 and eclipse >= 0 then
+					state:RemoveAuraOnGUID(self_guid, LUNAR_ECLIPSE, "HELPFUL", true, endCast)
+				end
+
 				-- Clamp Eclipse energy to min/max values and note that an Eclipse state will be reached after the spellcast.
 				if eclipse <= -100 then
 					eclipse = -100