Add Flight Finder
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e2f18f5fd6
commit
0a810dc451
9 changed files with 720 additions and 2 deletions
39
FlightFinder/tools/generate.py
Normal file
39
FlightFinder/tools/generate.py
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue