From ef6cb6ab607b0c59aba0733735bbdc379b1d6ceb Mon Sep 17 00:00:00 2001 From: rope Date: Tue, 10 Nov 2026 13:28:44 +0000 Subject: [PATCH] DungeonPreQuest: minimap markers Co-Authored-By: Claude Opus 5.5 --- DungeonPreQuest/DungeonPreQuest.lua | 3 + DungeonPreQuest/DungeonPreQuest.toc | 9 +- .../CallbackHandler-1.0.lua | 202 ++++ .../Libs/HereBeDragons/HereBeDragons-2.0.lua | 717 +++++++++++++++ .../HereBeDragons/HereBeDragons-Pins-2.0.lua | 865 ++++++++++++++++++ DungeonPreQuest/Libs/LibStub/LICENSE.txt | 29 + DungeonPreQuest/Libs/LibStub/LibStub.lua | 30 + DungeonPreQuest/Minimap.lua | 143 +++ DungeonPreQuest/PinData.lua | 321 +++++++ DungeonPreQuest/tools/extract.lua | 106 ++- DungeonPreQuest/tools/generate.lua | 73 ++ README.md | 10 +- tests/test_dpq_minimap.lua | 181 ++++ 13 files changed, 2682 insertions(+), 7 deletions(-) create mode 100644 DungeonPreQuest/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua create mode 100644 DungeonPreQuest/Libs/HereBeDragons/HereBeDragons-2.0.lua create mode 100644 DungeonPreQuest/Libs/HereBeDragons/HereBeDragons-Pins-2.0.lua create mode 100644 DungeonPreQuest/Libs/LibStub/LICENSE.txt create mode 100755 DungeonPreQuest/Libs/LibStub/LibStub.lua create mode 100644 DungeonPreQuest/Minimap.lua create mode 100644 DungeonPreQuest/PinData.lua create mode 100644 tests/test_dpq_minimap.lua diff --git a/DungeonPreQuest/DungeonPreQuest.lua b/DungeonPreQuest/DungeonPreQuest.lua index 9fc28fb..3aaef42 100644 --- a/DungeonPreQuest/DungeonPreQuest.lua +++ b/DungeonPreQuest/DungeonPreQuest.lua @@ -48,6 +48,9 @@ local function Describe(names) return LABEL .. ": " .. table.concat(names, ", ") end +ns.DungeonsFor = DungeonsFor +ns.Describe = Describe + local function MarkRow(button) local names = DungeonsFor(button.questID) if not names then diff --git a/DungeonPreQuest/DungeonPreQuest.toc b/DungeonPreQuest/DungeonPreQuest.toc index 8017e06..fe2db27 100644 --- a/DungeonPreQuest/DungeonPreQuest.toc +++ b/DungeonPreQuest/DungeonPreQuest.toc @@ -1,7 +1,14 @@ ## Interface: 16001 ## Title: Dungeon Pre-Quest ## Notes: Marks quests whose chain leads to a dungeon quest. -## Version: 1.0 +## Version: 1.1 + +Libs\LibStub\LibStub.lua +Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua +Libs\HereBeDragons\HereBeDragons-2.0.lua +Libs\HereBeDragons\HereBeDragons-Pins-2.0.lua Data.lua +PinData.lua DungeonPreQuest.lua +Minimap.lua diff --git a/DungeonPreQuest/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua b/DungeonPreQuest/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua new file mode 100644 index 0000000..21569f4 --- /dev/null +++ b/DungeonPreQuest/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua @@ -0,0 +1,202 @@ +--[[ $Id: CallbackHandler-1.0.lua 26 2022-12-12 15:09:39Z nevcairiel $ ]] +local MAJOR, MINOR = "CallbackHandler-1.0", 8 +local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR) + +if not CallbackHandler then return end -- No upgrade needed + +local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end} + +-- Lua APIs +local securecallfunction, error = securecallfunction, error +local setmetatable, rawget = setmetatable, rawget +local next, select, pairs, type, tostring = next, select, pairs, type, tostring + + +local function Dispatch(handlers, ...) + local index, method = next(handlers) + if not method then return end + repeat + securecallfunction(method, ...) + index, method = next(handlers, index) + until not method +end + +-------------------------------------------------------------------------- +-- CallbackHandler:New +-- +-- target - target object to embed public APIs in +-- RegisterName - name of the callback registration API, default "RegisterCallback" +-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback" +-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API. + +function CallbackHandler.New(_self, target, RegisterName, UnregisterName, UnregisterAllName) + + RegisterName = RegisterName or "RegisterCallback" + UnregisterName = UnregisterName or "UnregisterCallback" + if UnregisterAllName==nil then -- false is used to indicate "don't want this method" + UnregisterAllName = "UnregisterAllCallbacks" + end + + -- we declare all objects and exported APIs inside this closure to quickly gain access + -- to e.g. function names, the "target" parameter, etc + + + -- Create the registry object + local events = setmetatable({}, meta) + local registry = { recurse=0, events=events } + + -- registry:Fire() - fires the given event/message into the registry + function registry:Fire(eventname, ...) + if not rawget(events, eventname) or not next(events[eventname]) then return end + local oldrecurse = registry.recurse + registry.recurse = oldrecurse + 1 + + Dispatch(events[eventname], eventname, ...) + + registry.recurse = oldrecurse + + if registry.insertQueue and oldrecurse==0 then + -- Something in one of our callbacks wanted to register more callbacks; they got queued + for event,callbacks in pairs(registry.insertQueue) do + local first = not rawget(events, event) or not next(events[event]) -- test for empty before. not test for one member after. that one member may have been overwritten. + for object,func in pairs(callbacks) do + events[event][object] = func + -- fire OnUsed callback? + if first and registry.OnUsed then + registry.OnUsed(registry, target, event) + first = nil + end + end + end + registry.insertQueue = nil + end + end + + -- Registration of a callback, handles: + -- self["method"], leads to self["method"](self, ...) + -- self with function ref, leads to functionref(...) + -- "addonId" (instead of self) with function ref, leads to functionref(...) + -- all with an optional arg, which, if present, gets passed as first argument (after self if present) + target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]]) + if type(eventname) ~= "string" then + error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2) + end + + method = method or eventname + + local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten. + + if type(method) ~= "string" and type(method) ~= "function" then + error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2) + end + + local regfunc + + if type(method) == "string" then + -- self["method"] calling style + if type(self) ~= "table" then + error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2) + elseif self==target then + error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2) + elseif type(self[method]) ~= "function" then + error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2) + end + + if select("#",...)>=1 then -- this is not the same as testing for arg==nil! + local arg=select(1,...) + regfunc = function(...) self[method](self,arg,...) end + else + regfunc = function(...) self[method](self,...) end + end + else + -- function ref with self=object or self="addonId" or self=thread + if type(self)~="table" and type(self)~="string" and type(self)~="thread" then + error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2) + end + + if select("#",...)>=1 then -- this is not the same as testing for arg==nil! + local arg=select(1,...) + regfunc = function(...) method(arg,...) end + else + regfunc = method + end + end + + + if events[eventname][self] or registry.recurse<1 then + -- if registry.recurse<1 then + -- we're overwriting an existing entry, or not currently recursing. just set it. + events[eventname][self] = regfunc + -- fire OnUsed callback? + if registry.OnUsed and first then + registry.OnUsed(registry, target, eventname) + end + else + -- we're currently processing a callback in this registry, so delay the registration of this new entry! + -- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency + registry.insertQueue = registry.insertQueue or setmetatable({},meta) + registry.insertQueue[eventname][self] = regfunc + end + end + + -- Unregister a callback + target[UnregisterName] = function(self, eventname) + if not self or self==target then + error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2) + end + if type(eventname) ~= "string" then + error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2) + end + if rawget(events, eventname) and events[eventname][self] then + events[eventname][self] = nil + -- Fire OnUnused callback? + if registry.OnUnused and not next(events[eventname]) then + registry.OnUnused(registry, target, eventname) + end + end + if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then + registry.insertQueue[eventname][self] = nil + end + end + + -- OPTIONAL: Unregister all callbacks for given selfs/addonIds + if UnregisterAllName then + target[UnregisterAllName] = function(...) + if select("#",...)<1 then + error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2) + end + if select("#",...)==1 and ...==target then + error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2) + end + + + for i=1,select("#",...) do + local self = select(i,...) + if registry.insertQueue then + for eventname, callbacks in pairs(registry.insertQueue) do + if callbacks[self] then + callbacks[self] = nil + end + end + end + for eventname, callbacks in pairs(events) do + if callbacks[self] then + callbacks[self] = nil + -- Fire OnUnused callback? + if registry.OnUnused and not next(callbacks) then + registry.OnUnused(registry, target, eventname) + end + end + end + end + end + end + + return registry +end + + +-- CallbackHandler purposefully does NOT do explicit embedding. Nor does it +-- try to upgrade old implicit embeds since the system is selfcontained and +-- relies on closures to work. + diff --git a/DungeonPreQuest/Libs/HereBeDragons/HereBeDragons-2.0.lua b/DungeonPreQuest/Libs/HereBeDragons/HereBeDragons-2.0.lua new file mode 100644 index 0000000..4ed92a4 --- /dev/null +++ b/DungeonPreQuest/Libs/HereBeDragons/HereBeDragons-2.0.lua @@ -0,0 +1,717 @@ +-- HereBeDragons is a data API for the World of Warcraft mapping system + +local MAJOR, MINOR = "HereBeDragonsQuestie-2.0", 34 +assert(LibStub, MAJOR .. " requires LibStub") + +local HereBeDragons, oldversion = LibStub:NewLibrary(MAJOR, MINOR) +if not HereBeDragons then return end + +local CBH = LibStub("CallbackHandler-1.0") + +HereBeDragons.eventFrame = HereBeDragons.eventFrame or CreateFrame("Frame") + +HereBeDragons.mapData = HereBeDragons.mapData or {} +HereBeDragons.worldMapData = HereBeDragons.worldMapData or {} +HereBeDragons.transforms = HereBeDragons.transforms or {} +HereBeDragons.instanceZones = HereBeDragons.instanceZones or {} +HereBeDragons.callbacks = HereBeDragons.callbacks or CBH:New(HereBeDragons, nil, nil, false) + +-- Embedded libraries load before Questie's client flags. Forever shares Retail's project ID, +-- but its map hierarchy and instance transforms belong to Classic. +local interfaceVersion = select(4, GetBuildInfo()) +local WoWClassic = (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) or (interfaceVersion >= 16000 and interfaceVersion < 17000) +local WoWBC = (WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC) +local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC) +local WoWCata = (WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC) +local WoWMists = (WOW_PROJECT_ID == WOW_PROJECT_MISTS_CLASSIC) + +-- Data Constants +local COSMIC_MAP_ID = 946 +local WORLD_MAP_ID = 947 + +-- Lua upvalues +local PI2 = math.pi * 2 +local atan2 = math.atan2 +local pairs, ipairs = pairs, ipairs + +-- WoW API upvalues +local UnitPosition = UnitPosition +local C_Map = C_Map + +-- data table upvalues +local mapData = HereBeDragons.mapData -- table { width, height, left, top, .instance, .name, .mapType } +local worldMapData = HereBeDragons.worldMapData -- table { width, height, left, top } +local transforms = HereBeDragons.transforms +local instanceZones = HereBeDragons.instanceZones + +local currentPlayerUIMapID, currentPlayerUIMapType + +-- Override instance ids for phased content +local instanceIDOverrides = { + -- Draenor + [1152] = 1116, -- Horde Garrison 1 + [1330] = 1116, -- Horde Garrison 2 + [1153] = 1116, -- Horde Garrison 3 + [1154] = 1116, -- Horde Garrison 4 (unused) + [1158] = 1116, -- Alliance Garrison 1 + [1331] = 1116, -- Alliance Garrison 2 + [1159] = 1116, -- Alliance Garrison 3 + [1160] = 1116, -- Alliance Garrison 4 (unused) + [1191] = 1116, -- Ashran PvP Zone + [1203] = 1116, -- Frostfire Finale Scenario + [1207] = 1116, -- Talador Finale Scenario + [1277] = 1116, -- Defense of Karabor Scenario (SMV) + [1402] = 1116, -- Gorgrond Finale Scenario + [1464] = 1116, -- Tanaan + [1465] = 1116, -- Tanaan + -- Legion + [1478] = 1220, -- Temple of Elune Scenario (Val'Sharah) + [1495] = 1220, -- Protection Paladin Artifact Scenario (Stormheim) + [1502] = 1220, -- Dalaran Underbelly + [1533] = 0, -- Karazhan Artifact Scenario + [1539] = 0, -- Arm Warrior Artifact Tirisfal Scenario + [1612] = 1220, -- Feral Druid Artifact Scenario (Suramar) + [1626] = 1220, -- Suramar Withered Scenario + [1662] = 1220, -- Suramar Invasion Scenario + -- BfA + [2213] = 0, -- Horrific Vision of Stormwind + [2241] = 1, -- Uldum N'zoth assault + [2274] = 1, -- Uldum N'zoth Minor Vision + [2275] = 870, -- Vale of Eternal Blossoms N'zoth Minor Vision +} + +local dynamicInstanceIDOverrides = {} +instanceIDOverrides = setmetatable(instanceIDOverrides, { __index = dynamicInstanceIDOverrides }) + +local function overrideInstance(instance) return instanceIDOverrides[instance] or instance end + +-- debug only +HereBeDragons.___DIIDO = dynamicInstanceIDOverrides + +-- gather map info, but only if this isn't an upgrade (or the upgrade version forces a re-map) +if not oldversion or oldversion < 34 then + -- wipe old data, if required, otherwise the upgrade path isn't triggered + if oldversion then + wipe(mapData) + wipe(worldMapData) + wipe(transforms) + wipe(instanceZones) + end + + -- map transform data extracted from UIMapAssignment.db2 (see HereBeDragons-Scripts on GitHub) + -- format: instanceID, newInstanceID, minY, maxY, minX, maxX, offsetY, offsetX + local transformData + if WoWClassic then + transformData = {} + elseif WoWBC or WoWWrath or WoWCata then + transformData = { + { 530, 0, 4800, 16000, -10133.3, -2666.67, -2400, 2662.8 }, + { 530, 1, -6933.33, 533.33, -16000, -8000, 10339.7, 17600 }, + } + elseif WoWMists then + transformData = { + { 530, 1, -6933.33, 533.33, -16000, -8000, 10339.7, 17600 }, + { 530, 0, 4800, 16000, -10133.3, -2666.67, -2400, 2662.8 }, + { 1014, 870, 3200, 5333.3, 1066.7, 2666.7, 0, 0 }, + -- { 1064, 870, 5391, 8148, 3518, 7655, -2134.2, -2286.6 }, -- end of MoP values when Timeless Isle is out + } + else + transformData = { + { 530, 0, 4800, 16000, -10133.3, -2666.67, -2400, 2400 }, + { 530, 1, -6933.33, 533.33, -16000, -8000, 9916, 17600 }, + { 1014, 870, 3200, 5333.3, 1066.7, 2666.7, 0, 0 }, + { 1208, 1116, -2666, -2133, -2133, -1600, 10210.7, 2411.4 }, + { 1460, 1220, -1066.7, 2133.3, 0, 3200, -2333.9, 966.7 }, + { 1498, 1220, -533.3, 2133.3, 3733.3, 5866.7, 0, 0 }, + { 1545, 1220, -2666.7, 0, 4800, 8000, 0, -0 }, + { 1599, 1, 4800, 5866.7, -4266.7, -3200, -490.6, -0.4 }, + } + end + + local function processTransforms() + for _, transform in pairs(transformData) do + local instanceID, newInstanceID, minY, maxY, minX, maxX, offsetY, offsetX = unpack(transform) + if not transforms[instanceID] then + transforms[instanceID] = {} + end + table.insert(transforms[instanceID], { newInstanceID = newInstanceID, minY = minY, maxY = maxY, minX = minX, maxX = maxX, offsetY = offsetY, offsetX = offsetX }) + end + end + + local function applyMapTransforms(instanceID, left, right, top, bottom) + if transforms[instanceID] then + for _, data in ipairs(transforms[instanceID]) do + if left <= data.maxX and right >= data.minX and top <= data.maxY and bottom >= data.minY then + instanceID = data.newInstanceID + left = left + data.offsetX + right = right + data.offsetX + top = top + data.offsetY + bottom = bottom + data.offsetY + break + end + end + end + return instanceID, left, right, top, bottom + end + + local vector00, vector05 = CreateVector2D(0, 0), CreateVector2D(0.5, 0.5) + -- gather the data of one map (by uiMapID) + local function processMap(id, data, parent) + if not id or mapData[id] then return end + + if not data then + data = C_Map.GetMapInfo(id) + if not data then return end + end + + if data.parentMapID and data.parentMapID ~= 0 then + parent = data.parentMapID + elseif not parent then + parent = 0 + end + + -- get two positions from the map, we use 0/0 and 0.5/0.5 to avoid issues on some maps where 1/1 is translated inaccurately + local instance, center = C_Map.GetWorldPosFromMapPos(id, vector05) + local width, height + if C_Map.GetMapWorldSize then + width, height = C_Map.GetMapWorldSize(id) + else + -- compat for classic... why does that not have GetMapWorldSize? + local _, topleft = C_Map.GetWorldPosFromMapPos(id, vector00) + if center and topleft then + local top, left = topleft:GetXY() + local bottom, right = center:GetXY() + width = (left - right) * 2 + height = (top - bottom) * 2 + end + end + if center and width and height then + local top, left = center:GetXY() + top = top + (height / 2) + local bottom = top - height + left = left + (width / 2) + local right = left - width + + instance, left, right, top, bottom = applyMapTransforms(instance, left, right, top, bottom) + mapData[id] = {left - right, top - bottom, left, top, instance = instance, name = data.name, mapType = data.mapType, parent = parent } + else + mapData[id] = {0, 0, 0, 0, instance = instance or -1, name = data.name, mapType = data.mapType, parent = parent } + end + + -- check for zones that are a different instance as their parent continent + if data.mapType == Enum.UIMapType.Zone and mapData[parent] and mapData[parent].mapType == Enum.UIMapType.Continent and instance >= 0 and mapData[parent].instance >= 0 and instance ~= mapData[parent].instance then + local minX, maxX, minY, maxY = C_Map.GetMapRectOnMap(id, parent) + if minX and maxX and minY and maxY and maxX > 0 and maxY > 0 then + mapData[id].rectOnParent = { minX = minX, maxX = maxX, minY = minY, maxY = maxY, parentInstance = mapData[parent].instance } + if not instanceZones[instance] then + instanceZones[instance] = {} + end + if not instanceZones[instance][mapData[parent].instance] then + instanceZones[instance][mapData[parent].instance] = {} + end + table.insert(instanceZones[instance][mapData[parent].instance], id) + end + end + end + + local function processMapChildrenRecursive(parent) + local children = C_Map.GetMapChildrenInfo(parent) + if children and #children > 0 then + for i = 1, #children do + local id = children[i].mapID + if id and not mapData[id] then + processMap(id, children[i], parent) + processMapChildrenRecursive(id) + + -- process sibling maps (in the same group) + -- in some cases these are not discovered by GetMapChildrenInfo above + local groupID = C_Map.GetMapGroupID(id) + if groupID then + local groupMembers = C_Map.GetMapGroupMembersInfo(groupID) + if groupMembers then + for k = 1, #groupMembers do + local memberId = groupMembers[k].mapID + if memberId and not mapData[memberId] then + processMap(memberId, nil, parent) + processMapChildrenRecursive(memberId) + end + end + end + end + end + end + end + end + + ---Derives an instance's Azeroth bounds from its continent bounds and Blizzard's displayed rectangle. + ---@param continentMapID number + ---@return nil + local function updateClassicWorldMapData(continentMapID) + if not C_Map.GetMapRectOnMap then return end + local data = mapData[continentMapID] + if not data or data[1] <= 0 or data[2] <= 0 then return end + + local minX, maxX, minY, maxY = C_Map.GetMapRectOnMap(continentMapID, WORLD_MAP_ID) + if not (minX and maxX and minY and maxY and maxX > minX and maxY > minY) then return end + + -- Rectangles may extend outside 0..1; that is valid for continent maps and must not be clamped. + local width = data[1] / (maxX - minX) + local height = data[2] / (maxY - minY) + worldMapData[data.instance] = {width, height, data[3] + width * minX, data[4] + height * minY} + end + + local function fixupZones() + local cosmic = C_Map.GetMapInfo(COSMIC_MAP_ID) + if cosmic then + mapData[COSMIC_MAP_ID] = {0, 0, 0, 0} + mapData[COSMIC_MAP_ID].instance = -1 + mapData[COSMIC_MAP_ID].name = cosmic.name + mapData[COSMIC_MAP_ID].mapType = cosmic.mapType + end + + -- data for the azeroth world map + if WoWClassic then + worldMapData[0] = { 44688.53, 29795.11, 32601.04, 9894.93 } + worldMapData[1] = { 44878.66, 29916.10, 8723.96, 14824.53 } + -- Calibrate Era and Forever independently. Retain the legacy bounds only when the API has no usable rectangle. + updateClassicWorldMapData(1415) -- Eastern Kingdoms + updateClassicWorldMapData(1414) -- Kalimdor + elseif WoWBC then + worldMapData[0] = { 44688.53, 29791.24, 32681.47, 11479.44 } + worldMapData[1] = { 44878.66, 29916.10, 8723.96, 14824.53 } + elseif WoWWrath then + worldMapData[0] = { 48033.24, 32020.8, 36867.97, 14848.84 } + worldMapData[1] = { 47908.72, 31935.28, 8552.61, 18467.83 } + worldMapData[571] = { 47662.7, 31772.19, 25198.53, 11072.07 } + elseif WoWCata then + worldMapData[0] = { 48033.24, 32020.8, 36867.97, 14848.84 } + worldMapData[1] = { 47908.72, 31935.28, 8552.61, 18467.83 } + worldMapData[571] = { 47662.7, 31772.19, 25198.53, 11072.07 } + elseif WoWMists then + worldMapData[0] = { 57114.85, 38082.53, 46284.08, 15795.1 } + worldMapData[1] = { 58984.3, 39319.22, 10153.84, 19536.12 } + worldMapData[571] = { 56338.03, 37567.89, 29892.96, 11496.56 } + worldMapData[870] = { 53103.22, 35408.03, 28648.8, 30726.23 } + else + worldMapData[0] = { 76153.14, 50748.62, 65008.24, 23827.51 } + worldMapData[1] = { 77621.12, 51854.98, 12444.4, 28030.61 } + worldMapData[571] = { 71773.64, 50054.05, 36205.94, 12366.81 } + worldMapData[870] = { 67710.54, 45118.08, 33565.89, 38020.67 } + worldMapData[1220] = { 82758.64, 55151.28, 52943.46, 24484.72 } + worldMapData[1642] = { 77933.3, 51988.91, 44262.36, 32835.1 } + worldMapData[1643] = { 76060.47, 50696.96, 55384.8, 25774.35 } + worldMapData[2444] = { 111420.37, 74283, 86088.21, 15682.4 } + worldMapData[2552] = { 82171.44, 54787.67, 21219.3, 47876.05 } + worldMapData[2601] = { 67929.29, 49267.42, 18325.63, 42233.06 } + end + end + + local function gatherMapData() + processTransforms() + + -- find all maps in well known structures + if WoWClassic then + processMap(WORLD_MAP_ID) + processMapChildrenRecursive(WORLD_MAP_ID) + else + processMapChildrenRecursive(COSMIC_MAP_ID) + end + + fixupZones() + + -- try to fill in holes in the map list + for i = 1, 2500 do + if not mapData[i] then + local mapInfo = C_Map.GetMapInfo(i) + if mapInfo and mapInfo.name then + processMap(i, mapInfo, nil) + end + end + end + end + + gatherMapData() +end + +-- Transform a set of coordinates based on the defined map transformations +local function applyCoordinateTransforms(x, y, instanceID) + if transforms[instanceID] then + for _, transformData in ipairs(transforms[instanceID]) do + if transformData.minX <= x and transformData.maxX >= x and transformData.minY <= y and transformData.maxY >= y then + instanceID = transformData.newInstanceID + x = x + transformData.offsetX + y = y + transformData.offsetY + break + end + end + end + return x, y, overrideInstance(instanceID) +end + +local StartUpdateTimer +local function UpdateCurrentPosition(instanceCheck) + -- retrieve current zone + local uiMapID = C_Map.GetBestMapForUnit("player") + + -- try to override the instance if possible + if instanceCheck then + local _x, _y, instance = HereBeDragons:GetPlayerWorldPosition() + if instance and instance ~= -1 and mapData[uiMapID] and mapData[uiMapID].instance ~= instance and uiMapID ~= -1 and not instanceIDOverrides[instance] and not instanceIDOverrides[mapData[uiMapID].instance] then + dynamicInstanceIDOverrides[instance] = mapData[uiMapID].instance + end + end + + if uiMapID ~= currentPlayerUIMapID then + -- update location upvalues + currentPlayerUIMapID, currentPlayerUIMapType = uiMapID, mapData[uiMapID] and mapData[uiMapID].mapType or 0 + + -- signal callback + HereBeDragons.callbacks:Fire("PlayerZoneChanged", currentPlayerUIMapID, currentPlayerUIMapType) + end + + -- start a timer to update in micro dungeons since multi-level micro dungeons do not reliably fire events + if currentPlayerUIMapType == Enum.UIMapType.Micro then + StartUpdateTimer() + end +end + +-- upgradeable timer callback, don't want to keep calling the old function if the library is upgraded +HereBeDragons.UpdateCurrentPosition = UpdateCurrentPosition +local function UpdateTimerCallback() + -- signal that the timer ran + HereBeDragons.updateTimerActive = nil + + -- run update now + HereBeDragons.UpdateCurrentPosition() +end + +function StartUpdateTimer() + if not HereBeDragons.updateTimerActive then + -- prevent running multiple timers + HereBeDragons.updateTimerActive = true + + -- and queue an update + C_Timer.After(1, UpdateTimerCallback) + end +end + +local function OnEvent(frame, event, ...) + local instanceCheck = false + if event == "ZONE_CHANGED_NEW_AREA" then + instanceCheck = true + elseif event == "PLAYER_ENTERING_WORLD" then + local initial, reload = ... + instanceCheck = (initial or reload) + end + UpdateCurrentPosition(instanceCheck) + + -- try to work around missing zone changes where the event fires before the zone updates + StartUpdateTimer() +end + +HereBeDragons.eventFrame:SetScript("OnEvent", OnEvent) +HereBeDragons.eventFrame:UnregisterAllEvents() +HereBeDragons.eventFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA") +HereBeDragons.eventFrame:RegisterEvent("ZONE_CHANGED") +HereBeDragons.eventFrame:RegisterEvent("ZONE_CHANGED_INDOORS") +HereBeDragons.eventFrame:RegisterEvent("NEW_WMO_CHUNK") +HereBeDragons.eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD") + +--- Return the localized zone name for a given uiMapID +-- @param uiMapID uiMapID of the zone +function HereBeDragons:GetLocalizedMap(uiMapID) + return mapData[uiMapID] and mapData[uiMapID].name or nil +end + +--- Get the size of the zone +-- @param uiMapID uiMapID of the zone +-- @return width, height of the zone, in yards +function HereBeDragons:GetZoneSize(uiMapID) + local data = mapData[uiMapID] + if not data then return 0, 0 end + + return data[1], data[2] +end + +--- Get a list of all map IDs +-- @return array-style table with all known/valid map IDs +function HereBeDragons:GetAllMapIDs() + local t = {} + for id in pairs(mapData) do + table.insert(t, id) + end + return t +end + +--- Convert local/point coordinates to world coordinates in yards +-- @param x X position in 0-1 point coordinates +-- @param y Y position in 0-1 point coordinates +-- @param zone uiMapID of the zone +function HereBeDragons:GetWorldCoordinatesFromZone(x, y, zone) + local data = mapData[zone] + if not data or data[1] == 0 or data[2] == 0 then return nil, nil, nil end + if not x or not y then return nil, nil, nil end + + local width, height, left, top = data[1], data[2], data[3], data[4] + x, y = left - width * x, top - height * y + + return x, y, overrideInstance(data.instance) +end + +--- Convert local/point coordinates to world coordinates in yards. The coordinates have to come from the Azeroth World Map +-- @param x X position in 0-1 point coordinates +-- @param y Y position in 0-1 point coordinates +-- @param instance Instance to use for the world coordinates +function HereBeDragons:GetWorldCoordinatesFromAzerothWorldMap(x, y, instance) + local data = worldMapData[instance] + if not data or data[1] == 0 or data[2] == 0 then return nil, nil, nil end + if not x or not y then return nil, nil, nil end + + local width, height, left, top = data[1], data[2], data[3], data[4] + x, y = left - width * x, top - height * y + + return x, y, instance +end + +--- Convert world coordinates to local/point zone coordinates +-- @param x Global X position +-- @param y Global Y position +-- @param zone uiMapID of the target zone +-- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned +-- @deprecated Use GetZoneCoordinatesFromWorldInstance instead +function HereBeDragons:GetZoneCoordinatesFromWorld(x, y, zone, allowOutOfBounds) + local data = mapData[zone] + if not data or data[1] == 0 or data[2] == 0 then return nil, nil end + if not x or not y then return nil, nil end + + return self:GetZoneCoordinatesFromWorldInstance(x, y, data.instance, zone, allowOutOfBounds) +end + +local function TranslateInstanceZone(self, zoneList, x, y) + for _, id in pairs(zoneList) do + local x1, y1 = self:GetZoneCoordinatesFromWorldInstance(x, y, mapData[id].instance, id) + if x1 and y1 then + x1, y1 = Lerp(mapData[id].rectOnParent.minX, mapData[id].rectOnParent.maxX, x1), Lerp(mapData[id].rectOnParent.minY, mapData[id].rectOnParent.maxY, y1) + return self:GetWorldCoordinatesFromZone(x1, y1, mapData[id].parent) + end + end +end + +--- Convert world coordinates to local/point zone coordinates +-- @param x Global X position +-- @param y Global Y position +-- @param instance World instance of the X/Y coordinates +-- @param zone uiMapID of the target zone +-- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned +function HereBeDragons:GetZoneCoordinatesFromWorldInstance(x, y, instance, zone, allowOutOfBounds) + if zone == WORLD_MAP_ID then -- we can support this, so we should, even if the dedicated API exists + return self:GetAzerothWorldMapCoordinatesFromWorld(x, y, instance, allowOutOfBounds) + end + + local data = mapData[zone] + if not data or data[1] == 0 or data[2] == 0 then return nil, nil end + if not x or not y then return nil, nil end + + local targetInstance = data.instance + if targetInstance ~= instance then + if instanceZones[instance] and instanceZones[instance][targetInstance] then + x, y, instance = TranslateInstanceZone(self, instanceZones[instance][targetInstance], x, y) + end + if targetInstance ~= instance then + return nil, nil + end + end + + local width, height, left, top = data[1], data[2], data[3], data[4] + x, y = (left - x) / width, (top - y) / height + + -- verify the coordinates fall into the zone + if not allowOutOfBounds and (x < 0 or x > 1 or y < 0 or y > 1) then return nil, nil end + + return x, y +end + +--- Convert world coordinates to local/point zone coordinates on the azeroth world map +-- @param x Global X position +-- @param y Global Y position +-- @param instance Instance to translate coordinates from +-- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned +function HereBeDragons:GetAzerothWorldMapCoordinatesFromWorld(x, y, instance, allowOutOfBounds) + -- try to translate an instanced zone to a supported instance + if not worldMapData[instance] and instanceZones[instance] then + for k, zoneList in pairs(instanceZones[instance]) do + if worldMapData[k] then + x, y, instance = TranslateInstanceZone(self, zoneList, x, y) + break + end + end + end + + local data = worldMapData[instance] + if not data or data[1] == 0 or data[2] == 0 then return nil, nil end + if not x or not y then return nil, nil end + + local width, height, left, top = data[1], data[2], data[3], data[4] + x, y = (left - x) / width, (top - y) / height + + -- verify the coordinates fall into the zone + if not allowOutOfBounds and (x < 0 or x > 1 or y < 0 or y > 1) then return nil, nil end + + return x, y +end + +-- Helper function to handle world map coordinate translation +local function TranslateAzerothWorldMapCoordinates(self, x, y, oZone, dZone, allowOutOfBounds) + if (oZone ~= WORLD_MAP_ID and not mapData[oZone]) or (dZone ~= WORLD_MAP_ID and not mapData[dZone]) then return nil, nil end + -- determine the instance we're working with + local instance = overrideInstance((oZone == WORLD_MAP_ID) and mapData[dZone].instance or mapData[oZone].instance) + if not worldMapData[instance] then return nil, nil end + + if oZone == WORLD_MAP_ID then + x, y = self:GetWorldCoordinatesFromAzerothWorldMap(x, y, instance) + return self:GetZoneCoordinatesFromWorldInstance(x, y, instance, dZone, allowOutOfBounds) + else + x, y = self:GetWorldCoordinatesFromZone(x, y, oZone) + return self:GetAzerothWorldMapCoordinatesFromWorld(x, y, instance, allowOutOfBounds) + end +end + +--- Translate zone coordinates from one zone to another +-- @param x X position in 0-1 point coordinates, relative to the origin zone +-- @param y Y position in 0-1 point coordinates, relative to the origin zone +-- @param oZone Origin Zone, uiMapID +-- @param dZone Destination Zone, uiMapID +-- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned +function HereBeDragons:TranslateZoneCoordinates(x, y, oZone, dZone, allowOutOfBounds) + if oZone == dZone then return x, y end + + if oZone == WORLD_MAP_ID or dZone == WORLD_MAP_ID then + return TranslateAzerothWorldMapCoordinates(self, x, y, oZone, dZone, allowOutOfBounds) + end + + local data = mapData[dZone] + local data_origin = mapData[oZone] + if not data or not data_origin then return nil, nil end + + -- todo: short circuit some translation here for instanceZones + + local xCoord, yCoord, instance = self:GetWorldCoordinatesFromZone(x, y, oZone) + if not xCoord then return nil, nil end + + return self:GetZoneCoordinatesFromWorldInstance(xCoord, yCoord, instance, dZone, allowOutOfBounds) +end + +--- Return the distance from an origin position to a destination position in the same instance/continent. +-- @param instanceID instance ID +-- @param oX origin X +-- @param oY origin Y +-- @param dX destination X +-- @param dY destination Y +-- @return distance, deltaX, deltaY +function HereBeDragons:GetWorldDistance(instanceID, oX, oY, dX, dY) + if not oX or not oY or not dX or not dY then return nil, nil, nil end + local deltaX, deltaY = dX - oX, dY - oY + return (deltaX * deltaX + deltaY * deltaY)^0.5, deltaX, deltaY +end + +--- Return the distance between two points on the same continent +-- @param oZone origin zone uiMapID +-- @param oX origin X, in local zone/point coordinates +-- @param oY origin Y, in local zone/point coordinates +-- @param dZone destination zone uiMapID +-- @param dX destination X, in local zone/point coordinates +-- @param dY destination Y, in local zone/point coordinates +-- @return distance, deltaX, deltaY in yards +function HereBeDragons:GetZoneDistance(oZone, oX, oY, dZone, dX, dY) + local oInstance, dInstance + oX, oY, oInstance = self:GetWorldCoordinatesFromZone(oX, oY, oZone) + if not oX then return nil, nil, nil end + + -- translate dX, dY to the origin zone + dX, dY, dInstance = self:GetWorldCoordinatesFromZone(dX, dY, dZone) + if not dX then return nil, nil, nil end + + if oInstance ~= dInstance then return nil, nil, nil end + + return self:GetWorldDistance(oInstance, oX, oY, dX, dY) +end + +--- Return the angle and distance from an origin position to a destination position in the same instance/continent. +-- @param instanceID instance ID +-- @param oX origin X +-- @param oY origin Y +-- @param dX destination X +-- @param dY destination Y +-- @return angle, distance where angle is in radians and distance in yards +function HereBeDragons:GetWorldVector(instanceID, oX, oY, dX, dY) + local distance, deltaX, deltaY = self:GetWorldDistance(instanceID, oX, oY, dX, dY) + if not distance then return nil, nil end + + -- calculate the angle from deltaY and deltaX + local angle = atan2(-deltaX, deltaY) + + -- normalize the angle + if angle > 0 then + angle = PI2 - angle + else + angle = -angle + end + + return angle, distance +end + +--- Get the current world position of the specified unit +-- The position is transformed to the current continent, if applicable +-- NOTE: The same restrictions as for the UnitPosition() API apply, +-- which means a very limited set of unit ids will actually work. +-- @param unitId Unit Id +-- @return x, y, instanceID +function HereBeDragons:GetUnitWorldPosition(unitId) + -- get the current position + local y, x, _z, instanceID = UnitPosition(unitId) + if not x or not y then return nil, nil, overrideInstance(instanceID) end + + -- return transformed coordinates + return applyCoordinateTransforms(x, y, instanceID) +end + +--- Get the current world position of the player +-- The position is transformed to the current continent, if applicable +-- @return x, y, instanceID +function HereBeDragons:GetPlayerWorldPosition() + -- get the current position + local y, x, _z, instanceID = UnitPosition("player") + if not x or not y then return nil, nil, overrideInstance(instanceID) end + + -- return transformed coordinates + return applyCoordinateTransforms(x, y, instanceID) +end + +--- Get the current zone and level of the player +-- The returned mapFile can represent a micro dungeon, if the player currently is inside one. +-- @return uiMapID, mapType +function HereBeDragons:GetPlayerZone() + return currentPlayerUIMapID, currentPlayerUIMapType +end + +--- Get the current position of the player on a zone level +-- The returned values are local point coordinates, 0-1. The mapFile can represent a micro dungeon. +-- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned +-- @return x, y, uiMapID, mapType +function HereBeDragons:GetPlayerZonePosition(allowOutOfBounds) + if not currentPlayerUIMapID then return nil, nil, nil, nil end + local x, y, instanceID = self:GetPlayerWorldPosition() + if not x or not y then return nil, nil, nil, nil end + + x, y = self:GetZoneCoordinatesFromWorldInstance(x, y, instanceID, currentPlayerUIMapID, allowOutOfBounds) + if x and y then + return x, y, currentPlayerUIMapID, currentPlayerUIMapType + end + return nil, nil, nil, nil +end + +-- if we're loading after entering the world (ie. on demand), update position now +-- This needs to remain at the bottom of the library to ensure all functions are loaded before they are needed +if IsLoggedIn() then + UpdateCurrentPosition(true) +end diff --git a/DungeonPreQuest/Libs/HereBeDragons/HereBeDragons-Pins-2.0.lua b/DungeonPreQuest/Libs/HereBeDragons/HereBeDragons-Pins-2.0.lua new file mode 100644 index 0000000..808c01c --- /dev/null +++ b/DungeonPreQuest/Libs/HereBeDragons/HereBeDragons-Pins-2.0.lua @@ -0,0 +1,865 @@ +-- HereBeDragons-Pins is a library to show pins/icons on the world map and minimap + +local MAJOR, MINOR = "HereBeDragonsQuestie-Pins-2.0", 16 +assert(LibStub, MAJOR .. " requires LibStub") + +local pins, oldversion = LibStub:NewLibrary(MAJOR, MINOR) +if not pins then return end + +local HBD = LibStub("HereBeDragonsQuestie-2.0") + +local MinimapRadiusAPI = C_Minimap and C_Minimap.GetViewRadius + +pins.updateFrame = pins.updateFrame or CreateFrame("Frame") + +-- storage for minimap pins +pins.minimapPins = pins.minimapPins or {} +pins.activeMinimapPins = pins.activeMinimapPins or {} +pins.minimapPinRegistry = pins.minimapPinRegistry or {} + +-- and worldmap pins +pins.worldmapPins = pins.worldmapPins or {} +pins.worldmapPinRegistry = pins.worldmapPinRegistry or {} +pins.worldmapIconPins = pins.worldmapIconPins or {} -- Questie modification: icon -> acquired pin + +pins.worldmapProvider = pins.worldmapProvider or CreateFromMixins(MapCanvasDataProviderMixin) +pins.worldmapProviderPin = pins.worldmapProviderPin or CreateFromMixins(MapCanvasPinMixin) + +-- make sure the pool is refreshed +if oldversion and oldversion < 15 and pins.worldmapProvider and CreateUnsecuredRegionPoolInstance then + pins.worldmapProvider:RemoveAllData() + pins.worldmapPinsPool = nil +end + +if not pins.worldmapPinsPool then + -- new frame pools in WoW 11.x + if CreateUnsecuredRegionPoolInstance then + pins.worldmapPinsPool = CreateUnsecuredRegionPoolInstance("HereBeDragonsPinsTemplateQuestie") + else + pins.worldmapPinsPool = CreateFramePool("FRAME") + end +end + +-- store a reference to the active minimap object +pins.Minimap = pins.Minimap or Minimap + +-- Data Constants +local WORLD_MAP_ID = 947 + +-- upvalue lua api +local cos, sin, max = math.cos, math.sin, math.max +local type, pairs = type, pairs + +-- upvalue wow api +local GetPlayerFacing = GetPlayerFacing + +-- upvalue data tables +local minimapPins = pins.minimapPins +local activeMinimapPins = pins.activeMinimapPins +local minimapPinRegistry = pins.minimapPinRegistry + +local worldmapPins = pins.worldmapPins +local worldmapPinRegistry = pins.worldmapPinRegistry +local worldmapIconPins = pins.worldmapIconPins +local worldmapPinsPool = pins.worldmapPinsPool +local worldmapProvider = pins.worldmapProvider +local worldmapProviderPin = pins.worldmapProviderPin + +local minimap_size = { + indoor = { + [0] = 300, -- scale + [1] = 240, -- 1.25 + [2] = 180, -- 5/3 + [3] = 120, -- 2.5 + [4] = 80, -- 3.75 + [5] = 50, -- 6 + }, + outdoor = { + [0] = 466 + 2/3, -- scale + [1] = 400, -- 7/6 + [2] = 333 + 1/3, -- 1.4 + [3] = 266 + 2/6, -- 1.75 + [4] = 200, -- 7/3 + [5] = 133 + 1/3, -- 3.5 + }, +} + +local minimap_shapes = { + -- { upper-left, lower-left, upper-right, lower-right } + ["SQUARE"] = { false, false, false, false }, + ["CORNER-TOPLEFT"] = { true, false, false, false }, + ["CORNER-TOPRIGHT"] = { false, false, true, false }, + ["CORNER-BOTTOMLEFT"] = { false, true, false, false }, + ["CORNER-BOTTOMRIGHT"] = { false, false, false, true }, + ["SIDE-LEFT"] = { true, true, false, false }, + ["SIDE-RIGHT"] = { false, false, true, true }, + ["SIDE-TOP"] = { true, false, true, false }, + ["SIDE-BOTTOM"] = { false, true, false, true }, + ["TRICORNER-TOPLEFT"] = { true, true, true, false }, + ["TRICORNER-TOPRIGHT"] = { true, false, true, true }, + ["TRICORNER-BOTTOMLEFT"] = { true, true, false, true }, + ["TRICORNER-BOTTOMRIGHT"] = { false, true, true, true }, +} + +local tableCache = setmetatable({}, {__mode='k'}) + +local function newCachedTable() + local t = next(tableCache) + if t then + tableCache[t] = nil + else + t = {} + end + return t +end + +local function recycle(t) + tableCache[t] = true +end + +------------------------------------------------------------------------------------------- +-- Minimap pin position logic + +-- minimap rotation +local rotateMinimap = GetCVar("rotateMinimap") == "1" + +-- is the minimap indoors or outdoors +local indoors = GetCVar("minimapZoom")+0 == pins.Minimap:GetZoom() and "outdoor" or "indoor" + +local minimapPinCount, queueFullUpdate = 0, false +local minimapScale, minimapShape, mapRadius, minimapWidth, minimapHeight, mapSin, mapCos +local lastZoom, lastFacing, lastXY, lastYY + +local function drawMinimapPin(pin, data) + local xDist, yDist = lastXY - data.x, lastYY - data.y + + -- handle rotation + if rotateMinimap then + local dx, dy = xDist, yDist + xDist = dx*mapCos - dy*mapSin + yDist = dx*mapSin + dy*mapCos + end + + -- adapt delta position to the map radius + local diffX = xDist / mapRadius + local diffY = yDist / mapRadius + + -- different minimap shapes + local isRound = true + if minimapShape and not (xDist == 0 or yDist == 0) then + isRound = (xDist < 0) and 1 or 3 + if yDist < 0 then + isRound = minimapShape[isRound] + else + isRound = minimapShape[isRound + 1] + end + end + + -- calculate distance from the center of the map + local dist + if isRound then + dist = (diffX*diffX + diffY*diffY) / 0.9^2 + else + dist = max(diffX*diffX, diffY*diffY) / 0.9^2 + end + + -- if distance > 1, then adapt node position to slide on the border + if dist > 1 and data.floatOnEdge then + dist = dist^0.5 + diffX = diffX/dist + diffY = diffY/dist + end + + -- Questie Modification. + -- data.floatOnEdge is replaced by (data.floatOnEdge and ((pin.texture and pin.texture.a and pin.texture.a ~= 0) or pin.texture == nil)) + -- icons will now only float on edge if they have an opacity which is not 0 or if no texture exist. + data.distanceFromMinimapCenter = dist + if dist <= 1 or (data.floatOnEdge and ((pin.texture and pin.texture.a and pin.texture.a ~= 0) or pin.texture == nil)) then + pin:Show() + pin:ClearAllPoints() + pin:SetPoint("CENTER", pins.Minimap, "CENTER", diffX * minimapWidth, -diffY * minimapHeight) + data.onEdge = (dist > 1) + else + pin:Hide() + data.onEdge = nil + pin.keep = nil + end +end + +local function IsParentMap(originMapId, toCheckMapId) + local parentMapID = HBD.mapData[originMapId].parent + while parentMapID and HBD.mapData[parentMapID] do + local mapType = HBD.mapData[parentMapID].mapType + if mapType ~= Enum.UIMapType.Zone and mapType ~= Enum.UIMapType.Dungeon and mapType ~= Enum.UIMapType.Micro then + return false + end + if parentMapID == toCheckMapId then + return true + end + parentMapID = HBD.mapData[parentMapID].parent + end + return false +end + +local function UpdateMinimapPins(force) + -- get the current player position + local x, y, instanceID = HBD:GetPlayerWorldPosition() + local mapID = HBD:GetPlayerZone() + + -- get data from the API for calculations + local zoom = pins.Minimap:GetZoom() + local diffZoom = zoom ~= lastZoom + + -- for rotating minimap support + local facing + if rotateMinimap then + facing = GetPlayerFacing() + else + facing = lastFacing + end + + -- check for all values to be available (starting with 7.1.0, instances don't report coordinates) + if not x or not y or (rotateMinimap and not facing) then + minimapPinCount = 0 + for pin in pairs(activeMinimapPins) do + pin:Hide() + activeMinimapPins[pin] = nil + end + return + end + + local newScale = pins.Minimap:GetScale() + if minimapScale ~= newScale then + minimapScale = newScale + force = true + end + + if x ~= lastXY or y ~= lastYY or diffZoom or facing ~= lastFacing or force then + -- minimap information + minimapShape = GetMinimapShape and minimap_shapes[GetMinimapShape() or "ROUND"] + minimapWidth = pins.Minimap:GetWidth() / 2 + minimapHeight = pins.Minimap:GetHeight() / 2 + if MinimapRadiusAPI then + mapRadius = C_Minimap.GetViewRadius() + else + mapRadius = minimap_size[indoors][zoom] / 2 + end + + -- update upvalues for icon placement + lastZoom = zoom + lastFacing = facing + lastXY, lastYY = x, y + + if rotateMinimap then + mapSin = sin(facing) + mapCos = cos(facing) + end + + for pin, data in pairs(minimapPins) do + if data.instanceID == instanceID and math.abs(x-data.x) + math.abs(y-data.y) < 500 then -- questie specific fix + activeMinimapPins[pin] = data + data.keep = true + -- draw the pin (this may reset data.keep if outside of the map) + drawMinimapPin(pin, data) + end + end + + minimapPinCount = 0 + for pin, data in pairs(activeMinimapPins) do + if not data.keep then + pin:Hide() + activeMinimapPins[pin] = nil + else + minimapPinCount = minimapPinCount + 1 + data.keep = nil + end + end + end +end + +local function UpdateMinimapIconPosition() + + -- get the current map zoom + local zoom = pins.Minimap:GetZoom() + local diffZoom = zoom ~= lastZoom + -- if the map zoom changed, run a full update sweep + if diffZoom then + UpdateMinimapPins() + return + end + + -- we have no active minimap pins, just return early + if minimapPinCount == 0 then return end + + local x, y = HBD:GetPlayerWorldPosition() + + -- for rotating minimap support + local facing + if rotateMinimap then + facing = GetPlayerFacing() + else + facing = lastFacing + end + + -- check for all values to be available (starting with 7.1.0, instances don't report coordinates) + if not x or not y or (rotateMinimap and not facing) then + UpdateMinimapPins() + return + end + + local refresh + local newScale = pins.Minimap:GetScale() + if minimapScale ~= newScale then + minimapScale = newScale + refresh = true + end + + if x ~= lastXY or y ~= lastYY or facing ~= lastFacing or refresh then + -- update radius of the map + if MinimapRadiusAPI then + mapRadius = C_Minimap.GetViewRadius() + else + mapRadius = minimap_size[indoors][zoom] / 2 + end + -- update upvalues for icon placement + lastXY, lastYY = x, y + lastFacing = facing + + if rotateMinimap then + mapSin = sin(facing) + mapCos = cos(facing) + end + + -- iterate all nodes and check if they are still in range of our minimap display + for pin, data in pairs(activeMinimapPins) do + -- update the position of the node + drawMinimapPin(pin, data) + end + end +end + +local function UpdateMinimapZoom() + if not MinimapRadiusAPI then + local zoom = pins.Minimap:GetZoom() + if GetCVar("minimapZoom") == GetCVar("minimapInsideZoom") then + pins.Minimap:SetZoom(zoom < 2 and zoom + 1 or zoom - 1) + end + indoors = GetCVar("minimapZoom")+0 == pins.Minimap:GetZoom() and "outdoor" or "indoor" + pins.Minimap:SetZoom(zoom) + end +end + +------------------------------------------------------------------------------------------- +-- WorldMap data provider + +-- setup pin pool +worldmapPinsPool.parent = WorldMapFrame:GetCanvas() +worldmapPinsPool.createFunc = function() + local frame = CreateFrame("Frame", nil, WorldMapFrame:GetCanvas()) + frame:SetSize(1, 1) + return Mixin(frame, worldmapProviderPin) +end +worldmapPinsPool.resetFunc = function(pinPool, pin) + pin:Hide() + pin:ClearAllPoints() + pin:OnReleased() + + pin.pinTemplate = nil + pin.owningMap = nil +end + +-- pre-11.x func names +worldmapPinsPool.creationFunc = worldmapPinsPool.createFunc +worldmapPinsPool.resetterFunc = worldmapPinsPool.resetFunc + +-- register pin pool with the world map +WorldMapFrame.pinPools["HereBeDragonsPinsTemplateQuestie"] = worldmapPinsPool + +-- provider base API +function worldmapProvider:RemoveAllData() + self:GetMap():RemoveAllPinsByTemplate("HereBeDragonsPinsTemplateQuestie") +end + +-- Questie modification: look up the pin directly instead of scanning all pins, which made bulk removal O(n^2) +function worldmapProvider:RemovePinByIcon(icon) + local pin = worldmapIconPins[icon] + if pin and pin.icon == icon then + self:GetMap():RemovePin(pin) + end +end + +function worldmapProvider:RemovePinsByRef(ref) + for pin in self:GetMap():EnumeratePinsByTemplate("HereBeDragonsPinsTemplateQuestie") do + if pin.icon and worldmapPinRegistry[ref][pin.icon] then + self:GetMap():RemovePin(pin) + end + end +end + +-- Questie modification +local lastUiMapId = -1; +worldmapProvider.forceUpdate = false -- Put into worldmapProvider to allow addons to force update from outside of HBD. +function worldmapProvider:RefreshAllData(fromOnShow) + local mapId = self:GetMap():GetMapID() + if(lastUiMapId ~= mapId or worldmapProvider.forceUpdate) then + self:RemoveAllData() + local cacheMap = self:GetMap() + local uiMapID = cacheMap:GetMapID() + for icon, data in pairs(worldmapPins) do + self:HandlePin(icon, data, uiMapID, cacheMap) + end + --DEFAULT_CHAT_FRAME:AddMessage(mapId .. " - " .. lastUiMapId .. " : " .. tostring(worldmapProvider.forceUpdate)); + lastUiMapId = mapId; + worldmapProvider.forceUpdate = false; + end +end + +function worldmapProvider:HandlePin(icon, data) + -- Questie modification: an icon owns at most one pin, so re-adding must not leave the old one behind + self:RemovePinByIcon(icon) + + local uiMapID = self:GetMap():GetMapID() + + -- check for a valid map + if not uiMapID then return end + + -- Questie modification + if (Questie.db.profile.hideIconsOnContinents == true) and (HBD.mapData[uiMapID].mapType == Enum.UIMapType.Continent or uiMapID == 947) or (uiMapID ~= data.uiMapID and data.worldMapShowFlag == HBD_PINS_WORLDMAP_SHOW_CURRENT) then + icon:Hide(); + return; + elseif(uiMapID == data.uiMapID and data.worldMapShowFlag == HBD_PINS_WORLDMAP_SHOW_CURRENT) then + icon:Show(); + end + + local x, y + if uiMapID == WORLD_MAP_ID then + -- should this pin show on the world map? + if uiMapID ~= data.uiMapID and data.worldMapShowFlag ~= HBD_PINS_WORLDMAP_SHOW_WORLD then return end + + -- Questie modification + -- Icons which already have world map coordinates are not handled correctly by GetAzerothWorldMapCoordinatesFromWorld, so we use them directly. + if icon.UiMapID == WORLD_MAP_ID then + x, y = icon.x / 100, icon.y / 100 + else + -- translate to the world map + x, y = HBD:GetAzerothWorldMapCoordinatesFromWorld(data.x, data.y, data.instanceID) + end + else + -- check that there is data + if not HBD.mapData[uiMapID] then return end + + if uiMapID ~= data.uiMapID then + local mapType = HBD.mapData[uiMapID].mapType + if not data.uiMapID then + if mapType == Enum.UIMapType.Continent and data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_CONTINENT then + -- pass + elseif mapType ~= Enum.UIMapType.Zone and mapType ~= Enum.UIMapType.Dungeon and mapType ~= Enum.UIMapType.Micro then + -- fail + return + end + else + local show = true -- Questie fix to show icons in neighbour areas + local parentMapID = HBD.mapData[data.uiMapID].parent + while parentMapID and HBD.mapData[parentMapID] do + if parentMapID == uiMapID then + local parentMapType = HBD.mapData[parentMapID].mapType + -- show on any parent zones if they are normal zones + if data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_PARENT and + (parentMapType == Enum.UIMapType.Zone or parentMapType == Enum.UIMapType.Dungeon or parentMapType == Enum.UIMapType.Micro) then + show = true + -- show on the continent + elseif data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_CONTINENT and + parentMapType == Enum.UIMapType.Continent then + show = true + elseif data.worldMapShowFlag == HBD_PINS_WORLDMAP_SHOW_CURRENT then + -- Questie modification + show = false + end + break + -- worldmap is handled above already + else + parentMapID = HBD.mapData[parentMapID].parent + end + end + + if not show then return end + end + end + + -- translate coordinates + x, y = HBD:GetZoneCoordinatesFromWorldInstance(data.x, data.y, data.instanceID, uiMapID) + end + if x and y then + self:GetMap():AcquirePin("HereBeDragonsPinsTemplateQuestie", icon, x, y, data.frameLevelType) + end +end + +-- map pin base API +function worldmapProviderPin:OnLoad() + self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI") + self:SetScalingLimits(1, 1.0, 1.2) +end + +function worldmapProviderPin:OnAcquired(icon, x, y, frameLevelType) + self:UseFrameLevelType(frameLevelType or "PIN_FRAME_LEVEL_AREA_POI") + self:SetPosition(x, y) + + self.icon = icon + worldmapIconPins[icon] = self -- Questie modification + icon:SetParent(self) + icon:ClearAllPoints() + icon:SetPoint("CENTER", self, "CENTER") + icon:Show() +end + +function worldmapProviderPin:OnReleased() + if self.icon then + if worldmapIconPins[self.icon] == self then -- Questie modification + worldmapIconPins[self.icon] = nil + end + self.icon:Hide() + self.icon:SetParent(UIParent) + self.icon:ClearAllPoints() + self.icon = nil + end +end + +-- hack to avoid in-combat error on 10.1.5 +worldmapProviderPin.SetPassThroughButtons = function() end + +-- register with the world map +WorldMapFrame:AddDataProvider(worldmapProvider) + +-- map event handling +local function UpdateMinimap() + UpdateMinimapZoom() + UpdateMinimapPins() +end + +local function UpdateWorldMap() + worldmapProvider:RefreshAllData() +end + +local last_update = 0 +local function OnUpdateHandler(frame, elapsed) + last_update = last_update + elapsed + + -- skip updates while the minimap is hidden + if pins.Minimap and not pins.Minimap:IsVisible() then return end + + -- check for a full update every second, so pins coming in range get properly rendered + if last_update > 1 or queueFullUpdate then + UpdateMinimapPins(queueFullUpdate) + last_update = 0 + queueFullUpdate = false + else + UpdateMinimapIconPosition() + end +end +pins.updateFrame:SetScript("OnUpdate", OnUpdateHandler) + +local function OnEventHandler(frame, event, ...) + if event == "CVAR_UPDATE" then + local cvar, value = ... + if cvar == "rotateMinimap" or cvar == "ROTATE_MINIMAP" then + rotateMinimap = (value == "1") + queueFullUpdate = true + end + elseif event == "MINIMAP_UPDATE_ZOOM" then + UpdateMinimap() + elseif event == "PLAYER_LOGIN" then + -- recheck cvars after login + rotateMinimap = GetCVar("rotateMinimap") == "1" + elseif event == "PLAYER_ENTERING_WORLD" then + UpdateMinimap() + UpdateWorldMap() + end +end + +pins.updateFrame:SetScript("OnEvent", OnEventHandler) +pins.updateFrame:UnregisterAllEvents() +pins.updateFrame:RegisterEvent("CVAR_UPDATE") +pins.updateFrame:RegisterEvent("MINIMAP_UPDATE_ZOOM") +pins.updateFrame:RegisterEvent("PLAYER_LOGIN") +pins.updateFrame:RegisterEvent("PLAYER_ENTERING_WORLD") + +HBD.RegisterCallback(pins, "PlayerZoneChanged", UpdateMinimap) + + +--- Add a icon to the minimap (x/y world coordinate version) +-- Note: This API does not let you specify a map to limit the pin to, it'll be shown on all maps these coordinates are valid for. +-- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier) +-- @param icon Icon Frame +-- @param instanceID Instance ID of the map to add the icon to +-- @param x X position in world coordinates +-- @param y Y position in world coordinates +-- @param floatOnEdge flag if the icon should float on the edge of the minimap when going out of range, or hide immediately (default false) +function pins:AddMinimapIconWorld(ref, icon, instanceID, x, y, floatOnEdge) + if not ref then + error(MAJOR..": AddMinimapIconWorld: 'ref' must not be nil", 2) + end + if type(icon) ~= "table" or not icon.SetPoint then + error(MAJOR..": AddMinimapIconWorld: 'icon' must be a frame", 2) + end + if type(instanceID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then + error(MAJOR..": AddMinimapIconWorld: 'instanceID', 'x' and 'y' must be numbers", 2) + end + + if not minimapPinRegistry[ref] then + minimapPinRegistry[ref] = {} + end + + minimapPinRegistry[ref][icon] = true + + local t = minimapPins[icon] or newCachedTable() + t.instanceID = instanceID + t.x = x + t.y = y + t.floatOnEdge = floatOnEdge + t.uiMapID = nil + t.showInParentZone = nil + + minimapPins[icon] = t + queueFullUpdate = true + + icon:SetParent(pins.Minimap) +end + +--- Add a icon to the minimap (UiMapID zone coordinate version) +-- The pin will only be shown on the map specified, or optionally its parent map if specified +-- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier) +-- @param icon Icon Frame +-- @param uiMapID uiMapID of the map to place the icon on +-- @param x X position in local/point coordinates (0-1), relative to the zone +-- @param y Y position in local/point coordinates (0-1), relative to the zone +-- @param showInParentZone flag if the icon should be shown in its parent zone - ie. an icon in a microdungeon in the outdoor zone itself (default false) +-- @param floatOnEdge flag if the icon should float on the edge of the minimap when going out of range, or hide immediately (default false) +function pins:AddMinimapIconMap(ref, icon, uiMapID, x, y, showInParentZone, floatOnEdge) + if not ref then + error(MAJOR..": AddMinimapIconMap: 'ref' must not be nil", 2) + end + if type(icon) ~= "table" or not icon.SetPoint then + error(MAJOR..": AddMinimapIconMap: 'icon' must be a frame", 2) + end + if type(uiMapID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then + error(MAJOR..": AddMinimapIconMap: 'uiMapID', 'x' and 'y' must be numbers", 2) + end + + -- convert to world coordinates and use our known adding function + local xCoord, yCoord, instanceID = HBD:GetWorldCoordinatesFromZone(x, y, uiMapID) + if not xCoord then return end + + self:AddMinimapIconWorld(ref, icon, instanceID, xCoord, yCoord, floatOnEdge) + + -- store extra information + minimapPins[icon].uiMapID = uiMapID + minimapPins[icon].showInParentZone = showInParentZone +end + +--- Check if a floating minimap icon is on the edge of the map +-- @param icon the minimap icon +function pins:IsMinimapIconOnEdge(icon) + if not icon then return false end + local data = minimapPins[icon] + if not data then return nil end + + return data.onEdge +end + +--- Remove a minimap icon +-- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier) +-- @param icon Icon Frame +function pins:RemoveMinimapIcon(ref, icon) + if not ref or not icon or not minimapPinRegistry[ref] then return end + minimapPinRegistry[ref][icon] = nil + if minimapPins[icon] then + recycle(minimapPins[icon]) + minimapPins[icon] = nil + activeMinimapPins[icon] = nil + end + icon:Hide() +end + +--- Remove all minimap icons belonging to your addon (as tracked by "ref") +-- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier) +function pins:RemoveAllMinimapIcons(ref) + if not ref or not minimapPinRegistry[ref] then return end + for icon in pairs(minimapPinRegistry[ref]) do + recycle(minimapPins[icon]) + minimapPins[icon] = nil + activeMinimapPins[icon] = nil + icon:Hide() + end + wipe(minimapPinRegistry[ref]) +end + +--- Set the minimap object to position the pins on. Needs to support the usual functions a Minimap-type object exposes. +-- @param minimapObject The new minimap object, or nil to restore the default +function pins:SetMinimapObject(minimapObject) + pins.Minimap = minimapObject or Minimap + for pin in pairs(minimapPins) do + pin:SetParent(pins.Minimap) + end + UpdateMinimapPins(true) +end + +--- Questie addition: the view minimap icons are placed with, so other minimap drawings line up +--- with them. Clients without C_Minimap.GetViewRadius use the indoor/outdoor zoom table. +-- @return radius Yards from the minimap's center to its edge; nil for an unknown zoom level +-- @return rotating true while the minimap turns with the player +function pins:GetMinimapView() + local radius + if MinimapRadiusAPI then + radius = C_Minimap.GetViewRadius() + else + local size = minimap_size[indoors][pins.Minimap:GetZoom()] + radius = size and size / 2 + end + return radius, rotateMinimap +end + +-- world map constants +-- show worldmap pin only on zone map (Questie modification) +HBD_PINS_WORLDMAP_SHOW_CURRENT = -1 +-- show worldmap pin on its parent zone map (if any) +HBD_PINS_WORLDMAP_SHOW_PARENT = 1 +-- show worldmap pin on the continent map +HBD_PINS_WORLDMAP_SHOW_CONTINENT = 2 +-- show worldmap pin on the continent and world map +HBD_PINS_WORLDMAP_SHOW_WORLD = 3 + +--- Add a icon to the world map (x/y world coordinate version) +-- Note: This API does not let you specify a map to limit the pin to, it'll be shown on all maps these coordinates are valid for. +-- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier) +-- @param icon Icon Frame +-- @param instanceID Instance ID of the map to add the icon to +-- @param x X position in world coordinates +-- @param y Y position in world coordinates +-- @param showFlag Flag to control on which maps this pin will be shown +-- @param frameLevel Optional Frame Level type registered with the WorldMapFrame, defaults to PIN_FRAME_LEVEL_AREA_POI +function pins:AddWorldMapIconWorld(ref, icon, instanceID, x, y, showFlag, frameLevel) + if not ref then + error(MAJOR..": AddWorldMapIconWorld: 'ref' must not be nil", 2) + end + if type(icon) ~= "table" or not icon.SetPoint then + error(MAJOR..": AddWorldMapIconWorld: 'icon' must be a frame", 2) + end + if type(instanceID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then + error(MAJOR..": AddWorldMapIconWorld: 'instanceID', 'x' and 'y' must be numbers", 2) + end + if showFlag ~= nil and type(showFlag) ~= "number" then + error(MAJOR..": AddWorldMapIconWorld: 'showFlag' must be a number (or nil)", 2) + end + + if not worldmapPinRegistry[ref] then + worldmapPinRegistry[ref] = {} + end + + worldmapPinRegistry[ref][icon] = true + + local t = worldmapPins[icon] or newCachedTable() + t.instanceID = instanceID + t.x = x + t.y = y + t.uiMapID = nil + t.worldMapShowFlag = showFlag or 0 + t.frameLevelType = frameLevel + + worldmapPins[icon] = t + + worldmapProvider:HandlePin(icon, t) +end + +--- Add a icon to the world map (uiMapID zone coordinate version) +-- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier) +-- @param icon Icon Frame +-- @param uiMapID uiMapID of the map to place the icon on +-- @param x X position in local/point coordinates (0-1), relative to the zone +-- @param y Y position in local/point coordinates (0-1), relative to the zone +-- @param showFlag Flag to control on which maps this pin will be shown +-- @param frameLevel Optional Frame Level type registered with the WorldMapFrame, defaults to PIN_FRAME_LEVEL_AREA_POI +function pins:AddWorldMapIconMap(ref, icon, uiMapID, x, y, showFlag, frameLevel) + if not ref then + error(MAJOR..": AddWorldMapIconMap: 'ref' must not be nil", 2) + end + if type(icon) ~= "table" or not icon.SetPoint then + error(MAJOR..": AddWorldMapIconMap: 'icon' must be a frame", 2) + end + if type(uiMapID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then + error(MAJOR..": AddWorldMapIconMap: 'uiMapID', 'x' and 'y' must be numbers", 2) + end + if showFlag ~= nil and type(showFlag) ~= "number" then + error(MAJOR..": AddWorldMapIconMap: 'showFlag' must be a number (or nil)", 2) + end + + -- convert to world coordinates + local xCoord, yCoord, instanceID = HBD:GetWorldCoordinatesFromZone(x, y, uiMapID) + if not xCoord then return end + + if not worldmapPinRegistry[ref] then + worldmapPinRegistry[ref] = {} + end + + worldmapPinRegistry[ref][icon] = true + + local t = worldmapPins[icon] or newCachedTable() + t.instanceID = instanceID + t.x = xCoord + t.y = yCoord + t.uiMapID = uiMapID + t.worldMapShowFlag = showFlag or 0 + t.frameLevelType = frameLevel + + worldmapPins[icon] = t + + worldmapProvider:HandlePin(icon, t) +end + +--- Remove a worldmap icon +-- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier) +-- @param icon Icon Frame +function pins:RemoveWorldMapIcon(ref, icon) + if not ref or not icon or not worldmapPinRegistry[ref] then return end + worldmapPinRegistry[ref][icon] = nil + if worldmapPins[icon] then + recycle(worldmapPins[icon]) + worldmapPins[icon] = nil + end + worldmapProvider:RemovePinByIcon(icon) + + worldmapProvider.forceUpdate = true -- Questie modification +end + +--- Remove all worldmap icons belonging to your addon (as tracked by "ref") +-- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier) +function pins:RemoveAllWorldMapIcons(ref) + if not ref or not worldmapPinRegistry[ref] then return end + for icon in pairs(worldmapPinRegistry[ref]) do + recycle(worldmapPins[icon]) + worldmapPins[icon] = nil + end + worldmapProvider:RemovePinsByRef(ref) + wipe(worldmapPinRegistry[ref]) + + worldmapProvider.forceUpdate = true -- Questie modification +end + +--- Return the angle and distance from the player to the specified pin +-- @param icon icon object (minimap or worldmap) +-- @return angle, distance where angle is in radians and distance in yards +function pins:GetVectorToIcon(icon) + if not icon then return nil, nil end + local data = minimapPins[icon] or worldmapPins[icon] + if not data then return nil, nil end + + local x, y, instance = HBD:GetPlayerWorldPosition() + if not x or not y or instance ~= data.instanceID then return nil end + + return HBD:GetWorldVector(instance, x, y, data.x, data.y) +end + +if oldversion then + if WorldMapFrame:IsShown() then + worldmapProvider:RefreshAllData(false) + end +end diff --git a/DungeonPreQuest/Libs/LibStub/LICENSE.txt b/DungeonPreQuest/Libs/LibStub/LICENSE.txt new file mode 100644 index 0000000..866fc34 --- /dev/null +++ b/DungeonPreQuest/Libs/LibStub/LICENSE.txt @@ -0,0 +1,29 @@ +Copyright (c) 2007, Ace3 Development Team + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Redistribution of a stand alone version is strictly prohibited without + prior written authorization from the Lead of the Ace3 Development Team. + * Neither the name of the Ace3 Development Team nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/DungeonPreQuest/Libs/LibStub/LibStub.lua b/DungeonPreQuest/Libs/LibStub/LibStub.lua new file mode 100755 index 0000000..d50c267 --- /dev/null +++ b/DungeonPreQuest/Libs/LibStub/LibStub.lua @@ -0,0 +1,30 @@ +-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info +-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke +local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! +local LibStub = _G[LIBSTUB_MAJOR] + +if not LibStub or LibStub.minor < LIBSTUB_MINOR then + LibStub = LibStub or {libs = {}, minors = {} } + _G[LIBSTUB_MAJOR] = LibStub + LibStub.minor = LIBSTUB_MINOR + + function LibStub:NewLibrary(major, minor) + assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") + minor = assert(tonumber(string.match(minor, "%d+")), "Minor version must either be a number or contain a number.") + + local oldminor = self.minors[major] + if oldminor and oldminor >= minor then return nil end + self.minors[major], self.libs[major] = minor, self.libs[major] or {} + return self.libs[major], oldminor + end + + function LibStub:GetLibrary(major, silent) + if not self.libs[major] and not silent then + error(("Cannot find a library instance of %q."):format(tostring(major)), 2) + end + return self.libs[major], self.minors[major] + end + + function LibStub:IterateLibraries() return pairs(self.libs) end + setmetatable(LibStub, { __call = LibStub.GetLibrary }) +end diff --git a/DungeonPreQuest/Minimap.lua b/DungeonPreQuest/Minimap.lua new file mode 100644 index 0000000..5f3eeca --- /dev/null +++ b/DungeonPreQuest/Minimap.lua @@ -0,0 +1,143 @@ +-- Purple "!" minimap markers on quest givers offering a dungeon pre-quest you +-- can pick up right now. The game's own "!" icons can't be recoloured per quest, +-- so these are separate pins placed on top. + +local _, ns = ... + +local Pins = LibStub("HereBeDragonsQuestie-Pins-2.0") + +local ICON = "Interface\\GossipFrame\\AvailableQuestIcon" +local PIN_SIZE = 14 +local REFRESH_DELAY = 1 + +local active, free = {}, {} + +local function HasBit(mask, bit) + return math.floor(mask / bit) % 2 == 1 +end + +local function Done(id) + return C_QuestLog.IsQuestFlaggedCompleted(id) +end + +local function DoneOrTaken(id) + return Done(id) or C_QuestLog.IsOnQuest(id) +end + +local function AnyOf(list, test) + for _, id in ipairs(list or {}) do + if test(id) then + return true + end + end + return false +end + +local function AllOf(list, test) + for _, id in ipairs(list or {}) do + if not test(id) then + return false + end + end + return true +end + +local function CanPickUp(id, quest, level, raceBit, classBit) + if DoneOrTaken(id) or quest.l > level then + return false + end + if quest.r ~= 0 and raceBit and not HasBit(quest.r, raceBit) then + return false + end + if quest.c ~= 0 and not HasBit(quest.c, classBit) then + return false + end + if quest.p and not AnyOf(quest.p, Done) then + return false + end + if not AllOf(quest.g, Done) or AnyOf(quest.x, DoneOrTaken) then + return false + end + -- Past this step already, by another route. + if (quest.nx ~= 0 and DoneOrTaken(quest.nx)) or (quest.b ~= 0 and DoneOrTaken(quest.b)) then + return false + end + return true +end + +local function ShowTooltip(pin) + local names = ns.DungeonsFor(pin.questID) + GameTooltip:SetOwner(pin, "ANCHOR_RIGHT") + GameTooltip:SetText(ns.pinQuests[pin.questID].n) + if names then + GameTooltip:AddLine(ns.Describe(names), 1, 0.82, 0, true) + end + GameTooltip:Show() +end + +local function HideTooltip() + GameTooltip:Hide() +end + +local function AcquirePin() + local pin = table.remove(free) + if pin then + return pin + end + pin = CreateFrame("Frame", nil, Minimap) + pin:Hide() + pin:SetSize(PIN_SIZE, PIN_SIZE) + pin:SetFrameLevel(Minimap:GetFrameLevel() + 5) + local texture = pin:CreateTexture(nil, "ARTWORK") + texture:SetAllPoints() + texture:SetTexture(ICON) + texture:SetDesaturated(true) + texture:SetVertexColor(0.75, 0.35, 1) + pin:EnableMouse(true) + pin:SetScript("OnEnter", ShowTooltip) + pin:SetScript("OnLeave", HideTooltip) + return pin +end + +local function Refresh() + Pins:RemoveAllMinimapIcons(ns) + for i = #active, 1, -1 do + free[#free + 1] = table.remove(active, i) + end + + local level = UnitLevel("player") + local raceBit = ns.raceBits[select(3, UnitRace("player"))] + local classBit = 2 ^ (select(3, UnitClass("player")) - 1) + + for id, quest in pairs(ns.pinQuests) do + if ns.DungeonsFor(id) and CanPickUp(id, quest, level, raceBit, classBit) then + local spawns = quest.s + for i = 1, #spawns, 3 do + local pin = AcquirePin() + pin.questID = id + active[#active + 1] = pin + Pins:AddMinimapIconMap(ns, pin, spawns[i], spawns[i + 1], spawns[i + 2], false, false) + end + end + end +end + +-- Turning a quest in reports several events, and completion lags slightly behind. +local queued = false +local function QueueRefresh() + if not queued then + queued = true + C_Timer.After(REFRESH_DELAY, function() + queued = false + Refresh() + end) + end +end + +local frame = CreateFrame("Frame") +for _, event in ipairs({ "PLAYER_ENTERING_WORLD", "PLAYER_LEVEL_UP", "QUEST_ACCEPTED", "QUEST_REMOVED", "QUEST_TURNED_IN" }) do + if not C_EventUtils or C_EventUtils.IsEventValid(event) then + frame:RegisterEvent(event) + end +end +frame:SetScript("OnEvent", QueueRefresh) diff --git a/DungeonPreQuest/PinData.lua b/DungeonPreQuest/PinData.lua new file mode 100644 index 0000000..794112e --- /dev/null +++ b/DungeonPreQuest/PinData.lua @@ -0,0 +1,321 @@ +-- Generated from QuestieDB's Forever data. Do not edit. +local _, ns = ... + +ns.raceBits = {[1]=1,[2]=2,[3]=4,[4]=8,[5]=16,[6]=32,[7]=64,[8]=128,[9]=256,[10]=512,[11]=1024,[22]=2097152,[24]=8388608,[25]=16777216,[26]=33554432,[95]=4294967296,[96]=8589934592,} + +ns.pinQuests = { +[65]={n="The Defias Brotherhood",l=14,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=132,b=0,s={1436,0.5633,0.4752}}, +[132]={n="The Defias Brotherhood",l=14,r=4294967373,c=0,p={65},g=nil,x=nil,nx=135,b=0,s={1433,0.2139,0.4535}}, +[135]={n="The Defias Brotherhood",l=14,r=4294967373,c=0,p={132},g=nil,x=nil,nx=141,b=0,s={1436,0.5633,0.4752}}, +[141]={n="The Defias Brotherhood",l=14,r=4294967373,c=0,p={135},g=nil,x=nil,nx=142,b=0,s={1453,0.7831,0.7074}}, +[142]={n="The Defias Brotherhood",l=14,r=4294967373,c=0,p={141},g=nil,x=nil,nx=155,b=0,s={1436,0.5633,0.4752}}, +[155]={n="The Defias Brotherhood",l=14,r=4294967373,c=0,p={142},g=nil,x=nil,nx=166,b=0,s={1436,0.5568,0.4750}}, +[261]={n="Down the Scarlet Path",l=34,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=1052,b=0,s={1443,0.6652,0.0791}}, +[303]={n="The Dark Iron War",l=25,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=378,b=0,s={1437,0.4967,0.1823}}, +[389]={n="Bazil Thredd",l=16,r=4294967373,c=0,p={373},g=nil,x=nil,nx=391,b=0,s={1453,0.5774,0.4786}}, +[707]={n="Ironband Wants You!",l=30,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=738,b=738,s={1455,0.7464,0.1174}}, +[720]={n="A Sign of Hope",l=35,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=721,b=0,s={1418,0.5303,0.3394}}, +[721]={n="A Sign of Hope",l=35,r=4294967373,c=0,p={720},g=nil,x=nil,nx=722,b=0,s={1418,0.5342,0.4339}}, +[723]={n="Prospect of Faith",l=35,r=4294967373,c=0,p={722},g=nil,x=nil,nx=724,b=0,s={1418,0.3790,0.1059}}, +[724]={n="Prospect of Faith",l=35,r=4294967373,c=0,p={723},g=nil,x=nil,nx=725,b=0,s={1418,0.5342,0.4339}}, +[725]={n="Passing Word of a Threat",l=35,r=4294967373,c=0,p={724},g=nil,x=nil,nx=726,b=0,s={1455,0.7754,0.1182}}, +[726]={n="Passing Word of a Threat",l=35,r=4294967373,c=0,p={725},g=nil,x=nil,nx=762,b=0,s={1455,0.7734,0.0971}}, +[738]={n="Find Agmond",l=30,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=739,b=0,s={1432,0.6593,0.6562}}, +[739]={n="Murdaloc",l=30,r=4294967373,c=0,p={738},g=nil,x=nil,nx=704,b=0,s={1418,0.5089,0.6240}}, +[762]={n="An Ambassador of Evil",l=35,r=4294967373,c=0,p={726},g=nil,x=nil,nx=1139,b=0,s={1455,0.7754,0.1182}}, +[865]={n="Raptor Horns",l=13,r=0,c=0,p=nil,g=nil,x=nil,nx=1491,b=0,s={1413,0.6237,0.3762}}, +[870]={n="The Forgotten Pools",l=10,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=877,b=0,s={1413,0.5226,0.3193}}, +[877]={n="The Stagnant Oasis",l=10,r=8589934770,c=0,p={870},g=nil,x=nil,nx=880,b=0,s={1413,0.5226,0.3193}}, +[880]={n="Altered Beings",l=10,r=8589934770,c=0,p={877},g=nil,x=nil,nx=0,b=0,s={1413,0.5226,0.3193}}, +[886]={n="The Barrens Oases",l=10,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=870,b=870,s={1456,0.7862,0.2856}}, +[1052]={n="Down the Scarlet Path",l=34,r=4294967373,c=0,p={261},g=nil,x=nil,nx=1053,b=0,s={1443,0.6652,0.0791}}, +[1109]={n="Going, Going, Guano!",l=30,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=1113,b=0,s={1458,0.4882,0.6928}}, +[1149]={n="Test of Faith",l=25,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=1150,b=0,s={1441,0.5395,0.4149}}, +[1150]={n="Test of Endurance",l=25,r=8589934770,c=0,p={1149},g=nil,x=nil,nx=1151,b=0,s={1441,0.5395,0.4149}}, +[1151]={n="Test of Strength",l=25,r=8589934770,c=0,p={1150},g=nil,x=nil,nx=1152,b=0,s={1441,0.5395,0.4149}}, +[1152]={n="Test of Lore",l=25,r=8589934770,c=0,p={1151},g=nil,x=nil,nx=1154,b=0,s={1441,0.5395,0.4149}}, +[1154]={n="Test of Lore",l=25,r=8589934770,c=0,p={1152},g=nil,x=nil,nx=6627,b=0,s={1442,0.7880,0.4569}}, +[1159]={n="Test of Lore",l=25,r=8589934770,c=0,p={6627},g=nil,x=nil,nx=1160,b=0,s={1442,0.7880,0.4569}}, +[1198]={n="In Search of Thaelrid",l=18,r=0,c=0,p=nil,g=nil,x=nil,nx=1200,b=0,s={1457,0.5536,0.2503}}, +[1424]={n="Pool of Tears",l=38,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=1429,b=0,s={1435,0.4793,0.5478}}, +[1429]={n="The Atal'ai Exile",l=38,r=8589934770,c=0,p={1424},g=nil,x=nil,nx=1444,b=0,s={1435,0.4793,0.5478}}, +[1444]={n="Return to Fel'Zerul",l=38,r=8589934770,c=0,p={1429},g=nil,x=nil,nx=1445,b=0,s={1425,0.3375,0.7521}}, +[1448]={n="In Search of The Temple",l=38,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=1449,b=0,s={1453,0.6945,0.4040}}, +[1449]={n="To The Hinterlands",l=38,r=4294967373,c=0,p={1448},g=nil,x=nil,nx=1450,b=0,s={1453,0.6945,0.4040}}, +[1450]={n="Gryphon Master Talonaxe",l=38,r=4294967373,c=0,p={1449},g=nil,x=nil,nx=1451,b=0,s={1425,0.1181,0.4676}}, +[1451]={n="Rhapsody Shindigger",l=38,r=4294967373,c=0,p={1450},g=nil,x=nil,nx=1452,b=0,s={1425,0.0975,0.4447}}, +[1452]={n="Rhapsody's Kalimdor Kocktail",l=38,r=4294967373,c=0,p={1451},g=nil,x=nil,nx=1469,b=0,s={1425,0.2694,0.4859}}, +[1469]={n="Rhapsody's Tale",l=38,r=4294967373,c=0,p={1452},g=nil,x=nil,nx=1475,b=0,s={1425,0.2694,0.4859}}, +[1489]={n="Hamuul Runetotem",l=12,r=8589934770,c=0,p={880},g=nil,x=nil,nx=1490,b=0,s={1413,0.5226,0.3193}}, +[1490]={n="Nara Wildmane",l=12,r=8589934770,c=0,p={1489},g=nil,x=nil,nx=914,b=0,s={1456,0.7862,0.2856}}, +[1650]={n="The Tome of Valor",l=20,r=5,c=2,p={1649},g=nil,x=nil,nx=1651,b=0,s={1453,0.5048,0.4749}}, +[1651]={n="The Tome of Valor",l=20,r=5,c=2,p={1650},g=nil,x=nil,nx=1652,b=0,s={1436,0.4169,0.8924}}, +[1652]={n="The Tome of Valor",l=20,r=5,c=2,p={1651},g=nil,x=nil,nx=1653,b=0,s={1436,0.4169,0.8924}}, +[1653]={n="The Test of Righteousness",l=20,r=5,c=2,p={1652},g=nil,x=nil,nx=1654,b=0,s={1453,0.5048,0.4749}}, +[1947]={n="Journey to the Marsh",l=30,r=0,c=128,p=nil,g=nil,x=nil,nx=0,b=0,s={1456,0.2570,0.1419,1458,0.8514,0.1003,1454,0.3845,0.8613,1455,0.2725,0.0830,1453,0.4956,0.8580}}, +[1949]={n="Hidden Secrets",l=30,r=0,c=128,p={1947},g=nil,x=nil,nx=1950,b=0,s={1445,0.4606,0.5709}}, +[1950]={n="Get the Scoop",l=30,r=0,c=128,p={1949},g=nil,x=nil,nx=1951,b=0,s={1441,0.7829,0.7570}}, +[1953]={n="Return to the Marsh",l=35,r=0,c=128,p=nil,g=nil,x=nil,nx=1954,b=1954,s={1456,0.2570,0.1419,1458,0.8514,0.1003,1454,0.3845,0.8613,1455,0.2725,0.0830,1453,0.4956,0.8580}}, +[1954]={n="The Infernal Orb",l=35,r=0,c=128,p=nil,g=nil,x=nil,nx=1955,b=0,s={1445,0.4606,0.5709}}, +[1955]={n="The Exorcism",l=35,r=0,c=128,p={1954},g=nil,x=nil,nx=1956,b=0,s={1445,0.4606,0.5709}}, +[2041]={n="Speak with Shoni",l=15,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=2040,b=2040,s={1455,0.6918,0.5055}}, +[2200]={n="Back to Uldaman",l=37,r=4294967373,c=0,p={2199},g=nil,x=nil,nx=2201,b=0,s={1455,0.3638,0.0361}}, +[2258]={n="Badlands Reagent Run",l=36,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=2202,b=0,s={1418,0.0242,0.4606}}, +[2284]={n="Necklace Recovery, Take 2",l=37,r=8589934770,c=0,p={2283},g=nil,x=nil,nx=2318,b=0,s={1454,0.5949,0.3657}}, +[2338]={n="Translating the Journal",l=37,r=8589934770,c=0,p={2318},g=nil,x=nil,nx=2339,b=0,s={1418,0.0242,0.4606}}, +[2398]={n="The Lost Dwarves",l=35,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=2240,b=2240,s={1455,0.7464,0.1174}}, +[2500]={n="Badlands Reagent Run",l=36,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=17,b=0,s={1432,0.3707,0.4938}}, +[2769]={n="The Brassbolts Brothers",l=40,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=2770,b=2770,s={1455,0.6792,0.4610}}, +[2842]={n="Chief Engineer Scooty",l=20,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=2843,b=0,s={1454,0.7549,0.2536}}, +[2861]={n="Tabetha's Task",l=40,r=0,c=0,p=nil,g=nil,x=nil,nx=2846,b=2846,s={1458,0.8514,0.1003,1455,0.2725,0.0830,1453,0.4956,0.8580,1454,0.3845,0.8613}}, +[2864]={n="Tran'rek",l=40,r=0,c=0,p=nil,g=nil,x=nil,nx=2865,b=2865,s={1434,0.2695,0.7721}}, +[2923]={n="Tinkmaster Overspark",l=20,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=2922,b=2922,s={1453,0.5105,0.4839}}, +[2925]={n="Klockmort's Essentials",l=24,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=2924,b=2924,s={1457,0.5951,0.4538}}, +[2927]={n="The Day After",l=20,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=2926,b=2926,s={1455,0.6918,0.5055}}, +[2931]={n="Castpipe's Task",l=25,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=2930,b=2930,s={1442,0.5952,0.6715}}, +[2933]={n="Venom Bottles",l=40,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=2934,b=0,s={1425,0.2354,0.5880}}, +[2934]={n="Undamaged Venom Sac",l=40,r=8589934770,c=0,p={2933},g=nil,x=nil,nx=2935,b=0,s={1424,0.6144,0.1906}}, +[2935]={n="Consult Master Gadrin",l=40,r=8589934770,c=0,p={2934},g=nil,x=nil,nx=2936,b=0,s={1424,0.6144,0.1906}}, +[2988]={n="Witherbark Cages",l=40,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=2989,b=0,s={1425,0.0975,0.4447}}, +[2989]={n="The Altar of Zul",l=40,r=4294967373,c=0,p={2988},g=nil,x=nil,nx=2990,b=0,s={1425,0.0975,0.4447}}, +[2990]={n="Thadius Grimshade",l=40,r=4294967373,c=0,p={2989},g=nil,x=nil,nx=2991,b=0,s={1425,0.0975,0.4447}}, +[3380]={n="The Sunken Temple",l=46,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=3444,b=0,s={1444,0.7442,0.4336}}, +[3441]={n="Divine Retribution",l=40,r=0,c=0,p=nil,g=nil,x=nil,nx=3442,b=0,s={1427,0.3906,0.3899}}, +[3442]={n="The Flawless Flame",l=40,r=0,c=0,p={3441},g=nil,x=nil,nx=3443,b=0,s={1427,0.3906,0.3899}}, +[3443]={n="Forging the Shaft",l=40,r=0,c=0,p={3442},g=nil,x=nil,nx=3452,b=0,s={1427,0.3906,0.3899}}, +[3444]={n="The Stone Circle",l=46,r=0,c=0,p={3380,3445},g=nil,x=nil,nx=0,b=0,s={1446,0.5271,0.4592}}, +[3445]={n="The Sunken Temple",l=46,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=3444,b=0,s={1444,0.3183,0.4561}}, +[3452]={n="The Flame's Casing",l=40,r=0,c=0,p={3443},g=nil,x=nil,nx=3453,b=0,s={1427,0.3906,0.3899}}, +[3453]={n="The Torch of Retribution",l=40,r=0,c=0,p={3452},g=nil,x=nil,nx=3454,b=0,s={1427,0.3906,0.3899}}, +[3454]={n="The Torch of Retribution",l=40,r=0,c=0,p={3453},g=nil,x=nil,nx=3462,b=0,s={1427,0.3906,0.3899}}, +[3462]={n="Squire Maltrake",l=40,r=0,c=0,p={3454},g=nil,x=nil,nx=3463,b=0,s={1427,0.3906,0.3899}}, +[3463]={n="Set Them Ablaze!",l=40,r=0,c=0,p={3462},g=nil,x=nil,nx=3481,b=0,s={1427,0.3917,0.3900}}, +[3481]={n="Trinkets...",l=40,r=0,c=0,p={3463},g=nil,x=nil,nx=4022,b=0,s={1427,0.3885,0.3899}}, +[3520]={n="Screecher Spirits",l=40,r=0,c=0,p=nil,g=nil,x=nil,nx=3527,b=0,s={1446,0.6699,0.2236}}, +[3527]={n="The Prophecy of Mosh'aru",l=40,r=0,c=0,p={3520},g=nil,x=nil,nx=4787,b=0,s={1446,0.6699,0.2236}}, +[3528]={n="The God Hakkar",l=40,r=0,c=0,p={4787},g=nil,x=nil,nx=5065,b=0,s={1446,0.6699,0.2236}}, +[3701]={n="The Smoldering Ruins of Thaurissan",l=50,r=4294967373,c=0,p={3702},g=nil,x=nil,nx=4341,b=0,s={1455,0.3837,0.5531}}, +[3702]={n="The Smoldering Ruins of Thaurissan",l=50,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=3701,b=0,s={1455,0.3837,0.5531}}, +[3765]={n="The Corruption Abroad",l=18,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=1275,b=1275,s={1453,0.3624,0.6761}}, +[3801]={n="Dark Iron Legacy",l=48,r=0,c=0,p=nil,g=nil,x=nil,nx=3802,b=0,s={1428,0.2896,0.2893}}, +[3906]={n="Disharmony of Flame",l=48,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=3907,b=0,s={1418,0.0333,0.4826}}, +[3981]={n="Commander Gor'shak",l=48,r=8589934770,c=0,p={3906},g=nil,x=nil,nx=3982,b=0,s={1418,0.0596,0.4773}}, +[4002]={n="The Eastern Kingdom",l=48,r=8589934770,c=0,p={4001},g=nil,x=nil,nx=4003,b=0,s={1454,0.3173,0.3782}}, +[4022]={n="A Taste of Flame",l=52,r=0,c=0,p={3481},g=nil,x={4023},nx=4024,b=0,s={1428,0.9509,0.3156}}, +[4061]={n="The Rise of the Machines",l=52,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=4062,b=0,s={1418,0.0302,0.4781}}, +[4062]={n="The Rise of the Machines",l=52,r=8589934770,c=0,p={4061},g=nil,x=nil,nx=4063,b=0,s={1418,0.0302,0.4781}}, +[4122]={n="Grark Lorkrub",l=52,r=8589934770,c=0,p={4082},g=nil,x=nil,nx=4121,b=0,s={1418,0.0588,0.4763}}, +[4128]={n="Ragnar Thunderbrew",l=50,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=4126,b=4126,s={1419,0.6363,0.2063}}, +[4133]={n="Vivian Lagrave",l=50,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=4134,b=4134,s={1458,0.5014,0.6797}}, +[4141]={n="Muigin and Larion",l=47,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=4142,b=0,s={1449,0.4294,0.0964}}, +[4142]={n="A Visit to Gregan",l=47,r=4294967373,c=0,p={4141},g=nil,x=nil,nx=4143,b=0,s={1449,0.4294,0.0964}}, +[4145]={n="Larion and Muigin",l=47,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=4147,b=0,s={1449,0.4554,0.0872}}, +[4146]={n="Zapper Fuel",l=47,r=8589934770,c=0,p={4147},g=nil,x=nil,nx=4148,b=0,s={1413,0.6245,0.3873}}, +[4147]={n="Marvon's Workshop",l=47,r=8589934770,c=0,p={4145},g=nil,x=nil,nx=4146,b=0,s={1449,0.4554,0.0872}}, +[4182]={n="Dragonkin Menace",l=48,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=4183,b=0,s={1428,0.8582,0.6895}}, +[4183]={n="The True Masters",l=48,r=4294967373,c=0,p={4182},g=nil,x=nil,nx=4184,b=0,s={1428,0.8582,0.6895}}, +[4184]={n="The True Masters",l=48,r=4294967373,c=0,p={4183},g=nil,x=nil,nx=4185,b=0,s={1433,0.2490,0.4445}}, +[4185]={n="The True Masters",l=48,r=4294967373,c=0,p={4184},g=nil,x=nil,nx=4186,b=0,s={1453,0.8021,0.3835}}, +[4186]={n="The True Masters",l=48,r=4294967373,c=0,p={4185},g=nil,x=nil,nx=4223,b=0,s={1453,0.8021,0.3835}}, +[4223]={n="The True Masters",l=48,r=4294967373,c=0,p={4186},g=nil,x=nil,nx=4224,b=0,s={1433,0.2490,0.4445}}, +[4224]={n="The True Masters",l=48,r=4294967373,c=0,p={4223},g=nil,x=nil,nx=4241,b=0,s={1428,0.8474,0.6902}}, +[4241]={n="Marshal Windsor",l=48,r=4294967373,c=0,p={4224},g=nil,x=nil,nx=4242,b=0,s={1428,0.8474,0.6902}}, +[4262]={n="Overmaster Pyron",l=48,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=4263,b=0,s={1428,0.8541,0.7006}}, +[4324]={n="Yuka Screwspigot",l=48,r=0,c=0,p=nil,g=nil,x=nil,nx=4136,b=4136,s={1446,0.6704,0.2401}}, +[4341]={n="Kharan Mighthammer",l=50,r=4294967373,c=0,p={3701},g=nil,x=nil,nx=4342,b=0,s={1455,0.3909,0.5620}}, +[4726]={n="Broodling Essence",l=50,r=0,c=0,p=nil,g=nil,x=nil,nx=4808,b=0,s={1428,0.6524,0.2400}}, +[4734]={n="Egg Freezing",l=57,r=0,c=0,p={4810},g=nil,x=nil,nx=4735,b=0,s={1428,0.6524,0.2400}}, +[4735]={n="Egg Collection",l=57,r=0,c=0,p={4734},g=nil,x=nil,nx=5522,b=0,s={1428,0.6524,0.2400}}, +[4766]={n="Mayara Brightwing",l=57,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=4764,b=4764,s={1453,0.7694,0.4783}}, +[4769]={n="Vivian Lagrave and the Darkstone Tablet",l=57,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=4768,b=4768,s={1458,0.5014,0.6797}}, +[4787]={n="The Ancient Egg",l=40,r=0,c=0,p={3527},g=nil,x=nil,nx=3528,b=0,s={1446,0.6699,0.2236}}, +[4808]={n="Felnok Steelspring",l=50,r=0,c=0,p={4726},g=nil,x=nil,nx=4809,b=0,s={1428,0.6524,0.2400}}, +[4809]={n="Chillwind Horns",l=50,r=0,c=0,p={4808},g=nil,x=nil,nx=4810,b=0,s={1452,0.6163,0.3861}}, +[4810]={n="Return to Tinkee",l=50,r=0,c=0,p={4809},g=nil,x=nil,nx=4907,b=0,s={1452,0.6163,0.3861}}, +[4907]={n="Tinkee Steamboil",l=57,r=0,c=0,p={4810},g=nil,x=nil,nx=4734,b=4734,s={1452,0.6163,0.3861}}, +[4941]={n="Eitrigg's Wisdom",l=55,r=8589934770,c=0,p={4903},g=nil,x=nil,nx=4974,b=0,s={1418,0.0581,0.4752}}, +[4981]={n="Operative Bijou",l=55,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=4982,b=0,s={1418,0.0588,0.4763}}, +[5065]={n="The Lost Tablets of Mosh'aru",l=40,r=0,c=0,p={3528},g=nil,x=nil,nx=4788,b=0,s={1446,0.6689,0.2403}}, +[5281]={n="The Restless Souls",l=55,r=0,c=0,p=nil,g=nil,x=nil,nx=5282,b=0,s={1423,0.6993,0.5372}}, +[5382]={n="Doctor Theolen Krastinov, the Butcher",l=55,r=0,c=0,p=nil,g=nil,x=nil,nx=5515,b=0,s={1422,0.7022,0.7371}}, +[5384]={n="Kirtonos the Herald",l=55,r=0,c=0,p={5515},g=nil,x=nil,nx=5461,b=0,s={1422,0.7022,0.7371}}, +[5461]={n="The Human, Ras Frostwhisper",l=57,r=0,c=0,p={5384},g=nil,x=nil,nx=5462,b=0,s={1422,0.7057,0.7411}}, +[5462]={n="The Dying, Ras Frostwhisper",l=57,r=0,c=0,p={5461},g=nil,x=nil,nx=5463,b=0,s={1422,0.7057,0.7411}}, +[5463]={n="Menethil's Gift",l=57,r=0,c=0,p={5462},g=nil,x=nil,nx=5464,b=0,s={1423,0.7189,0.4829}}, +[5465]={n="Soulbound Keepsake",l=57,r=0,c=0,p={5464},g=nil,x=nil,nx=5466,b=0,s={1423,0.7189,0.4829}}, +[5515]={n="Krastinov's Bag of Horrors",l=55,r=0,c=0,p={5382},g=nil,x=nil,nx=5384,b=0,s={1422,0.7022,0.7371}}, +[5522]={n="Leonid Barthalomew",l=57,r=0,c=0,p={4735},g=nil,x=nil,nx=5531,b=0,s={1428,0.6524,0.2400}}, +[5527]={n="A Reliquary of Purity",l=56,r=0,c=0,p=nil,g=nil,x=nil,nx=5526,b=0,s={1450,0.5169,0.4510}}, +[5531]={n="Betina Bigglezink",l=57,r=0,c=0,p={5522},g=nil,x=nil,nx=4771,b=0,s={1423,0.7189,0.4829}}, +[5542]={n="Demon Dogs",l=52,r=0,c=0,p=nil,g=nil,x=nil,nx=5742,b=0,s={1423,0.0516,0.3557,1422,0.5395,0.2445}}, +[5543]={n="Blood Tinged Skies",l=52,r=0,c=0,p=nil,g=nil,x=nil,nx=5742,b=0,s={1423,0.0516,0.3557,1422,0.5395,0.2445}}, +[5544]={n="Carrion Grubbage",l=52,r=0,c=0,p=nil,g=nil,x=nil,nx=5742,b=0,s={1423,0.0516,0.3557,1422,0.5395,0.2445}}, +[5726]={n="Hidden Enemies",l=9,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=5727,b=0,s={1454,0.3173,0.3782}}, +[5727]={n="Hidden Enemies",l=9,r=8589934770,c=0,p={5726},g=nil,x=nil,nx=5728,b=0,s={1454,0.3173,0.3782}}, +[5742]={n="Redemption",l=52,r=0,c=0,p=nil,g={5542,5543,5544},x=nil,nx=5781,b=0,s={1423,0.0516,0.3557}}, +[5781]={n="Of Forgotten Memories",l=52,r=0,c=0,p={5742},g=nil,x=nil,nx=5845,b=0,s={1423,0.0516,0.3557}}, +[5845]={n="Of Lost Honor",l=52,r=0,c=0,p={5781},g=nil,x=nil,nx=5846,b=0,s={1423,0.0516,0.3557}}, +[5846]={n="Of Love and Family",l=52,r=0,c=0,p={5845},g=nil,x=nil,nx=5848,b=0,s={1423,0.0516,0.3557}}, +[6022]={n="To Kill With Purpose",l=54,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=0,b=0,s={1423,0.2223,0.6351}}, +[6042]={n="Un-Life's Little Annoyances",l=54,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=0,b=0,s={1423,0.2223,0.6351}}, +[6133]={n="The Ranger Lord's Behest",l=54,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=0,b=0,s={1423,0.2223,0.6351}}, +[6135]={n="Duskwing, Oh How I Hate Thee...",l=56,r=8589934770,c=0,p=nil,g={6022,6042,6133},x=nil,nx=0,b=0,s={1423,0.2223,0.6351}}, +[6136]={n="The Corpulent One",l=56,r=8589934770,c=0,p=nil,g={6022,6042,6133},x=nil,nx=0,b=0,s={1423,0.2223,0.6351}}, +[6141]={n="Brother Anton",l=34,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=261,b=261,s={1453,0.5262,0.4318}}, +[6402]={n="Stormwind Rendezvous",l=50,r=4294967373,c=0,p={4322},g=nil,x=nil,nx=6403,b=0,s={1428,0.8474,0.6902}}, +[6403]={n="The Great Masquerade",l=50,r=4294967373,c=0,p={6402},g=nil,x=nil,nx=6501,b=0,s={1453,0.7361,0.9105}}, +[6501]={n="The Dragon's Eye",l=50,r=4294967373,c=0,p={6403},g=nil,x=nil,nx=6502,b=0,s={1453,0.8021,0.3835}}, +[6562]={n="Trouble in the Deeps",l=17,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=6563,b=6563,s={1442,0.4736,0.6425}}, +[6566]={n="What the Wind Carries",l=55,r=8589934770,c=0,p={4974},g=nil,x=nil,nx=6567,b=0,s={1454,0.3173,0.3782}}, +[6567]={n="The Champion of the Horde",l=55,r=8589934770,c=0,p={6566},g=nil,x=nil,nx=6568,b=0,s={1454,0.3173,0.3782}}, +[6568]={n="The Testament of Rexxar",l=55,r=8589934770,c=0,p={6567},g=nil,x=nil,nx=6569,b=0,s={1443,0.5400,0.0200}}, +[6570]={n="Emberstrife",l=55,r=8589934770,c=0,p={6569},g=nil,x=nil,nx=0,b=0,s={1422,0.5079,0.7785}}, +[6582]={n="The Test of Skulls, Scryer",l=55,r=8589934770,c=0,p={6570},g=nil,x=nil,nx=0,b=0,s={1445,0.5666,0.8772}}, +[6583]={n="The Test of Skulls, Somnus",l=55,r=8589934770,c=0,p={6570},g=nil,x=nil,nx=0,b=0,s={1445,0.5666,0.8772}}, +[6584]={n="The Test of Skulls, Chronalis",l=55,r=8589934770,c=0,p={6570},g=nil,x=nil,nx=0,b=0,s={1445,0.5666,0.8772}}, +[6585]={n="The Test of Skulls, Axtroz",l=55,r=8589934770,c=0,p=nil,g={6582,6583,6584},x=nil,nx=6601,b=0,s={1445,0.5666,0.8772}}, +[6601]={n="Ascension...",l=55,r=8589934770,c=0,p={6585},g=nil,x=nil,nx=6602,b=0,s={1445,0.5666,0.8772}}, +[6627]={n="Test of Lore",l=25,r=8589934770,c=0,p={1154},g=nil,x=nil,nx=1159,b=0,s={1442,0.7880,0.4569}}, +[7492]={n="Camp Mojache",l=54,r=8589934770,c=0,p=nil,g=nil,x=nil,nx=7489,b=7489,s={1458,0.6390,0.4408,1454,0.3768,0.7516,1456,0.4433,0.5876}}, +[7494]={n="Feathermoon Stronghold",l=54,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=7488,b=7488,s={1453,0.5639,0.7409,1455,0.5592,0.8139,1457,0.4781,0.8197}}, +[7562]={n="Mor'zul Bloodbringer",l=60,r=0,c=256,p=nil,g=nil,x=nil,nx=7563,b=7563,s={1453,0.3953,0.8453,1454,0.4752,0.4672,1455,0.5270,0.0608,1435,0.4858,0.5527}}, +[7563]={n="Rage of Blood",l=60,r=0,c=256,p=nil,g=nil,x=nil,nx=7564,b=0,s={1428,0.1269,0.3164}}, +[7564]={n="Wildeyes",l=60,r=0,c=256,p={7563},g=nil,x=nil,nx=0,b=0,s={1428,0.1269,0.3164}}, +[7623]={n="Lord Banehollow",l=60,r=0,c=256,p=nil,g=nil,x=nil,nx=7624,b=0,s={1428,0.1244,0.3163}}, +[7624]={n="Ulathek the Traitor",l=60,r=0,c=256,p={7623},g=nil,x=nil,nx=7625,b=0,s={1448,0.3593,0.4442}}, +[7625]={n="Xorothian Stardust",l=60,r=0,c=256,p={7624},g=nil,x=nil,nx=0,b=0,s={1448,0.3593,0.4442}}, +[7626]={n="Bell of Dethmoora",l=60,r=0,c=256,p={7564},g=nil,x=nil,nx=0,b=0,s={1428,0.1269,0.3164}}, +[7627]={n="Wheel of the Black March",l=60,r=0,c=256,p={7564},g=nil,x=nil,nx=0,b=0,s={1428,0.1269,0.3164}}, +[7628]={n="Doomsday Candle",l=60,r=0,c=256,p={7564},g=nil,x=nil,nx=0,b=0,s={1428,0.1269,0.3164}}, +[7630]={n="Arcanite",l=60,r=0,c=256,p=nil,g={7626,7627,7628},x=nil,nx=0,b=0,s={1428,0.1244,0.3163}}, +[7637]={n="Emphasis on Sacrifice",l=60,r=5,c=2,p={7638},g=nil,x=nil,nx=7639,b=0,s={1453,0.4843,0.5022}}, +[7638]={n="Lord Grayson Shadowbreaker",l=60,r=5,c=2,p=nil,g=nil,x=nil,nx=0,b=0,s={1453,0.5048,0.4749}}, +[7639]={n="To Show Due Judgment",l=60,r=5,c=2,p={7637},g=nil,x=nil,nx=7640,b=0,s={1455,0.2473,0.0816}}, +[7640]={n="Exorcising Terrordale",l=60,r=5,c=2,p={7639},g=nil,x=nil,nx=0,b=0,s={1453,0.4843,0.5022}}, +[7641]={n="The Work of Grimand Elmore",l=60,r=5,c=2,p={7640},g=nil,x=nil,nx=7642,b=0,s={1453,0.4843,0.5022}}, +[7646]={n="The Divination Scryer",l=60,r=5,c=2,p={7644},g=nil,x=nil,nx=7647,b=0,s={1453,0.4843,0.5022}}, +[7667]={n="Material Assistance",l=58,r=8589934770,c=64,p=nil,g=nil,x=nil,nx=8258,b=0,s={1454,0.3866,0.3592}}, +[7670]={n="Lord Grayson Shadowbreaker",l=60,r=4294967373,c=2,p=nil,g=nil,x={7638},nx=7637,b=0,s={1455,0.2313,0.0614}}, +[7722]={n="What the Flux?",l=45,r=0,c=0,p=nil,g=nil,x=nil,nx=0,b=0,s={1427,0.3880,0.2851}}, +[8151]={n="The Hunter's Charm",l=50,r=0,c=4,p=nil,g=nil,x=nil,nx=8153,b=0,s={1456,0.5730,0.8979,1454,0.6605,0.1853,1457,0.4221,0.0727,1455,0.7089,0.8361,1453,0.6759,0.3578}}, +[8153]={n="Courser Antlers",l=50,r=0,c=4,p={8151},g=nil,x=nil,nx=8231,b=0,s={1447,0.4240,0.4262}}, +[8231]={n="Wavethrashing",l=50,r=0,c=4,p={8153},g=nil,x=nil,nx=8232,b=0,s={1447,0.4240,0.4262}}, +[8233]={n="A Simple Request",l=50,r=0,c=8,p=nil,g=nil,x=nil,nx=8234,b=8234,s={1453,0.7743,0.6531,1454,0.4390,0.5463,1457,0.3699,0.2191,1458,0.8521,0.7157,1455,0.5196,0.1484,1455,0.5150,0.1533}}, +[8234]={n="Sealed Azure Bag",l=50,r=0,c=8,p=nil,g=nil,x=nil,nx=8235,b=0,s={1416,0.8602,0.7888}}, +[8235]={n="Encoded Fragments",l=50,r=0,c=8,p={8234},g=nil,x=nil,nx=8236,b=0,s={1447,0.2925,0.4021}}, +[8251]={n="Magic Dust",l=50,r=0,c=128,p=nil,g=nil,x=nil,nx=8252,b=0,s={1447,0.2925,0.4021}}, +[8252]={n="The Siren's Coral",l=50,r=0,c=128,p={8251},g=nil,x=nil,nx=8253,b=0,s={1447,0.2925,0.4021}}, +[8254]={n="Cenarion Aid",l=50,r=0,c=16,p=nil,g=nil,x=nil,nx=8255,b=0,s={1456,0.2456,0.2257,1453,0.4950,0.4521,1454,0.3559,0.8782,1455,0.2473,0.0816}}, +[8255]={n="Of Coursers We Know",l=50,r=0,c=16,p={8254},g=nil,x=nil,nx=8256,b=0,s={1447,0.4240,0.4262}}, +[8256]={n="The Ichor of Undeath",l=50,r=0,c=16,p={8255},g=nil,x=nil,nx=8257,b=0,s={1447,0.4240,0.4262}}, +[8410]={n="Elemental Mastery",l=50,r=8589934770,c=64,p=nil,g=nil,x={8411},nx=8412,b=0,s={1456,0.2199,0.1880,1454,0.3866,0.3592}}, +[8411]={n="Mastering the Elements",l=50,r=8589934770,c=64,p=nil,g=nil,x={8410},nx=8412,b=0,s={1416,0.8050,0.6692}}, +[8412]={n="Spirit Totem",l=50,r=8589934770,c=64,p={8410,8411},g=nil,x=nil,nx=8413,b=0,s={1416,0.8050,0.6692}}, +[8414]={n="Dispelling Evil",l=50,r=5,c=2,p=nil,g=nil,x=nil,nx=8416,b=0,s={1422,0.4270,0.8403}}, +[8415]={n="Chillwind Point",l=50,r=5,c=2,p=nil,g=nil,x=nil,nx=8414,b=8414,s={1453,0.4843,0.5022,1455,0.2313,0.0614}}, +[8416]={n="Inert Scourgestones",l=50,r=5,c=2,p={8414},g=nil,x=nil,nx=8418,b=0,s={1422,0.5205,0.8327}}, +[8417]={n="A Troubled Spirit",l=50,r=0,c=1,p=nil,g=nil,x=nil,nx=8423,b=8423,s={1456,0.5724,0.8737,1454,0.8039,0.3238,1458,0.4693,0.1523,1455,0.7034,0.9065,1453,0.8055,0.5987,1457,0.5894,0.3535}}, +[8419]={n="An Imp's Request",l=50,r=0,c=256,p=nil,g=nil,x={8420},nx=8421,b=0,s={1453,0.3924,0.8496,1454,0.4847,0.4543,1458,0.8621,0.1593,1455,0.5035,0.0566}}, +[8420]={n="Hot and Itchy",l=50,r=0,c=256,p=nil,g=nil,x={8419},nx=8421,b=0,s={1448,0.4136,0.4502}}, +[8421]={n="The Wrong Stuff",l=50,r=0,c=256,p={8419,8420},g=nil,x=nil,nx=8422,b=0,s={1448,0.4136,0.4502}}, +[8423]={n="Warrior Kinship",l=50,r=0,c=1,p=nil,g=nil,x=nil,nx=8424,b=0,s={1435,0.3429,0.6614}}, +[8424]={n="War on the Shadowsworn",l=50,r=0,c=1,p={8423},g=nil,x=nil,nx=8425,b=0,s={1435,0.3429,0.6614}}, +[8905]={n="An Earnest Proposition",l=58,r=4294967373,c=1024,p=nil,g=nil,x=nil,nx=8922,b=0,s={1455,0.4353,0.5264}}, +[8906]={n="An Earnest Proposition",l=58,r=4294967373,c=4,p=nil,g=nil,x=nil,nx=8922,b=0,s={1455,0.4353,0.5264}}, +[8907]={n="An Earnest Proposition",l=58,r=4294967373,c=128,p=nil,g=nil,x=nil,nx=8922,b=0,s={1455,0.4353,0.5264}}, +[8908]={n="An Earnest Proposition",l=58,r=4294967373,c=2,p=nil,g=nil,x=nil,nx=8922,b=0,s={1455,0.4353,0.5264}}, +[8909]={n="An Earnest Proposition",l=58,r=4294967373,c=16,p=nil,g=nil,x=nil,nx=8922,b=0,s={1455,0.4353,0.5264}}, +[8910]={n="An Earnest Proposition",l=58,r=4294967373,c=8,p=nil,g=nil,x=nil,nx=8922,b=0,s={1455,0.4353,0.5264}}, +[8911]={n="An Earnest Proposition",l=58,r=4294967373,c=256,p=nil,g=nil,x=nil,nx=8922,b=0,s={1455,0.4353,0.5264}}, +[8912]={n="An Earnest Proposition",l=58,r=4294967373,c=1,p=nil,g=nil,x=nil,nx=8922,b=0,s={1455,0.4353,0.5264}}, +[8913]={n="An Earnest Proposition",l=58,r=8589934770,c=1024,p=nil,g=nil,x=nil,nx=8923,b=0,s={1454,0.3495,0.3829}}, +[8914]={n="An Earnest Proposition",l=58,r=8589934770,c=4,p=nil,g=nil,x=nil,nx=8923,b=0,s={1454,0.3495,0.3829}}, +[8915]={n="An Earnest Proposition",l=58,r=8589934770,c=128,p=nil,g=nil,x=nil,nx=8923,b=0,s={1454,0.3495,0.3829}}, +[8916]={n="An Earnest Proposition",l=58,r=8589934770,c=16,p=nil,g=nil,x=nil,nx=8923,b=0,s={1454,0.3495,0.3829}}, +[8917]={n="An Earnest Proposition",l=58,r=8589934770,c=8,p=nil,g=nil,x=nil,nx=8923,b=0,s={1454,0.3495,0.3829}}, +[8918]={n="An Earnest Proposition",l=58,r=8589934770,c=64,p=nil,g=nil,x=nil,nx=8923,b=0,s={1454,0.3495,0.3829}}, +[8919]={n="An Earnest Proposition",l=58,r=8589934770,c=256,p=nil,g=nil,x=nil,nx=8923,b=0,s={1454,0.3495,0.3829}}, +[8920]={n="An Earnest Proposition",l=58,r=8589934770,c=1,p=nil,g=nil,x=nil,nx=8923,b=0,s={1454,0.3495,0.3829}}, +[8921]={n="The Ectoplasmic Distiller",l=58,r=0,c=0,p={8922,8923},g=nil,x=nil,nx=8924,b=0,s={1446,0.5247,0.2723}}, +[8922]={n="A Supernatural Device",l=58,r=4294967373,c=0,p={8905,8906,8907,8908,8909,8910,8911,8912},g=nil,x=nil,nx=8921,b=0,s={1455,0.4353,0.5264}}, +[8923]={n="A Supernatural Device",l=58,r=8589934770,c=0,p={8913,8914,8915,8916,8917,8918,8919,8920},g=nil,x=nil,nx=8921,b=0,s={1454,0.3495,0.3829}}, +[8924]={n="Hunting for Ectoplasm",l=58,r=0,c=0,p={8921},g=nil,x=nil,nx=8925,b=0,s={1446,0.5247,0.2723}}, +[8925]={n="A Portable Power Source",l=58,r=0,c=0,p={8924},g=nil,x=nil,nx=8928,b=0,s={1446,0.5247,0.2723}}, +[8926]={n="Just Compensation",l=58,r=4294967373,c=1024,p={8977},g=nil,x=nil,nx=8929,b=0,s={1455,0.4353,0.5264}}, +[8927]={n="Just Compensation",l=58,r=8589934770,c=1024,p={8978},g=nil,x=nil,nx=8930,b=0,s={1454,0.3495,0.3829}}, +[8928]={n="A Shifty Merchant",l=58,r=0,c=0,p={8925},g=nil,x=nil,nx=0,b=0,s={1446,0.5247,0.2723}}, +[8929]={n="In Search of Anthion",l=58,r=4294967373,c=0,p={8926,8931,8932,8933,8934,8935,8936,8937},g=nil,x=nil,nx=8945,b=0,s={1455,0.4353,0.5264}}, +[8930]={n="In Search of Anthion",l=58,r=8589934770,c=0,p={8927,8938,8939,8940,8941,8942,8943,8944},g=nil,x=nil,nx=8945,b=0,s={1454,0.3495,0.3829}}, +[8931]={n="Just Compensation",l=58,r=4294967373,c=4,p={8977},g=nil,x=nil,nx=8929,b=0,s={1455,0.4353,0.5264}}, +[8932]={n="Just Compensation",l=58,r=4294967373,c=128,p={8977},g=nil,x=nil,nx=8929,b=0,s={1455,0.4353,0.5264}}, +[8933]={n="Just Compensation",l=58,r=4294967373,c=2,p={8977},g=nil,x=nil,nx=8929,b=0,s={1455,0.4353,0.5264}}, +[8934]={n="Just Compensation",l=58,r=4294967373,c=16,p={8977},g=nil,x=nil,nx=8929,b=0,s={1455,0.4353,0.5264}}, +[8935]={n="Just Compensation",l=58,r=4294967373,c=8,p={8977},g=nil,x=nil,nx=8929,b=0,s={1455,0.4353,0.5264}}, +[8936]={n="Just Compensation",l=58,r=4294967373,c=256,p={8977},g=nil,x=nil,nx=8929,b=0,s={1455,0.4353,0.5264}}, +[8937]={n="Just Compensation",l=58,r=4294967373,c=1,p={8977},g=nil,x=nil,nx=8929,b=0,s={1455,0.4353,0.5264}}, +[8938]={n="Just Compensation",l=58,r=8589934770,c=4,p={8978},g=nil,x=nil,nx=8930,b=0,s={1454,0.3495,0.3829}}, +[8939]={n="Just Compensation",l=58,r=8589934770,c=128,p={8978},g=nil,x=nil,nx=8930,b=0,s={1454,0.3495,0.3829}}, +[8940]={n="Just Compensation",l=58,r=8589934770,c=16,p={8978},g=nil,x=nil,nx=8930,b=0,s={1454,0.3495,0.3829}}, +[8941]={n="Just Compensation",l=58,r=8589934770,c=8,p={8978},g=nil,x=nil,nx=8930,b=0,s={1454,0.3495,0.3829}}, +[8942]={n="Just Compensation",l=58,r=8589934770,c=64,p={8978},g=nil,x=nil,nx=8930,b=0,s={1454,0.3495,0.3829}}, +[8943]={n="Just Compensation",l=58,r=8589934770,c=256,p={8978},g=nil,x=nil,nx=8930,b=0,s={1454,0.3495,0.3829}}, +[8944]={n="Just Compensation",l=58,r=8589934770,c=1,p={8978},g=nil,x=nil,nx=8930,b=0,s={1454,0.3495,0.3829}}, +[8945]={n="Dead Man's Plea",l=58,r=0,c=0,p={8929,8930},g=nil,x=nil,nx=8946,b=0,s={1423,0.2611,0.1130}}, +[8947]={n="Anthion's Strange Request",l=58,r=0,c=0,p={8946},g=nil,x=nil,nx=8948,b=0,s={1423,0.2611,0.1130}}, +[8948]={n="Anthion's Old Friend",l=58,r=0,c=0,p={8947},g=nil,x=nil,nx=8949,b=0,s={1423,0.2611,0.1130}}, +[8951]={n="Anthion's Parting Words",l=58,r=4294967373,c=1024,p={9015},g=nil,x=nil,nx=8960,b=0,s={1423,0.2611,0.1130}}, +[8952]={n="Anthion's Parting Words",l=58,r=4294967373,c=4,p={9015},g=nil,x=nil,nx=8960,b=0,s={1423,0.2611,0.1130}}, +[8953]={n="Anthion's Parting Words",l=58,r=4294967373,c=128,p={9015},g=nil,x=nil,nx=8960,b=0,s={1423,0.2611,0.1130}}, +[8954]={n="Anthion's Parting Words",l=58,r=4294967373,c=2,p={9015},g=nil,x=nil,nx=8960,b=0,s={1423,0.2611,0.1130}}, +[8955]={n="Anthion's Parting Words",l=58,r=4294967373,c=16,p={9015},g=nil,x=nil,nx=8960,b=0,s={1423,0.2611,0.1130}}, +[8956]={n="Anthion's Parting Words",l=58,r=4294967373,c=8,p={9015},g=nil,x=nil,nx=8960,b=0,s={1423,0.2611,0.1130}}, +[8957]={n="Anthion's Parting Words",l=58,r=8589934770,c=64,p={9015},g=nil,x=nil,nx=9032,b=0,s={1423,0.2611,0.1130}}, +[8958]={n="Anthion's Parting Words",l=58,r=4294967373,c=256,p={9015},g=nil,x=nil,nx=8960,b=0,s={1423,0.2611,0.1130}}, +[8959]={n="Anthion's Parting Words",l=58,r=4294967373,c=1,p={9015},g=nil,x=nil,nx=8960,b=0,s={1423,0.2611,0.1130}}, +[8960]={n="Bodley's Unfortunate Fate",l=58,r=4294967373,c=0,p={8951,8952,8953,8954,8955,8956,8958,8959},g=nil,x=nil,nx=8961,b=0,s={1455,0.4353,0.5264}}, +[8961]={n="Three Kings of Flame",l=58,r=0,c=0,p={8960,9032},g=nil,x=nil,nx=8962,b=0,s={1415,0.4890,0.6393}}, +[8962]={n="Components of Importance",l=58,r=0,c=0,p={8961},g=nil,x={8963,8964,8965},nx=8966,b=0,s={1415,0.4890,0.6393}}, +[8963]={n="Components of Importance",l=58,r=0,c=0,p={8961},g=nil,x={8962,8964,8965},nx=8966,b=0,s={1415,0.4890,0.6393}}, +[8964]={n="Components of Importance",l=58,r=0,c=0,p={8961},g=nil,x={8962,8963,8965},nx=8966,b=0,s={1415,0.4890,0.6393}}, +[8965]={n="Components of Importance",l=58,r=0,c=0,p={8961},g=nil,x={8962,8963,8964},nx=8966,b=0,s={1415,0.4890,0.6393}}, +[8966]={n="The Left Piece of Lord Valthalak's Amulet",l=58,r=0,c=0,p={8962,8963,8964,8965},g=nil,x={8967,8968,8969},nx=8970,b=0,s={1415,0.4890,0.6393}}, +[8967]={n="The Left Piece of Lord Valthalak's Amulet",l=58,r=0,c=0,p={8962,8963,8964,8965},g=nil,x={8966,8968,8969},nx=8970,b=0,s={1415,0.4890,0.6393}}, +[8968]={n="The Left Piece of Lord Valthalak's Amulet",l=58,r=0,c=0,p={8962,8963,8964,8965},g=nil,x={8966,8967,8969},nx=8970,b=0,s={1415,0.4890,0.6393}}, +[8969]={n="The Left Piece of Lord Valthalak's Amulet",l=58,r=0,c=0,p={8962,8963,8964,8965},g=nil,x={8966,8967,8968},nx=8970,b=0,s={1415,0.4890,0.6393}}, +[8970]={n="I See Alcaz Island In Your Future...",l=58,r=0,c=0,p={8966,8967,8968,8969},g=nil,x=nil,nx=8985,b=0,s={1415,0.4890,0.6393}}, +[8977]={n="Return to Deliana",l=58,r=4294967373,c=0,p={8928},g=nil,x=nil,nx=0,b=0,s={1446,0.5247,0.2723}}, +[8978]={n="Return to Mokvar",l=58,r=8589934770,c=0,p={8928},g=nil,x=nil,nx=0,b=0,s={1446,0.5247,0.2723}}, +[8985]={n="More Components of Importance",l=58,r=0,c=0,p={8970},g=nil,x={8986,8987,8988},nx=8989,b=0,s={1415,0.4890,0.6393}}, +[8986]={n="More Components of Importance",l=58,r=0,c=0,p={8970},g=nil,x={8985,8987,8988},nx=8989,b=0,s={1415,0.4890,0.6393}}, +[8987]={n="More Components of Importance",l=58,r=0,c=0,p={8970},g=nil,x={8986,8988,8989},nx=8989,b=0,s={1415,0.4890,0.6393}}, +[8988]={n="More Components of Importance",l=58,r=0,c=0,p={8970},g=nil,x={8986,8987,8989},nx=8989,b=0,s={1415,0.4890,0.6393}}, +[8989]={n="The Right Piece of Lord Valthalak's Amulet",l=58,r=0,c=0,p={8985,8986,8987,8988},g=nil,x={8990,8991,8992},nx=8994,b=0,s={1415,0.4890,0.6393}}, +[8990]={n="The Right Piece of Lord Valthalak's Amulet",l=58,r=0,c=0,p={8985,8986,8987,8988},g=nil,x={8989,8991,8992},nx=8994,b=0,s={1415,0.4890,0.6393}}, +[8991]={n="The Right Piece of Lord Valthalak's Amulet",l=58,r=0,c=0,p={8985,8986,8987,8988},g=nil,x={8989,8990,8992},nx=8994,b=0,s={1415,0.4890,0.6393}}, +[8992]={n="The Right Piece of Lord Valthalak's Amulet",l=58,r=0,c=0,p={8985,8986,8987,8988},g=nil,x={8989,8990,8991},nx=8994,b=0,s={1415,0.4890,0.6393}}, +[8994]={n="Final Preparations",l=58,r=0,c=0,p={8989,8990,8991,8992},g=nil,x=nil,nx=8995,b=0,s={1415,0.4890,0.6393}}, +[8995]={n="Mea Culpa, Lord Valthalak",l=58,r=0,c=0,p={8994},g=nil,x=nil,nx=8996,b=0,s={1415,0.4890,0.6393}}, +[8997]={n="Back to the Beginning",l=58,r=4294967373,c=0,p={8996},g=nil,x=nil,nx=0,b=0,s={1415,0.4890,0.6393}}, +[8998]={n="Back to the Beginning",l=58,r=8589934770,c=0,p={8996},g=nil,x=nil,nx=0,b=0,s={1415,0.4890,0.6393}}, +[9016]={n="Anthion's Parting Words",l=58,r=8589934770,c=1024,p={9015},g=nil,x=nil,nx=9032,b=0,s={1423,0.2611,0.1130}}, +[9017]={n="Anthion's Parting Words",l=58,r=8589934770,c=4,p={9015},g=nil,x=nil,nx=9032,b=0,s={1423,0.2611,0.1130}}, +[9018]={n="Anthion's Parting Words",l=58,r=8589934770,c=128,p={9015},g=nil,x=nil,nx=9032,b=0,s={1423,0.2611,0.1130}}, +[9019]={n="Anthion's Parting Words",l=58,r=8589934770,c=16,p={9015},g=nil,x=nil,nx=9032,b=0,s={1423,0.2611,0.1130}}, +[9020]={n="Anthion's Parting Words",l=58,r=8589934770,c=8,p={9015},g=nil,x=nil,nx=9032,b=0,s={1423,0.2611,0.1130}}, +[9021]={n="Anthion's Parting Words",l=58,r=8589934770,c=256,p={9015},g=nil,x=nil,nx=9032,b=0,s={1423,0.2611,0.1130}}, +[9022]={n="Anthion's Parting Words",l=58,r=8589934770,c=1,p={9015},g=nil,x=nil,nx=9032,b=0,s={1423,0.2611,0.1130}}, +[9032]={n="Bodley's Unfortunate Fate",l=58,r=8589934770,c=0,p={8957,9016,9017,9018,9019,9020,9021,9022},g=nil,x=nil,nx=8961,b=0,s={1454,0.3495,0.3829}}, +[9051]={n="Toxic Test",l=50,r=0,c=1024,p={9052},g=nil,x=nil,nx=9053,b=0,s={1449,0.7164,0.7596}}, +[9052]={n="Bloodpetal Poison",l=50,r=0,c=1024,p=nil,g=nil,x=nil,nx=9051,b=0,s={1449,0.7164,0.7596}}, +[9063]={n="Torwa Pathfinder",l=50,r=0,c=1024,p=nil,g=nil,x=nil,nx=9052,b=9052,s={1456,0.7648,0.2722,1457,0.3537,0.0840,1453,0.3611,0.6439,1450,0.5253,0.4057}}, +[9251]={n="Atiesh, the Befouled Greatstaff",l=60,r=0,c=1424,p={9250},g=nil,x=nil,nx=0,b=0,s={1446,0.6527,0.5003}}, +[92742]={n="Testing the Wells",l=9,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=0,b=0,s={1436,0.5248,0.5297}}, +[92744]={n="Murloc Gills",l=9,r=4294967373,c=0,p=nil,g=nil,x=nil,nx=0,b=0,s={1436,0.5248,0.5297}}, +[92745]={n="The State of the Mines",l=9,r=4294967373,c=0,p=nil,g={92742,92744},x=nil,nx=92747,b=0,s={1436,0.5248,0.5297}}, +[92747]={n="Moonbrook Espionage",l=9,r=4294967373,c=0,p={92745},g=nil,x=nil,nx=92748,b=0,s={1436,0.5248,0.5297}}, +[92748]={n="Explosive Consultation",l=9,r=4294967373,c=0,p={92747},g=nil,x=nil,nx=0,b=0,s={1436,0.5248,0.5297}}, +[92749]={n="A Dynamite Plan",l=9,r=4294967373,c=0,p={92748},g=nil,x=nil,nx=0,b=0,s={1453,0.6188,0.3056}}, +[92750]={n="Detonation at a Distance",l=9,r=4294967373,c=0,p={92748},g=nil,x=nil,nx=92751,b=0,s={1453,0.6188,0.3056}}, +[92751]={n="Detonation at a Distance",l=9,r=4294967373,c=0,p={92750},g=nil,x=nil,nx=0,b=0,s={1453,0.8028,0.7007}}, +[92752]={n="Explosive Consultation",l=9,r=4294967373,c=0,p=nil,g={92749,92751},x=nil,nx=92753,b=0,s={1453,0.6188,0.3056}}, +} diff --git a/DungeonPreQuest/tools/extract.lua b/DungeonPreQuest/tools/extract.lua index 145897d..30c9a26 100644 --- a/DungeonPreQuest/tools/extract.lua +++ b/DungeonPreQuest/tools/extract.lua @@ -103,12 +103,15 @@ for k, v in pairs(modules) do end local WANT = { "name", "questLevel", "requiredRaces", "requiredClasses", "preQuestGroup", "preQuestSingle", - "zoneOrSort", "nextQuestInChain", "breadcrumbForQuestId", "breadcrumbs", "objectives", "triggerEnd", "finishedBy", "specialFlags" } + "zoneOrSort", "nextQuestInChain", "breadcrumbForQuestId", "breadcrumbs", "objectives", "triggerEnd", "finishedBy", "specialFlags", + "startedBy", "requiredLevel", "exclusiveTo", "requiredSkill", "requiredMinRep", "requiredMaxRep", "requiredSpell", + "requiredSpecialization", "requiredRanks", "requiredMaxLevel", "availableUntilCompleted", "availableStartingWith", + "disabledByQuest", "parentQuest" } local wanted = {} for _, n in ipairs(WANT) do wanted[realKeys[n]] = true end -- These hold one list per kind of thing, and an edit can skip a kind. -local grouped = { [realKeys.objectives] = true, [realKeys.finishedBy] = true } +local grouped = { [realKeys.objectives] = true, [realKeys.finishedBy] = true, [realKeys.startedBy] = true } local function contains(list, v) for _, x in ipairs(list) do if x == v then return true end end return false end @@ -192,6 +195,73 @@ do end end +-- Where quest givers stand: base rows, then the same correction layers as quests. +local function spawnsFor(dbFile, keysName, dataName, layers) + local raw = {} + run(dbFile, sandbox({ QuestieLoader = { ImportModule = function() return raw end, CreateModule = function() return raw end } })) + local real = assert(raw[keysName], keysName) + local chunk = assert(loadstring(assert(raw[dataName], dataName), "=" .. dataName)) + setfenv(chunk, {}) + local rows = chunk() + local spawnKey = assert(real.spawns) + local spawns = {} + for id, row in pairs(rows) do spawns[id] = row[spawnKey] end + + modules.QuestieDB[keysName] = 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 }) + + for _, layer in ipairs(layers) do + run(qdb .. "/src/corrections/" .. layer[1], sandbox(stubs)) + local n = 0 + for id, row in pairs(modules[layer[2]]:Load()) do + n = n + 1 + if type(row[spawnKey]) == "table" then spawns[id] = row[spawnKey] end + local add = row[spawnKey + ADD] + if type(add) == "table" then + spawns[id] = spawns[id] or {} + for zone, list in pairs(add) do + spawns[id][zone] = spawns[id][zone] or {} + for _, c in ipairs(list) do table.insert(spawns[id][zone], c) end + end + end + end + io.stderr:write(layer[2], ": ", n, " rows\n") + end + return spawns +end + +modules.QuestieDB.npcFlags = forever.npcFlags +local npcSpawns = spawnsFor(qdb .. "/data/Forever/foreverNpcDB.lua", "npcKeys", "npcData", { + { "Forever/legacy/classicNPCFixes.lua", "QuestieNPCFixes" }, + { "Forever/generated/foreverBaseNpc.lua", "ForeverBaseNpc" }, + { "Forever/traces/foreverNpcTraces.lua", "ForeverNpcTraces" }, + { "Forever/foreverNPCFixes.lua", "ForeverNpcFixes" }, +}) +local objectSpawns = spawnsFor(qdb .. "/data/Forever/foreverObjectDB.lua", "objectKeys", "objectData", { + { "Forever/legacy/classicObjectFixes.lua", "QuestieObjectFixes" }, + { "Forever/generated/foreverBaseObject.lua", "ForeverBaseObject" }, + { "Forever/traces/foreverObjectTraces.lua", "ForeverObjectTraces" }, + { "Forever/foreverObjectFixes.lua", "ForeverObjectFixes" }, +}) + +local areaToMap = {} +do + local zonePrivate = { private = {} } + run(qdb .. "/support/Forever/Zones/areaIdToUiMapId.lua", sandbox({ QuestieLoader = { ImportModule = function() return zonePrivate end } })) + for _, field in ipairs({ "areaIdToUiMapId", "areaIdToUiMapIdOverride" }) do + local text = zonePrivate.private[field] + if text then + local chunk = assert(loadstring(text, "=" .. field)) + setfenv(chunk, {}) + for area, map in pairs(chunk()) do areaToMap[area] = map end + end + 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 @@ -253,7 +323,37 @@ out:write("},\nallDungeons=", ser(allNames), ",\n") out:write("ALL_ALLIANCE=", string.format("%.0f", forever.raceKeys.ALL_ALLIANCE), ",ALL_HORDE=", string.format("%.0f", forever.raceKeys.ALL_HORDE), ",\n") out:write("classKeys=", "{") for k, v in pairs(forever.classKeys) do out:write(k, "=", string.format("%.0f", v), ",") end -out:write("}}\n") +out:write("}") +local function writeSpawns(label, source, group) + local wantedIds = {} + for _, r in pairs(q) do + local list = type(r.startedBy) == "table" and r.startedBy[group] + if type(list) == "table" then + for _, id in ipairs(list) do wantedIds[id] = true end + end + end + out:write(",\n", label, "={\n") + for id in pairs(wantedIds) do + local zones = source[id] + if type(zones) == "table" then + out:write("[", id, "]={") + for zone, list in pairs(zones) do + if type(zone) == "number" and type(list) == "table" then + out:write("[", zone, "]=", ser(list), ",") + end + end + out:write("},\n") + end + end + out:write("}") +end +writeSpawns("npcs", npcSpawns, 1) +writeSpawns("objects", objectSpawns, 2) +out:write(",\nareaToMap={") +for area, map in pairs(areaToMap) do out:write("[", area, "]=", map, ",") end +out:write("},\nraceBits={") +for race, bit in pairs(Lib.Enum.raceMaskById) do out:write("[", race, "]=", string.format("%.0f", bit), ",") end +out:write("}\n}\n") out:close() io.stderr:write("quests: ", #ids, ", dungeon tags: ") local c = 0; for _ in pairs(tags) do c = c + 1 end diff --git a/DungeonPreQuest/tools/generate.lua b/DungeonPreQuest/tools/generate.lua index 1db9339..1d3bb8f 100644 --- a/DungeonPreQuest/tools/generate.lua +++ b/DungeonPreQuest/tools/generate.lua @@ -157,3 +157,76 @@ local function show(id) 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 + +-- 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. +if arg[3] then + local UNSUPPORTED = { "requiredSkill", "requiredMinRep", "requiredMaxRep", "requiredSpell", "requiredSpecialization", + "requiredRanks", "availableUntilCompleted", "availableStartingWith", "disabledByQuest", "parentQuest", "requiredMaxLevel" } + local MAX_SPAWNS = 20 + + local function isRepeatable(r) return r.specialFlags and r.specialFlags % 2 == 1 end + local function unsupported(r) + if isRepeatable(r) then return true end + for _, field in ipairs(UNSUPPORTED) do + local v = r[field] + if v ~= nil and v ~= 0 then return true end + end + return false + end + + local function addSpawns(flat, source, list) + for _, id in ipairs(list or {}) do + for zone, coords in pairs(source[id] or {}) do + local map = data.areaToMap[zone] + if map then + for _, c in ipairs(coords) do + if c[1] and c[1] > 0 and c[2] and c[2] > 0 and #flat < MAX_SPAWNS * 3 then + flat[#flat + 1] = map + flat[#flat + 1] = string.format("%.4f", c[1] / 100) + flat[#flat + 1] = string.format("%.4f", c[2] / 100) + end + end + end + end + end + end + + local function list(t) + if type(t) ~= "table" or #t == 0 then return "nil" end + return "{" .. table.concat(t, ",") .. "}" + end + + local stats = { pinned = 0, unsupported = 0, noPlace = 0 } + local pinOut = assert(io.open(arg[3], "w")) + pinOut:write("-- Generated from QuestieDB's Forever data. Do not edit.\n") + pinOut:write("local _, ns = ...\n\nns.raceBits = {") + local races = {} + for race in pairs(data.raceBits) do races[#races + 1] = race end + table.sort(races) + for _, race in ipairs(races) do pinOut:write("[", race, "]=", string.format("%.0f", data.raceBits[race]), ",") end + pinOut:write("}\n\nns.pinQuests = {\n") + for _, id in ipairs(ids) do + local r = q[id] + if unsupported(r) then + stats.unsupported = stats.unsupported + 1 + else + local flat = {} + local starters = type(r.startedBy) == "table" and r.startedBy or {} + addSpawns(flat, data.npcs, starters[1]) + addSpawns(flat, data.objects, starters[2]) + if #flat == 0 then + stats.noPlace = stats.noPlace + 1 + else + stats.pinned = stats.pinned + 1 + pinOut:write(string.format("[%d]={n=%q,l=%d,r=%.0f,c=%d,p=%s,g=%s,x=%s,nx=%d,b=%d,s={%s}},\n", + id, r.name or "?", r.requiredLevel or 0, r.requiredRaces or 0, r.requiredClasses or 0, + list(r.preQuestSingle), list(r.preQuestGroup), list(r.exclusiveTo), + r.nextQuestInChain or 0, r.breadcrumbForQuestId or 0, table.concat(flat, ","))) + end + end + end + pinOut:write("}\n") + pinOut:close() + print("markers", stats.pinned, "skipped: requirements", stats.unsupported, "no location", stats.noPlace) +end diff --git a/README.md b/README.md index 5d4bb06..46f5345 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Four small quality-of-life addons for WoW Forever (client 1.60.1, Interface 1600 | Quest Item Tip | Item tooltips show the quest, its level and have / need. Warns when a quest item is no longer needed. | `/qit` | | Quest Craft Highlight | Highlights profession recipes whose crafted item an active quest needs. | `/qch` | | Vendor Flag | Marks items for 10 minutes after Auctionator warns they would earn more at a vendor. Requires [Auctionator](https://www.curseforge.com/wow/addons/auctionator). | `/vf` | -| Dungeon Pre-Quest | Marks quests whose chain leads to a dungeon quest, in the quest log, NPC quest lists and the quest offer window. | `/dpq ` | +| Dungeon Pre-Quest | Marks quests whose chain leads to a dungeon quest, in the quest log, NPC quest lists and the quest offer window, with a purple "!" on the minimap for ones you can pick up now. | `/dpq ` | ## Install @@ -20,6 +20,7 @@ Each addon works on its own, so copy only the ones you want. Vendor Flag stays d - Quest Item Tip's "can delete" only knows quests seen since it was installed. - Quest Craft Highlight doesn't highlight recipes inside collapsed categories until you expand them. - Dungeon Pre-Quest misses chains that QuestieDB has no links for, which includes many quests new to Forever. +- Its minimap markers skip quests started by an item, and quests with profession or reputation requirements. ## Tests @@ -30,15 +31,16 @@ lua tests/test_qit.lua QuestItemTip/QuestItemTip.lua lua tests/test_qch.lua QuestCraftHighlight/QuestCraftHighlight.lua lua tests/test_vf.lua VendorFlag/VendorFlag.lua lua tests/test_dpq.lua DungeonPreQuest/DungeonPreQuest.lua +lua tests/test_dpq_minimap.lua DungeonPreQuest/Minimap.lua ``` ## Regenerating Dungeon Pre-Quest's data -`DungeonPreQuest/Data.lua` is generated from QuestieDB and Questie, cloned locally: +`DungeonPreQuest/Data.lua` and `PinData.lua` are generated from QuestieDB and Questie, cloned locally: ``` lua DungeonPreQuest/tools/extract.lua merged.lua -lua DungeonPreQuest/tools/generate.lua merged.lua DungeonPreQuest/Data.lua +lua DungeonPreQuest/tools/generate.lua merged.lua DungeonPreQuest/Data.lua DungeonPreQuest/PinData.lua ``` ## Credits and licence @@ -46,3 +48,5 @@ lua DungeonPreQuest/tools/generate.lua merged.lua DungeonPreQuest/Data.lua Dungeon Pre-Quest's data is derived from [QuestieDB](https://github.com/Questie/QuestieDB) and [Questie](https://github.com/Questie/Questie), both GPL-3.0. This project is released under the GNU General Public License v3.0, see [LICENSE.md](LICENSE.md). + +`DungeonPreQuest/Libs` bundles LibStub, CallbackHandler-1.0 and Questie's copy of HereBeDragons (BSD), each under its own licence. diff --git a/tests/test_dpq_minimap.lua b/tests/test_dpq_minimap.lua new file mode 100644 index 0000000..e7b769d --- /dev/null +++ b/tests/test_dpq_minimap.lua @@ -0,0 +1,181 @@ +-- Runs Minimap.lua against a mock of the WoW API. +-- arg[1] = addon file + +local completed, onQuest = {}, {} +C_QuestLog = { + IsQuestFlaggedCompleted = function(id) return completed[id] == true end, + IsOnQuest = function(id) return onQuest[id] == true end, +} + +local level, raceID, classID = 20, 7, 1 +function UnitLevel() return level end +function UnitRace() return "x", "X", raceID end +function UnitClass() return "x", "X", classID end + +local shown = {} +local removals = 0 +local pinsLib = { + AddMinimapIconMap = function(_, ref, pin, map, x, y, parent, edge) + shown[#shown + 1] = { ref = ref, pin = pin, map = map, x = x, y = y, parent = parent, edge = edge } + end, + RemoveAllMinimapIcons = function() removals = removals + 1; shown = {} end, +} +function LibStub(name) + assert(name == "HereBeDragonsQuestie-Pins-2.0", name) + return pinsLib +end + +local timers = {} +C_Timer = { After = function(_, fn) timers[#timers + 1] = fn end } +local function flush() + local list = timers + timers = {} + for _, fn in ipairs(list) do fn() end +end + +local created = 0 +local function texture() + local t = {} + function t:SetAllPoints() end + function t:SetTexture(p) self.path = p end + function t:SetDesaturated(v) self.desaturated = v end + function t:SetVertexColor(r, g, b) self.color = { r, g, b } end + return t +end + +local onEvent, registered = nil, {} +Minimap = { GetFrameLevel = function() return 1 end } +CreateFrame = function(kind) + if kind == "Frame" and not onEvent and created == 0 and not registered.frame then + registered.frame = true + return { + RegisterEvent = function(_, e) registered[e] = true end, + SetScript = function(_, _, fn) onEvent = fn end, + } + end + created = created + 1 + local f = { scripts = {} } + function f:Hide() self.hidden = true end + function f:SetSize() end + function f:SetFrameLevel() end + function f:CreateTexture() self.tex = texture(); return self.tex end + function f:EnableMouse() end + function f:SetScript(name, fn) self.scripts[name] = fn end + return f +end + +local tip = {} +GameTooltip = { + SetOwner = function(_, o) tip.owner = o end, + SetText = function(_, t) tip.title = t end, + AddLine = function(_, l) tip.line = l end, + Show = function() end, + Hide = function() tip.hidden = true end, +} + +local failures = 0 +local function check(cond, what) + if not cond then failures = failures + 1 end + print((cond and "ok " or "FAIL ") .. what) +end + +local SKYBORNE = 4294967296 +local notForMe = {} +local ns = { + raceBits = { [7] = 64, [95] = SKYBORNE }, + DungeonsFor = function(id) if notForMe[id] then return nil end return { "The Deadmines" } end, + Describe = function(names) return "Dungeon pre-quest: " .. names[1] end, + pinQuests = {}, +} +local function quest(fields) + local q = { n = "Q", l = 1, r = 0, c = 0, nx = 0, b = 0, s = { 1436, 0.5, 0.5 } } + for k, v in pairs(fields or {}) do q[k] = v end + return q +end + +assert(loadfile(arg[1]))("DungeonPreQuest", ns) + +local function count(fields) + ns.pinQuests = { [100] = quest(fields) } + onEvent() + flush() + return #shown +end + +check(count() == 1, "available quest gets a marker") +check(shown[1].map == 1436 and shown[1].x == 0.5 and shown[1].ref == ns, "marker is placed on the given map") +check(shown[1].edge == false, "markers out of range don't stick to the minimap edge") +check(shown[1].pin.tex.desaturated and shown[1].pin.tex.color[1] > shown[1].pin.tex.color[2], "marker is tinted purple") + +check(count({ s = { 1, 0.1, 0.1, 2, 0.2, 0.2 } }) == 2, "every spawn gets a marker") + +completed[100] = true +check(count() == 0, "finished quest has no marker") +completed[100] = nil +onQuest[100] = true +check(count() == 0, "quest already taken has no marker") +onQuest[100] = nil + +check(count({ l = 21 }) == 0, "too low level") +check(count({ l = 20 }) == 1, "exactly the right level") + +check(count({ r = 1 }) == 0, "wrong race") +check(count({ r = 64 + SKYBORNE }) == 1, "race check handles Forever's high race bits") +raceID = 95 +check(count({ r = 64 + SKYBORNE }) == 1, "high race bit itself matches") +check(count({ r = 64 }) == 0, "high race bit doesn't match a low mask") +raceID = 7 + +check(count({ c = 2 }) == 0, "wrong class") +classID = 11 +check(count({ c = 1024 }) == 1, "class ID 11 matches the druid bit") +classID = 1 + +check(count({ p = { 50, 51 } }) == 0, "prerequisite missing") +completed[51] = true +check(count({ p = { 50, 51 } }) == 1, "any one prerequisite is enough") +completed[51] = nil + +completed[50] = true +check(count({ g = { 50, 51 } }) == 0, "group needs every prerequisite") +completed[51] = true +check(count({ g = { 50, 51 } }) == 1, "group satisfied") +completed[50], completed[51] = nil, nil + +onQuest[60] = true +check(count({ x = { 60 } }) == 0, "exclusive quest in the log blocks it") +onQuest[60] = nil +completed[61] = true +check(count({ nx = 61 }) == 0, "already past this step") +check(count({ b = 61 }) == 0, "breadcrumb target already done") +completed[61] = nil + +notForMe[100] = true +check(count() == 0, "chain that isn't for this character") +notForMe[100] = nil + +-- Hover. +count({ n = "The Day After" }) +local pin = shown[1].pin +pin.questID = 100 +pin.scripts.OnEnter(pin) +check(tip.title == "The Day After" and tip.line == "Dungeon pre-quest: The Deadmines", "tooltip names quest and dungeon") +pin.scripts.OnLeave(pin) +check(tip.hidden, "tooltip hides on leave") + +-- Pooling and batching. +local before = created +count() +count() +check(created == before, "markers are reused") + +local removalsBefore = removals +onEvent(); onEvent(); onEvent() +check(#timers == 1, "several events only queue one refresh") +flush() +check(removals == removalsBefore + 1, "one refresh runs") + +check(registered.QUEST_TURNED_IN and registered.PLAYER_LEVEL_UP and registered.PLAYER_ENTERING_WORLD, "listens for what changes availability") + +print(failures == 0 and "ALL PASSED" or (failures .. " FAILED")) +os.exit(failures == 0 and 0 or 1)