changeset 26:dd1ef3996d7f v1.0beta4

Small change in UNIT_AURA
author contrebasse
date Fri, 10 Dec 2010 21:42:27 +0100
parents 06da6c8049fc (diff) ddcb7021838b (current diff)
children 239bedf57140
files Degaine.lua
diffstat 2 files changed, 47 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Fri Dec 10 20:07:03 2010 +0100
+++ b/.hgtags	Fri Dec 10 21:42:27 2010 +0100
@@ -1,2 +1,3 @@
 52e5a43002a87f0695607993bd03636617fe5e12 v1.0beta
 c627cef1c6d6f6c8af6065ad27abe60f1408fec3 v1.0beta2
+3b1123f50be4dab82386ed92d3a0dd6b3c18b7b6 v1.0beta3
--- a/Degaine.lua	Fri Dec 10 20:07:03 2010 +0100
+++ b/Degaine.lua	Fri Dec 10 21:42:27 2010 +0100
@@ -31,6 +31,7 @@
 local InCombatLockdown = InCombatLockdown
 local ToggleSheath = ToggleSheath
 local UnitName = UnitName
+local IsMounted = IsMounted
 
 
 ---------------------------------------------------------------
@@ -39,13 +40,14 @@
 -- const
 local DegaineFrame = CreateFrame("Frame")
 local playername = UnitName("player")
+local delay = 2 -- seconds
 
 -- vars
 local t_left = -1
-local delay = 2 -- seconds
 local isGossipClosed = true
 local wasGossipOpened = false
 local t_lastGossipClosed = 0
+local wasMounted = IsMounted() -- handle mounts with UNIT_AURA
 
 
 ---------------------------------------------------------------
@@ -92,6 +94,16 @@
 	UNIT_SPELLCAST_FAILED = true,
 	UNIT_SPELLCAST_INTERRUPTED = true,
 	UNIT_SPELLCAST_SUCCEEDED = true,
+	UNIT_AURA = function()
+		if IsMounted() then
+			wasMounted = true
+		else
+			if wasMounted then
+				wasMounted = false
+				start()
+			end
+		end
+	end
 }
 local SpellBlackList = { -- spells that don't stealth weapons (works with events1player)
 	[1784] = true,  -- Stealth (Rogue)
@@ -120,6 +132,33 @@
 
 
 ---------------------------------------------------------------
+-- Handle mounts with OnUpdate
+---------------------------------------------------------------
+-- works with GupPet but not with the default interface...
+-- I guess that's because a specific /cancelaura or alike is done
+-- hooksecurefunc("Dismount",start);
+
+--[[ With OnUpdate
+local handleMountsFrame = CreateFrame("frame")
+local handleMountsOnUpdate
+do
+	local IsMounted = IsMounted
+	local wasMounted = IsMounted()
+	function handleMountsOnUpdate(self,t_elapsed)
+		if IsMounted() then
+			wasMounted = true
+		else
+			if wasMounted then
+				start()
+				wasMounted = false
+			end
+		end
+	end
+end
+--]]
+
+
+---------------------------------------------------------------
 -- Launch drawing weapons
 ---------------------------------------------------------------
 -- Wait a few seconds before drawing, to be able to see the curren animation (and avoid bugs)
@@ -156,12 +195,15 @@
 	--@end-debug@
 	end
 	--@end-debug@
+	handleMountsFrame:SetScript("OnUpdate",handleMountsOnUpdate)
 end
 local desactivate = function()
+	DegaineFrame:SetScript("OnUpdate", nil)
+	handleMountsFrame:SetScript("OnUpdate",nil)
+	t_left = -1
 	for k,_ in pairs(events) do DegaineFrame:UnregisterEvent(k) end
 	for k,_ in pairs(events1player) do DegaineFrame:UnregisterEvent(k) end
 	for k,_ in pairs(events2playername) do DegaineFrame:UnregisterEvent(k) end
-	DegaineFrame:SetScript("OnUpdate", nil)
 end
 Degaine_ToggleAuto = function()
 	if Degaine_isAuto then
@@ -175,6 +217,7 @@
 end
 
 
+
 ---------------------------------------------------------------
 -- Event/hooks functions
 ---------------------------------------------------------------
@@ -193,7 +236,7 @@
 		end
 	elseif events1player[event] then
 		if arg1=="player" then
-			if not SpellBlackList[arg5] then -- arg5 is SpellID
+			if arg5==nil or not SpellBlackList[arg5] then -- arg5 is SpellID
 				start()
 			end
 		end