changeset 53:6da5658a3428

Added support for checking buff loss, added Ghost Wolf
author contrebasse
date Mon, 28 Feb 2011 01:18:29 +0100
parents d724fb112e7c
children 12a568d6387a
files Degaine.lua Exceptions.lua
diffstat 2 files changed, 68 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Degaine.lua	Mon Feb 28 00:20:19 2011 +0100
+++ b/Degaine.lua	Mon Feb 28 01:18:29 2011 +0100
@@ -27,6 +27,7 @@
 local pairs = pairs;
 local type = type;
 local select = select
+local wipe = wipe
 
 -- Wow functions
 local GetTime = GetTime
@@ -36,6 +37,7 @@
 local IsMounted = IsMounted
 local UnitCastingInfo = UnitCastingInfo
 local GetUnitSpeed = GetUnitSpeed
+local UnitBuff = UnitBuff
 
 
 ---------------------------------------------------------------
@@ -154,6 +156,7 @@
 do
 	local IsMounted = IsMounted
 	local wasMounted = IsMounted()
+	local buffsIDs = {}
 	function handleMountsOnUpdate(self,t_elapsed)
 		if IsMounted() then
 			wasMounted = true
@@ -163,6 +166,64 @@
 				wasMounted = false
 			end
 		end
+
+		-- hack to watch auras too
+		-- Loop over all buffs
+		-- name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable,
+		--    shouldConsolidate, spellId = UnitBuff("unit", index or ["name", "rank"][, "filter"])
+		local i = 1
+		-- list player's buffs
+		local buffID = select(11,UnitBuff("player", i)); -- spell id
+		while buffID do
+			buffsIDs[buffID] = true
+			i = i + 1;
+			buffID = select(11,UnitBuff("player", i));
+		end
+		--[[
+		for i=1,40 do
+			buffID = select(11,UnitBuff("player", i));
+			if buffID then
+				buffsIDs[buffID] = true
+			end
+		end
+		--]]
+		--@debug@
+		--if debug then
+		--	DEFAULT_CHAT_FRAME:AddMessage(""..i-1.."Buff(s) found")
+		--end
+		--@end-debug@
+
+		-- loop over watched buffs to check if it is present or not
+		-- we have to loop over T.LoseAura (and not buffsIDs) to be able to check for buff disappearance
+		for id,state in pairs(T.LoseAura) do
+			if buffsIDs[id] then
+				if not T.LoseAura[id] then
+					-- buff gained
+					--@debug@
+					if debug then
+						DEFAULT_CHAT_FRAME:AddMessage("Buff gained: "..id)
+					end
+					--@end-debug@
+					T.LoseAura[id] = true
+				end
+			else
+				if T.LoseAura[id] then
+					-- buff lost
+					--@debug@
+					if debug then
+						DEFAULT_CHAT_FRAME:AddMessage("Buff lost: "..id)
+					end
+					--@end-debug@
+					T.LoseAura[id] = false
+
+					-- draw weapon
+					start()
+				end
+			end
+		end
+
+		-- empty temporary table
+		wipe(buffsIDs)
 	end
 end
 
--- a/Exceptions.lua	Mon Feb 28 00:20:19 2011 +0100
+++ b/Exceptions.lua	Mon Feb 28 01:18:29 2011 +0100
@@ -17,6 +17,13 @@
 	[48778] = true, -- Acherus Deathcharger
 }
 
+T.LoseAura = { -- set these to false and not true !!!
+	[2645] = false,-- Shaman's Ghost wolf
+}
+
+T.GainAura = { -- set these to false and not true !!!
+}
+
 -- Not used any more, but I keep it just in case...
 T.SpellBlackList = { -- spells that don't stealth weapons (works with events1player)
 	-- All vanity pets and mount are added at PLAYER_LOGIN