diff --git a/src/main.lua b/src/main.lua index b3fc412..2e195f1 100644 --- a/src/main.lua +++ b/src/main.lua @@ -17,6 +17,23 @@ local NONFLYABLE_ZONES = { local RIDING_SKILLS = { [75] = false, [150] = false, [225] = true, [300] = true } +local MOUNT_SPELLS = { + DRUID = { + [40120] = 3, -- swift flight form + [33943] = 2, -- flight form + }, + PALADIN = { + [34767] = 1, -- Summon Charger (horde) + [34769] = 0, -- Summon Warhorse (horde) + [13819] = 0, -- Summon Warhorse (alliance) + [23214] = 1, -- Summon Charger (alliance) + }, + WARLOCK = { + [5784] = 0, -- Summon Felsteed + [23161] = 1, -- Summon Dreadsteed + }, +} + local function IsFlyable() local mapId = select(8, GetInstanceInfo()) if not FLYABLE_MAPS[mapId] then @@ -80,6 +97,16 @@ local function FindBestMount(flyable) end end end + + local mount_spells = MOUNT_SPELLS[(select(2, UnitClass("player")))] + if mount_spells then + for spellId, priority in pairs(mount_spells) do + if priority > bestPriority and priority <= maxPriority and C_SpellBook.IsSpellKnown(spellId) then + best = spellId + bestPriority = priority + end + end + end return best end @@ -93,13 +120,19 @@ local function MakeMountButton(name, forceGround) end local flyable = not forceGround and IsFlyable() local mount = FindBestMount(flyable) - if mount then + if mount and type(mount) == "table" then + self:SetAttribute("spell1", nil) + self:SetAttribute("type1", "item") self:SetAttribute("item1", mount.bag .. " " .. mount.slot) + elseif mount and type(mount) == "number" then + self:SetAttribute("type1", "spell") + self:SetAttribute("item1", nil) + self:SetAttribute("spell1", mount) else self:SetAttribute("item1", nil) + self:SetAttribute("spell1", nil) end end) - button:SetAttribute("type1", "item") return button end