Advertisement
Valiante

GoGoMount.lua

Aug 10th, 2023
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 62.52 KB | None | 0 0
  1. ---------
  2. function GoGo_OnLoad()
  3. ---------
  4.     SLASH_GOGOMOUNT1 = "/gogo"
  5.     SlashCmdList["GOGOMOUNT"] = function(msg) GoGo_OnSlash(msg) end
  6.     SLASH_GOGOID1 = "/id"
  7.     SlashCmdList["GOGOID"] = function(msg) GoGo_Msg(GoGo_Id(msg)) end
  8.  
  9.  
  10.     this:RegisterEvent("VARIABLES_LOADED")
  11.     this:RegisterEvent("UPDATE_BINDINGS")
  12.     this:RegisterEvent("TAXIMAP_OPENED")
  13.     this:RegisterEvent("CHAT_MSG_ADDON")
  14.     this:RegisterEvent("COMPANION_LEARNED")
  15.     this:RegisterEvent("PLAYER_ENTERING_WORLD")
  16. --  this:RegisterEvent("BAG_UPDATE")
  17. end --function
  18.  
  19. ---------
  20. function GoGo_OnEvent(event)
  21. ---------
  22.     if event == "VARIABLES_LOADED" then
  23.         GoGo_DebugLog = {}
  24.         if not GoGo_Prefs then
  25.             GoGo_Prefs = {}
  26.             GoGo_Settings_Default()
  27.         end --if
  28.  
  29. --      GoGo_Localize()
  30.  
  31. --      GoGo_LoadMountDB()
  32.         GoGo_Variables.TestVersion = false
  33. --      GoGo_Variables.Debug = false
  34.         _, GoGo_Variables.Player.Class = UnitClass("player")
  35.         if (GoGo_Variables.Player.Class == "DRUID") then
  36.             GoGo_Variables.Druid = {}
  37.             this:RegisterEvent("PLAYER_REGEN_DISABLED")
  38.         elseif (GoGo_Variables.Player.Class == "SHAMAN") then
  39.             GoGo_Variables.Shaman = {}
  40.             this:RegisterEvent("PLAYER_REGEN_DISABLED")
  41.         end --if
  42.         GOGO_KALIMDOR = table.concat({GetMapZones(1)}, ":")
  43.         GOGO_EASTERN_KINGDOMS = table.concat({GetMapZones(2)}, ":")
  44.         GOGO_AZEROTH = GOGO_KALIMDOR..":"..GOGO_EASTERN_KINGDOMS
  45.         GOGO_CAPITAL_CITIES = table.concat({"Stormwind City", "Ironforge", "Undercity", "Silvermoon City", "Darnassus", "Exodar", "Orgrimmar", "Thunder Bluff"}, ":")
  46.         GOGO_OUTLANDS = table.concat({GetMapZones(3)}, ":")..":"..GoGo_Variables.Localize.Zone.TwistingNether
  47.         GOGO_NORTHREND = table.concat({GetMapZones(4)}, ":")..":"..GoGo_Variables.Localize.Zone.TheFrozenSea
  48.         GoGoFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  49.         if not GoGo_Prefs.version then
  50.             GoGo_Settings_Default()
  51.         elseif GoGo_Prefs.version ~= GetAddOnMetadata("GoGoMount", "Version") then
  52.             GoGo_Settings_SetUpdates()
  53.         end --if
  54.         GoGo_Panel_Options()
  55.         GoGo_Panel_UpdateViews()
  56. --      GoGo_Panel_GlobalFavorites_Populate()
  57.        
  58.     elseif event == "PLAYER_REGEN_DISABLED" then
  59.         for i, button in ipairs({GoGoButton, GoGoButton2, GoGoButton3}) do
  60.             if GoGo_Variables.Player.Class == "SHAMAN" then
  61.                 GoGo_FillButton(button, GoGo_InBook(GOGO_SPELLS["SHAMAN"]))
  62.             elseif GoGo_Variables.Player.Class == "DRUID" then
  63.                 GoGo_FillButton(button, GoGo_InBook(GOGO_SPELLS["DRUID"]))
  64.             end --if
  65.         end --for
  66.     elseif event == "ZONE_CHANGED_NEW_AREA" then
  67.         SetMapToCurrentZone()
  68.         GoGo_Variables.Player.Zone = GetRealZoneText()
  69.     elseif event == "TAXIMAP_OPENED" then
  70.         GoGo_Dismount()
  71.     elseif event == "UPDATE_BINDINGS" then
  72.         if not InCombatLockdown() then  -- ticket 213
  73.             GoGo_CheckBindings()
  74.         end --if
  75.     elseif event == "UI_ERROR_MESSAGE" then
  76.         if GOGO_ERRORS[arg1] and not IsFlying() then
  77.             GoGo_Dismount()
  78.         end --if
  79.     elseif (event == "PLAYER_ENTERING_WORLD") then
  80.         if GoGo_Prefs.DebugMessages then
  81.             GoGo_DebugAddLine("EVENT: Player Entering World")
  82.         end --if
  83.         GoGo_BuildMountSpellList()
  84.         GoGo_BuildMountItemList()
  85.         GoGo_BuildMountList()
  86.         GoGo_CheckFor310()
  87.     elseif (event == "COMPANION_LEARNED") then
  88.         if GoGo_Prefs.DebugMessages then
  89.             GoGo_DebugAddLine("EVENT: Companion Learned")
  90.         end --if
  91.         GoGo_BuildMountSpellList()
  92.         GoGo_BuildMountList()
  93.         GoGo_CheckFor310()
  94. --  elseif (event == "BAG_UPDATE") then   -- currently causing a noticable lag when moving bag items around
  95. --      if GoGo_Prefs.DebugMessages then
  96. --          GoGo_DebugAddLine("EVENT: Bag Update")
  97. --      end --if
  98. --      GoGo_BuildMountItemList()
  99. --      GoGo_BuildMountList()
  100.     elseif (event == "CHAT_MSG_ADDON") and (arg1 == "GoGoMountVER") and not GoGo_Prefs.DisableUpdateNotice then
  101.         if (arg2 > GetAddOnMetadata("GoGoMount", "Version")) and not GoGo_Variables.UpdateShown then
  102.             GoGo_Variables.UpdateShown = true
  103.             GoGo_Msg(GOGO_STRING_NEWVERSIONFOUND .. arg4)
  104.         end --if
  105.     end --if
  106. end --function
  107.  
  108. ---------
  109. function GoGo_OnSlash(msg)
  110. ---------
  111.     if GOGO_COMMANDS[string.lower(msg)] then
  112.         GOGO_COMMANDS[string.lower(msg)]()
  113.     elseif string.find(msg, "spell:%d+") or string.find(msg, "item:%d+") then
  114.         local FItemID = string.gsub(msg,".-\124H([^\124]*)\124h.*", "%1");
  115.         local idtype, itemid = strsplit(":",FItemID);
  116.         GoGo_AddPrefMount(tonumber(itemid))
  117.         GoGo_Msg("pref")
  118.     else
  119.         GoGo_Msg("optiongui")
  120.         GoGo_Msg("auto")
  121.         GoGo_Msg("genericfastflyer")
  122.         GoGo_Msg("updatenotice")
  123.         GoGo_Msg("mountnotice")
  124.         if GoGo_Variables.Player.Class == "DRUID" then GoGo_Msg("druidclickform") end --if
  125.         if GoGo_Variables.Player.Class == "DRUID" then GoGo_Msg("druidflightform") end --if
  126.         GoGo_Msg("pref")
  127.     end --if
  128. end --function
  129.  
  130. ---------
  131. function GoGo_PreClick(button)
  132. ---------
  133.     if GoGo_Prefs.DebugMessages then
  134.         GoGo_DebugAddLine("GoGo_PreClick: Starts")
  135.         GoGo_DebugAddLine("GoGo_PreClick: Location = " .. GetRealZoneText() .. " - " .. GetZoneText() .. " - " ..GetSubZoneText() .. " - " .. GetMinimapZoneText())
  136.         GoGo_DebugAddLine("GoGo_PreClick: Current unit speed is " .. GetUnitSpeed("player"))
  137.         local level = UnitLevel("player")
  138.         GoGo_DebugAddLine("GoGo_PreClick: We are level " .. level)
  139.         GoGo_DebugAddLine("GoGo_PreClick: We are a " .. GoGo_Variables.Player.Class)
  140.         if GoGo_CanFly() then
  141.             GoGo_DebugAddLine("GoGo_PreClick: We can fly here as per GoGo_CanFly()")
  142.         else
  143.             GoGo_DebugAddLine("GoGo_PreClick: We can not fly here as per GoGo_CanFly()")
  144.         end --if
  145.         if IsOutdoors() then
  146.             GoGo_DebugAddLine("GoGo_PreClick: We are outdoors as per IsOutdoors()")
  147.         else
  148.             GoGo_DebugAddLine("GoGo_PreClick: We are not outdoors as per IsOutdoors()")
  149.         end --if
  150.         if IsIndoors() then
  151.             GoGo_DebugAddLine("GoGo_PreClick: We are indoors as per IsIndoors()")
  152.         else
  153.             GoGo_DebugAddLine("GoGo_PreClick: We are not indoors as per IsIndoors()")
  154.         end --if
  155.         if IsFlyableArea() then
  156.             GoGo_DebugAddLine("GoGo_PreClick: We can fly here as per IsFlyableArea()")
  157.         else
  158.             GoGo_DebugAddLine("GoGo_PreClick: We can not fly here as per IsFlyableArea()")
  159.         end --if
  160.         if IsFlying() then
  161.             GoGo_DebugAddLine("GoGo_PreClick: We are flying as per IsFlying()")
  162.         else
  163.             GoGo_DebugAddLine("GoGo_PreClick: We are not flying as per IsFlying()")
  164.         end --if
  165.         if IsSwimming() then
  166.             GoGo_DebugAddLine("GoGo_PreClick: We are swimming as per IsSwimming()")
  167.         else
  168.             GoGo_DebugAddLine("GoGo_PreClick: We are not swimming as per IsSwimming()")
  169.         end --if
  170.         if IsFalling() then
  171.             GoGo_DebugAddLine("GoGo_PreClick: We are falling as per IsFalling()")
  172.         else
  173.             GoGo_DebugAddLine("GoGo_PreClick: We are not falling as per IsFalling()")
  174.         end --if
  175.         if GoGo_IsMoving() then
  176.             GoGo_DebugAddLine("GoGo_PreClick: We are moving as per GoGo_IsMoving()")
  177.         else
  178.             GoGo_DebugAddLine("GoGo_PreClick: We are not moving as per GoGo_IsMoving()")
  179.         end --if
  180.         local posX, posY = GetPlayerMapPosition("Player")
  181.         GoGo_DebugAddLine("GoGo_PreClick: Player location: X = ".. posX .. ", Y = " .. posY)
  182.     end --if
  183.  
  184.     if not InCombatLockdown() then
  185.         GoGo_FillButton(button)
  186.     end --if
  187.  
  188.     if IsMounted() or CanExitVehicle() then
  189.         if GoGo_Prefs.DebugMessages then
  190.             GoGo_DebugAddLine("GoGo_PreClick: Player is mounted and is being dismounted.")
  191.         end --if
  192.         GoGo_Dismount()
  193.     elseif GoGo_Variables.Player.Class == "DRUID" and GoGo_IsShifted() and not InCombatLockdown() then
  194.         if GoGo_Prefs.DebugMessages then
  195.             GoGo_DebugAddLine("GoGo_PreClick: Player is a druid, is shifted and not in combat.")
  196.         end --if
  197.         GoGo_Dismount(button)
  198.     elseif GoGo_Variables.Player.Class == "SHAMAN" and UnitBuff("player", GoGo_Variables.Localize.GhostWolf) then
  199.         if GoGo_Prefs.DebugMessages then
  200.             GoGo_DebugAddLine("GoGo_PreClick: Player is a shaman and is in wolf form.")
  201.         end --if
  202.         GoGo_Dismount()
  203.     elseif not InCombatLockdown() then
  204.         if GoGo_Prefs.DebugMessages then
  205.             GoGo_DebugAddLine("GoGo_PreClick: Player not in combat, button pressed, looking for a mount.")
  206.         end --if
  207.         GoGo_FillButton(button, GoGo_GetMount())
  208.     end --if
  209.    
  210.     if not GoGo_Variables.TestVersion then
  211.         if ( IsInGuild() ) then
  212.             SendAddonMessage("GoGoMountVER", GetAddOnMetadata("GoGoMount", "Version"), "GUILD")
  213.         end --if
  214. --          SendAddonMessage("GoGoMountVER", GetAddOnMetadata("GoGoMount", "Version"), "BATTLEGROUND")
  215. --          SendAddonMessage("GoGoMountVER", GetAddOnMetadata("GoGoMount", "Version"), "RAID")
  216.     end --if
  217.     -- GoGo_Variables.Debug = false
  218. end --function
  219.  
  220. ---------
  221. function GoGo_GetMount()
  222. ---------
  223.  
  224.     local selectedmount = GoGo_ChooseMount()
  225.  
  226. --  if (GoGo_Variables.Player.Class == "PALADIN") and GoGo_Prefs.PaliUseCrusader and GoGo_InBook(GoGo_Variables.Localize.CrusaderAura) then
  227. --      local modifier = GetSpellInfo(GoGo_Variables.Localize.CrusaderAura)
  228. --      selectedmount = selectedmount .. "\n /stopcasting;\n /cast " .. modifier
  229. --  end --if
  230.    
  231.     return selectedmount
  232.    
  233. end --function
  234.  
  235. ---------
  236. function GoGo_ChooseMount()
  237. ---------
  238.     if (GoGo_Variables.Player.Class == "DRUID") then
  239.         GoGo_Variables.Druid.FeralSwiftness, _ = GoGo_GetTalentInfo(GOGO_TALENT_FERALSWIFTNESS)
  240.         if IsIndoors() then
  241.             if IsSwimming() then
  242.                 return GoGo_InBook(GoGo_Variables.Localize.AquaForm)
  243.             elseif GoGo_Variables.Druid.FeralSwiftness > 0 then
  244.                 return GoGo_InBook(GoGo_Variables.Localize.CatForm)
  245.             end --if
  246.             return
  247.         end --if
  248.         if (IsSwimming() or IsFalling() or GoGo_IsMoving()) then
  249.             if GoGo_Prefs.DebugMessages then
  250.                 GoGo_DebugAddLine("GoGo_ChooseMount: We are a druid and we're falling, swimming or moving.  Changing shape form.")
  251.             end --if
  252.             return GoGo_InBook(GOGO_SPELLS["DRUID"])
  253.         end --if
  254.     elseif (GoGo_Variables.Player.Class == "SHAMAN") and GoGo_IsMoving() then
  255.         if GoGo_Prefs.DebugMessages then
  256.             GoGo_DebugAddLine("GoGo_ChooseMount: We are a shaman and we're moving.  Changing shape form.")
  257.         end --if
  258.         GoGo_Variables.Shaman.ImprovedGhostWolf, _ = GoGo_GetTalentInfo(GOGO_TALENT_IMPROVEDGHOSTWOLF)
  259.         if (GoGo_Variables.Shaman.ImprovedGhostWolf == 2) then return GoGo_InBook(GOGO_SPELLS["SHAMAN"]) end --if
  260.     elseif (GoGo_Variables.Player.Class == "HUNTER") and GoGo_IsMoving() then
  261.         if GoGo_Prefs.DebugMessages then
  262.             GoGo_DebugAddLine("GoGo_ChooseMount: We are a hunter and we're moving.  Checking for aspects.")
  263.         end --if
  264. --      if GoGo_InBook(GoGo_Variables.Localize.AspectPack) then
  265. --          return GoGo_InBook(GoGo_Variables.Localize.AspectPack)
  266.         if GoGo_InBook(GoGo_Variables.Localize.AspectCheetah) then
  267.             return GoGo_InBook(GoGo_Variables.Localize.AspectCheetah)
  268.         end --if
  269.     end --if
  270.  
  271.     if GoGo_Prefs.DebugMessages then
  272.         GoGo_DebugAddLine("GoGo_ChooseMount: Passed Druid / Shaman forms - nothing selected.")
  273.     end --if
  274.  
  275.     local mounts = {}
  276.     local GoGo_FilteredMounts = {}
  277.     GoGo_Variables.Player.Zone = GetRealZoneText()
  278.     GoGo_Variables.EngineeringLevel = GoGo_GetSkillLevel(GOGO_SKILL_ENGINEERING) or 0
  279.     GoGo_Variables.TailoringLevel = GoGo_GetSkillLevel(GOGO_SKILL_TAILORING) or 0
  280.     GoGo_Variables.RidingLevel = GoGo_GetSkillLevel(GOGO_SKILL_RIDING) or 0
  281.    
  282.     if GoGo_Prefs.DebugMessages then
  283.         GoGo_DebugAddLine("GoGo_ChooseMount: " .. GOGO_SKILL_ENGINEERING .. " = "..GoGo_Variables.EngineeringLevel)
  284.         GoGo_DebugAddLine("GoGo_ChooseMount: " .. GOGO_SKILL_TAILORING .. " = "..GoGo_Variables.TailoringLevel)
  285.         GoGo_DebugAddLine("GoGo_ChooseMount: " .. GOGO_SKILL_RIDING .. " = "..GoGo_Variables.RidingLevel)
  286.     end --if
  287.  
  288.     if (table.getn(mounts) == 0) then
  289.         if GoGo_Prefs[GoGo_Variables.Player.Zone] then
  290.             GoGo_FilteredMounts = GoGo_Prefs[GoGo_Variables.Player.Zone]
  291.             GoGo_DisableUnknownMountNotice = true
  292.         end --if
  293.     end --if
  294.     if GoGo_Prefs.DebugMessages then
  295.         GoGo_DebugAddLine("GoGo_ChooseMount: Checked for zone favorites.")
  296.     end --if
  297.  
  298.     if (table.getn(mounts) == 0) and not GoGo_FilteredMounts or (table.getn(GoGo_FilteredMounts) == 0) then
  299.         if GoGo_Prefs.GlobalPrefMounts then
  300.             GoGo_FilteredMounts = GoGo_Prefs.GlobalPrefMounts
  301.             GoGo_DisableUnknownMountNotice = true
  302.         end --if
  303.         if GoGo_Prefs.DebugMessages then
  304.             GoGo_DebugAddLine("GoGo_ChooseMount: Checked for global favorites.")
  305.         end --if
  306.     end --if
  307.  
  308.     if (table.getn(mounts) == 0) and not GoGo_FilteredMounts or (table.getn(GoGo_FilteredMounts) == 0) then
  309.         if GoGo_Prefs.DebugMessages then
  310.             GoGo_DebugAddLine("GoGo_ChooseMount: Checking for spell and item mounts.")
  311.         end --if
  312.         -- Not updating bag items on bag changes right now so scan and update list
  313.         GoGo_BuildMountItemList()
  314.         GoGo_BuildMountList()
  315.         GoGo_FilteredMounts = GoGo_Variables.MountList
  316.         if not GoGo_FilteredMounts or (table.getn(GoGo_FilteredMounts) == 0) then
  317.             if GoGo_Variables.Player.Class == "SHAMAN" then
  318.                 if GoGo_Prefs.DebugMessages then
  319.                     GoGo_DebugAddLine("GoGo_ChooseMount: No mounts found. Forcing shaman shape form.")
  320.                 end --if
  321.                 return GoGo_InBook(GOGO_SPELLS["SHAMAN"])
  322.             elseif GoGo_Variables.Player.Class == "DRUID" then
  323.                 if GoGo_Prefs.DebugMessages then
  324.                     GoGo_DebugAddLine("GoGo_ChooseMount: No mounts found. Forcing druid shape form.")
  325.                 end --if
  326.                 return GoGo_InBook(GOGO_SPELLS["DRUID"])
  327.             else
  328.                 if GoGo_Prefs.DebugMessages then
  329.                     GoGo_DebugAddLine("GoGo_ChooseMount: No mounts found.  Giving up the search.")
  330.                 end --if
  331.                 return nil
  332.             end --if
  333.         end --if
  334.     end --if
  335.    
  336.     local GoGo_TempMounts = {}
  337.     if GoGo_Variables.EngineeringLevel <= 299 then
  338.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 45)
  339.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 46)
  340.     elseif GoGo_Variables.EngineeringLevel >= 300 and GoGo_Variables.EngineeringLevel <= 374 then
  341.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 46)
  342.     elseif GoGo_Variables.EngineeringLevel >= 375 then
  343.         -- filter nothing
  344.     else
  345.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 45)
  346.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 46)
  347.     end --if
  348.     if GoGo_Variables.TailoringLevel <= 299 then
  349.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 49)
  350.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 48)
  351.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 47)
  352.     elseif GoGo_Variables.TailoringLevel >= 300 and GoGo_Variables.TailoringLevel <= 424 then
  353.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 49)
  354.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 47)
  355.     elseif GoGo_Variables.TailoringLevel >= 425 and GoGo_Variables.TailoringLevel <= 449 then
  356.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 47)
  357.     elseif GoGo_Variables.TailoringLevel >= 450 then
  358.         -- filter nothing
  359.     else
  360.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 49)
  361.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 48)
  362.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 47)
  363.     end --if
  364.  
  365.     if IsSwimming() then
  366.         if GoGo_Prefs.DebugMessages then
  367.             GoGo_DebugAddLine("GoGo_ChooseMount: Forcing ground mounts because we're swimming.")
  368.         end --if
  369.         GoGo_Variables.SkipFlyingMount = true
  370.     else
  371.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 53)
  372.     end --if
  373.    
  374.     if GoGo_Variables.Player.Zone ~= GoGo_Variables.Localize.Zone.AQ40 then
  375.         if GoGo_Prefs.DebugMessages then
  376.             GoGo_DebugAddLine("GoGo_ChooseMount: Removing AQ40 mounts since we are not in AQ40.")
  377.         end --if
  378.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 50)
  379.     end --if
  380.  
  381.     if GoGo_Variables.SelectPassengerMount then
  382.         if GoGo_Prefs.DebugMessages then
  383.             GoGo_DebugAddLine("GoGo_ChooseMount: Filtering out all mounts except passenger mounts since passenger mount only was requested.")
  384.         end --if
  385.         GoGo_FilteredMounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 2) or {}
  386.     end --if
  387.  
  388.     if (table.getn(mounts) == 0) and IsSwimming() then
  389.         if GoGo_Prefs.DebugMessages then
  390.             GoGo_DebugAddLine("GoGo_ChooseMount: Looking for water speed increase mounts since we're in water.")
  391.         end --if
  392.         mounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 5) or {}
  393.     end --if
  394.    
  395.     if (table.getn(mounts) == 0) and GoGo_CanFly() and not GoGo_Variables.SkipFlyingMount then
  396.         if GoGo_Prefs.DebugMessages then
  397.             GoGo_DebugAddLine("GoGo_ChooseMount: Looking for flying mounts since we past flight checks.")
  398.         end --if
  399.         if GoGo_Variables.RidingLevel <= 224 then
  400.             GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 36)
  401.             GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 35)
  402.         elseif GoGo_Variables.RidingLevel >= 225 and GoGo_Variables.RidingLevel <= 299 then
  403.             GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 35)
  404.         elseif GoGo_Variables.RidingLevel >= 300 then
  405.             -- filter nothing
  406.         else
  407.             GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 36)
  408.             GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 35)
  409.         end --if
  410.  
  411.         -- Druid stuff...
  412.         -- Use flight forms if preferred
  413.         if GoGo_Variables.Player.Class == "DRUID" and (GoGo_InBook(GoGo_Variables.Localize.FastFlightForm) or GoGo_InBook(GoGo_Variables.Localize.FlightForm)) and GoGo_Prefs.DruidFlightForm then
  414.             if GoGo_Prefs.DebugMessages then
  415.                 GoGo_DebugAddLine("GoGo_ChooseMount: Druid with preferred flight forms option enabled.  Using flight form.")
  416.             end --if
  417.             return GoGo_InBook(GOGO_SPELLS["DRUID"])
  418.         end --if
  419.    
  420.         if (table.getn(mounts) == 0) then
  421.             GoGo_TempMounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 9)
  422.             mounts = GoGo_FilterMountsIn(GoGo_TempMounts, 24)
  423.         end --if
  424.         if GoGo_Prefs.genericfastflyer then
  425.             local GoGo_TempMountsA = GoGo_FilterMountsIn(GoGo_TempMounts, 23)
  426.             if GoGo_Variables.RidingLevel <= 299 then
  427.                 GoGo_TempMountsA = GoGo_FilterMountsOut(GoGo_TempMountsA, 29)
  428.             end --if
  429.             if GoGo_TempMountsA then
  430.                 for counter = 1, table.getn(GoGo_TempMountsA) do
  431.                     table.insert(mounts, GoGo_TempMountsA[counter])
  432.                 end --for
  433.             end --if
  434.             local GoGo_TempMountsA = GoGo_FilterMountsIn(GoGo_TempMounts, 26)
  435.             if GoGo_TempMountsA then
  436.                 for counter = 1, table.getn(GoGo_TempMountsA) do
  437.                     table.insert(mounts, GoGo_TempMountsA[counter])
  438.                 end --for
  439.             end --if
  440.         end --if
  441.         if (table.getn(mounts) == 0) then
  442.             GoGo_TempMountsA = GoGo_FilterMountsIn(GoGo_TempMounts, 23)
  443.             if GoGo_Variables.RidingLevel <= 299 then
  444.                 mounts = GoGo_FilterMountsOut(GoGo_TempMountsA, 29)
  445.             else
  446.                 mounts = GoGo_TempMountsA
  447.             end --if
  448.         end --if
  449.  
  450.         -- no epic flyers found - add druid swift flight if available
  451.         if (table.getn(mounts) == 0 and (GoGo_Variables.Player.Class == "Druid") and (GoGo_InBook(GoGo_Variables.Localize.FastFlightForm))) then
  452.             table.insert(mounts, GoGo_Variables.Localize.FastFlightForm)
  453.         end --if
  454.  
  455.         if (table.getn(mounts) == 0) then
  456.             GoGo_TempMounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 9)
  457.             mounts = GoGo_FilterMountsIn(GoGo_TempMounts, 22)
  458.         end --if
  459.  
  460.         -- no slow flying mounts found - add druid flight if available
  461.         if (table.getn(mounts) == 0 and (GoGo_Variables.Player.Class == "Druid") and (GoGo_InBook(GoGo_Variables.Localize.FlightForm))) then
  462.             table.insert(mounts, GoGo_Variables.Localize.FlightForm)
  463.         end --if
  464.     end --if
  465.    
  466.     if (table.getn(GoGo_FilteredMounts) >= 1) then
  467.         --GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 1)
  468.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 36)
  469.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 35)
  470.     end --if
  471.  
  472.     if (table.getn(mounts) == 0) and (table.getn(GoGo_FilteredMounts) >= 1) then  -- no flying mounts selected yet - try to use loaned mounts
  473.         GoGo_TempMounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 52) or {}
  474.         if (table.getn(GoGo_TempMounts) >= 1) and (GoGo_Variables.Player.Zone == GoGo_Variables.Localize.Zone.SholazarBasin or GoGo_Variables.Player.Zone == GoGo_Variables.Localize.Zone.TheStormPeaks or GoGo_Variables.Player.Zone == GOGO_ZONE_ICECROWN) then
  475.             mounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 52)
  476.         end --if
  477.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 52)
  478.     end --if
  479.    
  480.     -- Set the oculus mounts as the only mounts available if we're in the oculus, not skiping flying and have them in inventory
  481.     if (table.getn(mounts) == 0) and (table.getn(GoGo_FilteredMounts) >= 1) and (GoGo_Variables.Player.Zone == GOGO_ZONE_THEOCULUS) and not GoGo_Variables.SkipFlyingMount then
  482.         GoGo_TempMounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 54) or {}
  483.         if (table.getn(GoGo_TempMounts) >= 1) then
  484.             mounts = GoGo_TempMounts
  485.             if GoGo_Prefs.DebugMessages then
  486.                 GoGo_DebugAddLine("GoGo_ChooseMount: In the Oculus, Oculus only mount found, using.")
  487.             end --if
  488.         else
  489.             if GoGo_Prefs.DebugMessages then
  490.                 GoGo_DebugAddLine("GoGo_ChooseMount: In the Oculus, no oculus mount found in inventory.")
  491.             end --if
  492.         end --if
  493.     else
  494.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 54)
  495.         if GoGo_Prefs.DebugMessages then
  496.             GoGo_DebugAddLine("GoGo_ChooseMount: Not in Oculus or forced ground mount only.")
  497.         end --if
  498.     end --if
  499.    
  500.     -- Select ground mounts
  501.     if (table.getn(mounts) == 0) and GoGo_CanRide() then
  502.         if GoGo_Prefs.DebugMessages then
  503.             GoGo_DebugAddLine("GoGo_ChooseMount: Looking for ground mounts since we can't fly.")
  504.         end --if
  505.         if GoGo_Variables.RidingLevel <= 74 then
  506.             GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 37)
  507.             GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 38)
  508.         elseif GoGo_Variables.RidingLevel >= 75 and GoGo_Variables.RidingLevel <= 149 then
  509.             GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 37)
  510.         end --if
  511.         GoGo_TempMounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 21)
  512.         if GoGo_Variables.RidingLevel <= 149 then
  513.             GoGo_TempMounts = GoGo_FilterMountsOut(GoGo_TempMounts, 29)
  514.         end --if
  515.         if GoGo_Variables.RidingLevel <= 225 and GoGo_CanFly() then
  516.             mounts = GoGo_FilterMountsOut(GoGo_TempMounts, 3)
  517.         else
  518.             mounts = GoGo_TempMounts
  519.         end --if
  520.         if (table.getn(mounts) == 0) then
  521.             mounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 20)
  522.         end --if
  523.         if (table.getn(mounts) == 0) then
  524.             mounts = GoGo_FilterMountsIn(GoGo_FilteredMounts, 25)
  525.         end --if
  526.     end --if
  527.    
  528.     if table.getn(GoGo_FilteredMounts) >= 1 then
  529.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 37)
  530.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 38)
  531.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 21)
  532.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 20)
  533.         GoGo_FilteredMounts = GoGo_FilterMountsOut(GoGo_FilteredMounts, 25)
  534.     end --if
  535.    
  536.     if (table.getn(mounts) == 0) then
  537.         if (GoGo_Variables.Player.Class == "SHAMAN") and (GoGo_InBook(GoGo_Variables.Localize.GhostWolf)) then
  538.             table.insert(mounts, GoGo_Variables.Localize.GhostWolf)
  539.         end --if
  540.     end --if
  541.  
  542.     if (table.getn(mounts) >= 1) then
  543.         if GoGo_Prefs.DebugMessages then
  544.             for a = 1, table.getn(mounts) do
  545.                 GoGo_DebugAddLine("GoGo_ChooseMount: Found mount " .. mounts[a] .. " - included in random pick.")
  546.             end --for
  547.         end --if
  548.         selected = mounts[math.random(table.getn(mounts))]
  549.         if type(selected) == "string" then
  550.             if GoGo_Prefs.DebugMessages then
  551.                 GoGo_DebugAddLine("GoGo_ChooseMount: Selected string " .. selected)
  552.             end --if
  553.             return selected
  554.         else
  555.             selected = GoGo_GetIDName(selected)
  556.             return selected
  557.         end --if
  558.     end --if
  559. end --function
  560.  
  561. ---------
  562. function GoGo_FilterMountsOut(PlayerMounts, FilterID)
  563. ---------
  564.     local GoGo_FilteringMounts = {}
  565.     if table.getn(PlayerMounts) == 0 then
  566.         return GoGo_FilteringMounts
  567.     end --if
  568.     for a = 1, table.getn(PlayerMounts) do
  569.         local MountID = PlayerMounts[a]
  570.         for DBMountID, DBMountData in pairs(GoGo_Variables.MountDB) do
  571.             if (DBMountID == MountID) and not DBMountData[FilterID] then
  572.                 table.insert(GoGo_FilteringMounts, MountID)
  573.             elseif not GoGo_Variables.MountDB[MountID] then
  574.                 GoGo_Prefs.UnknownMounts[MountID] = true
  575.                 if not GoGo_Prefs.DisableMountNotice and not GoGo_DisableUnknownMountNotice then
  576.                     GoGo_DisableUnknownMountNotice = true
  577.                     GoGo_Msg("UnknownMount")
  578.                 end --if
  579.             end --if
  580.         end --for
  581.     end --for
  582.     return GoGo_FilteringMounts
  583. end --function
  584.  
  585. ---------
  586. function GoGo_FilterMountsIn(PlayerMounts, FilterID)
  587. ---------
  588.     local GoGo_FilteringMounts = {}
  589.     if table.getn(PlayerMounts) == 0 then
  590.         return GoGo_FilteringMounts
  591.     end --if
  592.     for a = 1, table.getn(PlayerMounts) do
  593.         local MountID = PlayerMounts[a]
  594.         for DBMountID, DBMountData in pairs(GoGo_Variables.MountDB) do
  595.             if (DBMountID == MountID) and DBMountData[FilterID] then
  596.                 table.insert(GoGo_FilteringMounts, MountID)
  597.             elseif not GoGo_Variables.MountDB[MountID] then
  598.                 GoGo_Prefs.UnknownMounts[MountID] = true
  599.                 if not GoGo_Prefs.DisableMountNotice and not GoGo_DisableUnknownMountNotice then
  600.                     GoGo_DisableUnknownMountNotice = true
  601.                     GoGo_Msg("UnknownMount")
  602.                 end --if
  603.             end --if
  604.         end --for
  605.     end --for
  606.     return GoGo_FilteringMounts
  607. end --function
  608.  
  609. ---------
  610. function GoGo_Dismount(button)
  611. ---------
  612.     if IsMounted() then
  613.         Dismount()
  614.     elseif CanExitVehicle() then   
  615.         VehicleExit()
  616.     elseif GoGo_Variables.Player.Class == "DRUID" then
  617.         if GoGo_IsShifted() and button then
  618.             if GoGo_Prefs.DruidClickForm and not IsFlying() then
  619.                 GoGo_FillButton(button, GoGo_GetMount())
  620.             else
  621. --              CancelUnitBuff("player", GoGo_IsShifted())  -- protected by blizzard now
  622.                 GoGo_FillButton(button, GoGo_IsShifted())
  623.             end --if
  624.         end --if
  625.     elseif GoGo_Variables.Player.Class == "SHAMAN" and UnitBuff("player", GoGo_InBook(GoGo_Variables.Localize.GhostWolf)) then
  626.         CancelUnitBuff("player", GoGo_InBook(GoGo_Variables.Localize.GhostWolf))
  627.     else
  628.         return nil
  629.     end --if
  630.     return true
  631. end --function
  632.  
  633. ---------
  634. function GoGo_InCompanions(item)
  635. ---------
  636.     for slot = 1, GetNumCompanions("MOUNT") do
  637.         local _, _, spellID = GetCompanionInfo("MOUNT", slot)
  638.         if spellID and string.find(item, spellID) then
  639.             if GoGo_Prefs.DebugMessages then
  640.                 GoGo_DebugAddLine("GoGo_InCompanions: Found mount name  " .. GetSpellInfo(spellID) .. " in mount list.")
  641.             end --if
  642.             return GetSpellInfo(spellID)
  643.         end --if
  644.     end --for
  645. end --function
  646.  
  647. ---------
  648. function GoGo_BuildMountList()
  649. ---------
  650.     GoGo_Variables.MountList = {}
  651.     if (table.getn(GoGo_Variables.MountSpellList) > 0) then
  652.         for a=1, table.getn(GoGo_Variables.MountSpellList) do
  653.             table.insert(GoGo_Variables.MountList, GoGo_Variables.MountSpellList[a])
  654.         end --for
  655.     end --if
  656.    
  657.     if (table.getn(GoGo_Variables.MountItemList) > 0) then
  658.         for a=1, table.getn(GoGo_Variables.MountItemList) do
  659.             table.insert(GoGo_Variables.MountList, GoGo_Variables.MountItemList[a])
  660.         end --for
  661.     end --if
  662.  
  663.     return GoGo_Variables.MountList
  664. end  --function
  665.  
  666. ---------
  667. function GoGo_BuildMountSpellList()
  668. ---------
  669.     GoGo_Variables.MountSpellList = {}
  670.     if (GetNumCompanions("MOUNT") >= 1) then
  671.         for slot = 1, GetNumCompanions("MOUNT"),1 do
  672.             local _, _, SpellID = GetCompanionInfo("MOUNT", slot)
  673.             if GoGo_Prefs.DebugMessages then
  674.                 GoGo_DebugAddLine("GoGo_BuildMountSpellList: Found mount spell ID " .. SpellID .. " at slot " .. slot .. " and added to known mount list.")
  675.             end --if
  676.             table.insert(GoGo_Variables.MountSpellList, SpellID)
  677.         end --for
  678.     end --if
  679.     return GoGo_Variables.MountSpellList
  680. end  -- function
  681.  
  682. ---------
  683. function GoGo_BuildMountItemList()
  684. ---------
  685.     GoGo_Variables.MountItemList = {}
  686.    
  687.     for a = 1, table.getn(GoGo_MountsItems) do
  688.         local MountID = GoGo_MountsItems[a]
  689.         if GoGo_InBags(MountID) then
  690.             if GoGo_Prefs.DebugMessages then
  691.                 GoGo_DebugAddLine("GoGo_BuildMountItemList: Found mount item ID " .. MountID .. " in a bag and added to known mount list.")
  692.             end --if
  693.             table.insert(GoGo_Variables.MountItemList, MountID)
  694.         end --if
  695.     end --for
  696.     return GoGo_Variables.MountItemList
  697. end --function
  698.  
  699. ---------
  700. function GoGo_InBags(item)
  701. ---------
  702.     if GoGo_Prefs.DebugMessages then
  703.         GoGo_DebugAddLine("GoGo_InBags: Searching for " .. item)
  704.     end --if
  705.  
  706.     for bag = 0, NUM_BAG_FRAMES do
  707.         for slot = 1, GetContainerNumSlots(bag) do
  708.             local link = GetContainerItemLink(bag, slot)
  709.             if link then
  710.                 local _, itemid, _ = strsplit(":",link,3)
  711.                 if tonumber(itemid) == item then
  712.                     if GoGo_Prefs.DebugMessages then
  713.                         GoGo_DebugAddLine("GoGo_InBags: Found item ID " .. item .. " in bag " .. (bag+1) .. ", at slot " .. slot .. " and added to known mount list.")
  714.                     end --if
  715.                     return GetItemInfo(link)
  716.                 end --if
  717.             end --if
  718.         end --for
  719.     end --for
  720. end --function
  721.  
  722. ---------
  723. function GoGo_InBook(spell)
  724. ---------
  725.     if GoGo_Prefs.DebugMessages then
  726.         GoGo_DebugAddLine("GoGo_InBook: Searching for type " .. type(spell))
  727.     end --if
  728.     if type(spell) == "function" then
  729.         return spell()
  730.     else
  731.         if type(spell) == "string" then
  732.             if GoGo_Prefs.DebugMessages then
  733.                 GoGo_DebugAddLine("GoGo_InBook: Searching for " .. spell)
  734.             end --if
  735.             local slot = 1
  736.             while GetSpellName(slot, "spell") do
  737.                 local name = GetSpellName(slot, "spell")
  738.                 if name == spell then
  739.                     return spell
  740.                 end --if
  741.                 slot = slot + 1
  742.             end --while
  743.         elseif type(spell) == "number" then
  744.             local spellname = GetSpellInfo(spell)
  745.             if GoGo_Prefs.DebugMessages then
  746.                 GoGo_DebugAddLine("GoGo_InBook: Searching for spell ID " .. spell)
  747.             end --if
  748.             local slot = 1
  749.             while GetSpellName(slot, "spell") do
  750.                 local name = GetSpellName(slot, "spell")
  751.                 if name == spellname then
  752.                     if GoGo_Prefs.DebugMessages then
  753.                         GoGo_DebugAddLine("GoGo_InBook: Found spell ID " .. spell .. " in book slot " .. slot)
  754.                     end --if
  755.                     return name
  756.                 end --if
  757.                 slot = slot + 1
  758.             end --while
  759.             if GoGo_Prefs.DebugMessages then
  760.                 GoGo_DebugAddLine("GoGo_InBook: Spell ID " .. spell .. " not found")
  761.             end --if
  762.         end --if
  763.     end --if
  764. end --function
  765.  
  766. ---------
  767. function GoGo_IsShifted()
  768. ---------
  769.     if GoGo_Prefs.DebugMessages then
  770.         GoGo_DebugAddLine("GoGo_IsShifted:  GoGo_IsShifted starting")
  771.     end --if
  772.     for i = 1, GetNumShapeshiftForms() do
  773.         local _, name, active = GetShapeshiftFormInfo(i)
  774.         if active then
  775.             if GoGo_Prefs.DebugMessages then
  776.                 GoGo_DebugAddLine("GoGo_IsShifted: Found " .. name)
  777.             end --if
  778.             return name
  779.         end
  780.     end --for
  781. end --function
  782.  
  783. ---------
  784. function GoGo_InAzeroth()
  785. ---------
  786.     if string.find(GOGO_AZEROTH, GoGo_Variables.Player.Zone, 1, true) then
  787.         return true
  788.     end --if
  789. end --function
  790.  
  791. function GoGo_InCapitalCity()
  792. ---------
  793.     if string.find(GOGO_CAPITAL_CITIES, GoGo_Variables.Player.Zone, 1, true) then
  794.         return true
  795.     end --if
  796. end --function
  797.  
  798. function GoGo_InOutlands()
  799. ---------
  800.     if string.find(GOGO_OUTLANDS, GoGo_Variables.Player.Zone, 1, true) then
  801.         return true
  802.     end --if
  803. end --function
  804.  
  805. function GoGo_InNorthrend()
  806. ---------
  807.     if string.find(GOGO_NORTHREND, GoGo_Variables.Player.Zone, 1, true) then
  808.         return true
  809.     end --if
  810. end --function
  811.  
  812. ---------
  813. function GoGo_AddPrefMount(spell)
  814. ---------
  815.     if GoGo_Prefs.DebugMessages then
  816.         GoGo_DebugAddLine("GoGo_AddPrefMount: Preference " .. spell)
  817.     end --if
  818.  
  819.     if not GoGo_Prefs.GlobalPrefMount then
  820.         GoGo_Variables.Player.Zone = GetRealZoneText()
  821.         if not GoGo_Prefs[GoGo_Variables.Player.Zone] then GoGo_Prefs[GoGo_Variables.Player.Zone] = {} end
  822.         table.insert(GoGo_Prefs[GoGo_Variables.Player.Zone], spell)
  823.         if table.getn(GoGo_Prefs[GoGo_Variables.Player.Zone]) > 1 then
  824.             local i = 2
  825.             repeat
  826.                 if GoGo_Prefs[GoGo_Variables.Player.Zone][i] == GoGo_Prefs[GoGo_Variables.Player.Zone][i - 1] then
  827.                     table.remove(GoGo_Prefs[GoGo_Variables.Player.Zone], i)
  828.                 else
  829.                     i = i + 1
  830.                 end --if
  831.             until i > table.getn(GoGo_Prefs[GoGo_Variables.Player.Zone])
  832.         end --if
  833.     else
  834.         if not GoGo_Prefs.GlobalPrefMounts then GoGo_Prefs.GlobalPrefMounts = {} end
  835.         table.insert(GoGo_Prefs.GlobalPrefMounts, spell)
  836.         if table.getn(GoGo_Prefs.GlobalPrefMounts) > 1 then
  837.             local i = 2
  838.             repeat
  839.                 if GoGo_Prefs.GlobalPrefMounts[i] == GoGo_Prefs.GlobalPrefMounts[i - 1] then
  840.                     table.remove(GoGo_Prefs.GlobalPrefMounts, i)
  841.                 else
  842.                     i = i + 1
  843.                 end --if
  844.             until i > table.getn(GoGo_Prefs.GlobalPrefMounts)
  845.         end --if
  846.     end --if
  847. end --function
  848.  
  849. ---------
  850. function GoGo_GetIDName(itemid)
  851. ---------
  852.     local tempname = ""
  853.     local ItemName = ""
  854.     if type(itemid) == "number" then
  855.         local GoGo_TempMount = {}
  856.         table.insert(GoGo_TempMount, itemid)
  857.         if (table.getn(GoGo_FilterMountsIn(GoGo_TempMount, 4)) == 1) then
  858.             return GetItemInfo(itemid) or "Unknown Mount"
  859.         else
  860.             return GetSpellInfo(itemid) or "Unknown Mount"
  861.         end --if
  862.     elseif type(itemid) == "table" then
  863.         for a=1, table.getn(itemid) do
  864.             tempname = itemid[a]
  865.             local GoGo_TempTable = {}
  866.             table.insert(GoGo_TempTable, tempname)
  867.             if (table.getn(GoGo_FilterMountsIn(GoGo_TempTable, 4)) == 1) then
  868. --              tempname = GetItemInfo(tempname)
  869.                 if GoGo_Prefs.DebugMessages then
  870.                     GoGo_DebugAddLine("GoGo_GetIDName: GetItemID for " .. tempname .. GetItemInfo(tempname))
  871.                 end --if
  872.                 ItemName = ItemName .. (GetItemInfo(tempname) or "Unknown Mount") .. ", "
  873.             else
  874. --              tempname = GetSpellInfo(tempname)
  875.                 if GoGo_Prefs.DebugMessages then
  876.                     GoGo_DebugAddLine("GoGo_GetIDName: GetSpellID for " .. tempname .. GetSpellInfo(tempname))
  877.                 end --if
  878.                 ItemName = ItemName .. (GetSpellInfo(tempname) or "Unknown Mount") .. ", "
  879.             end --if
  880.                 if GoGo_Prefs.DebugMessages then
  881.                     GoGo_DebugAddLine("GoGo_GetIDName: Itemname string is " .. ItemName)
  882.                 end --if
  883.         end --for
  884.         return ItemName
  885.     end --if
  886. end --function
  887.  
  888. ---------
  889. function GoGo_GetTalentInfo(talentname)
  890. ---------
  891.     if GoGo_Prefs.DebugMessages then
  892.         GoGo_DebugAddLine("GoGo_GetTalentInfo: Searching talent tree for " .. talentname)
  893.     end --if
  894.     local numTabs = GetNumTalentTabs()
  895.     for tab=1, numTabs do
  896.         local numTalents = GetNumTalents(tab)
  897.         for talent=1, numTalents do
  898.             local name, _, _, _, rank, maxrank = GetTalentInfo(tab,talent)
  899.             if (talentname == name) then
  900.                 if GoGo_Prefs.DebugMessages then
  901.                     GoGo_DebugAddLine("GoGo_GetTalentInfo: Found " .. talentname .. " with rank " .. rank)
  902.                 end --if
  903.                 return rank, maxrank
  904.             end --if
  905.         end --for
  906.     end --for
  907.     return 0,0
  908. end --function
  909.  
  910. ---------
  911. function GoGo_FillButton(button, mount)
  912. ---------
  913.     if mount then
  914.         if GoGo_Prefs.DebugMessages then
  915.             GoGo_DebugAddLine("GoGo_FillButton: Casting " .. mount)
  916.         end --if
  917.         button:SetAttribute("macrotext", "/use "..mount)
  918.     else
  919.         button:SetAttribute("macrotext", nil)
  920.     end --if
  921. end --function
  922.  
  923. ---------
  924. function GoGo_CheckBindings()
  925. ---------
  926.     for binding, button in pairs({GOGOBINDING = GoGoButton, GOGOBINDING2 = GoGoButton2, GOGOBINDING3 = GoGoButton3}) do
  927.         ClearOverrideBindings(button)
  928.         local key1, key2 = GetBindingKey(binding)
  929.         if key1 then
  930.             SetOverrideBindingClick(button, true, key1, button:GetName())
  931.         end --if
  932.         if key2 then
  933.             SetOverrideBindingClick(button, true, key2, button:GetName())
  934.         end --if
  935.     end --if
  936. end --function
  937.  
  938. ---------
  939. function GoGo_CanFly()
  940. ---------
  941.     GoGo_Variables.Player.Zone = GetRealZoneText()
  942.     GoGo_Variables.Player.SubZone = GetSubZoneText()
  943.  
  944.     local level = UnitLevel("player")
  945. --  if (level <= 69) and not (GoGo_Variables.Player.Class == "DRUID") then
  946. --      return false
  947. --  elseif (GoGo_Variables.Player.Class == "DRUID" and level <= 67) then
  948. --      return false
  949. --  end --if
  950.     if (level < 60) then
  951.         if GoGo_Prefs.DebugMessages then
  952.             GoGo_DebugAddLine("GoGo_CanFly: Failed - Player under level 60")
  953.         end --if
  954.         return false
  955.     end --if
  956.    
  957.     if GoGo_InOutlands() then
  958.         if GoGo_Prefs.DebugMessages then
  959.             GoGo_DebugAddLine("GoGo_CanFly: Player in Outlands, we can fly here") -- we can fly here
  960.         end --if
  961.     elseif GoGo_InAzeroth() then
  962.         if GoGo_Prefs.DebugMessages then
  963.             GoGo_DebugAddLine("GoGo_CanFly: Player in Azeroth, checking to see if we're in a capitcal city..")
  964.         end --if
  965.         -- exclude Stormwind, Ironforge, Undercity, Silvermoon City, Darnassus, Exodar, Orgrimmar, Thunder Bluff
  966.         if GoGo_InCapitalCity() then
  967.             if GoGo_Prefs.DebugMessages then
  968.                 GoGo_DebugAddLine("GoGo_CanFly: Failed - Player in capital city, not in flyable area.")
  969.             end --if
  970.             return false
  971.         end --if
  972.     elseif GoGo_InNorthrend() then --and (GoGo_InBook(GoGo_Variables.Localize.ColdWeatherFlying))) then -- removing this check for Wow-Mania VIP mounts, but will need to find a better way
  973.         if GoGo_Prefs.DebugMessages then
  974.             GoGo_DebugAddLine("GoGo_CanFly: Player in Northrend, but doing some more checks..")
  975.         end --if
  976.         if GoGo_Variables.Player.Zone == GoGo_Variables.Localize.Zone.Dalaran then
  977.             if GoGo_Prefs.DebugMessages then
  978.                 GoGo_DebugAddLine("GoGo_CanFly: Player in Dalaran, but doing even more checks..")
  979.             end --if
  980.             if (GoGo_Variables.Player.SubZone == GOGO_SZONE_KRASUSLANDING) then
  981.                 if not IsFlyableArea() then
  982.                     if GoGo_Prefs.DebugMessages then
  983.                         GoGo_DebugAddLine("GoGo_CanFly: Failed - Player in " .. GOGO_SZONE_KRASUSLANDING .. " and not in flyable area.")
  984.                     end --if
  985.                     return false
  986.                 end --if
  987.             elseif (GoGo_Variables.Player.SubZone == GOGO_SZONE_THEVIOLETCITADEL) then
  988.                 if not IsOutdoors() then
  989.                     if GoGo_Prefs.DebugMessages then
  990.                         GoGo_DebugAddLine("GoGo_CanFly: Failed - Player in " .. GOGO_SZONE_THEVIOLETCITADEL .. " and not outdoors area.")
  991.                     end --if
  992.                     return false
  993.                 end --if
  994. --              if not GoGo_CheckCoOrds("Dalaran", "VioletCitadel") then
  995. --                  return false
  996. --              end --if
  997.                 if not IsFlyableArea() then
  998.                     if GoGo_Prefs.DebugMessages then
  999.                         GoGo_DebugAddLine("GoGo_CanFly: Failed - Player in " .. GOGO_SZONE_THEVIOLETCITADEL .. " and not in flyable area.")
  1000.                     end --if
  1001.                     return false
  1002.                 end --if
  1003.             elseif (GoGo_Variables.Player.SubZone == GOGO_SZONE_THEUNDERBELLY) then
  1004. --              if not GoGo_CheckCoOrds("Dalaran", "Underbelly") then
  1005. --                  return false
  1006. --              end --if
  1007.                 if not IsFlyableArea() then
  1008.                     if GoGo_Prefs.DebugMessages then
  1009.                         GoGo_DebugAddLine("GoGo_CanFly: Failed - Player in " .. GOGO_SZONE_THEUNDERBELLY .. " and not in flyable area.")
  1010.                     end --if
  1011.                     return false
  1012.                 end --if
  1013.             elseif (GoGo_Variables.Player.SubZone == GoGo_Variables.Localize.Zone.Dalaran) then
  1014. --              if not GoGo_CheckCoOrds("Dalaran", "Dalaran") then
  1015. --                  return false
  1016. --              end --if
  1017.                 if not IsFlyableArea() then
  1018.                     if GoGo_Prefs.DebugMessages then
  1019.                         GoGo_DebugAddLine("GoGo_CanFly: Failed - Player in " .. GoGo_Variables.Localize.Zone.Dalaran .. " and not outdoors area.")
  1020.                     end --if
  1021.                     return false
  1022.                 end --if
  1023.             else
  1024.                 if GoGo_Prefs.DebugMessages then
  1025.                     GoGo_DebugAddLine("GoGo_CanFly: Failed - Player in " .. GoGo_Variables.Localize.Zone.Dalaran .. " and not in known flyable subzone.")
  1026.                 end --if
  1027.                 return false
  1028.             end --if
  1029.         end --if
  1030.  
  1031.         if GoGo_Variables.Player.Zone == GoGo_Variables.Localize.Zone.Wintergrasp then
  1032.             if GetWintergraspWaitTime() then
  1033.                 if GoGo_Prefs.DebugMessages then
  1034.                     GoGo_DebugAddLine("GoGo_CanFly: Player in Wintergrasp and battle ground is not active.")
  1035.                 end --if
  1036.                 -- timer ticking to start wg.. we can mount
  1037.             else
  1038.                 if GoGo_Prefs.DebugMessages then
  1039.                     GoGo_DebugAddLine("GoGo_CanFly: Failed - Player in Wintergrasp and battle ground is active.")
  1040.                 end --if
  1041.                 -- we should be in battle.. can't mount
  1042.                 return false
  1043.             end --if
  1044.         end --if
  1045.     else
  1046.         if GoGo_Prefs.DebugMessages then
  1047.             GoGo_DebugAddLine("GoGo_CanFly: Failed - Player does not meet any flyable conditions.")
  1048.         end --if
  1049.         return false  -- we can't fly anywhere else
  1050.     end --if
  1051.    
  1052.     return true
  1053. end --function
  1054.  
  1055. ---------
  1056. function GoGo_CanRide()
  1057. ---------
  1058.     local level = UnitLevel("player")
  1059.     if level >= 20 then
  1060.         if GoGo_Prefs.DebugMessages then
  1061.             GoGo_DebugAddLine("GoGo_CanRide: Passed - Player is over level 20.")
  1062.         end --if
  1063.         return true
  1064.     end --if
  1065. end --function
  1066.  
  1067. ---------
  1068. function GoGo_CheckFor310()  -- checks to see if any existing 310% mounts exist to increase the speed of [6] mounts
  1069. ---------
  1070.     local loop
  1071.     local MountID
  1072.     if GoGo_Prefs.DebugMessages then
  1073.         GoGo_DebugAddLine("GoGo_CheckFor310: Function executed.")
  1074.     end --if
  1075.  
  1076.     local Find310Mounts = GoGo_FilterMountsIn(GoGo_Variables.MountList,24)
  1077.     for loop=1, table.getn(Find310Mounts) do
  1078.         MountID = Find310Mounts[loop]
  1079.         if GoGo_Prefs.DebugMessages then
  1080.             GoGo_DebugAddLine("GoGo_CheckFor310: Mount ID " .. MountID .. " found as 310% flying.")
  1081.         end --if
  1082.     end --for
  1083.     if (table.getn(Find310Mounts) > 0) then
  1084.         Find310Mounts = GoGo_FilterMountsIn(GoGo_Variables.MountList,6)
  1085.         if table.getn(Find310Mounts) then
  1086.             for loop=1, table.getn(Find310Mounts) do
  1087.                 MountID = Find310Mounts[loop]
  1088.                 GoGo_Variables.MountDB[MountID][24] = true
  1089.                 if GoGo_Prefs.DebugMessages then
  1090.                     GoGo_DebugAddLine("GoGo_CheckFor310: Mount ID " .. MountID .. " added as 310% flying.")
  1091.                 end --if
  1092.  
  1093.             end --for
  1094.         end --if
  1095.     end --if
  1096. end --function
  1097.  
  1098. ---------
  1099. function GoGo_IsMoving()
  1100. ---------
  1101.     if GetUnitSpeed("player") ~= 0 then
  1102.         return true
  1103.     else
  1104.         return false
  1105.     end --if
  1106. end --function
  1107.  
  1108. ---------
  1109. function GoGo_GetSkillLevel(searchname)
  1110. ---------
  1111.     for skillIndex = 1, GetNumSkillLines() do
  1112.         skillName, isHeader, isExpanded, skillRank = GetSkillLineInfo(skillIndex)
  1113.         if isHeader == nil then
  1114.             if skillName == searchname then
  1115.                 return skillRank
  1116.             end --if
  1117.         end --if
  1118.     end --for
  1119. end --function
  1120.  
  1121. ---------
  1122. function GoGo_CheckCoOrds(ZoneName, SubZoneName)
  1123. ---------
  1124.     local posX, posY = GetPlayerMapPosition("Player")
  1125.     local CanFlyHere = false
  1126.     local ZoneName = GoGo_FlyCoOrds[ZoneName]
  1127.     local SubZoneName = ZoneName[SubZoneName]
  1128.     for a = 1, table.getn(SubZoneName) or 0 do
  1129.         if GoGo_Prefs.DebugMessages then
  1130.             GoGo_DebugAddLine("GoGo_CheckCoOrds: Checking CoOrds " .. a)
  1131.         end --if
  1132.         local PointAX, PointAY, PointBX, PointBY = SubZoneName[a][1], SubZoneName[a][2], SubZoneName[a][3], SubZoneName[a][4]
  1133.         if posX >= PointAX and posX <= PointBX and posY >= PointAY and posY <= PointBY then
  1134.             -- we are in the rectangle a
  1135.             return true
  1136.         end --if
  1137.     end --for
  1138.     return false
  1139. end --function
  1140.  
  1141. ---------
  1142. function GoGo_Msg(msg)
  1143. ---------
  1144.     if msg then
  1145.         if GOGO_MESSAGES[msg] then
  1146.             GoGo_Msg(GOGO_MESSAGES[msg]())
  1147.         else
  1148.             msg = string.gsub(msg, "<", LIGHTYELLOW_FONT_COLOR_CODE)
  1149.             msg = string.gsub(msg, ">", "|r")
  1150.             DEFAULT_CHAT_FRAME:AddMessage(GREEN_FONT_COLOR_CODE.."GoGo: |r"..msg)
  1151.         end --if
  1152.     end --if
  1153. end --function
  1154.  
  1155. ---------
  1156. function GoGo_Id(itemstring)
  1157. ---------
  1158.     local _, _, itemid = string.find(itemstring,"(item:%d+)")
  1159.     if itemid then
  1160.         return itemid.." - "..itemstring
  1161.     end --if
  1162.     local _, _, spellid = string.find(itemstring,"(spell:%d+)")
  1163.     if spellid then
  1164.         return spellid.." - "..itemstring
  1165.     end --if
  1166.  
  1167. end --function
  1168.  
  1169. GOGO_ERRORS = {
  1170.     [SPELL_FAILED_NOT_MOUNTED] = true,
  1171.     [SPELL_FAILED_NOT_SHAPESHIFT] = true,
  1172.     [ERR_ATTACK_MOUNTED] = true,
  1173. }
  1174.  
  1175. GOGO_SPELLS = {
  1176.     ["DRUID"] = function()
  1177.         if GoGo_InBook(GoGo_Variables.Localize.AquaForm) then
  1178.             if not GoGo_Variables.SkipFlyingMount and GoGo_CanFly() and GoGo_InBook(GoGo_Variables.Localize.FastFlightForm) then
  1179.                 return "[swimming] "..GoGo_InBook(GoGo_Variables.Localize.AquaForm).."; [combat]"..GoGo_InBook(GoGo_Variables.Localize.TravelForm).."; "..GoGo_InBook(GoGo_Variables.Localize.FastFlightForm)
  1180.             elseif not GoGo_Variables.SkipFlyingMount and GoGo_CanFly() and GoGo_InBook(GoGo_Variables.Localize.FlightForm) then
  1181.                 return "[swimming] "..GoGo_InBook(GoGo_Variables.Localize.AquaForm).."; [combat]"..GoGo_InBook(GoGo_Variables.Localize.TravelForm).."; "..GoGo_InBook(GoGo_Variables.Localize.FlightForm)
  1182.             else
  1183.                 return "[swimming] "..GoGo_InBook(GoGo_Variables.Localize.AquaForm).."; "..GoGo_InBook(GoGo_Variables.Localize.TravelForm)
  1184.             end --if
  1185.         end --if
  1186.     end, --function
  1187.     ["SHAMAN"] = function()
  1188.         return GoGo_InBook(GoGo_Variables.Localize.GhostWolf)
  1189.     end, --function
  1190. }
  1191.  
  1192. GOGO_COMMANDS = {
  1193.     ["auto"] = function()
  1194.         GoGo_Prefs.autodismount = not GoGo_Prefs.autodismount
  1195.         GoGo_Msg("auto")
  1196.         GoGo_Panel_UpdateViews()
  1197.     end, --function
  1198.     ["genericfastflyer"] = function()
  1199.         if not GoGo_CanFly() then
  1200.             return
  1201.         else
  1202.             GoGo_Prefs.genericfastflyer = not GoGo_Prefs.genericfastflyer
  1203.             GoGo_Msg("genericfastflyer")
  1204.             GoGo_Panel_UpdateViews()
  1205.         end --if
  1206.     end, --function
  1207.     ["clear"] = function()
  1208.         if GoGo_Prefs.GlobalPrefMount then
  1209.             GoGo_Prefs.GlobalPrefMounts = nil
  1210.             if not InCombatLockdown() then
  1211.                 for i, button in ipairs({GoGoButton, GoGoButton2}) do
  1212.                     GoGo_FillButton(button)
  1213.                 end --for
  1214.             end --if
  1215.         else
  1216.             GoGo_Prefs[GoGo_Variables.Player.Zone] = nil
  1217.             if not InCombatLockdown() then
  1218.                 for i, button in ipairs({GoGoButton, GoGoButton2}) do
  1219.                     GoGo_FillButton(button)
  1220.                 end --for
  1221.             end --if
  1222.         end --if
  1223.         GoGo_Msg("pref")
  1224.     end, --function
  1225.     ["updatenotice"] = function()
  1226.         GoGo_Prefs.DisableUpdateNotice = not GoGo_Prefs.DisableUpdateNotice
  1227.         GoGo_Msg("updatenotice")
  1228.         GoGo_Panel_UpdateViews()
  1229.     end, --function
  1230.     ["mountnotice"] = function()
  1231.         GoGo_Prefs.DisableMountNotice = not GoGo_Prefs.DisableMountNotice
  1232.         GoGo_Msg("mountnotice")
  1233.         GoGo_Panel_UpdateViews()
  1234.     end, --function
  1235.     ["druidclickform"] = function()
  1236.         GoGo_Prefs.DruidClickForm = not GoGo_Prefs.DruidClickForm
  1237.         GoGo_Msg("druidclickform")
  1238.         GoGo_Panel_UpdateViews()
  1239.     end, --function
  1240.     ["druidflightform"] = function()
  1241.         GoGo_Prefs.DruidFlightForm = not GoGo_Prefs.DruidFlightForm
  1242.         GoGo_Msg("druidflightform")
  1243.         GoGo_Panel_UpdateViews()
  1244.     end, --function
  1245.     ["options"] = function()
  1246.         InterfaceOptionsFrame_OpenToCategory(GoGo_Panel)
  1247.     end, --function
  1248. }
  1249.  
  1250. GOGO_MESSAGES = {
  1251.     ["auto"] = function()
  1252.         if GoGo_Prefs.autodismount then
  1253.             return "Autodismount active - </gogo auto> to toggle"
  1254.         else
  1255.             return "Autodismount inactive - </gogo auto> to toggle"
  1256.         end --if
  1257.     end, --function
  1258.     ["genericfastflyer"] = function()
  1259.         if not GoGo_CanFly() then
  1260.             return
  1261.         elseif GoGo_Prefs.genericfastflyer then
  1262.             return "Considering epic flying mounts 310% - 280% speeds the same for random selection - </gogo genericfastflyer> to toggle"
  1263.         else
  1264.             return "Considering epic flying mounts 310% - 280% speeds different for random selection - </gogo genericfastflyer> to toggle"
  1265.         end --if
  1266.     end, --function
  1267.     ["pref"] = function()
  1268.         local msg = ""
  1269.         if not GoGo_Prefs.GlobalPrefMount then
  1270.             local list = ""
  1271.             if GoGo_Prefs[GoGo_Variables.Player.Zone] then
  1272.                 list = list .. GoGo_GetIDName(GoGo_Prefs[GoGo_Variables.Player.Zone])
  1273.                 msg = GoGo_Variables.Player.Zone..": "..list.." - </gogo clear> to clear"
  1274.             else
  1275.                 msg = GoGo_Variables.Player.Zone..": ?".." - </gogo ItemLink> or </gogo SpellName> to add"
  1276.             end --if
  1277.             if GoGo_Prefs.GlobalPrefMounts then
  1278.                 list = list .. GoGo_GetIDName(GoGo_Prefs.GlobalPrefMounts)
  1279.                 msg = msg .. "\nGlobal Preferred Mounts: "..list.." - Enable global mount preferences to change."
  1280.             end --if
  1281.             return msg
  1282.         else
  1283.             local list = ""
  1284.             if GoGo_Prefs.GlobalPrefMounts then
  1285.                 list = list .. GoGo_GetIDName(GoGo_Prefs.GlobalPrefMounts)
  1286.                 msg = "Global Preferred Mounts: "..list.." - </gogo clear> to clear"
  1287.             else
  1288.                 msg =  "Global Preferred Mounts: ?".." - </gogo ItemLink> or </gogo SpellName> to add"
  1289.             end --if
  1290.             if GoGo_Prefs[GoGo_Variables.Player.Zone] then
  1291.                 list = list .. GoGo_GetIDName(GoGo_Prefs[GoGo_Variables.Player.Zone])
  1292.                 msg = msg .. "\n" .. GoGo_Variables.Player.Zone ..": "..list.." - Disable global mount preferences to change."
  1293.             end --if
  1294.             return msg
  1295.         end --if
  1296.     end, --function
  1297.     ["updatenotice"] = function()
  1298.         if GoGo_Prefs.DisableUpdateNotice then
  1299.             return "Update notices from other players disabled - </gogo updatenotice> to toggle"
  1300.         else
  1301.             return "Update notices from other players enabled - </gogo updatenotice> to toggle"
  1302.         end --if
  1303.     end, --function
  1304.     ["mountnotice"] = function()
  1305.         if GoGo_Prefs.DisableMountNotice then
  1306.             return "Update notices about unknown mounts are disabled - </gogo mountnotice> to toggle"
  1307.         else
  1308.             return "Update notices about unknown mounts are enabled - </gogo mountnotice> to toggle"
  1309.         end --if
  1310.     end, --function
  1311.     ["druidclickform"] = function()
  1312.         if GoGo_Prefs.DruidClickForm then
  1313.             return "Single click form changes enabled - </gogo druidclickform> to toggle"
  1314.         else
  1315.             return "Single click form changes disabled - </gogo druidclickform> to toggle"
  1316.         end --if
  1317.     end, --function
  1318.     ["druidflightform"] = function()
  1319.         if GoGo_Prefs.DruidFlightForm then
  1320.             return "Flight Forms always used over flying mounts - </gogo druidflightform> to toggle"
  1321.         else
  1322.             return "Flighing mounts selected, flight forms if moving - </gogo druidflightform> to toggle"
  1323.         end --if
  1324.     end, --function
  1325.     ["UnknownMount"] = function() return GOGO_STRING_UNKNOWNMOUNTFOUND end, --function
  1326.     ["optiongui"] = function() return "To open the GUI options window - </gogo options>" end, --function
  1327. }
  1328.  
  1329. ---------
  1330. function GoGo_DebugAddLine(LogLine)
  1331. ---------
  1332.     if not GoGo_Variables.DebugLine then GoGo_Variables.DebugLine = 1 end --if
  1333.     GoGo_DebugLog[GoGo_Variables.DebugLine] = LogLine
  1334.     GoGo_Msg(LogLine)
  1335.     GoGo_Variables.DebugLine = GoGo_Variables.DebugLine + 1
  1336.    
  1337. end --function
  1338.  
  1339. ---------
  1340. function GoGo_Panel_OnLoad(GoGo_Panel)
  1341. ---------
  1342. --  local GoGo_Panel = CreateFrame("FRAME", nil);
  1343. --  GoGo_Panel:SetScript("OnShow",function() GoGo_Panel_UpdateViews(); end);
  1344.     GoGo_Panel.name = "GoGoMount"
  1345.     GoGo_Panel.okay = function (self) GoGo_Panel_Okay(); end;
  1346.     GoGo_Panel.default = function (self) GoGo_Settings_Default(); GoGo_Panel_UpdateViews(); end;
  1347.     InterfaceOptions_AddCategory(GoGo_Panel)
  1348.    
  1349. end --function
  1350.  
  1351. ---------
  1352. function GoGo_Panel_CurrentZoneFavorites_OnLoad(GoGo_Panel_CurrentZoneFavorites)
  1353. ---------
  1354.     GoGo_Panel_CurrentZoneFavorites.name = GOGO_STRING_CURRENTZONEFAVORITES
  1355.     GoGo_Panel_CurrentZoneFavorites.parent = "GoGoMount"
  1356.     GoGo_Panel_CurrentZoneFavorites.okay = function (self) GoGo_Panel_Okay(); end;
  1357.     GoGo_Panel_CurrentZoneFavorites.default = function (self) GOGO_COMMANDS["clear"](); GoGo_UpdateFavoritesTabs(); end;  -- use clear command with default button
  1358.     InterfaceOptions_AddCategory(GoGo_Panel_CurrentZoneFavorites)
  1359. end --function
  1360.  
  1361. ---------
  1362. function GoGo_Panel_GlobalFavorites_OnLoad(GoGo_Panel_GlobalFavorites)
  1363. ---------
  1364.     GoGo_Panel_GlobalFavorites.name = GOGO_STRING_GLOBALFAVORITES
  1365.     GoGo_Panel_GlobalFavorites.parent = "GoGoMount"
  1366.     GoGo_Panel_GlobalFavorites.okay = function (self) GoGo_Panel_Okay(); end;
  1367.     GoGo_Panel_GlobalFavorites.default = function (self) GOGO_COMMANDS["clear"](); GoGo_UpdateFavoritesTabs(); end;  -- use clear command with default button
  1368.     InterfaceOptions_AddCategory(GoGo_Panel_GlobalFavorites)
  1369. end --function
  1370.  
  1371. --[[
  1372. ---------
  1373. function GoGo_Panel_GlobalFavorites_Populate()
  1374. ---------
  1375.  
  1376.    
  1377.     if getn(GoGo_Variables.MountList) > 0 then
  1378.         for numMounts = 1, getn(GoGo_Variables.MountList) do
  1379.             GoGo_CurrentMountID = CreateFrame("CheckButton", GoGo_Variables.MountList[numMounts], GoGo_Panel_GlobalFavorites, "OptionsCheckButtonTemplate")
  1380.             GoGo_CurrentMountID:SetPoint("TOPLEFT", numMounts * 16, -16)
  1381.             --GoGo_Panel_MountItem = getglobal(GoGo_Panel_MountItem[GoGo_CurrentMountID])
  1382.             GoGo_CurrentMountIDText:SetText(GoGo_Variables.MountList[numMounts])
  1383.    
  1384.         end --for
  1385.     end --if
  1386.    
  1387.  
  1388.  
  1389. end --function
  1390.  
  1391. ]]
  1392. ---------
  1393. function GoGo_Panel_Options()
  1394. ---------
  1395.     GoGo_Panel_DruidClickForm = CreateFrame("CheckButton", "GoGo_Panel_DruidClickForm", GoGo_Panel, "OptionsCheckButtonTemplate")
  1396.     GoGo_Panel_DruidClickForm:SetPoint("TOPLEFT", 16, -16)
  1397.     GoGo_Panel_DruidClickFormText:SetText(GOGO_STRING_DRUIDSINGLECLICK)
  1398.  
  1399.     GoGo_Panel_DruidFlightForm = CreateFrame("CheckButton", "GoGo_Panel_DruidFlightForm", GoGo_Panel, "OptionsCheckButtonTemplate")
  1400.     GoGo_Panel_DruidFlightForm:SetPoint("TOPLEFT", "GoGo_Panel_DruidClickForm", "BOTTOMLEFT", 0, -4)
  1401.     GoGo_Panel_DruidFlightFormText:SetText(GoGo_Variables.Localize.String.DruidFlightPreference)
  1402.  
  1403.     GoGo_Panel_AutoDismount = CreateFrame("CheckButton", "GoGo_Panel_AutoDismount", GoGo_Panel, "OptionsCheckButtonTemplate")
  1404.     GoGo_Panel_AutoDismount:SetPoint("TOPLEFT", "GoGo_Panel_DruidFlightForm", "BOTTOMLEFT", 0, -4)
  1405.     GoGo_Panel_AutoDismountText:SetText(GOGO_STRING_ENABLEAUTODISMOUNT)
  1406.  
  1407.     GoGo_Panel_GenericFastFlyer = CreateFrame("CheckButton", "GoGo_Panel_GenericFastFlyer", GoGo_Panel, "OptionsCheckButtonTemplate")
  1408.     GoGo_Panel_GenericFastFlyer:SetPoint("TOPLEFT", "GoGo_Panel_AutoDismount", "BOTTOMLEFT", 0, -4)
  1409.     GoGo_Panel_GenericFastFlyerText:SetText(GOGO_STRING_SAMEEPICFLYSPEED)
  1410.  
  1411.  
  1412.     GoGo_Panel_GlobalPrefMount = CreateFrame("CheckButton", "GoGo_Panel_GlobalPrefMount", GoGo_Panel, "OptionsCheckButtonTemplate")
  1413.     GoGo_Panel_GlobalPrefMount:SetPoint("TOPLEFT", "GoGo_Panel_GenericFastFlyer", "BOTTOMLEFT", 0, -4)
  1414.     GoGo_Panel_GlobalPrefMountText:SetText("Preferred mount changes apply to global setting")
  1415.  
  1416. --  GoGo_Panel_PaliUseCrusader = CreateFrame("CheckButton", "GoGo_Panel_PaliUseCrusader", GoGo_Panel, "OptionsCheckButtonTemplate")
  1417. --  GoGo_Panel_PaliUseCrusader:SetPoint("TOPLEFT", "GoGo_Panel_GlobalPrefMount", "BOTTOMLEFT", 0, -4)
  1418. --  GoGo_Panel_PaliUseCrusaderText:SetText("Paladins:  Auto start Crusader Aura when mounting")
  1419.  
  1420.     GoGo_Panel_DisableUpdateNotice = CreateFrame("CheckButton", "GoGo_Panel_DisableUpdateNotice", GoGo_Panel, "OptionsCheckButtonTemplate")
  1421. --  GoGo_Panel_DisableUpdateNotice:SetPoint("TOPLEFT", "GoGo_Panel_PaliUseCrusader", "BOTTOMLEFT", 0, -12)
  1422.     GoGo_Panel_DisableUpdateNotice:SetPoint("TOPLEFT", "GoGo_Panel_GlobalPrefMount", "BOTTOMLEFT", 0, -12)
  1423.     GoGo_Panel_DisableUpdateNoticeText:SetText(GOGO_STRING_DISABLEUPDATENOTICES)
  1424.  
  1425.     GoGo_Panel_DisableMountNotice = CreateFrame("CheckButton", "GoGo_Panel_DisableMountNotice", GoGo_Panel, "OptionsCheckButtonTemplate")
  1426.     GoGo_Panel_DisableMountNotice:SetPoint("TOPLEFT", "GoGo_Panel_DisableUpdateNotice", "BOTTOMLEFT", 0, -4)
  1427.     GoGo_Panel_DisableMountNoticeText:SetText(GOGO_STRING_DISABLEUNKNOWNMOUNTNOTICES)
  1428.  
  1429.     GoGo_Panel_DebugMessages = CreateFrame("CheckButton", "GoGo_Panel_DebugMessages", GoGo_Panel, "OptionsCheckButtonTemplate")
  1430.     GoGo_Panel_DebugMessages:SetPoint("TOPLEFT", "GoGo_Panel_DisableMountNotice", "BOTTOMLEFT", 0, -4)
  1431.     GoGo_Panel_DebugMessagesText:SetText("Enable Debug Messages")
  1432.  
  1433. -- Global favorite scroll frame and buttons
  1434. --[[
  1435.     GoGo_Panel_GlobalFavorites_Scroll = CreateFrame("ScrollFrame", "GoGo_Panel_GlobalFavorites_Scroll", GoGo_Panel_GlobalFavorites, "FauxScrollFrameTemplate")
  1436.     GoGo_Panel_GlobalFavorites_Scroll:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites", "TOPLEFT")
  1437.     GoGo_Panel_GlobalFavorites_Scroll:SetScript("OnVerticalScroll",function() FauxScrollFrame_OnVerticalScroll(this, offset, 16, GoGo_Panel_GlobalFavorites_Scroll_Update); end);
  1438.     GoGo_Panel_GlobalFavorites_Scroll:SetScript("OnShow",function() GoGo_Panel_GlobalFavorites_Scroll_Update(); end);
  1439.    
  1440.     GoGo_Panel_GlobalFavorites_Line1 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line1", GoGo_Panel_GlobalFavorites_Scroll, "GoGo_Favorite_Button")
  1441.     GoGo_Panel_GlobalFavorites_Line1:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Scroll", "TOPLEFT", 8, 0)
  1442.     GoGo_Panel_GlobalFavorites_Line2 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line2",GoGo_Panel_GlobalFavorites_Scroll, "GoGo_Favorite_Button")
  1443.     GoGo_Panel_GlobalFavorites_Line2:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line1", "BOTTOMLEFT")
  1444.     GoGo_Panel_GlobalFavorites_Line3 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line3", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1445.     GoGo_Panel_GlobalFavorites_Line3:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line2", "BOTTOMLEFT")
  1446.     GoGo_Panel_GlobalFavorites_Line4 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line4", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1447.     GoGo_Panel_GlobalFavorites_Line4:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line3", "BOTTOMLEFT")
  1448.     GoGo_Panel_GlobalFavorites_Line5 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line5", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1449.     GoGo_Panel_GlobalFavorites_Line5:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line4", "BOTTOMLEFT")
  1450.     GoGo_Panel_GlobalFavorites_Line6 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line6", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1451.     GoGo_Panel_GlobalFavorites_Line6:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line5", "BOTTOMLEFT")
  1452.     GoGo_Panel_GlobalFavorites_Line7 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line7", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1453.     GoGo_Panel_GlobalFavorites_Line7:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line6", "BOTTOMLEFT")
  1454.     GoGo_Panel_GlobalFavorites_Line8 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line8", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1455.     GoGo_Panel_GlobalFavorites_Line8:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line7", "BOTTOMLEFT")
  1456.     GoGo_Panel_GlobalFavorites_Line9 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line9", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1457.     GoGo_Panel_GlobalFavorites_Line9:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line8", "BOTTOMLEFT")
  1458.     GoGo_Panel_GlobalFavorites_Line10 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line10", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1459.     GoGo_Panel_GlobalFavorites_Line10:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line9", "BOTTOMLEFT")
  1460.     GoGo_Panel_GlobalFavorites_Line11 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line11", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1461.     GoGo_Panel_GlobalFavorites_Line11:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line10", "BOTTOMLEFT")
  1462.     GoGo_Panel_GlobalFavorites_Line12 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line12", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1463.     GoGo_Panel_GlobalFavorites_Line12:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line11", "BOTTOMLEFT")
  1464.     GoGo_Panel_GlobalFavorites_Line13 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line13", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1465.     GoGo_Panel_GlobalFavorites_Line13:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line12", "BOTTOMLEFT")
  1466.     GoGo_Panel_GlobalFavorites_Line14 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line14", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1467.     GoGo_Panel_GlobalFavorites_Line14:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line13", "BOTTOMLEFT")
  1468.     GoGo_Panel_GlobalFavorites_Line15 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line15", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1469.     GoGo_Panel_GlobalFavorites_Line15:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line14", "BOTTOMLEFT")
  1470.     GoGo_Panel_GlobalFavorites_Line16 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line16", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1471.     GoGo_Panel_GlobalFavorites_Line16:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line15", "BOTTOMLEFT")
  1472.     GoGo_Panel_GlobalFavorites_Line17 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line17", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1473.     GoGo_Panel_GlobalFavorites_Line17:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line16", "BOTTOMLEFT")
  1474.     GoGo_Panel_GlobalFavorites_Line18 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line18", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1475.     GoGo_Panel_GlobalFavorites_Line18:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line17", "BOTTOMLEFT")
  1476.     GoGo_Panel_GlobalFavorites_Line19 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line19", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1477.     GoGo_Panel_GlobalFavorites_Line19:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line18", "BOTTOMLEFT")
  1478.     GoGo_Panel_GlobalFavorites_Line20 = CreateFrame("Button", "GoGo_Panel_GlobalFavorites_Line20", GoGo_Panel_GlobalFavorites, "GoGo_Favorite_Button")
  1479.     GoGo_Panel_GlobalFavorites_Line20:SetPoint("TOPLEFT", "GoGo_Panel_GlobalFavorites_Line19", "BOTTOMLEFT")
  1480.  
  1481. ]]
  1482. end --function
  1483.  
  1484. ---------
  1485. function GoGo_Panel_GlobalFavorites_Scroll_Update()
  1486. ---------
  1487.     local line; -- 1 through 5 of our window to scroll
  1488.     local lineplusoffset; -- an index into our data calculated from the scroll offset
  1489.     FauxScrollFrame_Update(GoGo_Panel_GlobalFavorites_Scroll,50,20,16);
  1490.     for line=1,20 do
  1491.         lineplusoffset = line + FauxScrollFrame_GetOffset(GoGo_Panel_GlobalFavorites_Scroll);
  1492.         if lineplusoffset <= 50 then
  1493.             getglobal("GoGo_Panel_GlobalFavorites_Line"..line):SetText(GoGo_GetIDName(GoGo_Variables.MountSpellList[lineplusoffset]));
  1494.             --GoGo_DebugAddLine(GoGo_GetIDName(GoGo_Variables.MountSpellList[lineplusoffset]))
  1495.             getglobal("GoGo_Panel_GlobalFavorites_Line"..line):Show();
  1496.         else
  1497.             getglobal("GoGo_Panel_GlobalFavorites_Line"..line):Hide();
  1498.         end --if
  1499.     end  --for
  1500. end --function
  1501.  
  1502. ---------
  1503. function GoGo_Panel_UpdateViews()
  1504. ---------
  1505.     GoGo_Panel_AutoDismount:SetChecked(GoGo_Prefs.autodismount)
  1506.     GoGo_Panel_GenericFastFlyer:SetChecked(GoGo_Prefs.genericfastflyer)
  1507.  
  1508.     GoGo_Panel_DisableUpdateNotice:SetChecked(GoGo_Prefs.DisableUpdateNotice)
  1509.     GoGo_Panel_DisableMountNotice:SetChecked(GoGo_Prefs.DisableMountNotice)
  1510.     GoGo_Panel_DebugMessages:SetChecked(GoGo_Prefs.DebugMessages)
  1511.     GoGo_Panel_DruidClickForm:SetChecked(GoGo_Prefs.DruidClickForm)
  1512.     GoGo_Panel_DruidFlightForm:SetChecked(GoGo_Prefs.DruidFlightForm)
  1513.     GoGo_Panel_GlobalPrefMount:SetChecked(GoGo_Prefs.GlobalPrefMount)
  1514. --  GoGo_Panel_PaliUseCrusader:SetChecked(GoGo_Prefs.PaliUseCrusader)
  1515.    
  1516.     if GoGo_Prefs.autodismount then
  1517.         GoGoFrame:RegisterEvent("UI_ERROR_MESSAGE")
  1518.     else
  1519.         GoGoFrame:UnregisterEvent("UI_ERROR_MESSAGE")
  1520.     end --if
  1521. end -- function
  1522.  
  1523. ---------
  1524. function GoGo_Panel_Okay()
  1525. ---------
  1526.     GoGo_Prefs.autodismount = GoGo_Panel_AutoDismount:GetChecked()
  1527.     GoGo_Prefs.genericfastflyer = GoGo_Panel_GenericFastFlyer:GetChecked()
  1528.     GoGo_Prefs.DisableUpdateNotice = GoGo_Panel_DisableUpdateNotice:GetChecked()
  1529.     GoGo_Prefs.DisableMountNotice = GoGo_Panel_DisableMountNotice:GetChecked()
  1530.     GoGo_Prefs.DebugMessages = GoGo_Panel_DebugMessages:GetChecked()
  1531.     GoGo_Prefs.DruidClickForm = GoGo_Panel_DruidClickForm:GetChecked()
  1532.     GoGo_Prefs.DruidFlightForm = GoGo_Panel_DruidFlightForm:GetChecked()
  1533.     GoGo_Prefs.GlobalPrefMount = GoGo_Panel_GlobalPrefMount:GetChecked()
  1534.     --  GoGo_Prefs.PaliUseCrusader = GoGo_Panel_PaliUseCrusader:GetChecked()
  1535. end --function
  1536.  
  1537. ---------
  1538. function GoGo_Settings_Default()
  1539. ---------
  1540.     GoGo_Prefs.version = GetAddOnMetadata("GoGoMount", "Version")
  1541.     GoGo_Prefs.autodismount = true
  1542.     GoGo_Prefs.DisableUpdateNotice = false
  1543.     GoGo_Prefs.DisableMountNotice = false
  1544.     GoGo_Prefs.DebugMessages = false
  1545.     GoGo_Prefs.genericfastflyer = false
  1546.     GoGo_Prefs.DruidClickForm = true
  1547.     GoGo_Prefs.DruidFlightForm = false
  1548.     GoGo_Prefs.UnknownMounts = {}
  1549.     GoGo_Prefs.GlobalPrefMounts = {}
  1550.     GoGo_Prefs.GlobalPrefMount = false
  1551. --  GoGo_Prefs.PaliUseCrusader = false
  1552. end --function
  1553.  
  1554. ---------
  1555. function GoGo_Settings_SetUpdates()
  1556. ---------
  1557.     GoGo_Prefs.version = GetAddOnMetadata("GoGoMount", "Version")
  1558.     if not GoGo_Prefs.autodismount then GoGo_Prefs.autodismount = false end
  1559.     if not GoGo_Prefs.DisableUpdateNotice then GoGo_Prefs.DisableUpdateNotice = false end
  1560.     if not GoGo_Prefs.DisableMountNotice then GoGo_Prefs.DisableMountNotice = false end
  1561.     if not GoGo_Prefs.DebugMessages then GoGo_Prefs.DebugMessages = false end
  1562.     if not GoGo_Prefs.genericfastflyer then GoGo_Prefs.genericfastflyer = false end
  1563.     if not GoGo_Prefs.DruidClickForm then GoGo_Prefs.DruidClickForm = false end
  1564.     if not GoGo_Prefs.DruidFlightForm then GoGo_Prefs.DruidFlightForm = false end
  1565.     if not GoGo_Prefs.GlobalPrefMount then GoGo_Prefs.GlobalPrefMount = false end
  1566. --  if not GoGo_Prefs.PaliUseCrusader then GoGo_Prefs.PaliUseCrusader = false end
  1567.     GoGo_Prefs.UnknownMounts = {}
  1568. end --function
  1569.  
  1570.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement