Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------- file 1: ---------------------------------------------------
- DMU = {
- MaxSourceFilters = 10,
- MountGroundExceptions = {},
- MountTypeToTravelType = {},
- ZoneToExpansion = {},
- TravelType = {
- GROUND = 1,
- FLYING = 2,
- SWIMMING = 4,
- },
- Exp = {
- BASE = 0,
- BC = 1,
- WRATH = 2,
- CATA = 3,
- PANDA = 4,
- WOD = 5,
- LEGION = 6,
- BFA = 7,
- SL = 8
- },
- }
- DMU.MountTypeToTravelType = {
- [230] = DMU.TravelType.GROUND,
- [231] = DMU.TravelType.SWIMMING,
- [232] = DMU.TravelType.SWIMMING,
- [241] = DMU.TravelType.GROUND,
- [247] = DMU.TravelType.FLYING,
- [248] = DMU.TravelType.FLYING,
- [254] = DMU.TravelType.SWIMMING,
- [269] = DMU.TravelType.GROUND,
- [284] = DMU.TravelType.GROUND,
- [398] = DMU.TravelType.FLYING
- }
- DMU.ZoneToExpansion = {
- [13] = DMU.Exp.BASE, --- EasternKingdoms
- [12] = DMU.Exp.BASE, --- Kalimdor
- [101] = DMU.Exp.BC, --- Outland
- [113] = DMU.Exp.WRATH, --- Northrend
- [424] = DMU.Exp.PANDA, --- Pandaria
- [572] = DMU.Exp.WOD, --- Draenor
- [619] = DMU.Exp.LEGION, --- BrokenIsles
- [875] = DMU.Exp.BFA, --- Zandalar
- [876] = DMU.Exp.BFA, --- KulTiras
- [905] = DMU.Exp.LEGION, --- Argus
- [948] = DMU.Exp.CATA, --- TheMaelstrom
- [985] = DMU.Exp.BASE, --- EasternKingdoms
- [986] = DMU.Exp.BASE, --- Kalimdor
- [987] = DMU.Exp.BC, --- Outland
- [988] = DMU.Exp.WRATH, --- Northrend
- [989] = DMU.Exp.PANDA, --- Pandaria
- [990] = DMU.Exp.WOD, --- Draenor
- [991] = DMU.Exp.BFA, --- Zandalar
- [992] = DMU.Exp.BFA, --- KulTiras
- [993] = DMU.Exp.LEGION, --- BrokenIsles
- [994] = DMU.Exp.LEGION, --- Argus
- [1011] = DMU.Exp.BFA, --- Zandalar
- [1014] = DMU.Exp.BFA, --- KulTiras
- [1208] = DMU.Exp.BASE, --- EasternKingdoms
- [1209] = DMU.Exp.BASE, --- Kalimdor
- [1384] = DMU.Exp.WRATH, --- Northrend
- [1467] = DMU.Exp.BC, --- Outland
- [1504] = DMU.Exp.BFA, --- Nazjatar
- [1550] = DMU.Exp.SL, --- TheShadowlands
- [1645] = DMU.Exp.SL, --- Torghast
- [1647] = DMU.Exp.SL --- TheShadowlands
- }
- --------------------------------- file 2 --------------------------------------------------
- local panel = CreateFrame("FRAME")
- panel.name = "Draugor's Mount Up"
- panel:RegisterEvent("ADDON_LOADED")
- InterfaceOptions_AddCategory(panel)
- panel:SetScript("OnEvent", function(self, event, arg1)
- if event == "ADDON_LOADED" and arg1 == "DrgrMountUp" then
- -- Our saved variables, if they exist, have been loaded at this point.
- if DMU.MountGroundExceptions == nil then
- -- This is the first time this addon is loaded; set SVs to default values
- DMU.MountGroundExceptions = {
- [1011] = true -- Shu zen
- }
- end
- end
- end)
- DMU.AddContextMenuOption = function(level)
- if not MountJournal.menuMountIndex then return; end
- if C_MountJournal.NeedsFanfare(MountJournal.menuMountID) then return; end
- --- local isFavorite, canFavorite = C_MountJournal.GetIsFavorite(MountJournal.menuMountIndex);
- local mountTypeID = select(5,C_MountJournal.GetMountInfoExtraByID(MountJournal.menuMountID));
- if DMU.MountTypeToTravelType[mountTypeID] == DMU.TravelType.GROUND then return; end
- local info = UIDropDownMenu_CreateInfo();
- info.text = "Exception";
- info.checked = DMU.MountGroundExceptions[MountJournal.menuMountID];
- info.func = function()
- DMU.MountGroundExceptions[MountJournal.menuMountID] = not DMU.MountGroundExceptions[MountJournal.menuMountID]
- for i,v in pairs(DMU.MountGroundExceptions) do
- print(i,v)
- -- printresult = printresult .. tostring(i) .. ": " .. tostring(v) .. "\n"
- end
- end
- UIDropDownMenu_AddButton(info, level)
- end
- --- hooks ---
- local oldMountOptionsMenu_Init = MountOptionsMenu_Init;
- MountOptionsMenu_Init = function(...)
- self, level = ... ;
- DMU.AddContextMenuOption (level);
- oldMountOptionsMenu_Init(self, level, ...)
- end
- UIDropDownMenu_Initialize(MountJournal.mountOptionsMenu, MountOptionsMenu_Init, "MENU");
- --- local frame = CreateFrame("Frame", "DMUOverlayFrame_", parentFrame) -- parentFrame =
- --- frame:SetAllPoints()
- --- local blubb = frame:CreateTexture("DMUOverlay", "OVERLAY")
- --- blubb:SetTexture(ICON, false) -- false ?
- --- blubb:SetPoint(unpack({"TOPRIGHT", -2, -2}))
- local orgMountUP = C_MountJournal.SummonByID;
- C_MountJournal.SummonByID = function(...)
- print("Mount Up !")
- local summonID = ...;
- if summonID == 0 then
- DMU.MountUp ();
- else
- orgMountUP(...);
- end
- end
- -- hooksecurefunc(C_MountJournal, "SummonByID", function(mountID)
- -- print("hooked on a feeling ...", mountID)
- -- end)
- -------------
- DMU.MountUp = function()
- --- deactivate all filters
- local tmp_filter1 = C_MountJournal.GetCollectedFilterSetting(1)
- local tmp_filter2 = C_MountJournal.GetCollectedFilterSetting(2)
- local SourceSet = {}
- for i = 0, DMU.MaxSourceFilters do
- if C_MountJournal.IsValidSourceFilter(i) then
- SourceSet[i] = C_MountJournal.IsSourceChecked(i)
- end
- end
- C_MountJournal.SetSearch("")
- C_MountJournal.SetAllSourceFilters(true)
- C_MountJournal.SetCollectedFilterSetting(1, true)
- C_MountJournal.SetCollectedFilterSetting(2, false)
- --- C_MountJournal.SummonByID(0)
- --- /script print(IsSpellKnown(233368))
- --- /script cn, si, i, a, iu, st, iF, iFS, f, hoc, iC, mi =C_MountJournal.GetDisplayedMountInfo(1) print(mi)
- --- /script a,b,c,d,mountTypeID,e,f,g,h = C_MountJournal.GetDisplayedMountInfoExtra(1) print(mountTypeID)
- --- /script print(C_Map.GetMapInfo(C_Map.GetBestMapForUnit("player")))
- ---1011 --- Shu zen
- local canFlyAtAll = IsSpellKnown(90265) or IsSpellKnown(34090) or IsSpellKnown(34091)
- local canFlyInArea = IsFlyableArea()
- local underWater = IsSubmerged()
- local summonType = DMU.TravelType.FLYING
- if not(canFlyInArea) then
- summonType = DMU.TravelType.GROUND
- elseif underWater then
- summonType = DMU.TravelType.SWIMMING
- else
- local currentZoneID = C_Map.GetBestMapForUnit("player")
- local currentZoneInfo = C_Map.GetMapInfo(currentZoneID)
- while currentZoneInfo.mapType > 2 do
- currentZoneID = currentZoneInfo.parentMapID
- currentZoneInfo = C_Map.GetMapInfo(currentZoneID)
- end
- if currentZoneInfo.mapType == 2 then
- local currentExpansion = DMU.ZoneToExpansion[currentZoneID]
- local canFlyBFA = IsSpellKnown(278833) and canFlyAtAll
- -- local canFlySL = IsSpellKnown(278833)// ToDo Spell ID
- if ((currentExpansion == DMU.Exp.BFA) and not(canFlyBFA)) or (currentExpansion == DMU.Exp.SL ) or false then
- summonType = DMU.TravelType.GROUND
- else
- if(canFlyAtAll and canFlyInArea) then
- summonType = DMU.TravelType.FLYING
- else
- summonType = DMU.TravelType.GROUND
- end
- end
- end
- end
- local summonID = 0
- local ids = {}
- local counter = 0
- local numMounts = C_MountJournal.GetNumDisplayedMounts()
- for i= 1, numMounts do
- local name, spellID, icon, isActive, isUsable, sourceType, isFavorite, isFactionSpecific, faction, shouldHideOnChar, isCollected, mountID = C_MountJournal.GetDisplayedMountInfo(i)
- if isUsable and isFavorite then
- local mountTypeID = select(5,C_MountJournal.GetMountInfoExtraByID(mountID))
- if (summonType == DMU.MountTypeToTravelType[mountTypeID]) or (DMU.MountGroundExceptions[mountID] and (summonType ~= DMU.TravelType.SWIMMING)) then
- print(summonType, DMU.MountGroundExceptions[mountID], DMU.MountTypeToTravelType[mountTypeID])
- table.insert(ids, mountID)
- counter = counter + 1
- end
- end
- end
- if counter>0 then
- local rand = random(counter)
- summonID = ids[rand]
- end
- if IsMounted() then
- Dismount()
- end
- for i = 0, DMU.MaxSourceFilters do
- if C_MountJournal.IsValidSourceFilter(i) then
- C_MountJournal.SetSourceFilter(i, SourceSet[i])
- end
- end
- C_MountJournal.SetCollectedFilterSetting(1, tmp_filter1)
- C_MountJournal.SetCollectedFilterSetting(2, tmp_filter2)
- orgMountUP(summonID)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement