Files

711 lines
37 KiB
Python

#!/usr/bin/env python3
"""Builds Data/Fast.lua, pfQuest xpGuide's own "Fast" guides, for both factions, levels 1-60.
python3 build_fast.py <addon dir>
Where the facts come from (all inside the addon, nothing is typed from memory except the tables at the top):
Data/Quests.lua the order of the zones to go through and the quests of each zone visit, with who gives them and where
Data/Zones.lua each quest's level, the quest before it in a chain, the place it starts and whether its target is an elite
The class trainers and profession trainers below were read out of the addon's own guide data (names and places).
What is written here, and is new:
* the choice of quests for 2x and 1x. A 1x server needs every good quest of a zone visit to reach the next level range;
on 2x the quests and the kills give double, so about half is enough, and it should be the better half: the quests
of the highest level, with the quests before them in their chain. The rest are marked XP1 and only show on 1x.
* the steps: one step per giver (pick up, and hand in what is finished), one for the work, and one for each hand-in
place; class quests only for the class (and race) they are for.
* the interludes: class trainers at 10, 20, 30, 40, 50 and 60, and the checkpoints for the professions.
"""
import json, os, re, sys
ADDON = sys.argv[1] if len(sys.argv) > 1 else "."
HERE = os.path.dirname(os.path.abspath(__file__))
KEEP_2X = 0.52 # share of a visit's quest experience that 2x keeps (double experience: about half is enough)
MIN_2X = 3 # but never fewer than this many (when the visit has that many)
XPN = [0, 400, 900, 1400, 2100, 2800, 3600, 4500, 5400, 6500, 7600, 8800, 10100, 11400, 12900, 14400, 16000, 17700, 19400, 21300,
23200, 25200, 27300, 29400, 31700, 34000, 36400, 38900, 41400, 44300, 47400, 50800, 54500, 58600, 62800, 67100, 71600, 76100,
80800, 85700, 90700, 95800, 101000, 106300, 111800, 117500, 123200, 129100, 135100, 141200, 147500, 153900, 160400, 167100,
173900, 180800, 187900, 195000, 202300, 209800]
NPC = "|cff00ff25"
# ----------------------------------------------------------------------------------------------------------------------------
# What the addon's data holds
# ----------------------------------------------------------------------------------------------------------------------------
def load_zones():
t = open(os.path.join(ADDON, "Data", "Zones.lua"), encoding="utf8").read()
rows = {}
blocks = [(m.start(), m.group(2)) for m in re.finditer(r'\[(\d+)\] = \{ name = "([^"]+)"', t)]
rr = re.compile(r'\{ id = (\d+), n = "((?:[^"\\]|\\.)*)", l = (\d+), m = (\d+), x = ([\d.]+), y = ([\d.]+), g = "((?:[^"\\]|\\.)*)"(.*?) \}')
for i, (pos, zname) in enumerate(blocks):
end = blocks[i + 1][0] if i + 1 < len(blocks) else len(t)
for r in rr.finditer(t[pos:end]):
id_, n, l, m, x, y, g, rest = r.groups()
d = dict(id=int(id_), n=unq(n), l=int(l), m=int(m), x=float(x), y=float(y), g=unq(g), zone=zname)
pm = re.search(r'\bp = (\d+)', rest)
d["p"] = int(pm.group(1)) if pm else None
d["e"] = bool(re.search(r'\be = true', rest))
rows[d["id"]] = d
return rows
def unq(s):
"""A name as the data file spells it, without the escapes (a backslash is dropped: the names never need one)."""
return s.replace("\\", "")
def load_legs():
t = open(os.path.join(ADDON, "Data", "Quests.lua"), encoding="utf8").read()
fac = {m.group(1): m.start() for m in re.finditer(r'\["(Alliance|Horde)"\] = \{', t)}
parts = {"Alliance": t[fac["Alliance"]:fac["Horde"]], "Horde": t[fac["Horde"]:]}
rr = re.compile(r'\{ id = (\d+), name = "((?:[^"\\]|\\.)*)", order = (\d+), giver = "((?:[^"\\]|\\.)*)", place = "((?:[^"\\]|\\.)*)", x = ([\d.]+), y = ([\d.]+)(.*?) \},')
out = {}
for f, txt in parts.items():
heads = list(re.finditer(r'\{ name = "([^"]+)", zone = "([^"]+)", lo = (\d+), hi = (\d+), next = "([^"]*)", quests = \{', txt))
legs = []
for i, h in enumerate(heads):
end = heads[i + 1].start() if i + 1 < len(heads) else len(txt)
rows = []
for r in rr.finditer(txt[h.start():end]):
id_, n, o, g, pl, x, y, rest = r.groups()
cls = re.search(r'class = "([^"]+)"', rest)
race = re.search(r'race = "([^"]+)"', rest)
tk = re.search(r'taker = "((?:[^"\\]|\\.)*)"', rest)
tc = re.search(r'tx = ([\d.]+), ty = ([\d.]+)', rest)
rows.append(dict(id=int(id_), name=unq(n), order=int(o), giver=unq(g), place=unq(pl).strip(), x=float(x), y=float(y),
taker=unq(tk.group(1)) if tk else None, tx=float(tc.group(1)) if tc else None,
ty=float(tc.group(2)) if tc else None, cls=cls.group(1) if cls else None,
race=race.group(1) if race else None))
legs.append(dict(dbname=h.group(1), zone=h.group(2), lo=int(h.group(3)), hi=int(h.group(4)), dbnext=h.group(5), rows=rows))
out[f] = legs
return out
# ----------------------------------------------------------------------------------------------------------------------------
# Choosing the quests
# ----------------------------------------------------------------------------------------------------------------------------
def race_cond(race):
if not race:
return ""
names = []
for r in race.split(","):
r = r.strip().replace("Night Elf", "NightElf")
if r == "Scourge":
r = "Undead"
if r not in names:
names.append(r)
return "/".join(names)
def row_cond(row):
c = row["cls"] or ""
r = race_cond(row["race"])
if c and r and "/" in r:
return "(%s) %s" % (r, c)
return (r + " " + c).strip()
ZONE_ALIAS = {"stranglethorn": "stranglethorn vale", "un'goro": "un'goro crater", "tirisfal": "tirisfal glades"}
def same_zone(zname, leg_zone):
a = zname.lower()
b = ZONE_ALIAS.get(leg_zone.lower(), leg_zone.lower())
return a == b
def load_xp():
"""Real quest experience by quest id (classicdb.ch quest list, 1.12 values; tools/classicdb_quest_xp.json)."""
import json
p = os.path.join(os.path.dirname(os.path.abspath(__file__)), "classicdb_quest_xp.json")
try:
return {int(k): int(v) for k, v in json.load(open(p, encoding="utf8")).items()}
except OSError:
return {}
XPDATA = load_xp()
EST = {}
def est_table(zones):
"""For a quest the list does not have (a server's own quests): the middle experience of the listed quests of its level."""
by = {}
for qid, z in zones.items():
v = XPDATA.get(qid)
if v:
by.setdefault(z["l"], []).append(v)
for lv, vs in by.items():
vs.sort()
EST[lv] = vs[len(vs) // 2]
def xp_of(r):
v = XPDATA.get(r["id"])
if v:
return v
lv = r["lvl"]
for d in range(0, 6):
for l2 in (lv - d, lv + d):
if l2 in EST:
return EST[l2]
return 100
def choose(leg, zones):
"""Marks every generic quest of the visit core (2x and 1x), extra (1x only) or out. Class quests are always in.
A visit only does the quests that start in its own zone: the data also lists quests picked up on the way for a later
zone, and the visit for that zone has them."""
rows = leg["rows"]
seen = set()
gen = []
for r in rows:
if r["id"] in seen:
continue
seen.add(r["id"])
z = zones.get(r["id"])
r["z"] = z
r["lvl"] = z["l"] if z else leg["lo"]
r["elite"] = bool(z and z["e"])
r["prev"] = z["p"] if z else None
r["local"] = bool(z and same_zone(z["zone"], leg["zone"]))
r["known"] = z is not None # a quest the zone data does not have has no title in the game's data either
if not r["cls"] and r["local"] and r["known"]:
gen.append(r)
# A visit that mostly starts its quests elsewhere is a tour (the quests are taken in other zones and done here): keep them all.
allgen = [r for r in rows if not r["cls"] and r["known"]]
seen2, uniq = set(), []
for r in allgen:
if r["id"] not in seen2:
seen2.add(r["id"])
uniq.append(r)
if uniq and sum(1 for r in uniq if r["local"]) < 0.6 * len(uniq):
for r in uniq:
r["local"] = True
gen = list(uniq)
byid = {r["id"]: r for r in gen}
# the better half: the highest quest levels first, later in the order first among equals (their chains are longer).
# A first visit (level 1) needs its first quests whatever their level: they make the first levels.
if not EST:
est_table(zones)
for r in gen:
r["xp"] = xp_of(r)
ranked = sorted(gen, key=lambda r: (-r["xp"], -r["lvl"], -r["order"]))
total = sum(r["xp"] for r in gen)
target = total * KEEP_2X
want = min(MIN_2X, len(gen))
core = set()
def core_xp():
return sum(byid[i]["xp"] for i in core)
def chain_of(i):
"""The quest and the quests before it in its chain that this visit also has."""
out, cur, guard = [], i, 0
while cur in byid and guard < 30:
out.append(cur)
cur = byid[cur]["prev"]
guard += 1
return out
if leg["lo"] == 1:
for r in gen:
if r["lvl"] <= 4:
core.update(chain_of(r["id"]))
for r in ranked:
if len(core) >= want and core_xp() >= target:
break
if r["id"] in core:
continue
add = [i for i in chain_of(r["id"]) if i not in core]
# a long chain is worth it, but not at any price: leave it when it would take the visit well past its share
if core and core_xp() + sum(byid[i]["xp"] for i in add) > target * 1.25 and len(core) >= want:
continue
core.update(add)
for r in rows:
if not r["known"]:
r["tier"] = "out"
elif r["cls"]:
r["tier"] = "class"
elif not r["local"]:
r["tier"] = "out"
elif r["id"] in core:
r["tier"] = "core"
else:
r["tier"] = "extra"
# one row per quest id
done, out = set(), []
for r in rows:
if r["id"] in done:
continue
done.add(r["id"])
if r["tier"] != "out":
out.append(r)
leg["rows"] = out
return len(gen), len(core)
# ----------------------------------------------------------------------------------------------------------------------------
# Steps
# ----------------------------------------------------------------------------------------------------------------------------
T = "\t"
def clean(s):
return re.sub(r"[\t\r\n]", " ", str(s))
def coords(v):
return ("%g" % round(v, 2))
class Leg:
def __init__(self):
self.lines = [] # list of steps; a step is a list of lines
self.npc_at = {} # giver name -> (zone, x, y)
def step(self, lines, need="", flags=""):
self.lines.append(["S" + T + need + T + T + flags] + lines)
def audience(row):
"""Who the quest is for: its class and race condition ("" for everybody)."""
return row_cond(row)
def elem_cond(row):
"""The condition on a quest's own lines: only the 1x mark (the audience is the step's)."""
return "XP1" if row["tier"] == "extra" else ""
def step_need(rows, aud):
"""A step for a class or a race is that; a step whose quests are all for 1x only is also left out as a whole on 2x."""
if rows and all(r["tier"] == "extra" for r in rows):
return (aud + " XP1").strip()
return aud
def build_leg_steps(leg, zones, npc_at, fac):
steps = []
zone = leg["zone"]
rows = sorted(leg["rows"], key=lambda r: r["order"])
def giver_place(r):
z = r["z"]
if z:
return z["zone"], z["x"], z["y"]
return zone, r["x"], r["y"]
pending = [] # accepted, not yet handed in
def hub_key(r):
return (r["giver"], r["place"])
clusters = []
for r in rows:
if clusters and hub_key(clusters[-1][0]) == hub_key(r):
clusters[-1].append(r)
else:
clusters.append([r])
def auds(rs):
out = []
for r in rs:
a = audience(r)
if a not in out:
out.append(a)
# everybody's first, then the classes
out.sort(key=lambda a: (a != "", ))
return out
def place_lines(where, name, spot):
lines = []
if where:
lines.append("G" + T + T + clean(where[0]) + T + coords(where[1]) + T + coords(where[2]) + T + T + T)
if name:
lines.append("I" + T + T + "%s%s|r%s" % (NPC, clean(name), (", " + clean(spot)) if spot else ""))
return lines
def near(a, b, d=14.0):
return a and b and a[0] == b[0] and abs(a[1] - b[1]) + abs(a[2] - b[2]) <= d
def flush(here):
"""Before walking away: hand in what is finished and handed in close by (the walk back would cost more)."""
out = [p for p in pending if p["taker"] and near(npc_at.get(p["taker"]), here)]
while out:
who, a = out[0]["taker"], audience(out[0])
group = [p for p in out if p["taker"] == who and audience(p) == a]
lines = place_lines(npc_at.get(who), who, "")
for p in group:
lines.append("T" + T + elem_cond(p) + T + str(p["id"]) + T)
pending.remove(p)
out.remove(p)
steps.append((step_need(group, a), "", lines))
here = None
for cl in clusters:
gname = cl[0]["giver"]
where = giver_place(cl[0])
if here is not None and not near(here, where):
flush(here)
for a in auds(cl + [p for p in pending if p["taker"] == gname]):
take = [p for p in pending if p["taker"] == gname and audience(p) == a]
give = [r for r in cl if audience(r) == a]
if not take and not give:
continue
lines = place_lines(npc_at.get(gname) or where, gname, cl[0]["place"])
for p in take:
lines.append("T" + T + elem_cond(p) + T + str(p["id"]) + T)
pending.remove(p)
# a quest whose earlier part is taken at this same hub is offered only after that part is handed in: it follows in
# its own round (hand in, accept, do), so the same name is never accepted twice at once
ids = [r["id"] for r in give]
first, rest, names = [], [], set()
for r in give:
nm = r["z"]["n"] if r.get("z") else r["name"]
if r.get("prev") in ids or nm in names:
rest.append(r)
else:
first.append(r)
names.add(nm)
waves = [first]
while rest:
done = [x["id"] for w in waves for x in w]
w = [r for r in rest if r.get("prev") in done]
if not w:
w = rest
waves.append(w)
rest = [r for r in rest if r not in w]
for wi, wave in enumerate(waves):
if wi == 0:
for r in wave:
lines.append("A" + T + elem_cond(r) + T + str(r["id"]) + T)
steps.append((step_need(take + wave, a), "", lines))
else:
gone = [p for p in prevwave if p["taker"] == gname]
l2 = place_lines(None, gname, cl[0]["place"])
for p in gone:
l2.append("T" + T + elem_cond(p) + T + str(p["id"]) + T)
pending.remove(p)
for r in wave:
l2.append("A" + T + elem_cond(r) + T + str(r["id"]) + T)
steps.append((step_need(gone + wave, a), "", l2))
if wave:
work = ["C" + T + elem_cond(r) + T + str(r["id"]) + T + T for r in wave]
steps.append((step_need(wave, a), "", work))
pending.extend(wave)
prevwave = wave
here = npc_at.get(gname) or where
# what is left: hand in by place, in the order the quests were taken
left = list(pending)
while left:
who = left[0]["taker"]
a = audience(left[0])
group = [r for r in left if r["taker"] == who and audience(r) == a]
where = npc_at.get(who)
lines = place_lines(where, who, "")
for r in group:
lines.append("T" + T + elem_cond(r) + T + str(r["id"]) + T)
steps.append((step_need(group, a), "", lines))
for r in group:
left.remove(r)
return steps
def leg_name(leg):
return "%d-%d %s" % (leg["lo"], leg["hi"], leg["zone"])
# ----------------------------------------------------------------------------------------------------------------------------
# Class trainers and professions (names and places read from the addon's own guide data)
# ----------------------------------------------------------------------------------------------------------------------------
HOME = {
"Alliance": [("Stormwind City", "Human"), ("Ironforge", "(Dwarf/Gnome)"), ("Darnassus", "NightElf")],
"Horde": [("Orgrimmar", "(Orc/Troll)"), ("Thunder Bluff", "Tauren"), ("Undercity", "Undead")],
}
CLASSES = {
"Alliance": ["Warrior", "Paladin", "Hunter", "Rogue", "Priest", "Shaman", "Mage", "Warlock", "Druid"],
"Horde": ["Warrior", "Paladin", "Hunter", "Rogue", "Priest", "Shaman", "Mage", "Warlock", "Druid"],
}
# (city, class) -> (trainer, x, y)
TRAINER = {
("Stormwind City", "Druid"): ("Sheldras Moontree", 35.84, 67.38), ("Stormwind City", "Hunter"): ("Einris Brightspear", 67.35, 36.25),
("Stormwind City", "Mage"): ("Jennea Cannon", 49.56, 85.8), ("Stormwind City", "Paladin"): ("Arthur the Faithful", 49.61, 49.84),
("Stormwind City", "Priest"): ("High Priestess Laurena", 49.53, 44.6), ("Stormwind City", "Rogue"): ("Osborne the Night Man", 77.43, 65.31),
("Stormwind City", "Warlock"): ("Demisette Cloyce", 39.24, 84.96), ("Stormwind City", "Warrior"): ("Wu Shen", 80.55, 59.87),
("Ironforge", "Hunter"): ("Olmin Burningbeard", 70.89, 83.61), ("Ironforge", "Mage"): ("Bink", 27.25, 8.3),
("Ironforge", "Paladin"): ("Brandur Ironhammer", 23.13, 6.14), ("Ironforge", "Priest"): ("High Priest Rohan", 24.73, 8.16),
("Ironforge", "Rogue"): ("Hulfdan Blackbeard", 51.96, 14.84), ("Ironforge", "Shaman"): ("Eldrun Stormbreaker", 47.14, 13.52),
("Ironforge", "Warlock"): ("Briarthorn", 50.35, 5.66), ("Ironforge", "Warrior"): ("Kelv Sternhammer", 70.34, 90.65),
("Darnassus", "Druid"): ("Mathrengyl Bearwalker", 35.37, 8.4), ("Darnassus", "Hunter"): ("Jocaste", 40.38, 8.55),
("Darnassus", "Mage"): ("Elissa Dumas", 40.6, 82.13), ("Darnassus", "Priest"): ("Priestess Alathea", 39.52, 81.2),
("Darnassus", "Rogue"): ("Ilyenia Moonfire", 57.56, 46.73), ("Darnassus", "Warrior"): ("Darnath Bladesinger", 58.94, 35.35),
("Orgrimmar", "Hunter"): ("Xao'tsu", 66.32, 14.81), ("Orgrimmar", "Mage"): ("Pephredo", 38.35, 85.56),
("Orgrimmar", "Priest"): ("Ur'kyo", 35.59, 87.82), ("Orgrimmar", "Rogue"): ("Shenthul", 43.05, 53.74),
("Orgrimmar", "Shaman"): ("Sagorne Creststrider", 38.66, 35.92), ("Orgrimmar", "Warlock"): ("Zevrost", 48.47, 45.43),
("Orgrimmar", "Warrior"): ("Sorek", 80.39, 32.38),
("Thunder Bluff", "Druid"): ("Turak Runetotem", 76.48, 27.22), ("Thunder Bluff", "Hunter"): ("Holt", 57.3, 89.79),
("Thunder Bluff", "Mage"): ("Birgitte Cranston", 22.5, 16.91), ("Thunder Bluff", "Paladin"): ("Alodan the Hopeful", 22.62, 19.91),
("Thunder Bluff", "Shaman"): ("Beram Skychaser", 21.99, 18.8), ("Thunder Bluff", "Warrior"): ("Torm Ragetotem", 57.24, 87.37),
("Undercity", "Mage"): ("Anastasia Hartwell", 85.14, 10.03), ("Undercity", "Paladin"): ("Garen Largo", 47.08, 15.9),
("Undercity", "Priest"): ("Aelthalyste", 49.26, 17.12), ("Undercity", "Rogue"): ("Gregory Charles", 84.88, 73.53),
("Undercity", "Warlock"): ("Kaal Soulreaper", 86.21, 15.93), ("Undercity", "Warrior"): ("Baltus Fowler", 47.4, 17.29),
}
DECADES = [10, 20, 30, 40, 50, 60]
def class_steps(fac, level):
out = []
for city, race in HOME[fac]:
for cls in CLASSES[fac]:
need = "%s %s" % (race, cls)
tr = TRAINER.get((city, cls))
lines = []
if tr:
lines.append("G" + T + T + city + T + coords(tr[1]) + T + coords(tr[2]) + T + T + T)
lines.append("I" + T + T + "Level %d: new %s spells. Visit %s%s|r in %s." % (level, cls, NPC, tr[0], city))
lines.append("V" + T + T + "trainer" + T + "Visit your class trainer")
else:
lines.append("I" + T + T + "Level %d: new %s spells. Visit your %s trainer in %s." % (level, cls, cls, city))
lines.append("V" + T + T + "trainer" + T + "Visit your class trainer")
out.append((need, "optional=1", lines))
return out
# profession trainers: (cond, zone, x, y, text, first level it makes sense)
PROF_TOWN = { # apprentice trainers of the starting towns: leg zone -> list of (cond, zone, x, y, text)
"Dun Morogh": [("FirstAid", "Dun Morogh", 47.18, 52.61, "Learn Apprentice First Aid from Thamner Pol in the Kharanos inn."),
("Cooking", "Dun Morogh", 47.67, 52.31, "Learn Apprentice Cooking from Gremlock Pilsnor in the back room of the Kharanos inn."),
("Fishing", "Dun Morogh", 35.48, 40.22, "Learn Apprentice Fishing from Paxton Ganter at Iceflow Lake, and buy a pole from Gretta Ganter in Brewnall Village.")],
"Elwynn Forest": [("FirstAid", "Elwynn Forest", 43.39, 65.55, "Learn Apprentice First Aid from Michelle Belle upstairs in the Goldshire inn."),
("Cooking", "Elwynn Forest", 44.37, 65.99, "Learn Apprentice Cooking from Tomas in the Goldshire inn's kitchen."),
("Fishing", "Elwynn Forest", 47.61, 62.32, "Learn Apprentice Fishing from Lee Brown by Crystal Lake, and buy a pole from Tharynn Bouden.")],
"Teldrassil": [("FirstAid", "Teldrassil", 55.29, 56.82, "Learn Apprentice First Aid from Byancie in Dolanaar."),
("Cooking", "Teldrassil", 57.12, 61.3, "Learn Apprentice Cooking from Zarrin in Dolanaar."),
("Fishing", "Darnassus", 47.89, 56.65, "Learn Apprentice Fishing from Astaia in Darnassus, and buy a pole from Voloren.")],
"Durotar": [("FirstAid", "Durotar", 54.17, 41.93, "Learn Apprentice First Aid from Rawrk in Razor Hill."),
("Cooking", "Durotar", 51.11, 42.45, "Learn Apprentice Cooking from Cook Torka in Razor Hill."),
("Fishing", "Durotar", 53.25, 81.59, "Learn Apprentice Fishing at Lau'Tiki south of Sen'jin Village, and buy a pole from Zansoa.")],
"Mulgore": [("FirstAid", "Mulgore", 46.08, 63.96, "Learn Apprentice First Aid from Vira Younghoof in Bloodhoof Village."),
("Cooking", "Mulgore", 44.92, 61.67, "Learn Apprentice Cooking from Pyall Silentstride in Bloodhoof Village."),
("Fishing", "Mulgore", 44.16, 63.8, "Learn Apprentice Fishing from Uthan Stillwater, and buy a pole from Wunna Darkmane.")],
"Tirisfal": [("FirstAid", "Tirisfal Glades", 61.82, 52.83, "Learn Apprentice First Aid from Nurse Neela inside the Brill inn."),
("Cooking", "Tirisfal Glades", 61.77, 51.5, "Learn Apprentice Cooking from William Pickman in Brill."),
("Fishing", "Tirisfal Glades", 65.86, 59.64, "Buy a Fishing Pole from Martine Tramblay in Brill; Apprentice Fishing is taught at Brightwater Lake east of Brill.")],
}
# later checkpoints, by faction: (cond, level, zone of the trainer or None, x, y, text)
JOURNEYMAN = {
"Alliance": [("(Dwarf/Gnome) FirstAid", "Ironforge", 55.09, 58.26, "Journeyman First Aid (needs 50 skill): Nissa Firestone in Ironforge."),
("(Dwarf/Gnome) Cooking", "Ironforge", 60.08, 36.43, "Journeyman Cooking (needs 50 skill): Daryl Riknussun in Ironforge."),
("(Dwarf/Gnome) Fishing", "Ironforge", 48.07, 6.91, "Journeyman Fishing (needs 50 skill): Grimnur Stonebrand in Ironforge.")],
"Horde": [("(Orc/Troll) FirstAid", "Orgrimmar", 34.18, 84.58, "Journeyman First Aid (needs 50 skill): Arnok in Orgrimmar."),
("(Orc/Troll) Cooking", "Orgrimmar", 57.4, 53.96, "Journeyman Cooking (needs 50 skill): Zamja in Orgrimmar."),
("(Orc/Troll) Fishing", "Orgrimmar", 69.8, 29.21, "Journeyman Fishing (needs 50 skill): Lumak in Orgrimmar.")],
}
# Expert (level 20, skill 125) books and Artisan (level 35, skill 200) trainers, attached to the first visit in that zone
LATE = {
"Alliance": [
(20, "Fishing", "Stranglethorn Vale", 27.42, 77.16, "Expert Fishing (125 skill): buy 'The Bass and You' from Old Man Heming at the Nesingwary camp and use it."),
(20, "Cooking", "Ashenvale", 49.48, 67.09, "Expert Cooking (125 skill): buy the Expert Cookbook from Shandrina at Silverwind Refuge and use it."),
(20, "FirstAid", "Arathi Highlands", 26.97, 58.83, "Expert First Aid (125 skill): buy 'Under Wraps' from Deneb Walker in Stromgarde and use it."),
(35, "Tailoring", "Dustwallow Marsh", 66.18, 51.81, "Artisan Tailoring (level 35, 200 skill): Timothy Worthington, upstairs in the building beside the Theramore docks."),
(35, "Blacksmithing", "Stranglethorn Vale", 28.99, 75.56, "Artisan Blacksmithing (level 35, 200 skill): Brikk Keencraft in the house behind the shops near Booty Bay's land exit."),
(35, "Engineering", "Tanaris", 52.34, 27.72, "Artisan Engineering (level 35, 200 skill): Buzzek Bracketswing outside the Gadgetzan inn."),
(35, "Leatherworking", "The Hinterlands", 13.39, 43.49, "Artisan Leatherworking (level 35, 200 skill): Drakk Stonehand downstairs in Wildhammer Keep."),
(35, "Alchemy", "Feralas", 32.62, 43.78, "Artisan Alchemy (level 35, 200 skill): Kylanna Windwhisper at the treehouse in the northeast of the island."),
],
"Horde": [
(20, "Fishing", "Stranglethorn Vale", 27.42, 77.16, "Expert Fishing (125 skill): buy 'The Bass and You' from Old Man Heming at the Nesingwary camp and use it."),
(20, "FirstAid", "Dustwallow Marsh", 36.49, 30.36, "Expert First Aid (125 skill): buy 'Under Wraps' from Balai Lok'Wein and use it."),
(20, "Enchanting", "Stonetalon Mountains", 49.18, 57.18, "Expert Enchanting (level 20, 125 skill): Hgarth, on the path east-northeast of Sun Rock Retreat's largest tent."),
(35, "Tailoring", "Hillsbrad Foothills", 63.75, 20.79, "Artisan Tailoring (level 35, 200 skill): Daryl Stack in the Southshore church."),
(35, "Blacksmithing", "Stranglethorn Vale", 28.99, 75.56, "Artisan Blacksmithing (level 35, 200 skill): Brikk Keencraft in the house behind the shops near Booty Bay's land exit."),
(35, "Engineering", "Tanaris", 52.34, 27.72, "Artisan Engineering (level 35, 200 skill): Buzzek Bracketswing outside the Gadgetzan inn."),
(35, "Leatherworking", "Feralas", 74.36, 43.12, "Artisan Leatherworking (level 35, 200 skill): Hahrana Ironhide in the building opposite the Camp Mojache inn."),
(35, "Alchemy", "Swamp of Sorrows", 48.53, 55.85, "Artisan Alchemy (level 35, 200 skill): Rogvar on the first landing of Stonard's largest building."),
],
}
PRIMARY_GENERIC = {
10: "Journeyman %s (level 10, 50 skill): train it at your capital's %s trainer.",
20: "Expert %s (level 20, 125 skill): train it at a %s trainer (a capital has one), or the book/trainer named in the guide.",
}
STARTER_PROF = {
"Mining": "Mining: learn Apprentice Mining from a Mining trainer (your capital has one) and carry a Mining Pick; mine the copper veins you pass.",
"Herbalism": "Herbalism: learn Apprentice Herbalism from a trainer (your capital has one); pick the herbs you pass.",
"Skinning": "Skinning: learn Apprentice Skinning from a trainer (your capital has one), buy a Skinning Knife and skin what you kill.",
"Alchemy": "Alchemy: learn Apprentice Alchemy in your capital; keep the herbs you gather and the vials you buy.",
"Blacksmithing": "Blacksmithing: learn Apprentice Blacksmithing in your capital; keep the copper and the stone you find.",
"Engineering": "Engineering: learn Apprentice Engineering in your capital; keep the copper and the stone you find.",
"Enchanting": "Enchanting: learn Apprentice Enchanting in your capital; disenchant the green items you do not need.",
"Leatherworking": "Leatherworking: learn Apprentice Leatherworking in your capital; keep the leather you skin.",
"Tailoring": "Tailoring: learn Apprentice Tailoring in your capital; keep the cloth you loot.",
"Survival": "Survival: learn it from its trainer if your server has one; its first ranks come from the camp you rest at.",
}
def starter_prof():
return [(p, "", ["I" + T + T + text]) for p, text in STARTER_PROF.items()]
def prof_steps_start(leg_zone):
out = []
for cond, z, x, y, text in PROF_TOWN.get(leg_zone, []):
lines = ["G" + T + T + z + T + coords(x) + T + coords(y) + T + T + T, "I" + T + T + text]
out.append((cond, "optional=1", lines))
return out
def generic_prof(level):
"""Checkpoints without a place: gathering and crafting professions, and the secondary ones in every capital."""
out = []
for prof in ["Mining", "Herbalism", "Skinning", "Alchemy", "Blacksmithing", "Engineering", "Enchanting", "Leatherworking", "Tailoring"]:
if level == 10:
text = "%s checkpoint, level 10: if your skill is 50 or more, train Journeyman %s at a %s trainer (every capital has one)." % (prof, prof, prof)
elif level == 20:
text = "%s checkpoint, level 20: at 125 skill train Expert %s; a capital's %s trainer teaches it." % (prof, prof, prof)
elif level == 35:
text = "%s checkpoint, level 35: at 200 skill train Artisan %s; the guide names the trainer for the crafts." % (prof, prof)
else:
continue
out.append((prof, "optional=1", ["I" + T + T + text]))
sec = {10: "Level 10: Journeyman First Aid, Cooking and Fishing need 50 skill; the capital's trainers teach them.",
20: "Level 20: Expert First Aid, Cooking and Fishing need 125 skill and a book; the guide names where as you pass.",
35: "Level 35: Artisan First Aid (the Triage quest, 225 skill) and Artisan Cooking (225 skill)."}
if level in sec:
out.append(("Survival", "optional=1", ["I" + T + T + "Survival checkpoint: " + sec[level].replace("Level", "level")]))
return out
# ----------------------------------------------------------------------------------------------------------------------------
# Writing
# ----------------------------------------------------------------------------------------------------------------------------
def lua_str(s):
s = s.replace("\\", "\\\\").replace('"', '\\"').replace("\t", "\\t").replace("\n", "\\n")
return '"' + s + '"'
GROUPS = [(1, 30), (30, 60)]
def group_of(lo, fac):
# the faction is in the name: a guide's saved key is its group and its name, and both factions have the same visits
for a, b in GROUPS:
if lo < b:
return "xpGuide Fast %s %d-%d" % (fac, a, b)
return "xpGuide Fast %s 30-60" % fac
START_FOR = {"Dun Morogh": "Dwarf/Gnome", "Elwynn Forest": "Human", "Teldrassil": "NightElf",
"Durotar": "Orc/Troll", "Mulgore": "Tauren", "Tirisfal": "Undead"}
def main():
zones = load_zones()
legs_by_fac = load_legs()
npc_at = {}
for z in zones.values():
npc_at.setdefault(z["g"], (z["zone"], z["x"], z["y"]))
guides, report = [], []
for fac in ("Alliance", "Horde"):
legs = legs_by_fac[fac]
names, used = [], {}
for leg in legs:
n = leg_name(leg)
used[n] = used.get(n, 0) + 1
# "Fast " keeps the names apart from RestedXP's guides, whose names are the same ("29-30 Ashenvale")
names.append("Fast " + (n if used[n] == 1 else "%s (%d)" % (n, used[n])))
for i, leg in enumerate(legs):
gen, core = choose(leg, zones)
steps = build_leg_steps(leg, zones, npc_at, fac)
lines_steps = []
for need, flags, lines in steps:
lines_steps.append((need, flags, lines))
# starting towns: the apprentice trainers, a little way in
if leg["lo"] == 1 and leg["zone"] in PROF_TOWN:
at = max(1, int(len(lines_steps) * 0.6))
extra = prof_steps_start(leg["zone"]) + starter_prof()
lines_steps[at:at] = [(c, f, l) for c, f, l in extra]
# the end of the visit: the level, then what is due at the levels passed
lines_steps.append(("", "", ["X" + T + T + T + str(leg["hi"]) + T + T + T]))
for D in DECADES:
if leg["lo"] < D <= leg["hi"] or (leg["lo"] == D == 60):
lines_steps += class_steps(fac, D)
if D in (10, 20, 35):
lines_steps += generic_prof(D)
if leg["lo"] < 10 <= leg["hi"]:
for cond, zone, x, y, text in JOURNEYMAN[fac]:
lines_steps.append((cond, "optional=1", ["G" + T + T + zone + T + coords(x) + T + coords(y) + T + T + T, "I" + T + T + text]))
if leg["lo"] < 35 <= leg["hi"]:
lines_steps += generic_prof(35)
leg["_steps"] = lines_steps
# the profession books and Artisan trainers, in the first visit in their zone from their level
for lvl, cond, zone, x, y, text in LATE[fac]:
home = None
for leg in legs:
if leg["zone"].startswith(zone.split()[0]) and (zone in leg["zone"] or leg["zone"] in zone) and leg["hi"] >= lvl - 1:
home = leg
break
if home is None:
for leg in legs:
if leg["lo"] <= lvl <= leg["hi"] and leg["lo"] >= lvl - 3:
home = leg
break
if home is None:
report.append("no visit for %s %s" % (fac, text[:40]))
continue
home["_steps"].insert(len(home["_steps"]) - 1,
(cond, "optional=1", ["G" + T + T + zone + T + coords(x) + T + coords(y) + T + T + T, "I" + T + T + text]))
# one guide per visit
for i, leg in enumerate(legs):
lines = []
for need, flags, ls in leg["_steps"]:
lines.append("S" + T + need + T + T + (flags or ""))
lines += ls
nxt = ""
alts = []
if leg["dbnext"]:
for j in range(i + 1, len(legs)):
if legs[j]["dbname"] == leg["dbnext"]:
alts.append(names[j])
break
if i + 1 < len(legs) and not alts:
alts.append(names[i + 1])
nxt = ";".join(alts)
qn = len([r for r in leg["rows"] if r["tier"] in ("core", "class")])
q1 = len([r for r in leg["rows"] if r["tier"] in ("core", "extra", "class")])
guides.append(dict(name=names[i], title=leg["zone"] + " " + "%d-%d" % (leg["lo"], leg["hi"]),
group=group_of(leg["lo"], fac), faction=fac, lo=leg["lo"], hi=leg["hi"], next=nxt,
defaultFor=START_FOR.get(leg["zone"], "") if leg["lo"] == 1 else "", cond=fac,
about="%d quests on 2x, %d on 1x." % (qn, q1), steps="\n".join(lines)))
report.append("%-9s %-34s core %3d / %3d (1x: %3d)" % (fac, names[i], len([r for r in leg["rows"] if r["tier"] == "core"]),
len([r for r in leg["rows"] if r["tier"] in ("core", "extra")]), q1))
out = ["-- Generated by build_fast.py from this addon's own quest data (Data\\Quests.lua, Data\\Zones.lua). Do not edit by hand.",
"-- pfQuest xpGuide's own fast guides: the order of the zones and the quests are read from the addon's data; which quests to do",
"-- on a 2x server and on a 1x server, the steps, the class trainers and the profession checkpoints are this addon's own.",
"-- Steps with the word XP1 in their condition are for 1x servers only. Steps.lua explains the line format.",
"pfQuest_xpGuide_Guides = pfQuest_xpGuide_Guides or {}",
"pfQuest_xpGuide_Fast = { version = 1, guides = %d }" % len(guides),
"for _, g in ipairs({"]
for g in guides:
out.append(" { name = %s, title = %s, group = %s, faction = %s, lo = %d, hi = %d, next = %s, defaultFor = %s, cond = %s, fast = true,"
% (lua_str(g["name"]), lua_str(g["title"]), lua_str(g["group"]), lua_str(g["faction"]), g["lo"], g["hi"],
lua_str(g["next"]), lua_str(g["defaultFor"]), lua_str(g["cond"])))
out.append(" about = %s," % lua_str(g["about"]))
out.append(" steps = %s }," % lua_str(g["steps"]))
out.append("}) do table.insert(pfQuest_xpGuide_Guides, g) end")
path = os.path.join(ADDON, "Data", "Fast.lua")
open(path, "w", encoding="utf8").write("\n".join(out) + "\n")
print("\n".join(report))
print("wrote", path, len(guides), "guides")
if __name__ == "__main__":
main()