Add Quest Shopping List

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-10 13:58:06 +00:00
parent adc76b9a87
commit 9d30c8fed8
7 changed files with 1766 additions and 3 deletions

View file

@ -262,6 +262,47 @@ do
end
end
-- Names and classes of quest objective items, for the shopping list.
local itemInfo = {}
do
local raw = {}
run(qdb .. "/data/Forever/foreverItemDB.lua", sandbox({ QuestieLoader = { ImportModule = function() return raw end, CreateModule = function() return raw end } }))
local real = assert(raw.itemKeys)
local chunk = assert(loadstring(assert(raw.itemData), "=itemData"))
setfenv(chunk, {})
for id, row in pairs(chunk()) do
itemInfo[id] = { name = row[real.name], class = row[real.class] }
end
local keys = setmetatable({}, { __index = function(_, k)
local base, op = k:match("^(.-)_(add)$")
if not base then base, op = k:match("^(.-)_(remove)$") end
if base then return (real[base] or 900) + (op == "add" and ADD or REMOVE) end
return real[k] or 900
end })
modules.QuestieDB.itemKeys = keys
for _, layer in ipairs({
{ "Forever/legacy/classicItemFixes.lua", "QuestieItemFixes" },
{ "Forever/generated/foreverBaseItem.lua", "ForeverBaseItem" },
{ "Forever/traces/foreverItemTraces.lua", "ForeverItemTraces" },
{ "Forever/foreverItemFixes.lua", "ForeverItemFixes" },
}) do
run(qdb .. "/src/corrections/" .. layer[1], sandbox(stubs))
local n = 0
for id, row in pairs(modules[layer[2]]:Load(keys)) do
n = n + 1
local name, class = row[real.name], row[real.class]
if type(name) == "string" or type(class) == "number" then
itemInfo[id] = itemInfo[id] or {}
if type(name) == "string" then itemInfo[id].name = name end
if type(class) == "number" then itemInfo[id].class = class end
end
end
io.stderr:write(layer[2], ": ", n, " rows\n")
end
end
-- Dungeon list is parsed as text, not run.
local zoneNames, allNames = {}, {}
for line in read(qdb .. "/support/Forever/Zones/dungeons.lua"):gmatch("[^\n]+") do
@ -349,6 +390,24 @@ local function writeSpawns(label, source, group)
end
writeSpawns("npcs", npcSpawns, 1)
writeSpawns("objects", objectSpawns, 2)
do
local seen = {}
out:write(",\nobjectiveItems={\n")
for _, r in pairs(q) do
local group = type(r.objectives) == "table" and r.objectives[3]
if type(group) == "table" then
for _, objective in ipairs(group) do
local id = type(objective) == "table" and objective[1]
local info = id and itemInfo[id]
if info and info.name and not seen[id] then
seen[id] = true
out:write("[", id, "]={name=", string.format("%q", info.name), ",class=", tostring(info.class or 0), "},\n")
end
end
end
end
out:write("}")
end
out:write(",\nareaToMap={")
for area, map in pairs(areaToMap) do out:write("[", area, "]=", map, ",") end
out:write("},\nraceBits={")