Add Flight Finder

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-12 14:47:59 +00:00
parent e2f18f5fd6
commit 0a810dc451
9 changed files with 720 additions and 2 deletions

73
FlightFinder/Data.lua Normal file
View file

@ -0,0 +1,73 @@
-- Generated by tools/generate.py from TaxiNodes.db2. Do not edit.
-- [nodeID] = { instance, world x, world y, faction, name }
local _, ns = ...
ns.nodes = {
[2] = { 0, -8832.8, 478.6, "Alliance", "Stormwind, Elwynn" },
[4] = { 0, -10628.9, 1036.7, "Alliance", "Sentinel Hill, Westfall" },
[5] = { 0, -9429.1, -2231.4, "Alliance", "Lakeshire, Redridge" },
[6] = { 0, -4821.8, -1155.4, "Alliance", "Ironforge, Dun Morogh" },
[7] = { 0, -3792.3, -783.3, "Alliance", "Menethil Harbor, Wetlands" },
[8] = { 0, -5421.9, -2930.0, "Alliance", "Thelsamar, Loch Modan" },
[10] = { 0, 478.9, 1536.6, "Horde", "The Sepulcher, Silverpine Forest" },
[11] = { 0, 1568.6, 268.0, "Horde", "Undercity, Tirisfal" },
[12] = { 0, -10515.5, -1261.7, "Alliance", "Darkshire, Duskwood" },
[13] = { 0, -0.1, -859.9, "Horde", "Tarren Mill, Hillsbrad" },
[14] = { 0, -711.5, -515.5, "Alliance", "Southshore, Hillsbrad" },
[16] = { 0, -1240.5, -2515.1, "Alliance", "Refuge Pointe, Arathi" },
[17] = { 0, -916.3, -3496.9, "Horde", "Hammerfall, Arathi" },
[18] = { 0, -14444.3, 509.6, "Horde", "Booty Bay, Stranglethorn" },
[19] = { 0, -14473.0, 464.1, "Alliance", "Booty Bay, Stranglethorn" },
[20] = { 0, -12414.2, 146.3, "Horde", "Grom'gol, Stranglethorn" },
[21] = { 0, -6634.0, -2180.1, "Horde", "Kargath, Badlands" },
[22] = { 1, -1197.2, 29.7, "Horde", "Thunder Bluff, Mulgore" },
[23] = { 1, 1677.6, -4315.7, "Horde", "Orgrimmar, Durotar" },
[25] = { 1, -441.8, -2596.1, "Horde", "Crossroads, The Barrens" },
[26] = { 1, 6341.4, 557.7, "Alliance", "Auberdine, Darkshore" },
[27] = { 1, 8643.6, 841.0, "Alliance", "Rut'theran Village, Teldrassil" },
[28] = { 1, 2827.3, -289.2, "Alliance", "Astranaar, Ashenvale" },
[29] = { 1, 966.6, 1040.3, "Horde", "Sun Rock Retreat, Stonetalon Mountains" },
[30] = { 1, -5407.7, -2414.3, "Horde", "Freewind Post, Thousand Needles" },
[31] = { 1, -4491.9, -775.9, "Alliance", "Thalanaar, Feralas" },
[32] = { 1, -3825.4, -4516.6, "Alliance", "Theramore, Dustwallow Marsh" },
[33] = { 1, 2681.1, 1461.7, "Alliance", "Stonetalon Peak, Stonetalon Mountains" },
[37] = { 1, 139.2, 1325.8, "Alliance", "Nijel's Point, Desolace" },
[38] = { 1, -1767.6, 3263.9, "Horde", "Shadowprey Village, Desolace" },
[39] = { 1, -7224.0, -3734.6, "Alliance", "Gadgetzan, Tanaris" },
[40] = { 1, -7048.9, -3780.4, "Horde", "Gadgetzan, Tanaris" },
[41] = { 1, -4373.8, 3338.6, "Alliance", "Feathermoon, Feralas" },
[42] = { 1, -4419.9, 199.3, "Horde", "Camp Mojache, Feralas" },
[43] = { 0, 283.7, -2002.8, "Alliance", "Aerie Peak, The Hinterlands" },
[44] = { 1, 3661.5, -4390.4, "Horde", "Valormok, Azshara" },
[45] = { 0, -11112.2, -3435.7, "Alliance", "Nethergarde Keep, Blasted Lands" },
[48] = { 1, 5068.4, -337.2, "Horde", "Bloodvenom Post, Felwood" },
[49] = { 1, 7458.5, -2487.2, "Alliance", "Moonglade" },
[52] = { 1, 6799.2, -4742.4, "Alliance", "Everlook, Winterspring" },
[53] = { 1, 6813.1, -4611.1, "Horde", "Everlook, Winterspring" },
[55] = { 1, -3147.4, -2842.2, "Horde", "Brackenwall Village, Dustwallow Marsh" },
[56] = { 0, -10457.0, -3279.2, "Horde", "Stonard, Swamp of Sorrows" },
[58] = { 1, 3374.7, 997.0, "Horde", "Zoram'gar Outpost, Ashenvale" },
[61] = { 1, 2302.4, -2524.6, "Horde", "Splintertree Post, Ashenvale" },
[64] = { 1, 2722.0, -3880.6, "Alliance", "Talrendis Point, Azshara" },
[65] = { 1, 6205.9, -1949.6, "Alliance", "Talonbranch Glade, Felwood" },
[66] = { 0, 931.3, -1430.1, "Alliance", "Chillwind Camp, Western Plaguelands" },
[67] = { 0, 2271.1, -5340.8, "Alliance", "Light's Hope Chapel, Eastern Plaguelands" },
[68] = { 0, 2327.4, -5286.9, "Horde", "Light's Hope Chapel, Eastern Plaguelands" },
[69] = { 1, 7470.4, -2123.4, "Horde", "Moonglade" },
[70] = { 0, -7504.0, -2187.5, "Horde", "Flame Crest, Burning Steppes" },
[71] = { 0, -8364.6, -2738.4, "Alliance", "Morgan's Vigil, Burning Steppes" },
[72] = { 1, -6811.4, 836.7, "Horde", "Cenarion Hold, Silithus" },
[73] = { 1, -6761.8, 772.0, "Alliance", "Cenarion Hold, Silithus" },
[74] = { 0, -6552.6, -1168.3, "Alliance", "Thorium Point, Searing Gorge" },
[75] = { 0, -6554.9, -1100.1, "Horde", "Thorium Point, Searing Gorge" },
[76] = { 0, -635.3, -4720.5, "Horde", "Revantusk Village, The Hinterlands" },
[77] = { 1, -2380.7, -1882.7, "Horde", "Camp Taurajo, The Barrens" },
[79] = { 1, -6113.8, -1142.7, "Neutral", "Marshal's Refuge, Un'Goro Crater" },
[80] = { 1, -894.6, -3773.0, "Neutral", "Ratchet, The Barrens" },
[559] = { 1, 5283.2, -3306.7, "Neutral", "Summit of Eternity, Mount Hyjal" },
[3203] = { 0, -7923.7, -4783.0, "Horde", "Rog'mar, Riverglades" },
[3242] = { 1, 4393.5, -2836.4, "Neutral", "Tainted Foothills, Mount Hyjal" },
[3274] = { 0, -8157.2, -5724.7, "Neutral", "Powderfuse Port, Riverglades" },
[3275] = { 0, -8180.0, -5616.3, "Neutral", "Powderfuse Port, Riverglades" },
[3276] = { 0, -9104.1, -4830.5, "Alliance", "Farholde Keep, Riverglades" },
}

View file

@ -0,0 +1,355 @@
-- Flight Finder: marks the flight masters you haven't discovered yet on zone and continent
-- maps. Flight master positions are in Data.lua (generated from the client's TaxiNodes.db2).
--
-- A flight point counts as discovered when Blizzard's map API lists it as discovered for its
-- zone, or when a flight master's taxi map showed it as a destination. Both are remembered
-- per character, so continent maps and zones you haven't opened yet stay right.
local addonName, ns = ...
local PREFIX = "|cff66bbffFlight Finder|r: "
local TEMPLATE = "FlightFinderPinTemplate"
local GLYPH = "Interface\\Minimap\\Tracking\\FlightMaster"
local COLORS = {
Alliance = { 0.35, 0.62, 1.00 },
Horde = { 1.00, 0.32, 0.24 },
Neutral = { 1.00, 0.82, 0.25 },
}
local SAME_PLACE = 400 -- yards: flight masters with one name this close count as one place
local db, known
local function Visible(id)
local f = ns.nodes[id][4]
return f == "Neutral" or f == UnitFactionGroup("player")
end
---------------------------------------------------------------------------
-- Groups: one marker per place, discovered if any of its flight masters is
---------------------------------------------------------------------------
local groups, byName = {}, {}
for id, n in pairs(ns.nodes) do
byName[n[5]] = byName[n[5]] or {}
table.insert(byName[n[5]], id)
end
for _, ids in pairs(byName) do
table.sort(ids)
for _, a in ipairs(ids) do
local g = {}
for _, b in ipairs(ids) do
local na, nb = ns.nodes[a], ns.nodes[b]
if na[1] == nb[1] and math.sqrt((na[2] - nb[2]) ^ 2 + (na[3] - nb[3]) ^ 2) <= SAME_PLACE then
g[#g + 1] = b
end
end
groups[a] = g
end
end
ns.groups, ns.byName = groups, byName
local function Discovered(id)
for _, other in ipairs(groups[id]) do
if known[other] and Visible(other) then
return true
end
end
return false
end
-- the marker for a place goes on its lowest visible node
local function Leader(id)
for _, other in ipairs(groups[id]) do
if Visible(other) then
return other == id
end
end
return false
end
---------------------------------------------------------------------------
-- Projection: world position -> position on a uiMap, and which maps a node sits in
---------------------------------------------------------------------------
local rects = {}
local function Rect(uiMapID)
local cached = rects[uiMapID]
if cached ~= nil then
return cached or nil
end
local r = false
local inst, topLeft = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0, 0))
local _, mid = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0.5, 0.5))
if inst and topLeft and mid then
local top, left = topLeft:GetXY()
local midTop, midLeft = mid:GetXY()
local height, width = (top - midTop) * 2, (left - midLeft) * 2
if height ~= 0 and width ~= 0 then
r = { inst = inst, top = top, left = left, height = height, width = width }
end
end
rects[uiMapID] = r
return r or nil
end
local function Project(uiMapID, id)
local r, n = Rect(uiMapID), ns.nodes[id]
if not r or r.inst ~= n[1] then
return nil
end
local u, v = (r.left - n[3]) / r.width, (r.top - n[2]) / r.height
if u < 0 or u > 1 or v < 0 or v > 1 then
return nil
end
return u, v
end
ns.Project = Project
-- the map the client places a node on, plus every map above it
local chains = {}
local function Chain(id)
local c = chains[id]
if c then
return c
end
local n = ns.nodes[id]
c = { maps = {} }
local ok, mapID = pcall(C_Map.GetMapPosFromWorldPos, n[1], CreateVector2D(n[2], n[3]))
for _ = 1, 10 do
if not ok or not mapID or mapID == 0 or c.maps[mapID] then
break
end
local info = C_Map.GetMapInfo(mapID)
if not info then
break
end
c.maps[mapID] = true
c.found = true
if not c.zone and info.mapType == Enum.UIMapType.Zone then
c.zone = mapID
end
mapID = info.parentMapID
end
chains[id] = c
return c
end
-- whether node id belongs on uiMapID, and where
local function Place(uiMapID, mapType, id)
local c = Chain(id)
if c.found then
if not c.maps[uiMapID] then
return nil
end
elseif mapType ~= Enum.UIMapType.Continent then
return nil -- client can't say which zone it's in: only trust the continent map
end
return Project(uiMapID, id)
end
---------------------------------------------------------------------------
-- Learning which flight points the character has
---------------------------------------------------------------------------
-- Blizzard's own map list for a zone; learns its discovered nodes
local function LearnZone(uiMapID)
if not (C_TaxiMap and C_TaxiMap.GetTaxiNodesForMap) then
return
end
local ok, list = pcall(C_TaxiMap.GetTaxiNodesForMap, uiMapID)
if ok and type(list) == "table" then
for _, info in ipairs(list) do
if info.nodeID and not info.isUndiscovered then
known[info.nodeID] = true
end
end
end
end
-- a flight master's taxi map lists every node on the continent; "NONE" ones aren't known yet
local function LearnTaxiMap()
if not (NumTaxiNodes and TaxiNodeName and TaxiNodeGetType) then
return
end
for i = 1, NumTaxiNodes() do
if TaxiNodeGetType(i) ~= "NONE" then
for _, id in ipairs(byName[TaxiNodeName(i)] or {}) do
if Visible(id) then
known[id] = true
end
end
end
end
end
ns.LearnTaxiMap = LearnTaxiMap
---------------------------------------------------------------------------
-- Map data provider
---------------------------------------------------------------------------
local SHOWN_ON = {
[Enum.UIMapType.Continent] = true,
[Enum.UIMapType.Zone] = true,
[Enum.UIMapType.Micro or 5] = true,
}
local provider = CreateFromMixins(MapCanvasDataProviderMixin)
ns.provider = provider
function provider:RemoveAllData()
self:GetMap():RemoveAllPinsByTemplate(TEMPLATE)
end
function provider:RefreshAllData()
self:RemoveAllData()
if db.hidden then
return
end
local map = self:GetMap()
local mapID = map:GetMapID()
local info = mapID and C_Map.GetMapInfo(mapID)
if not info or not SHOWN_ON[info.mapType] then
return
end
local learned = {}
for id in pairs(ns.nodes) do
if Visible(id) and Leader(id) then
local u, v = Place(mapID, info.mapType, id)
if u then
local zone = Chain(id).zone
if zone and not learned[zone] then
learned[zone] = true
LearnZone(zone)
end
if not Discovered(id) then
map:AcquirePin(TEMPLATE, id):SetPosition(u, v)
end
end
end
end
end
function provider:OnShow()
self:RegisterEvent("TAXI_NODE_STATUS_CHANGED")
end
function provider:OnHide()
self:UnregisterEvent("TAXI_NODE_STATUS_CHANGED")
end
function provider:OnEvent()
self:RefreshAllData()
end
---------------------------------------------------------------------------
-- Pins
---------------------------------------------------------------------------
FlightFinderPinMixin = CreateFromMixins(MapCanvasPinMixin)
function FlightFinderPinMixin:OnLoad()
self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI")
self:SetScalingLimits(1, 1.0, 1.25)
end
function FlightFinderPinMixin:OnAcquired(id)
self.nodeID = id
local c = COLORS[ns.nodes[id][4]]
self.Disc:SetVertexColor(0.06, 0.06, 0.08, 0.9)
self.Ring:SetVertexColor(c[1], c[2], c[3], 1)
self.Glyph:SetTexture(GLYPH)
self:CheckMouseButtonPassthrough("RightButton")
end
-- where a waypoint for the node goes: its zone map, since continents don't take waypoints
local function WaypointPoint(id, mapID)
if not (C_Map.CanSetUserWaypointOnMap and C_Map.SetUserWaypoint and UiMapPoint) then
return nil
end
for _, m in ipairs({ Chain(id).zone or mapID, mapID }) do
local u, v = Project(m, id)
if u and C_Map.CanSetUserWaypointOnMap(m) then
return UiMapPoint.CreateFromCoordinates(m, u, v)
end
end
end
function FlightFinderPinMixin:OnMouseEnter()
local n = ns.nodes[self.nodeID]
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:AddLine(n[5], 1, 1, 1)
local c = COLORS[n[4]]
GameTooltip:AddLine(n[4] == "Neutral" and "Undiscovered flight point" or ("Undiscovered " .. n[4] .. " flight point"), c[1], c[2], c[3])
if WaypointPoint(self.nodeID, self:GetMap():GetMapID()) then
GameTooltip:AddLine("Click to set a waypoint", 0.6, 0.6, 0.6)
end
GameTooltip:Show()
end
function FlightFinderPinMixin:OnMouseLeave()
GameTooltip:Hide()
end
function FlightFinderPinMixin:OnMouseClickAction(button)
if button ~= "LeftButton" then
return
end
local point = WaypointPoint(self.nodeID, self:GetMap():GetMapID())
if point then
C_Map.SetUserWaypoint(point)
if C_SuperTrack and C_SuperTrack.SetSuperTrackedUserWaypoint then
C_SuperTrack.SetSuperTrackedUserWaypoint(true)
end
end
end
---------------------------------------------------------------------------
-- Setup and slash command
---------------------------------------------------------------------------
local function Refresh()
if provider:GetMap() then
provider:RefreshAllData()
end
end
local attached = false
local function Attach()
if not attached and WorldMapFrame and WorldMapFrame.AddDataProvider then
attached = true
WorldMapFrame:AddDataProvider(provider)
end
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("TAXIMAP_OPENED")
frame:SetScript("OnEvent", function(_, event, name)
if event == "TAXIMAP_OPENED" then
LearnTaxiMap()
Refresh()
elseif name == addonName then
FlightFinderDB = FlightFinderDB or {}
FlightFinderCharDB = FlightFinderCharDB or {}
FlightFinderCharDB.known = FlightFinderCharDB.known or {}
db, known = FlightFinderDB, FlightFinderCharDB.known
Attach()
elseif name == "Blizzard_WorldMap" then
Attach()
end
end)
SLASH_FLIGHTFINDER1 = "/ff"
SlashCmdList.FLIGHTFINDER = function()
db.hidden = not db.hidden
local total, have = 0, 0
for id in pairs(ns.nodes) do
if Visible(id) and Leader(id) then
total = total + 1
if Discovered(id) then
have = have + 1
end
end
end
print(PREFIX .. (db.hidden and "hidden. " or "shown. ") .. string.format("%d / %d flight points known.", have, total))
Refresh()
end

View file

@ -0,0 +1,10 @@
## Interface: 16001
## Title: Flight Finder
## Notes: Marks the flight masters you haven't discovered yet on zone and continent maps.
## Version: 1.0
## SavedVariables: FlightFinderDB
## SavedVariablesPerCharacter: FlightFinderCharDB
Data.lua
FlightFinder.lua
FlightFinder.xml

View file

@ -0,0 +1,24 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Frame name="FlightFinderPinTemplate" mixin="FlightFinderPinMixin" enableMouse="true" virtual="true">
<Size x="20" y="20"/>
<Layers>
<Layer level="BACKGROUND">
<Texture parentKey="Disc" file="Interface\AddOns\FlightFinder\Icons\disc" setAllPoints="true"/>
</Layer>
<Layer level="BORDER">
<Texture parentKey="Ring" file="Interface\AddOns\FlightFinder\Icons\ring" setAllPoints="true"/>
</Layer>
<Layer level="ARTWORK">
<Texture parentKey="Glyph">
<Anchors>
<Anchor point="TOPLEFT" x="3" y="-3"/>
<Anchor point="BOTTOMRIGHT" x="-3" y="3"/>
</Anchors>
</Texture>
</Layer>
</Layers>
<Scripts>
<OnLoad method="OnLoad"/>
</Scripts>
</Frame>
</Ui>

BIN
FlightFinder/Icons/disc.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
FlightFinder/Icons/ring.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -0,0 +1,39 @@
"""Builds FlightFinder/Data.lua from the client's TaxiNodes.db2 (FileDataID 1068100).
usage: python3 generate.py <TaxiNodes.db2> <Data.lua>
A node counts as a flight master when it has a CharacterBitNumber (the bit that records
it as learned) and isn't a placeholder (old "zz" nodes, the zeppelin world target).
Faction comes from the Flags field: 0x1 shows on the Alliance map, 0x2 on the Horde map;
both or neither means neutral.
"""
import os, sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "ShipRoutes", "tools"))
from wdc5 import read, f32, string
F_NAME, F_POS, F_ID, F_INST, F_BIT, F_FLAGS = 0, 1, 4, 5, 7, 8
HIDDEN = 0x80 # "don't show in the world map UI"
SKIP = ("zz", "Generic,", "Transport,", "Quest Path") # placeholders that still carry a bit
rows, finfo = read(sys.argv[1])
assert len(finfo) == 15, "TaxiNodes layout changed: %d fields" % len(finfo)
out = []
for r in sorted(rows, key=lambda r: r["id"]):
v = r["fields"]
name = string(r, finfo, F_NAME)
flags = v[F_FLAGS]
if v[F_BIT] == 0 or name.startswith(SKIP) or flags & HIDDEN:
continue
x, y = f32(v[F_POS][0]), f32(v[F_POS][1])
faction = {1: "Alliance", 2: "Horde"}.get(flags & 3, "Neutral")
out.append(' [%d] = { %d, %.1f, %.1f, "%s", "%s" },' % (
r["id"], v[F_INST], x, y, faction, name.replace("\\", "\\\\").replace('"', '\\"')))
with open(sys.argv[2], "w") as f:
f.write("-- Generated by tools/generate.py from TaxiNodes.db2. Do not edit.\n")
f.write("-- [nodeID] = { instance, world x, world y, faction, name }\n")
f.write("local _, ns = ...\n\nns.nodes = {\n")
f.write("\n".join(out))
f.write("\n}\n")
print(len(out), "flight masters", file=sys.stderr)