diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index 45b2f57..d795abf 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -3112,6 +3112,40 @@ do end end +-- Mounted Frame +do + local mountedFrame + WeakAuras.frames["Mount Use Handler"] = mountedFrame; + local elapsed = 0; + local delay = 0.5; + local isMounted = IsMounted(); + + local function checkForMounted(self, elaps) + WeakAuras.StartProfileSystem("generictrigger"); + elapsed = elapsed + elaps + if(isMounted ~= IsMounted()) then + isMounted = IsMounted(); + WeakAuras.ScanEvents("MOUNTED_UPDATE"); + mountedFrame:SetScript("OnUpdate", nil); + end + if(elapsed > delay) then + mountedFrame:SetScript("OnUpdate", nil); + end + WeakAuras.StopProfileSystem("generictrigger"); + end + + function WeakAuras.WatchForMounts() + if not(mountedFrame) then + mountedFrame = CreateFrame("frame"); + mountedFrame:RegisterEvent("COMPANION_UPDATE"); + mountedFrame:SetScript("OnEvent", function() + elapsed = 0; + mountedFrame:SetScript("OnUpdate", checkForMounted); + end) + end + end +end + -- Player Moving do local playerMovingFrame = nil diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index d1ffabd..405103b 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -5074,6 +5074,7 @@ WeakAuras.event_prototypes = { if trigger.use_mounted ~= nil then tinsert(events, "COMPANION_UPDATE") tinsert(events, "PLAYER_ENTERING_WORLD") + tinsert(events, "MOUNTED_UPDATE") end local unit_events = {} local pet_unit_events = {} @@ -5123,6 +5124,9 @@ WeakAuras.event_prototypes = { force_events = "CONDITIONS_CHECK", name = L["Conditions"], init = function(trigger) + if(trigger.use_mounted ~= nil) then + WeakAuras.WatchForMounts(); + end return ""; end, args = {