Mercurial > wow > degaine
diff Degaine.lua @ 24:3b1123f50be4 v1.0beta3
Adding support for dismount
author | contrebasse |
---|---|
date | Fri, 10 Dec 2010 21:06:46 +0100 |
parents | 44e8394d6982 |
children | dd1ef3996d7f |
line wrap: on
line diff
--- a/Degaine.lua Fri Dec 10 20:37:09 2010 +0100 +++ b/Degaine.lua Fri Dec 10 21:06:46 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 + start() + wasMounted = false + 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 @@ -207,10 +250,8 @@ t_lastGossipClosed = GetTime() elseif event == "PLAYER_REGEN_ENABLED" then - --for k,_ in pairs(events1player) do DegaineFrame:UnregisterEvent(k) end desactivate() elseif event == "PLAYER_REGEN_DISABLED" then - --for k,_ in pairs(events1player) do DegaineFrame:RegisterEvent(k) end activate() elseif event == "ADDON_LOADED" and arg1==AddonName then @@ -227,7 +268,6 @@ -- Hook when standing up -- (Didn't work, see http://forums.wowace.com/showthread.php?p=310547#post310547) hooksecurefunc("SitStandOrDescendStart",start); -hooksecurefunc("Dismount",start); -- works with GupPet but not with the default interface... ---------------------------------------------------------------