Files
pfQuest xpGuideandClaude Sonnet 5.5 ef2f4f34b3 pfQuest xpGuide 1.0.0
A leveling guide for WoW 1.12 players of pfQuest, based on Easy Route by stealthzi (MIT).
See README.md and CHANGES.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XfR1apt9f3R7SxBKB2FF2D
2026-11-16 14:47:43 +08:00

351 lines
22 KiB
Lua

-- [PFUI=1] texlua abandon.lua <addon> <race> <class> 1 casual
-- An abandoned quest's steps, passed over by the guide, can be taken back: from the list (back to where you pick it up),
-- or by picking the quest up again from the giver (its steps come back and the guide goes back to them by itself).
local here = arg[0]:match("^(.*)/") or "."
dofile(here .. "/lib.lua")
local W, ER, S, P = H.W, H.ER, H.S, H.P
local fails = 0
local function check(ok, what) if not ok then fails = fails + 1; P("FAIL " .. what) else P("ok " .. what) end end
local function strip(s) return (L53.gsub(L53.gsub(s or "", "|c%x%x%x%x%x%x%x%x", ""), "|r", "")) end
local function F(n) return _G["pfQuest_xpGuide" .. n] end
local function click(f, b) if f and f._scripts.OnClick and not f._off then this = f; arg1 = b or "LeftButton"; f._scripts.OnClick() end end
local function settle() W.Fire("QUEST_LOG_UPDATE"); W.Tick(0.4, 4); W.Tick(3, 1); ER.StepsChanged() end
local function logIdx(title) for i, q in ipairs(W.log) do if q.title == title then return i end end end
W.Tick(3, 3)
W.level = math.max(1, (S.QuestLevel(921) or 5)) -- a character at the level of the quests tested here (the game offers them)
ER.ShowTracker()
-- a clean slate: nothing handed in, an empty quest log, the guide from its start
local function fresh()
if ER.db.done then ER.db.done[ER.Char()] = {} end
pfQuest_history = nil
for i = table.getn(W.log), 1, -1 do table.remove(W.log, i) end
settle()
S.Load(S.Key(S.Info()), true); settle()
end
-- plays the guide properly (pick up, do, hand in) until a step with the given kind of element for the quest
local function playTo(kind, qid)
local g = 0
while g < 150 do
local st = S.Current()
if not st then return end
for _, e in ipairs(st.elements) do if e.kind == kind and tonumber(e.id) == qid then return end end
for _, e in ipairs(st.elements) do
local id = tonumber(e.id); local title = id and S.QuestTitle(id)
if title and e.kind == "A" and not logIdx(title) and not S.TurnedIn(id) then table.insert(W.log, { id = id, title = title, level = S.QuestLevel(id), objs = { { text = "x: 0/1", done = false } } }) end
if title and e.kind == "C" and logIdx(title) then local q = W.log[logIdx(title)] q.complete = true q.objs[1].done = true end
if title and e.kind == "T" and logIdx(title) then W_TITLE = title; GetQuestReward(0); table.remove(W.log, logIdx(title)) end
end
settle()
if S.Current() == st then S.Next() end
g = g + 1
end
end
-- a quest with a pick-up step, then a work step and a hand-in step later
local qid, aStep, cStep, tStep
for _, it in ipairs(S.All()) do
for _, e in ipairs(it.step.elements) do
local id = tonumber(e.id)
if id and e.kind == "A" and not qid and it.step.n >= S.Position() then qid, aStep = id, it.step.n end
if id and id == qid and e.kind == "C" and not cStep then cStep = it.step.n end
if id and id == qid and e.kind == "T" and not tStep then tStep = it.step.n end
end
if qid and (not cStep or not tStep) and false then end
end
-- want one with both a work step and a hand-in step
if not (cStep and tStep) then
qid, aStep, cStep, tStep = nil, nil, nil, nil
for _, it in ipairs(S.All()) do
for _, e in ipairs(it.step.elements) do
local id = tonumber(e.id)
if id and e.kind == "C" then
for _, it2 in ipairs(S.All()) do for _, e2 in ipairs(it2.step.elements) do
if tonumber(e2.id) == id and e2.kind == "A" and it2.step.n < it.step.n then
for _, it3 in ipairs(S.All()) do for _, e3 in ipairs(it3.step.elements) do
if tonumber(e3.id) == id and e3.kind == "T" and it3.step.n > it.step.n and not qid then qid, aStep, cStep, tStep = id, it2.step.n, it.step.n, it3.step.n end
end end
end
end end
end
end
if qid then break end
end
end
local title = S.QuestTitle(qid)
P("note quest " .. tostring(title) .. " (" .. tostring(qid) .. "): pick up at " .. tostring(aStep) .. ", work " .. tostring(cStep) .. ", hand in " .. tostring(tStep))
-- pick it up, get to its work step
-- play properly to its work step (the quests before it handed in, so the game would offer it again)
local lvl0 = W.level
W.level = math.max(W.level, S.QuestLevel(qid) or 1)
playTo("C", qid)
if not logIdx(title) then table.insert(W.log, { id = qid, title = title, level = S.QuestLevel(qid) or 1, objs = { { text = "thing: 0/1", done = false } } }) settle() end
check(S.Position() == cStep, "on the quest's work step (" .. S.Position() .. ")")
-- abandon it
GetAbandonQuestName = function() return title end
SetAbandonQuest()
table.remove(W.log, logIdx(title)); settle()
-- carry on with the guide until past its hand-in step; the guide never stops at the abandoned quest's steps
local stoppedAtIt = false
for g = 1, 80 do
if S.Position() > tStep then break end
local cur = S.Current()
for _, e in ipairs(cur.elements) do if tonumber(e.id) == qid and (e.kind == "C" or e.kind == "T") then stoppedAtIt = true end end
S.Next(); settle()
end
check(S.Position() > tStep and not stoppedAtIt, "abandoned: the guide passes over its work and hand-in steps (now at " .. S.Position() .. ")")
local rowC
local function rowFor(n) for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.step and r.step.n == n then return r end end end
FauxScrollFrame_SetOffset(F("GuideScroll"), 0); ER.StepsChanged()
for _, it in ipairs(S.All()) do if it.step.n == cStep then check(it.how == "abandoned", "the work step counts as passed over because you abandoned the quest (" .. tostring(it.how) .. ")") end end
check(S.CanUnskip(cStep) and S.CanUnskip(tStep), " ...and it can be taken back, the hand-in step too")
for _, it in ipairs(S.All()) do if it.step.n == aStep then check(it.how == "abandoned", " ...its pick-up step shows the skip mark, not a tick (" .. tostring(it.how) .. ")") end end
rowC = rowFor(cStep)
if rowC then
check(rowC.skipMark:IsShown() and not rowC.check:GetChecked(), " ...shown with the skip mark, not a tick")
end
-- the footer counts it; the list keeps its button in view
local bc = F("GuideBackCount")
check(bc and bc:IsShown() and strip(bc.text._text) == "1 step to go back to", "the footer says how many steps there are to go back to: " .. strip(bc and bc.text._text or "none"))
local btnRow
for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.regain then btnRow = r end end
check(btnRow and btnRow.step.n == aStep, " ...the list did not scroll past its button (step " .. tostring(btnRow and btnRow.step.n) .. ")")
-- way 1: pick it up again from the giver: its steps come back and the guide goes back to them by itself
table.insert(W.log, { id = qid, title = title, level = S.QuestLevel(qid) or 1, objs = { { text = "thing: 0/1", done = false } } })
settle()
check(not S.Passed(tStep), "picked up again: its work and hand-in steps are back")
check(S.Position() == cStep, " ...and the guide goes back to its work step by itself (" .. S.Position() .. ")")
local inBox
for j = 1, 12 do local b = F("GuideLine" .. j) if b and b:IsShown() and strip(b.text._text):find("again", 1, true) then inBox = true end end
check(not inBox, " ...with no line about it in the step box")
check(not F("GuideBackCount"):IsShown(), " ...and nothing left to go back to in the footer")
-- do the work: the guide stops at the hand-in, not passing it over
local i = logIdx(title); W.log[i].complete = true; W.log[i].objs[1].done = true; W.log[i].objs[1].text = "thing: 1/1"; settle()
check(S.Position() == tStep, " ...with the work done, the guide goes on to its hand-in (" .. S.Position() .. ")")
-- way 2: abandon again, then click its step in the list: back to where you pick it up
SetAbandonQuest()
table.remove(W.log, logIdx(title)); settle()
for g = 1, 80 do if S.Position() > tStep then break end S.Next(); settle() end
check(S.Position() > tStep, "abandoned again: passed over (now at " .. S.Position() .. ")")
FauxScrollFrame_SetOffset(F("GuideScroll"), 0); ER.StepsChanged()
local r = rowFor(tStep) or rowFor(cStep)
if r then
local n = r.step.n
click(r.check)
check(S.Position() == aStep, "clicking a passed-over step of an abandoned quest goes back to where you pick it up (" .. S.Position() .. ", pick-up " .. aStep .. ")")
check(not S.Passed(cStep) and not S.Passed(tStep), " ...its work and hand-in steps are back")
else P("note the abandoned quest's steps were not in view") end
-- a chain: abandoning its first quest holds back the rest of the chain; picking it up again brings the whole chain back
do
local chain = ER.ChainOf and ER.ChainOf(921)
local function stepsOf(id) local t = {} for _, it in ipairs(S.All()) do for _, e in ipairs(it.step.elements) do
if tonumber(e.id) == id and (e.kind == "A" or e.kind == "C" or e.kind == "T") then table.insert(t, it.step.n) break end end end return t end
local c921 = stepsOf(921)
if chain and table.getn(c921) > 0 then
P("note chain " .. table.concat(chain.ids, " > "))
-- only the quests after 921 are held back by abandoning it
local after = {}
for k = (chain.pos or 1) + 1, table.getn(chain.ids) do table.insert(after, chain.ids[k]) end
local laterIds = after
local ids921 = { 921 }
for _, id in ipairs(laterIds) do table.insert(ids921, id) end
fresh()
local a921
for _, it in ipairs(S.All()) do for _, e in ipairs(it.step.elements) do if e.kind == "A" and tonumber(e.id) == 921 then a921 = a921 or it.step.n end end end
playTo("C", 921)
local t921 = S.QuestTitle(921)
-- abandon it, then the guide goes on well past the whole chain
GetAbandonQuestName = function() return t921 end
SetAbandonQuest()
table.remove(W.log, logIdx(t921)); settle()
local lastChainStep = 0
for _, id in ipairs(laterIds) do for _, n in ipairs(stepsOf(id)) do if n > lastChainStep then lastChainStep = n end end end
local guard = 0
while S.Position() <= lastChainStep and guard < 400 do S.Next(); guard = guard + 1 end
settle()
local heldBack = 0
for _, id in ipairs(laterIds) do for _, n in ipairs(stepsOf(id)) do if S.Passed(n) then heldBack = heldBack + 1 end end end
check(S.Position() > lastChainStep and heldBack > 0, "abandoned " .. t921 .. " (921); the guide went past the whole chain (" .. heldBack .. " later chain steps passed over)")
-- no step of the abandoned quest or its chain behind you shows as completed: the pick-up of 921 neither
local ticked = {}
for _, it in ipairs(S.All()) do
for _, id in ipairs(ids921) do
for _, e in ipairs(it.step.elements) do
if tonumber(e.id) == id and it.step.n < S.Position() and it.how ~= "abandoned" then table.insert(ticked, it.step.n .. "=" .. tostring(it.how)) end
end
end
end
check(table.getn(ticked) == 0, "abandoned: every step of the quest and its chain behind you shows the skip mark, none a tick" .. (table.getn(ticked) > 0 and (" (" .. table.concat(ticked, " ") .. ")") or ""))
-- the later chain quests' steps show as passed over because of the abandon, and can be taken back
local laterN = stepsOf(laterIds[1])[1]
local how
for _, it in ipairs(S.All()) do if it.step.n == laterN then how = it.how end end
check(how == "abandoned" and S.CanUnskip(laterN), " ...a later chain quest's step (" .. tostring(laterN) .. ") shows as passed over because of the abandon, and can be taken back (" .. tostring(how) .. ")")
-- pick 921 up again
local where = S.Position()
table.insert(W.log, { id = 921, title = t921, level = S.QuestLevel(921) or 4, objs = { { text = "Filled Crystal Phial: 0/1", done = false } } })
settle()
local back, left = 0, {}
for _, id in ipairs(ids921) do for _, n in ipairs(stepsOf(id)) do
if n == a921 then
elseif S.Passed(n) then table.insert(left, n) else back = back + 1 end
end end
check(table.getn(left) == 0 and back > 3, "picked up again: every later step of the chain is back (" .. back .. " back" .. (table.getn(left) > 0 and (", still passed: " .. table.concat(left, " ")) or "") .. ")")
check(S.Position() < where, " ...and the guide goes back to them by itself (now at " .. S.Position() .. ")")
-- without clicking anything, the brought-back steps show as still to do: no tick, no skip mark
FauxScrollFrame_SetOffset(F("GuideScroll"), 0); ER.StepsChanged()
local marked, open = {}, 0
for _, it in ipairs(S.All()) do
for _, id in ipairs(ids921) do
for _, e in ipairs(it.step.elements) do
if tonumber(e.id) == id and it.step.n < where and it.step.n ~= a921 and (e.kind ~= "A" or id ~= 921) then
if it.done then table.insert(marked, it.step.n .. "=" .. tostring(it.how)) else open = open + 1 end
end
end
end
end
check(table.getn(marked) == 0 and open > 0, " ...the brought-back steps show as still to do (no tick, no skip mark) without clicking them (" .. open .. " open" .. (table.getn(marked) > 0 and (", marked: " .. table.concat(marked, " ")) or "") .. ")")
local rowB
for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.step and r.step.n == c921[2] then rowB = r end end
if rowB then check(not rowB.check:GetChecked() and not rowB.skipMark:IsShown(), " ...in the list too: its box is empty") end
-- go back and play the chain: the guide stops at each part's steps
local visited = {}
local g2 = 0
while S.Position() <= lastChainStep and g2 < 200 do
local st = S.Current()
for _, e in ipairs(st.elements) do
local id = tonumber(e.id)
if id == 921 then visited[921] = true end
for _, cid in ipairs(laterIds) do if id == cid then visited[cid] = true end end
local title = id and S.QuestTitle(id)
if title and e.kind == "A" and not logIdx(title) then table.insert(W.log, { id = id, title = title, level = S.QuestLevel(id) or 5, objs = { { text = "thing: 0/1", done = false } } }) end
if title and e.kind == "C" and logIdx(title) then local q = W.log[logIdx(title)] q.complete = true q.objs[1].done = true end
if title and e.kind == "T" and logIdx(title) then W_TITLE = title; GetQuestReward(0); table.remove(W.log, logIdx(title)) end
end
settle()
if S.Current() == st then S.Next() end
g2 = g2 + 1
end
local seen, want = {}, 0
for _, cid in ipairs(laterIds) do if table.getn(stepsOf(cid)) > 0 then want = want + 1 if visited[cid] then table.insert(seen, cid) end end end
check(visited[921] and table.getn(seen) == want, " ...going back, the guide walks the whole chain again (" .. table.concat(seen, " ") .. ")")
else P("note no Crown of the Earth chain in this guide") end
end
-- right after abandoning, the step box offers to go back to where you pick it up, and the arrow then points at the giver
do
local a921
for _, it in ipairs(S.All()) do for _, e in ipairs(it.step.elements) do if e.kind == "A" and tonumber(e.id) == 921 then a921 = a921 or it.step.n end end end
if a921 then
fresh()
playTo("C", 921)
local t921 = S.QuestTitle(921)
if logIdx(t921) then
GetAbandonQuestName = function() return t921 end
SetAbandonQuest()
table.remove(W.log, logIdx(t921)); settle()
local inBox
for j = 1, 12 do local b = F("GuideLine" .. j) if b and b:IsShown() and strip(b.text._text):find("abandoned", 1, true) then inBox = true end end
check(not inBox, "just abandoned: nothing about it in the step box")
-- scroll the list to it with the mouse wheel
local list = F("GuideList")
local function shownRow(n) for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.step and r.step.n == n then return r end end end
for k = 1, 60 do if shownRow(a921) then break end this = list; arg1 = 1; list._scripts.OnMouseWheel() end
for k = 1, 60 do if shownRow(a921) then break end this = list; arg1 = -1; list._scripts.OnMouseWheel() end
local btn
for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.step and r.step.n == a921 then btn = r end end
check(btn and btn.regain and btn.btn[1]:IsShown() and btn.btn[4]:IsShown(), " ...its pick-up step in the list looks like a button (outlined)")
if btn then
GameTooltip.SetText = function(self, t) self._title = t end
this = btn; btn._scripts.OnEnter()
check(GameTooltip._title == "Click to go back and pick it up again", " ...its tooltip: \"" .. tostring(GameTooltip._title) .. "\"")
this = btn; btn._scripts.OnLeave()
local p0 = S.Position()
this = btn; arg1 = "LeftButton"; btn._scripts.OnClick()
local tg = S.Target()
local giver
for _, e in ipairs(S.Current().elements) do if e.kind == "G" then giver = e end end
check(S.Position() == a921, " ...one click goes back to where you pick it up (step " .. S.Position() .. ")")
check(tg and giver and math.abs(tg.x - giver.x) < 0.01 and math.abs(tg.y - giver.y) < 0.01 and strip(tg.text or ""):find("Tenaron", 1, true),
" ...and the arrow points at the quest giver: " .. strip(tg and tg.text or "none") .. " (" .. (tg and (tg.x .. ", " .. tg.y) or "?") .. ")")
end
-- while it can be picked up it stays a button; once it cannot (here: below its level), it is skipped for good
for i = 1, 4 do S.Next() end
settle()
local function regainRow() for _, it in ipairs(S.All()) do if it.step.n == a921 then return it end end end
local it1 = regainRow()
check(it1 and it1.regain, " ...moving on, it is still a button while the quest can be picked up")
-- the game would no longer offer it: here the quest before it (Tenaron's Summons) no longer counts as handed in
local saved920 = ER.db.done[ER.Char()][920]
local t920 = S.QuestTitle(920)
local savedT = ER.db.done[ER.Char()][t920]
ER.db.done[ER.Char()][920], ER.db.done[ER.Char()][t920] = nil, nil
settle()
local it2 = regainRow()
check(it2 and not it2.regain and it2.how == "passed" and not S.CanUnskip(a921), "can no longer be picked up: skipped for good, no button, not offered back (" .. tostring(it2 and it2.how) .. ")")
ER.db.done[ER.Char()][920], ER.db.done[ER.Char()][t920] = saved920, savedT
settle()
local it3 = regainRow()
check(it3 and not it3.regain, " ...and it stays skipped for good afterwards")
else P("note Crown of the Earth was not in the log at its work step") end
-- a quest the game would not offer again (the quest before it not handed in): skipped for good, still listed
fresh()
S.Jump(a921); settle()
table.insert(W.log, { id = 921, title = t921, level = S.QuestLevel(921), objs = { { text = "x: 0/1", done = false } } }); settle()
for i = 1, 4 do S.Next() end
SetAbandonQuest()
table.remove(W.log, logIdx(t921)); settle()
local listed
for _, it in ipairs(S.All()) do if it.step.n == a921 then listed = it end end
check(listed and not listed.regain and listed.how == "passed", "an abandoned quest the game would not offer (the quest before it not handed in) is skipped for good, still listed (" .. tostring(listed and listed.how) .. ")")
end
end
-- a quest you skip yourself becomes a button too, only at the top of a skipped chain; a grey quest is skipped for good
do
local hasChain = false
for _, it in ipairs(S.All()) do for _, e in ipairs(it.step.elements) do if e.kind == "C" and tonumber(e.id) == 921 then hasChain = true end end end
if hasChain then
fresh()
W.level = math.max(1, (S.QuestLevel(921) or 5))
playTo("C", 921)
local c921 = S.Position()
-- mark a later quest of the chain skipped too (Crown of the Earth 928's work), then skip 921's work with the Skip button
local c928
for _, it in ipairs(S.All()) do for _, e in ipairs(it.step.elements) do if e.kind == "C" and tonumber(e.id) == 928 and not c928 then c928 = it.step.n end end end
if c928 then S.SkipLater(c928, true) end
click(F("GuideSkip")); settle()
for g = 1, 4 do S.Next(); settle() end
local regs = {}
for _, it in ipairs(S.All()) do if it.step.n == c921 or it.step.n == c928 then print("dbg how", it.step.n, it.how, "main", S.MainQuest(it.step), "pos", S.Position()) end end
for _, it in ipairs(S.All()) do if it.regain then regs[it.step.n] = it.regain end end
check(regs[c921] and regs[c921].kind == "skipped", "a quest you skipped is a button in the list (step " .. c921 .. ")")
check(not c928 or not regs[c928], " ...only the top of the skipped chain: Crown of the Earth 928's skipped step is not a button of its own")
local list = F("GuideList")
local function shownRow(n) for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.step and r.step.n == n then return r end end end
for k = 1, 60 do if shownRow(c921) then break end this = list; arg1 = 1; list._scripts.OnMouseWheel() end
for k = 1, 60 do if shownRow(c921) then break end this = list; arg1 = -1; list._scripts.OnMouseWheel() end
local row = shownRow(c921)
check(row ~= nil, " ...found in the list")
if row then
GameTooltip.SetText = function(self, t) self._title = t end
this = row; row._scripts.OnEnter()
check(GameTooltip._title == "Click to go back and do it", " ...its tooltip: \"" .. tostring(GameTooltip._title) .. "\"")
this = row; row._scripts.OnLeave()
check(row.btn[1]:IsShown(), " ...outlined like a button")
this = row; arg1 = "LeftButton"; row._scripts.OnClick()
check(S.Position() == c921, " ...one click goes back to it (" .. S.Position() .. ")")
end
-- skip it again, then it goes grey: no longer worth going back for, skipped for good
click(F("GuideSkip")); settle()
for g = 1, 10 do S.Next() end
settle()
local lvl = W.level
W.level = 30
settle()
local after = nil
for _, it in ipairs(S.All()) do if it.step.n == c921 then after = it end end
check(after and not after.regain and not S.CanUnskip(c921), "grey now: the skipped quest is no longer a button and is not offered back")
W.level = lvl
settle()
end
end
P(fails == 0 and "ALL PASSED" or (fails .. " FAILED"))
REPORT()