comparison Degaine.lua @ 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
comparison
equal deleted inserted replaced
52:d724fb112e7c 53:6da5658a3428
25 25
26 -- Lua functions 26 -- Lua functions
27 local pairs = pairs; 27 local pairs = pairs;
28 local type = type; 28 local type = type;
29 local select = select 29 local select = select
30 local wipe = wipe
30 31
31 -- Wow functions 32 -- Wow functions
32 local GetTime = GetTime 33 local GetTime = GetTime
33 local InCombatLockdown = InCombatLockdown 34 local InCombatLockdown = InCombatLockdown
34 local ToggleSheath = ToggleSheath 35 local ToggleSheath = ToggleSheath
35 local UnitName = UnitName 36 local UnitName = UnitName
36 local IsMounted = IsMounted 37 local IsMounted = IsMounted
37 local UnitCastingInfo = UnitCastingInfo 38 local UnitCastingInfo = UnitCastingInfo
38 local GetUnitSpeed = GetUnitSpeed 39 local GetUnitSpeed = GetUnitSpeed
40 local UnitBuff = UnitBuff
39 41
40 42
41 --------------------------------------------------------------- 43 ---------------------------------------------------------------
42 -- Local vars 44 -- Local vars
43 --------------------------------------------------------------- 45 ---------------------------------------------------------------
152 local handleMountsFrame = CreateFrame("frame") 154 local handleMountsFrame = CreateFrame("frame")
153 local handleMountsOnUpdate 155 local handleMountsOnUpdate
154 do 156 do
155 local IsMounted = IsMounted 157 local IsMounted = IsMounted
156 local wasMounted = IsMounted() 158 local wasMounted = IsMounted()
159 local buffsIDs = {}
157 function handleMountsOnUpdate(self,t_elapsed) 160 function handleMountsOnUpdate(self,t_elapsed)
158 if IsMounted() then 161 if IsMounted() then
159 wasMounted = true 162 wasMounted = true
160 else 163 else
161 if wasMounted then 164 if wasMounted then
162 start(delay_short) -- no animation for unmounting 165 start(delay_short) -- no animation for unmounting
163 wasMounted = false 166 wasMounted = false
164 end 167 end
165 end 168 end
169
170 -- hack to watch auras too
171 -- Loop over all buffs
172 -- name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable,
173 -- shouldConsolidate, spellId = UnitBuff("unit", index or ["name", "rank"][, "filter"])
174 local i = 1
175 -- list player's buffs
176 local buffID = select(11,UnitBuff("player", i)); -- spell id
177 while buffID do
178 buffsIDs[buffID] = true
179 i = i + 1;
180 buffID = select(11,UnitBuff("player", i));
181 end
182 --[[
183 for i=1,40 do
184 buffID = select(11,UnitBuff("player", i));
185 if buffID then
186 buffsIDs[buffID] = true
187 end
188 end
189 --]]
190 --@debug@
191 --if debug then
192 -- DEFAULT_CHAT_FRAME:AddMessage(""..i-1.."Buff(s) found")
193 --end
194 --@end-debug@
195
196 -- loop over watched buffs to check if it is present or not
197 -- we have to loop over T.LoseAura (and not buffsIDs) to be able to check for buff disappearance
198 for id,state in pairs(T.LoseAura) do
199 if buffsIDs[id] then
200 if not T.LoseAura[id] then
201 -- buff gained
202 --@debug@
203 if debug then
204 DEFAULT_CHAT_FRAME:AddMessage("Buff gained: "..id)
205 end
206 --@end-debug@
207 T.LoseAura[id] = true
208 end
209 else
210 if T.LoseAura[id] then
211 -- buff lost
212 --@debug@
213 if debug then
214 DEFAULT_CHAT_FRAME:AddMessage("Buff lost: "..id)
215 end
216 --@end-debug@
217 T.LoseAura[id] = false
218
219 -- draw weapon
220 start()
221 end
222 end
223 end
224
225 -- empty temporary table
226 wipe(buffsIDs)
166 end 227 end
167 end 228 end
168 229
169 230
170 --------------------------------------------------------------- 231 ---------------------------------------------------------------