Advertisement
Guest User

Untitled

a guest
Nov 21st, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.78 KB | None | 0 0
  1. -------------------------------- file 1: ---------------------------------------------------
  2.  
  3. DMU = {
  4.     MaxSourceFilters = 10,
  5.     MountGroundExceptions = {},
  6.     MountTypeToTravelType = {},
  7.     ZoneToExpansion = {},
  8.     TravelType = {
  9.         GROUND = 1,
  10.         FLYING = 2,
  11.         SWIMMING = 4,
  12.     },
  13.     Exp = {
  14.        BASE = 0,
  15.        BC = 1,
  16.        WRATH = 2,
  17.        CATA = 3,
  18.        PANDA = 4,
  19.        WOD = 5,
  20.        LEGION = 6,
  21.        BFA = 7,
  22.        SL = 8
  23.     },
  24. }
  25.  
  26. DMU.MountTypeToTravelType = {
  27.     [230] = DMU.TravelType.GROUND,
  28.     [231] = DMU.TravelType.SWIMMING,
  29.     [232] = DMU.TravelType.SWIMMING,
  30.     [241] = DMU.TravelType.GROUND,
  31.     [247] = DMU.TravelType.FLYING,
  32.     [248] = DMU.TravelType.FLYING,
  33.     [254] = DMU.TravelType.SWIMMING,
  34.     [269] = DMU.TravelType.GROUND,
  35.     [284] = DMU.TravelType.GROUND,
  36.     [398] = DMU.TravelType.FLYING
  37. }
  38.  
  39. DMU.ZoneToExpansion = {
  40.     [13]    = DMU.Exp.BASE, --- EasternKingdoms
  41.     [12]    = DMU.Exp.BASE, --- Kalimdor
  42.     [101]   = DMU.Exp.BC,   --- Outland
  43.     [113]   = DMU.Exp.WRATH,    --- Northrend
  44.     [424]   = DMU.Exp.PANDA,    --- Pandaria
  45.     [572]   = DMU.Exp.WOD,  --- Draenor
  46.     [619]   = DMU.Exp.LEGION,   --- BrokenIsles
  47.     [875]   = DMU.Exp.BFA,  --- Zandalar
  48.     [876]   = DMU.Exp.BFA,  --- KulTiras
  49.     [905]   = DMU.Exp.LEGION,   --- Argus
  50.     [948]   = DMU.Exp.CATA, --- TheMaelstrom
  51.     [985]   = DMU.Exp.BASE, --- EasternKingdoms
  52.     [986]   = DMU.Exp.BASE, --- Kalimdor
  53.     [987]   = DMU.Exp.BC,   --- Outland
  54.     [988]   = DMU.Exp.WRATH,    --- Northrend
  55.     [989]   = DMU.Exp.PANDA,    --- Pandaria
  56.     [990]   = DMU.Exp.WOD,  --- Draenor
  57.     [991]   = DMU.Exp.BFA,  --- Zandalar
  58.     [992]   = DMU.Exp.BFA,  --- KulTiras
  59.     [993]   = DMU.Exp.LEGION,   --- BrokenIsles
  60.     [994]   = DMU.Exp.LEGION,   --- Argus
  61.     [1011]  = DMU.Exp.BFA,  --- Zandalar
  62.     [1014]  = DMU.Exp.BFA,  --- KulTiras
  63.     [1208]  = DMU.Exp.BASE, --- EasternKingdoms
  64.     [1209]  = DMU.Exp.BASE, --- Kalimdor
  65.     [1384]  = DMU.Exp.WRATH,    --- Northrend
  66.     [1467]  = DMU.Exp.BC,   --- Outland
  67.     [1504]  = DMU.Exp.BFA,  --- Nazjatar
  68.     [1550]  = DMU.Exp.SL,   --- TheShadowlands
  69.     [1645]  = DMU.Exp.SL,   --- Torghast
  70.     [1647]  = DMU.Exp.SL    --- TheShadowlands
  71. }
  72.  
  73.  
  74.  
  75.  
  76.  
  77. --------------------------------- file 2 --------------------------------------------------
  78. local panel = CreateFrame("FRAME")
  79. panel.name = "Draugor's Mount Up"
  80. panel:RegisterEvent("ADDON_LOADED")
  81. InterfaceOptions_AddCategory(panel)
  82. panel:SetScript("OnEvent", function(self, event, arg1) 
  83.     if event == "ADDON_LOADED" and arg1 == "DrgrMountUp" then  
  84.         -- Our saved variables, if they exist, have been loaded at this point.
  85.         if DMU.MountGroundExceptions == nil then
  86.             -- This is the first time this addon is loaded; set SVs to default values
  87.             DMU.MountGroundExceptions = {
  88.                 [1011] = true   -- Shu zen
  89.             }
  90.         end
  91.     end
  92. end)
  93.  
  94.  
  95. DMU.AddContextMenuOption = function(level)
  96.     if not MountJournal.menuMountIndex then return; end
  97.     if C_MountJournal.NeedsFanfare(MountJournal.menuMountID) then return; end
  98.     --- local isFavorite, canFavorite = C_MountJournal.GetIsFavorite(MountJournal.menuMountIndex);
  99.     local mountTypeID = select(5,C_MountJournal.GetMountInfoExtraByID(MountJournal.menuMountID));
  100.     if DMU.MountTypeToTravelType[mountTypeID] == DMU.TravelType.GROUND then return; end
  101.    
  102.     local info = UIDropDownMenu_CreateInfo();  
  103.     info.text = "Exception";
  104.     info.checked = DMU.MountGroundExceptions[MountJournal.menuMountID];
  105.     info.func = function()
  106.         DMU.MountGroundExceptions[MountJournal.menuMountID] = not DMU.MountGroundExceptions[MountJournal.menuMountID]
  107.         for i,v in pairs(DMU.MountGroundExceptions) do
  108.             print(i,v)
  109.             -- printresult = printresult .. tostring(i) .. ": " .. tostring(v) .. "\n"
  110.         end
  111.     end
  112.     UIDropDownMenu_AddButton(info, level)
  113. end
  114.  
  115.  
  116. --- hooks ---
  117. local oldMountOptionsMenu_Init = MountOptionsMenu_Init;
  118. MountOptionsMenu_Init = function(...)
  119.     self, level = ... ;
  120.     DMU.AddContextMenuOption (level);  
  121.     oldMountOptionsMenu_Init(self, level, ...)
  122. end
  123. UIDropDownMenu_Initialize(MountJournal.mountOptionsMenu, MountOptionsMenu_Init, "MENU");
  124.  
  125. --- local frame = CreateFrame("Frame", "DMUOverlayFrame_", parentFrame) -- parentFrame =
  126. --- frame:SetAllPoints()
  127. --- local blubb = frame:CreateTexture("DMUOverlay", "OVERLAY")
  128. --- blubb:SetTexture(ICON, false) -- false ?
  129. --- blubb:SetPoint(unpack({"TOPRIGHT", -2, -2}))
  130.  
  131.  local orgMountUP = C_MountJournal.SummonByID;
  132.  C_MountJournal.SummonByID = function(...)
  133.     print("Mount Up !")
  134.     local summonID = ...;  
  135.     if summonID == 0 then
  136.         DMU.MountUp ();
  137.     else
  138.         orgMountUP(...);
  139.     end
  140.  end
  141.  
  142. -- hooksecurefunc(C_MountJournal, "SummonByID", function(mountID)
  143. --      print("hooked on a feeling ...", mountID)
  144. -- end)
  145.  
  146. -------------
  147.  
  148.  
  149.  DMU.MountUp = function()
  150.  --- deactivate all filters
  151.  
  152.  local tmp_filter1 = C_MountJournal.GetCollectedFilterSetting(1)
  153.  local tmp_filter2 = C_MountJournal.GetCollectedFilterSetting(2)
  154.  local SourceSet = {}
  155.  for i = 0, DMU.MaxSourceFilters do
  156.     if C_MountJournal.IsValidSourceFilter(i) then
  157.         SourceSet[i] =  C_MountJournal.IsSourceChecked(i)
  158.     end
  159.  end
  160.  
  161.  
  162.  
  163.  C_MountJournal.SetSearch("")
  164.  C_MountJournal.SetAllSourceFilters(true)
  165.  C_MountJournal.SetCollectedFilterSetting(1, true)
  166.  C_MountJournal.SetCollectedFilterSetting(2, false)
  167.  
  168.  
  169. --- C_MountJournal.SummonByID(0)
  170. --- /script print(IsSpellKnown(233368))
  171. --- /script cn, si, i, a, iu, st, iF, iFS, f, hoc, iC, mi =C_MountJournal.GetDisplayedMountInfo(1) print(mi)
  172. --- /script a,b,c,d,mountTypeID,e,f,g,h = C_MountJournal.GetDisplayedMountInfoExtra(1) print(mountTypeID)
  173. --- /script print(C_Map.GetMapInfo(C_Map.GetBestMapForUnit("player")))
  174.  
  175. ---1011 --- Shu zen
  176.  
  177.     local canFlyAtAll = IsSpellKnown(90265) or IsSpellKnown(34090) or IsSpellKnown(34091)
  178.     local canFlyInArea = IsFlyableArea()
  179.  
  180.  
  181.     local underWater = IsSubmerged()
  182.     local summonType = DMU.TravelType.FLYING
  183.     if not(canFlyInArea) then
  184.         summonType = DMU.TravelType.GROUND
  185.     elseif underWater then
  186.         summonType = DMU.TravelType.SWIMMING
  187.     else
  188.         local currentZoneID = C_Map.GetBestMapForUnit("player")
  189.         local currentZoneInfo = C_Map.GetMapInfo(currentZoneID)  
  190.         while currentZoneInfo.mapType > 2 do
  191.             currentZoneID = currentZoneInfo.parentMapID
  192.             currentZoneInfo = C_Map.GetMapInfo(currentZoneID)
  193.         end
  194.         if  currentZoneInfo.mapType == 2 then
  195.             local currentExpansion = DMU.ZoneToExpansion[currentZoneID]
  196.             local canFlyBFA = IsSpellKnown(278833) and canFlyAtAll
  197.             -- local canFlySL = IsSpellKnown(278833)// ToDo Spell ID
  198.             if ((currentExpansion == DMU.Exp.BFA) and not(canFlyBFA)) or (currentExpansion == DMU.Exp.SL ) or false then
  199.                 summonType = DMU.TravelType.GROUND
  200.             else
  201.                 if(canFlyAtAll and canFlyInArea) then
  202.                     summonType = DMU.TravelType.FLYING
  203.                 else
  204.                     summonType = DMU.TravelType.GROUND
  205.                 end
  206.             end
  207.         end
  208.     end
  209.     local summonID = 0
  210.         local ids = {}
  211.         local counter = 0
  212.         local numMounts = C_MountJournal.GetNumDisplayedMounts()
  213.         for i= 1, numMounts do
  214.             local name, spellID, icon, isActive, isUsable, sourceType, isFavorite, isFactionSpecific, faction, shouldHideOnChar, isCollected, mountID = C_MountJournal.GetDisplayedMountInfo(i)
  215.             if isUsable and isFavorite then
  216.                 local mountTypeID = select(5,C_MountJournal.GetMountInfoExtraByID(mountID))
  217.                 if (summonType == DMU.MountTypeToTravelType[mountTypeID]) or (DMU.MountGroundExceptions[mountID] and (summonType ~= DMU.TravelType.SWIMMING)) then
  218.                     print(summonType, DMU.MountGroundExceptions[mountID], DMU.MountTypeToTravelType[mountTypeID])
  219.                     table.insert(ids, mountID)
  220.                     counter = counter + 1
  221.                 end
  222.                
  223.             end
  224.         end
  225.        
  226.  
  227.         if counter>0 then
  228.             local rand = random(counter)
  229.             summonID = ids[rand]
  230.         end
  231.     if IsMounted() then
  232.         Dismount()
  233.     end
  234.  
  235.     for i = 0, DMU.MaxSourceFilters do
  236.         if C_MountJournal.IsValidSourceFilter(i) then
  237.             C_MountJournal.SetSourceFilter(i, SourceSet[i])
  238.         end
  239.     end
  240.     C_MountJournal.SetCollectedFilterSetting(1, tmp_filter1)
  241.     C_MountJournal.SetCollectedFilterSetting(2, tmp_filter2)
  242.     orgMountUP(summonID)
  243. end
  244.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement