DungeonPreQuest: mark dungeon quests too, refresh QuestieDB data
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9d30c8fed8
commit
01a351a865
10 changed files with 628 additions and 70 deletions
|
|
@ -57,8 +57,14 @@ local function available(r, factionMask, classBit)
|
|||
return true
|
||||
end
|
||||
|
||||
-- result[quest][dungeon][factionBit] = class mask
|
||||
local result = {}
|
||||
-- result[quest][dungeon][factionBit] = class mask, for the dungeons a quest
|
||||
-- leads to; own[...] the same for the dungeon a quest itself is done in.
|
||||
local result, own = {}, {}
|
||||
local function add(t, id, name, factionBit, classBit)
|
||||
t[id] = t[id] or {}
|
||||
t[id][name] = t[id][name] or {}
|
||||
t[id][name][factionBit] = (t[id][name][factionBit] or 0) + classBit
|
||||
end
|
||||
for _, faction in ipairs(FACTIONS) do
|
||||
for _, class in ipairs(CLASSES) do
|
||||
local classBit = data.classKeys[class]
|
||||
|
|
@ -76,11 +82,8 @@ for _, faction in ipairs(FACTIONS) do
|
|||
local found = {}
|
||||
walk(id, { [id] = true }, found)
|
||||
found[dungeon[id] or false] = nil
|
||||
for name in pairs(found) do
|
||||
result[id] = result[id] or {}
|
||||
result[id][name] = result[id][name] or {}
|
||||
result[id][name][faction.bit] = (result[id][name][faction.bit] or 0) + classBit
|
||||
end
|
||||
for name in pairs(found) do add(result, id, name, faction.bit, classBit) end
|
||||
if dungeon[id] then add(own, id, dungeon[id], faction.bit, classBit) end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -95,36 +98,50 @@ for _, n in ipairs(data.allDungeons) do
|
|||
end
|
||||
nameIndex[UNNAMED] = 0
|
||||
|
||||
local ids = {}
|
||||
for id in pairs(result) do ids[#ids + 1] = id end
|
||||
table.sort(ids)
|
||||
local function sortedIds(...)
|
||||
local seen, list = {}, {}
|
||||
for _, t in ipairs({ ... }) do
|
||||
for id in pairs(t) do
|
||||
if not seen[id] then seen[id] = true; list[#list + 1] = id end
|
||||
end
|
||||
end
|
||||
table.sort(list)
|
||||
return list
|
||||
end
|
||||
local ids = sortedIds(result, own)
|
||||
|
||||
local out = assert(io.open(arg[2], "w"))
|
||||
out:write("-- Generated from QuestieDB's Forever quest data. Do not edit.\n")
|
||||
out:write("-- quests[id] = { dungeon, faction, classes, ... }; faction 1 Alliance, 2 Horde, 3 both; classes 0 = all; dungeon 0 = unnamed.\n")
|
||||
out:write("-- quests[id] = { dungeon, faction, classes, ... } for the dungeons a quest leads to;\n")
|
||||
out:write("-- dungeonQuests[id] the same for the dungeon a quest is done in.\n")
|
||||
out:write("-- faction 1 Alliance, 2 Horde, 3 both; classes 0 = all; dungeon 0 = unnamed.\n")
|
||||
out:write("local _, ns = ...\n\nns.dungeons = {\n")
|
||||
for _, n in ipairs(names) do out:write(string.format(" %q,\n", n)) end
|
||||
out:write("}\n\nns.quests = {\n")
|
||||
for _, id in ipairs(ids) do
|
||||
local parts = {}
|
||||
local dungeonsHere = {}
|
||||
for name in pairs(result[id]) do dungeonsHere[#dungeonsHere + 1] = name end
|
||||
table.sort(dungeonsHere)
|
||||
for _, name in ipairs(dungeonsHere) do
|
||||
local byFaction = result[id][name]
|
||||
local a, h = byFaction[1], byFaction[2]
|
||||
local function emit(faction, mask)
|
||||
parts[#parts + 1] = nameIndex[name] .. "," .. faction .. "," .. (mask == ALL_CLASSES and 0 or mask)
|
||||
end
|
||||
if a and a == h then
|
||||
emit(3, a)
|
||||
else
|
||||
if a then emit(1, a) end
|
||||
if h then emit(2, h) end
|
||||
local function writeTable(label, t)
|
||||
out:write("}\n\nns.", label, " = {\n")
|
||||
for _, id in ipairs(sortedIds(t)) do
|
||||
local parts = {}
|
||||
local dungeonsHere = {}
|
||||
for name in pairs(t[id]) do dungeonsHere[#dungeonsHere + 1] = name end
|
||||
table.sort(dungeonsHere)
|
||||
for _, name in ipairs(dungeonsHere) do
|
||||
local byFaction = t[id][name]
|
||||
local a, h = byFaction[1], byFaction[2]
|
||||
local function emit(faction, mask)
|
||||
parts[#parts + 1] = nameIndex[name] .. "," .. faction .. "," .. (mask == ALL_CLASSES and 0 or mask)
|
||||
end
|
||||
if a and a == h then
|
||||
emit(3, a)
|
||||
else
|
||||
if a then emit(1, a) end
|
||||
if h then emit(2, h) end
|
||||
end
|
||||
end
|
||||
out:write(" [", id, "]={", table.concat(parts, ","), "},\n")
|
||||
end
|
||||
out:write(" [", id, "]={", table.concat(parts, ","), "},\n")
|
||||
end
|
||||
writeTable("quests", result)
|
||||
writeTable("dungeonQuests", own)
|
||||
out:write("}\n")
|
||||
out:close()
|
||||
|
||||
|
|
@ -156,7 +173,7 @@ local function show(id)
|
|||
end
|
||||
print(id, q[id] and q[id].name, table.concat(list, " | "))
|
||||
end
|
||||
for _, id in ipairs({ 65, 155, 166, 8928, 8916, 94501 }) do show(id) end
|
||||
for _, id in ipairs({ 65, 155, 166, 2929, 8928, 8916, 94501 }) do show(id) end
|
||||
|
||||
-- Quest giver locations and the rules for when each quest can be picked up.
|
||||
-- Quests whose requirements the addon can't check get no marker.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue