View Single Post
11-14-12, 08:55 AM   #16
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
My local copy looks like this
Code:
local MOUNTERRORS = {
  [SPELL_FAILED_NOT_MOUNTED] = true,
  [ERR_NOT_WHILE_MOUNTED] = true,
  [ERR_ATTACK_MOUNTED] = true,
  [ERR_TAXIPLAYERALREADYMOUNTED] = true,
  [SPELL_FAILED_NOT_FLYING] = true,
  [ERR_PETBATTLE_NOT_WHILE_FLYING] = true,
}
local f=CreateFrame("frame")
f.OnEvent=function(self,event,...)
  if not MOUNTERRORS[...] then return end -- not an error message we care about, return immediately.
  if IsFlying() and not GetCVarBool("autoDismountFlying") then return end -- we are flying and don't have flight auto-dismount option checked, do nothing.
  Dismount()
end
f:RegisterEvent("UI_ERROR_MESSAGE")
f:SetScript("OnEvent",f.OnEvent)
(had submitted a patch along these lines long time ago but wasn't accepted so ... )

The issue with the sha voidzones is a bug with Blizzard and trying to apply Overcome by Anger on the player as if the player themselves are casting it.
This has a location trigger (like the auto-pickup quest functionality) but is applied as a texture debuff (same as "rested" can be applied to a map texture).

My suggestion would be to use the first version I posted and simply uncheck "Auto Dismount in Flight" from Interface Options -> Controls.

If you absolutely must keep that checked and want to suppress the dismount in this particular occasion,
this code will not win any beauty contests but will do the job.
Code:
local MOUNTERRORS,supress = {
  [SPELL_FAILED_NOT_MOUNTED] = true,
  [ERR_NOT_WHILE_MOUNTED] = true,
  [ERR_ATTACK_MOUNTED] = true,
  [ERR_TAXIPLAYERALREADYMOUNTED] = true,
  [SPELL_FAILED_NOT_FLYING] = true,
  [ERR_PETBATTLE_NOT_WHILE_FLYING] = true,
}
local f=CreateFrame("frame")
f.OnUpdate=function(self,elapsed)
  if supress then 
    supress=nil 
    f:SetScript("OnUpdate",nil) 
    return 
  end
  Dismount()
  f:SetScript("OnUpdate",nil)
end
f.OnEvent=function(self,event,...)
  if event=="UNIT_SPELLCAST_FAILED" then
    local _,_,_,_,id = ...
    if id == 129356 or id == 110668 then -- Overcome by Anger, or Fleet Winds
      supress = IsMounted() or IsFlying()
    end
  end
  if not MOUNTERRORS[...] then return end -- not an error message we care about, return immediately.
  if IsFlying() and not GetCVarBool("autoDismountFlying") then return end -- we are flying and don't have flight auto-dismount option checked, do nothing.
  if supress then supress = nil return end -- one time suppression for sha voidzones/smoke circles, and since we're not sure of the order of events do it both ways.
  f:SetScript("OnUpdate",f.OnUpdate) -- dismount on next frame
end
f:RegisterEvent("UI_ERROR_MESSAGE")
f:RegisterUnitEvent("UNIT_SPELLCAST_FAILED","player")
f:SetScript("OnEvent",f.OnEvent)

Last edited by Dridzt : 11-16-12 at 01:08 AM. Reason: added Smoke Circles
  Reply With Quote