Initial commit

This commit is contained in:
2026-07-02 19:11:13 +02:00
commit 085f148337
7 changed files with 196 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
build/
+1
View File
@@ -0,0 +1 @@
indent_type = "Spaces"
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2026 <omicron.me@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+33
View File
@@ -0,0 +1,33 @@
.PHONY: all addon txz zip clean
SRC_FILES := $(wildcard src/*)
ROOT_FILES := LICENSE.md README.md
SOURCES := $(SRC_FILES) $(ROOT_FILES)
ADDON_NAME := LocationMount
BUILD_DIR := build
ADDON_DIR := $(BUILD_DIR)/$(ADDON_NAME)
BUILD_SOURCES := $(patsubst src/%,$(ADDON_DIR)/%,$(SRC_FILES)) \
$(addprefix $(ADDON_DIR)/,$(ROOT_FILES))
$(ADDON_DIR)/%: src/%
mkdir -p $(dir $@)
cp $< $@
$(ADDON_DIR)/%: %
mkdir -p $(dir $@)
cp $< $@
addon: $(BUILD_SOURCES)
txz: addon
tar -cJf $(BUILD_DIR)/$(ADDON_NAME).tar.xz -C $(BUILD_DIR) $(ADDON_NAME)
zip: addon
cd $(BUILD_DIR) && 7z a $(ADDON_NAME).zip $(ADDON_NAME)
all: txz zip
clean:
rm -rf $(BUILD_DIR)
+22
View File
@@ -0,0 +1,22 @@
# What
LocationMount is a small addon that provides a macro command to automatically
select the correct mount based on your current location. It will prioritize
flying mounts over ground mounts and epic mounts over rare mounts. There is no
configuration.
# How
Install the addon and make a macro:
```
/click LocationMount
```
or if for some reason you want one that only picks the correct ground mount:
```
/click LocationMountGround
```
# Why not just use a [flyable] macro?
In TBC anniversary the flyable condition (and the related `IsFlyableArea()`
API) appears broken and returns true in many more zones than it should.
+7
View File
@@ -0,0 +1,7 @@
## Interface: 20504
## Title: Location Mount
## Notes: Add a macro command that uses the correct mount for the current location
## Version: 0.1.0
## IconTexture: 132245
main.lua
+113
View File
@@ -0,0 +1,113 @@
local scanTooltip
local FLYABLE_MAPS = {
[530] = true, -- Outland (TBC)
}
-- zones that share a flyable instanceMapID but are not flyable
-- using UI map IDs as a proxy for zones
local NONFLYABLE_ZONES = {
[1941] = true, -- Eversong Woods
[1942] = true, -- Ghostlands
[1943] = true, -- Azuremyst Isle
[1947] = true, -- The Exodar
[1950] = true, -- Bloodmyst Isle
[1954] = true, -- Silvermoon City
}
local RIDING_SKILLS = { [75] = false, [150] = false, [225] = true, [300] = true }
local function IsFlyable()
local mapId = select(8, GetInstanceInfo())
if not FLYABLE_MAPS[mapId] then
return false
end
local mapId = C_Map.GetBestMapForUnit("player")
return not NONFLYABLE_ZONES[mapId]
end
local function IsFlyingMount(link)
scanTooltip:ClearLines()
scanTooltip:SetHyperlink(link)
for i = 1, scanTooltip:NumLines() do
local text = _G["LocationMountScanTooltipTextLeft" .. i]:GetText()
if text then
local skill = tonumber(string.match(text, "%((%d+)%)"))
local flying = skill and RIDING_SKILLS[skill]
if flying ~= nil then
return flying
end
end
end
return false
end
local function GetMountPriority(bag, slot)
local link = C_Container.GetContainerItemLink(bag, slot)
if not link then
return -1
end
local name, _, rarity, _, _, _, _, _, _, _, _, classID, subclassID = GetItemInfo(link)
if not name then
return -1
end
if classID ~= Enum.ItemClass.Miscellaneous or subclassID ~= Enum.ItemMiscellaneousSubclass.Mount then
return -1
end
local isFlying = IsFlyingMount(link)
local isEpic = rarity == Enum.ItemQuality.Epic
local priority = (isFlying and 2 or 0) + (isEpic and 1 or 0)
return priority
end
local function FindBestMount(flyable)
local best, bestPriority = nil, -1
local maxPriority = flyable and 3 or 1
for bag = 0, 4 do
for slot = 1, C_Container.GetContainerNumSlots(bag) do
local priority = GetMountPriority(bag, slot)
if priority > bestPriority and priority <= maxPriority then
bestPriority = priority
best = { bag = bag, slot = slot }
if bestPriority == maxPriority then
return best
end
end
end
end
return best
end
local function MakeMountButton(name, forceGround)
local button = CreateFrame("Button", name, UIParent, "SecureActionButtonTemplate")
button:SetAttribute("useOnKeyDown", false)
button:RegisterForClicks("AnyDown")
button:SetScript("PreClick", function(self)
if InCombatLockdown() then
return
end
local flyable = not forceGround and IsFlyable()
local mount = FindBestMount(flyable)
if mount then
self:SetAttribute("item1", mount.bag .. " " .. mount.slot)
else
self:SetAttribute("item1", nil)
end
end)
button:SetAttribute("type1", "item")
return button
end
local function main()
scanTooltip = CreateFrame("GameTooltip", "LocationMountScanTooltip", nil, "GameTooltipTemplate")
scanTooltip:SetOwner(UIParent, "ANCHOR_NONE")
MakeMountButton("LocationMount", false)
MakeMountButton("LocationMountGround", true)
end
main()