@piekasz/wow-mcp 0.0.0-stage → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/NOTICE +37 -0
- package/README.md +41 -2
- package/addon/WowMcp/AuctionTooltip.lua +106 -0
- package/addon/WowMcp/Commands.lua +259 -0
- package/addon/WowMcp/Compat.lua +167 -0
- package/addon/WowMcp/Core.lua +50 -0
- package/addon/WowMcp/Events.lua +62 -0
- package/addon/WowMcp/Items.lua +314 -0
- package/addon/WowMcp/Maps.lua +66 -0
- package/addon/WowMcp/MinimapButton.lua +114 -0
- package/addon/WowMcp/Options.lua +208 -0
- package/addon/WowMcp/Panel.lua +294 -0
- package/addon/WowMcp/QuestDb.lua +303 -0
- package/addon/WowMcp/QuestRewards.lua +137 -0
- package/addon/WowMcp/Sections/ActionBars.lua +54 -0
- package/addon/WowMcp/Sections/Auctions.lua +305 -0
- package/addon/WowMcp/Sections/Bank.lua +48 -0
- package/addon/WowMcp/Sections/Buyback.lua +47 -0
- package/addon/WowMcp/Sections/Character.lua +177 -0
- package/addon/WowMcp/Sections/Cooldowns.lua +76 -0
- package/addon/WowMcp/Sections/Currencies.lua +47 -0
- package/addon/WowMcp/Sections/Deaths.lua +43 -0
- package/addon/WowMcp/Sections/Dungeons.lua +117 -0
- package/addon/WowMcp/Sections/EquipmentSets.lua +83 -0
- package/addon/WowMcp/Sections/FlightPaths.lua +145 -0
- package/addon/WowMcp/Sections/Friends.lua +70 -0
- package/addon/WowMcp/Sections/Group.lua +101 -0
- package/addon/WowMcp/Sections/Guide.lua +317 -0
- package/addon/WowMcp/Sections/Guild.lua +131 -0
- package/addon/WowMcp/Sections/Inspect.lua +100 -0
- package/addon/WowMcp/Sections/Inventory.lua +64 -0
- package/addon/WowMcp/Sections/Legacy.lua +375 -0
- package/addon/WowMcp/Sections/Loot.lua +170 -0
- package/addon/WowMcp/Sections/Macros.lua +26 -0
- package/addon/WowMcp/Sections/Mail.lua +70 -0
- package/addon/WowMcp/Sections/Note.lua +38 -0
- package/addon/WowMcp/Sections/Pet.lua +127 -0
- package/addon/WowMcp/Sections/Played.lua +52 -0
- package/addon/WowMcp/Sections/Probe.lua +79 -0
- package/addon/WowMcp/Sections/Professions.lua +129 -0
- package/addon/WowMcp/Sections/Pvp.lua +45 -0
- package/addon/WowMcp/Sections/QuestDb.lua +106 -0
- package/addon/WowMcp/Sections/QuestGiver.lua +45 -0
- package/addon/WowMcp/Sections/Quests.lua +146 -0
- package/addon/WowMcp/Sections/Recipes.lua +195 -0
- package/addon/WowMcp/Sections/Reputation.lua +56 -0
- package/addon/WowMcp/Sections/Spells.lua +87 -0
- package/addon/WowMcp/Sections/Stable.lua +90 -0
- package/addon/WowMcp/Sections/Talents.lua +137 -0
- package/addon/WowMcp/Sections/Trainer.lua +58 -0
- package/addon/WowMcp/Sections/Vendor.lua +72 -0
- package/addon/WowMcp/Sections/XpGains.lua +258 -0
- package/addon/WowMcp/Snapshot.lua +412 -0
- package/addon/WowMcp/Store.lua +142 -0
- package/addon/WowMcp/TalentGrid.lua +171 -0
- package/addon/WowMcp/Timing.lua +61 -0
- package/addon/WowMcp/TraitTree.lua +158 -0
- package/addon/WowMcp/WowMcp.lua +24 -0
- package/addon/WowMcp/WowMcp.toc +72 -0
- package/bin/wow-mcp.js +248 -0
- package/package.json +41 -4
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section pet: the character's pet (happiness, loyalty, training points,
|
|
5
|
+
-- action bar and spellbook).
|
|
6
|
+
|
|
7
|
+
local _, ns = ...
|
|
8
|
+
local plain, plainFields = ns.Compat.plain, ns.Compat.plainFields
|
|
9
|
+
local callFirst, firstValue = ns.Compat.callFirst, ns.Compat.firstValue
|
|
10
|
+
|
|
11
|
+
-- Happiness. Forever: C_PetInfo.GetPetHappiness(); older clients: GetPetHappiness().
|
|
12
|
+
-- Classically: 1 = unhappy, 2 = content, 3 = happy, then % damage.
|
|
13
|
+
local function addHappiness(pet)
|
|
14
|
+
local happiness = callFirst({ "C_PetInfo.GetPetHappiness", "GetPetHappiness" })
|
|
15
|
+
if not happiness then return end
|
|
16
|
+
if type(happiness[1]) == "table" then
|
|
17
|
+
pet.happinessInfo = plainFields(happiness[1])
|
|
18
|
+
else
|
|
19
|
+
pet.happiness = plain(happiness[1])
|
|
20
|
+
pet.damagePercent = plain(happiness[2])
|
|
21
|
+
pet.loyaltyRate = plain(happiness[3])
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
local function addLoyalty(pet)
|
|
26
|
+
local loyalty = callFirst({ "C_PetInfo.GetPetLoyalty", "GetPetLoyalty" })
|
|
27
|
+
if not loyalty then return end
|
|
28
|
+
if type(loyalty[1]) == "table" then
|
|
29
|
+
pet.loyaltyInfo = plainFields(loyalty[1])
|
|
30
|
+
else
|
|
31
|
+
pet.loyalty = plain(loyalty[1])
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
local function addTrainingPoints(pet)
|
|
36
|
+
local points = callFirst({ "C_PetInfo.GetPetTrainingPoints", "GetPetTrainingPoints" })
|
|
37
|
+
if not points then return end
|
|
38
|
+
if type(points[1]) == "table" then
|
|
39
|
+
pet.trainingPointsInfo = plainFields(points[1])
|
|
40
|
+
else
|
|
41
|
+
pet.trainingPointsTotal = plain(points[1])
|
|
42
|
+
pet.trainingPointsSpent = plain(points[2])
|
|
43
|
+
if pet.trainingPointsTotal and pet.trainingPointsSpent then
|
|
44
|
+
pet.trainingPointsFree = pet.trainingPointsTotal - pet.trainingPointsSpent
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
local function addExperience(pet)
|
|
50
|
+
local experience = callFirst({ "C_PetInfo.GetPetExperience", "GetPetExperience" })
|
|
51
|
+
if not experience then return end
|
|
52
|
+
pet.xp = plain(experience[1])
|
|
53
|
+
pet.xpMax = plain(experience[2])
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
local function addFoodTypes(pet)
|
|
57
|
+
local foods = callFirst({ "C_PetInfo.GetPetFoodTypes", "GetPetFoodTypes" })
|
|
58
|
+
if not foods then return end
|
|
59
|
+
local list = {}
|
|
60
|
+
for _, food in ipairs(type(foods[1]) == "table" and foods[1] or foods) do
|
|
61
|
+
if type(food) == "string" then list[#list + 1] = food end
|
|
62
|
+
end
|
|
63
|
+
if #list > 0 then pet.foodTypes = list end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
-- Auto-cast: nil when the ability does not support it; false when it does but is turned off.
|
|
67
|
+
local function autoCastState(allowed, enabled)
|
|
68
|
+
if not allowed then return nil end
|
|
69
|
+
return enabled and true or false
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
-- The pet's action bar: what it has available and whether it works automatically (e.g. Growl).
|
|
73
|
+
local function addActionBar(pet)
|
|
74
|
+
if not GetPetActionInfo then return end
|
|
75
|
+
pet.actionBar = {}
|
|
76
|
+
for slot = 1, NUM_PET_ACTION_SLOTS or 10 do
|
|
77
|
+
local ok, name, _, isToken, isActive, autoCastAllowed, autoCastEnabled, spellID = pcall(GetPetActionInfo, slot)
|
|
78
|
+
if ok and plain(name) then
|
|
79
|
+
if isToken and type(_G[name]) == "string" then name = _G[name] end
|
|
80
|
+
pet.actionBar[#pet.actionBar + 1] = {
|
|
81
|
+
slot = slot,
|
|
82
|
+
name = name,
|
|
83
|
+
id = plain(spellID),
|
|
84
|
+
active = isActive and true or nil,
|
|
85
|
+
autoCast = autoCastState(autoCastAllowed, autoCastEnabled),
|
|
86
|
+
}
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
-- The pet's spellbook: everything it has learned, with ranks.
|
|
92
|
+
local function addAbilities(pet)
|
|
93
|
+
if not (C_SpellBook and C_SpellBook.HasPetSpells and C_SpellBook.GetSpellBookItemInfo) then return end
|
|
94
|
+
local okCount, count = pcall(C_SpellBook.HasPetSpells)
|
|
95
|
+
local bank = Enum and Enum.SpellBookSpellBank and Enum.SpellBookSpellBank.Pet or 1
|
|
96
|
+
if not (okCount and type(count) == "number") then return end
|
|
97
|
+
pet.abilities = {}
|
|
98
|
+
for i = 1, count do
|
|
99
|
+
local ok, info = pcall(C_SpellBook.GetSpellBookItemInfo, i, bank)
|
|
100
|
+
if ok and type(info) == "table" and info.name then
|
|
101
|
+
pet.abilities[#pet.abilities + 1] = ns.Spellbook.entryFromItemInfo(info)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
local function collectPet()
|
|
107
|
+
local pet = { exists = UnitExists("pet") and true or false }
|
|
108
|
+
if not pet.exists then
|
|
109
|
+
return pet
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
pet.name = plain(UnitName("pet"))
|
|
113
|
+
pet.level = UnitLevel("pet")
|
|
114
|
+
pet.family = UnitCreatureFamily and UnitCreatureFamily("pet") or nil
|
|
115
|
+
pet.dead = UnitIsDead and UnitIsDead("pet") and true or false
|
|
116
|
+
pet.healthMax = firstValue({ "UnitHealthMax" }, "pet")
|
|
117
|
+
addHappiness(pet)
|
|
118
|
+
addLoyalty(pet)
|
|
119
|
+
addTrainingPoints(pet)
|
|
120
|
+
addExperience(pet)
|
|
121
|
+
addFoodTypes(pet)
|
|
122
|
+
addActionBar(pet)
|
|
123
|
+
addAbilities(pet)
|
|
124
|
+
return pet
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
ns.Snapshot.addSection("pet", collectPet)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section played: played time from /played. The client supplies it in the TIME_PLAYED_MSG event; the addon requests
|
|
5
|
+
-- it once after login (and after every /reload), and on a dump adds the time elapsed since the response.
|
|
6
|
+
|
|
7
|
+
local _, ns = ...
|
|
8
|
+
local plain, callFirst = ns.Compat.plain, ns.Compat.callFirst
|
|
9
|
+
|
|
10
|
+
local Played = {}
|
|
11
|
+
ns.Played = Played
|
|
12
|
+
|
|
13
|
+
local playedInfo -- { total, level, at } from the client's last response
|
|
14
|
+
|
|
15
|
+
-- Request for played time (/played). The response arrives in TIME_PLAYED_MSG and also appears in chat.
|
|
16
|
+
function Played.request()
|
|
17
|
+
if not Played.isTracking() then return end
|
|
18
|
+
callFirst({ "RequestTimePlayed" })
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
-- Whether played time is requested after login (on by default; /mcp played on|off, the options page).
|
|
22
|
+
function Played.isTracking()
|
|
23
|
+
return ns.Store.settings().played ~= false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
-- Only turning it off is saved. Turning it on requests played time right away.
|
|
27
|
+
function Played.setTracking(enabled)
|
|
28
|
+
if enabled then
|
|
29
|
+
ns.Store.settings().played = nil
|
|
30
|
+
Played.request()
|
|
31
|
+
else
|
|
32
|
+
ns.Store.settings().played = false
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
local function onTimePlayed(total, level)
|
|
37
|
+
if type(plain(total)) == "number" and type(plain(level)) == "number" then
|
|
38
|
+
playedInfo = { total = total, level = level, at = time() }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
local function collectPlayed()
|
|
43
|
+
if not playedInfo then return nil end
|
|
44
|
+
local elapsed = time() - playedInfo.at
|
|
45
|
+
return {
|
|
46
|
+
totalSeconds = playedInfo.total + elapsed,
|
|
47
|
+
levelSeconds = playedInfo.level + elapsed,
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
ns.Snapshot.addSection("played", collectPlayed)
|
|
52
|
+
ns.Events.on("TIME_PLAYED_MSG", onTimePlayed)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section probe (diagnostics, only via /mcp probe): list of client API functions
|
|
5
|
+
-- in selected namespaces and the registration result of the addon's events (events).
|
|
6
|
+
-- Used to find out what a function is called in this client and whether it knows a given event.
|
|
7
|
+
|
|
8
|
+
local _, ns = ...
|
|
9
|
+
|
|
10
|
+
local NAMESPACES = {
|
|
11
|
+
"C_PetInfo", "C_StableInfo", "C_Trainer", "C_SkillInfo", "C_Item", "C_TooltipInfo",
|
|
12
|
+
"C_Container", "C_MerchantFrame", "C_Reputation", "C_ActionBar", "C_Bank", "C_TaxiMap",
|
|
13
|
+
"C_UnitAuras", "C_PaperDollInfo", "C_Macro", "C_SpellBook", "C_Spell", "C_QuestLog",
|
|
14
|
+
"C_Traits", "C_ClassTalents", "C_TradeSkillUI", "C_GameRules", "C_CurrencyInfo", "C_Mail", "C_Timer",
|
|
15
|
+
"C_AuctionHouse", "C_LFGList", "C_PartyInfo", "C_EncounterJournal", "C_QuestInfoSystem", "TooltipDataProcessor",
|
|
16
|
+
-- 0.7.0: equipment sets, friends, guild, PvP, map (flight point zone), XP from quests
|
|
17
|
+
"C_EquipmentSet", "C_FriendList", "C_GuildInfo", "C_PvP", "C_Map", "C_BattleNet",
|
|
18
|
+
-- 0.10.0: achievements (is there an API worth a section?), zone IDs for quests and flight points
|
|
19
|
+
"C_AchievementInfo",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
local GLOBAL_PREFIXES = {
|
|
23
|
+
"^GetPet", "^HasPet", "^PetCan", "^PetHas", "^GetStable", "^GetTrainer", "^GetNumTrainer",
|
|
24
|
+
"^GetMerchant", "^GetInventory", "^UnitStat", "^UnitRanged", "^GetNumStable", "^Taxi", "^NumTaxi",
|
|
25
|
+
"^GetTradeSkill", "^GetCraft", "^GetNumCrafts", "^GetInbox", "^GetCurrency", "^GetQuestGreen", "^RequestTimePlayed",
|
|
26
|
+
"^GetAuction", "^GetNumAuction", "^GetLFG", "^GetLFD", "^GetSavedInstance", "^GetNumSavedInstances", "^GetRaidRoster",
|
|
27
|
+
"^GetTalent", "^GetNumTalent", "^UnitCharacterPoints", "^GetInspect", "^GetLoot",
|
|
28
|
+
"^GetQuestLog", "^GetNumQuestLog", "^SelectQuestLog", "^GetQuestItem", "^GetNumQuest", "^GetReward",
|
|
29
|
+
"^GetBuyback", "^GetNumBuyback", "^GetEquipmentSet", "^GetNumEquipmentSet", "^GetFriendInfo", "^GetNumFriends",
|
|
30
|
+
"^GetGuild", "^GetNumGuild", "^IsInGuild", "^GetPVP", "^UnitHonor", "^UnitPVP", "^GetHonor", "^GetCursorPosition",
|
|
31
|
+
"^GetXPExhaustion", "^UnitXP",
|
|
32
|
+
-- 0.7.1: quest window at an NPC, repair at the vendor, flight map, buyback
|
|
33
|
+
"^GetTitleText", "^GetQuestID", "^GetObjectiveText", "^CanMerchant", "^GetRepair", "^GetTaxi",
|
|
34
|
+
-- 0.10.0: achievements and statistics (probe before a section is written), weapon format strings are variables, not functions
|
|
35
|
+
"^GetAchievement", "^GetCategory", "^GetTotalAchievement", "^GetNumCompletedAchievements",
|
|
36
|
+
"^GetLatestCompletedAchievements", "^GetPreviousAchievement", "^GetNextAchievement", "^GetStatistic",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
local GLOBAL_FRAGMENTS = { "Loyal", "Happiness", "TrainingPoint", "PetFood", "PetExperience", "CritChance" }
|
|
40
|
+
|
|
41
|
+
local function functionNames(object)
|
|
42
|
+
local names = {}
|
|
43
|
+
for key, fn in pairs(object) do
|
|
44
|
+
if type(key) == "string" and type(fn) == "function" then
|
|
45
|
+
names[#names + 1] = key
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
table.sort(names)
|
|
49
|
+
return names
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
local function isProbedGlobal(name)
|
|
53
|
+
for _, pattern in ipairs(GLOBAL_PREFIXES) do
|
|
54
|
+
if name:find(pattern) then return true end
|
|
55
|
+
end
|
|
56
|
+
for _, fragment in ipairs(GLOBAL_FRAGMENTS) do
|
|
57
|
+
if name:find(fragment, 1, true) then return true end
|
|
58
|
+
end
|
|
59
|
+
return false
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
local function collectProbe()
|
|
63
|
+
local probe = { capturedAt = time(), namespaces = {}, globals = {}, events = ns.Events.registrationResults() }
|
|
64
|
+
for _, namespace in ipairs(NAMESPACES) do
|
|
65
|
+
local object = _G[namespace]
|
|
66
|
+
if type(object) == "table" then
|
|
67
|
+
probe.namespaces[namespace] = functionNames(object)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
for key, fn in pairs(_G) do
|
|
71
|
+
if type(key) == "string" and type(fn) == "function" and isProbedGlobal(key) then
|
|
72
|
+
probe.globals[#probe.globals + 1] = key
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
table.sort(probe.globals)
|
|
76
|
+
return probe
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
ns.Snapshot.addWindowSection("probe", collectProbe, nil, { quiet = true })
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section professions: professions and other skills from the Skills window, together with
|
|
5
|
+
-- weapon skills (group = "weapon").
|
|
6
|
+
|
|
7
|
+
local _, ns = ...
|
|
8
|
+
local plain = ns.Compat.plain
|
|
9
|
+
|
|
10
|
+
-- Weapon skills: skill line IDs have been constant since the classic version of the game.
|
|
11
|
+
-- The client returns nil for a skill the character does not know.
|
|
12
|
+
local WEAPON_SKILLS = {
|
|
13
|
+
{ id = 43, name = "Swords" }, { id = 55, name = "Two-Handed Swords" },
|
|
14
|
+
{ id = 44, name = "Axes" }, { id = 172, name = "Two-Handed Axes" },
|
|
15
|
+
{ id = 54, name = "Maces" }, { id = 160, name = "Two-Handed Maces" },
|
|
16
|
+
{ id = 173, name = "Daggers" }, { id = 136, name = "Staves" },
|
|
17
|
+
{ id = 229, name = "Polearms" }, { id = 473, name = "Fist Weapons" },
|
|
18
|
+
{ id = 45, name = "Bows" }, { id = 46, name = "Guns" },
|
|
19
|
+
{ id = 226, name = "Crossbows" }, { id = 176, name = "Thrown" },
|
|
20
|
+
{ id = 162, name = "Unarmed" }, { id = 95, name = "Defense" },
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
-- Profession skill line IDs (constant since the classic game): the dump gets skillID next to the name, which
|
|
24
|
+
-- is in the client's language, so the server can recognise a profession on any client.
|
|
25
|
+
local PROFESSION_SKILLS = { 129, 164, 165, 171, 182, 185, 186, 197, 202, 333, 356, 393 }
|
|
26
|
+
|
|
27
|
+
-- Name of a skill line in the client's language: C_SkillInfo.GetSkillLineInfoByID returns a table or several values.
|
|
28
|
+
local function skillLineName(id)
|
|
29
|
+
if not (C_SkillInfo and C_SkillInfo.GetSkillLineInfoByID) then return nil end
|
|
30
|
+
local ok, a = pcall(C_SkillInfo.GetSkillLineInfoByID, id)
|
|
31
|
+
if not ok then return nil end
|
|
32
|
+
if type(a) == "table" then return plain(a.name) or plain(a.skillLineDisplayName) end
|
|
33
|
+
return plain(a)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
-- Adds skillID to profession entries that came without one (the old Skills window has no IDs): the client's
|
|
37
|
+
-- own name of each profession skill line is matched against the entry name.
|
|
38
|
+
local function addProfessionSkillIDs(professions)
|
|
39
|
+
local byName = {}
|
|
40
|
+
for _, id in ipairs(PROFESSION_SKILLS) do
|
|
41
|
+
local name = skillLineName(id)
|
|
42
|
+
if type(name) == "string" and name ~= "" then byName[name] = id end
|
|
43
|
+
end
|
|
44
|
+
for _, entry in ipairs(professions) do
|
|
45
|
+
if entry.skillID == nil and entry.name then entry.skillID = byName[entry.name] end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
-- Weapon skill entry from C_SkillInfo.GetSkillLineInfoByID (a table or multiple values).
|
|
50
|
+
local function weaponSkillEntry(skill, a, b, c)
|
|
51
|
+
local entry = { name = skill.name, group = "weapon", skillID = skill.id }
|
|
52
|
+
if type(a) == "table" then
|
|
53
|
+
-- Table variant: fields name, rank, maxRank.
|
|
54
|
+
entry.name = plain(a.name) or plain(a.skillLineDisplayName) or skill.name
|
|
55
|
+
entry.rank = plain(a.rank) or plain(a.skillLevel)
|
|
56
|
+
entry.maxRank = plain(a.maxRank) or plain(a.maxSkillLevel)
|
|
57
|
+
else
|
|
58
|
+
-- Multi-value variant: name, rank, maxRank.
|
|
59
|
+
if type(a) == "string" then entry.name = a end
|
|
60
|
+
entry.rank = plain(b)
|
|
61
|
+
entry.maxRank = plain(c)
|
|
62
|
+
end
|
|
63
|
+
return entry
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
local function appendWeaponSkills(professions)
|
|
67
|
+
if not (C_SkillInfo and C_SkillInfo.GetSkillLineInfoByID) then return end
|
|
68
|
+
-- The old skill list already contains weapons; we do not duplicate entries.
|
|
69
|
+
local known = {}
|
|
70
|
+
for _, entry in ipairs(professions) do known[entry.name or ""] = true end
|
|
71
|
+
for _, skill in ipairs(WEAPON_SKILLS) do
|
|
72
|
+
local ok, a, b, c = pcall(C_SkillInfo.GetSkillLineInfoByID, skill.id)
|
|
73
|
+
if ok and a ~= nil then
|
|
74
|
+
local entry = weaponSkillEntry(skill, a, b, c)
|
|
75
|
+
if entry.rank and not known[entry.name] then
|
|
76
|
+
professions[#professions + 1] = entry
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
-- Old Skills window: all skills with group headers.
|
|
83
|
+
local function skillLines()
|
|
84
|
+
local professions = {}
|
|
85
|
+
local header
|
|
86
|
+
for i = 1, GetNumSkillLines() or 0 do
|
|
87
|
+
local name, isHeader, _, rank, _, _, maxRank = GetSkillLineInfo(i)
|
|
88
|
+
if isHeader then
|
|
89
|
+
header = name
|
|
90
|
+
elseif name then
|
|
91
|
+
professions[#professions + 1] = { name = name, rank = rank, maxRank = maxRank, group = header }
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
return professions
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
local MAX_PROFESSION_SLOTS = 6
|
|
98
|
+
|
|
99
|
+
-- New API: professions only (primary, secondary), no headers.
|
|
100
|
+
local function professionSlots()
|
|
101
|
+
local professions = {}
|
|
102
|
+
local indexes = { GetProfessions() }
|
|
103
|
+
for i = 1, MAX_PROFESSION_SLOTS do
|
|
104
|
+
local index = indexes[i]
|
|
105
|
+
if index then
|
|
106
|
+
local name, _, rank, maxRank, _, _, skillLine = GetProfessionInfo(index)
|
|
107
|
+
if name then
|
|
108
|
+
local entry = { name = name, rank = rank, maxRank = maxRank }
|
|
109
|
+
if type(plain(skillLine)) == "number" then entry.skillID = plain(skillLine) end
|
|
110
|
+
professions[#professions + 1] = entry
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
return professions
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
local function collectProfessions()
|
|
118
|
+
local professions = {}
|
|
119
|
+
if GetNumSkillLines and GetSkillLineInfo then
|
|
120
|
+
professions = skillLines()
|
|
121
|
+
elseif GetProfessions and GetProfessionInfo then
|
|
122
|
+
professions = professionSlots()
|
|
123
|
+
end
|
|
124
|
+
addProfessionSkillIDs(professions)
|
|
125
|
+
appendWeaponSkills(professions)
|
|
126
|
+
return professions
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
ns.Snapshot.addSection("professions", collectProfessions)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Section pvp: honor statistics, if the client supplies them readily (honorable kills, honor,
|
|
5
|
+
-- rank). Every field is optional; with none supplied the section is absent from the dump.
|
|
6
|
+
|
|
7
|
+
local _, ns = ...
|
|
8
|
+
local plain, callFirst, firstValue = ns.Compat.plain, ns.Compat.callFirst, ns.Compat.firstValue
|
|
9
|
+
|
|
10
|
+
local function number(value)
|
|
11
|
+
if type(value) == "number" then return value end
|
|
12
|
+
return nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
local function collectPvp()
|
|
16
|
+
local pvp = {}
|
|
17
|
+
|
|
18
|
+
-- GetPVPLifetimeStats: honorableKills, dishonorableKills, highestRank.
|
|
19
|
+
local lifetime = callFirst({ "GetPVPLifetimeStats" })
|
|
20
|
+
if lifetime then
|
|
21
|
+
pvp.honorableKills = number(plain(lifetime[1]))
|
|
22
|
+
pvp.dishonorableKills = number(plain(lifetime[2]))
|
|
23
|
+
pvp.highestRank = number(plain(lifetime[3]))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
pvp.honor = number(firstValue({ "UnitHonor" }, "player"))
|
|
27
|
+
pvp.honorMax = number(firstValue({ "UnitHonorMax" }, "player"))
|
|
28
|
+
pvp.honorLevel = number(firstValue({ "UnitHonorLevel" }, "player"))
|
|
29
|
+
|
|
30
|
+
-- Rank: raw number from UnitPVPRank (0 = no rank), rank name and number from GetPVPRankInfo.
|
|
31
|
+
-- Clients without ranks return nothing.
|
|
32
|
+
local raw = number(firstValue({ "UnitPVPRank" }, "player"))
|
|
33
|
+
if raw and raw > 0 then
|
|
34
|
+
pvp.rank = raw
|
|
35
|
+
local info = callFirst({ "GetPVPRankInfo" }, raw, "player")
|
|
36
|
+
local name = info and plain(info[1])
|
|
37
|
+
if type(name) == "string" and name ~= "" then pvp.rankName = name end
|
|
38
|
+
pvp.rank = number(info and plain(info[2])) or raw
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
if next(pvp) == nil then return nil end
|
|
42
|
+
return pvp
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
ns.Snapshot.addSection("pvp", collectPvp)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Sections questDb (where the quests of the log and of the next guide steps start and end, from the installed
|
|
5
|
+
-- quest database, see QuestDb.lua) and questLookups (answers to /mcp quest <id or name>, kept between dumps).
|
|
6
|
+
-- Both are absent when the player has no quest database addon.
|
|
7
|
+
|
|
8
|
+
local _, ns = ...
|
|
9
|
+
local QuestDb, Guide, Snapshot = ns.QuestDb, ns.Guide, ns.Snapshot
|
|
10
|
+
|
|
11
|
+
local MAX_QUESTS = 60
|
|
12
|
+
local MAX_LOOKUPS = 10
|
|
13
|
+
|
|
14
|
+
local function collectQuestDb()
|
|
15
|
+
if not QuestDb.available() then return nil end
|
|
16
|
+
local section = { source = QuestDb.source(), quests = {} }
|
|
17
|
+
local unknown, seen = {}, {}
|
|
18
|
+
local function add(questID, mark)
|
|
19
|
+
if type(questID) ~= "number" then return end
|
|
20
|
+
local quest = seen[questID]
|
|
21
|
+
if quest == nil then
|
|
22
|
+
if #section.quests >= MAX_QUESTS then return end
|
|
23
|
+
quest = QuestDb.quest(questID) or false
|
|
24
|
+
seen[questID] = quest
|
|
25
|
+
if quest then
|
|
26
|
+
section.quests[#section.quests + 1] = quest
|
|
27
|
+
else
|
|
28
|
+
unknown[#unknown + 1] = questID
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
if quest then quest[mark] = true end
|
|
32
|
+
end
|
|
33
|
+
local logIDs = {}
|
|
34
|
+
for questID in pairs(Guide.logState()) do logIDs[#logIDs + 1] = questID end
|
|
35
|
+
table.sort(logIDs)
|
|
36
|
+
for _, questID in ipairs(logIDs) do add(questID, "inLog") end
|
|
37
|
+
for _, questID in ipairs(Guide.pendingQuestIDs()) do add(questID, "inGuide") end
|
|
38
|
+
if #unknown > 0 then section.unknownQuestIDs = unknown end
|
|
39
|
+
return section
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
local QuestLookup = {}
|
|
43
|
+
ns.QuestLookup = QuestLookup
|
|
44
|
+
|
|
45
|
+
-- Looks the text up and stores the answer in the current dump (newest first). Returns the stored entry, or nil
|
|
46
|
+
-- when there is no quest database.
|
|
47
|
+
function QuestLookup.run(query)
|
|
48
|
+
local result = QuestDb.lookup(query)
|
|
49
|
+
if not result then return nil end
|
|
50
|
+
local entry = { query = tostring(query), at = time(), quests = result.quests, npcs = result.npcs }
|
|
51
|
+
if Snapshot.isDisabled("questLookups") then return entry end
|
|
52
|
+
local current = Snapshot.current()
|
|
53
|
+
local lookups = type(current.questLookups) == "table" and current.questLookups or {}
|
|
54
|
+
for i = #lookups, 1, -1 do
|
|
55
|
+
if type(lookups[i]) ~= "table" or lookups[i].query == entry.query then table.remove(lookups, i) end
|
|
56
|
+
end
|
|
57
|
+
table.insert(lookups, 1, entry)
|
|
58
|
+
while #lookups > MAX_LOOKUPS do table.remove(lookups) end
|
|
59
|
+
current.questLookups = lookups
|
|
60
|
+
Snapshot.windowCaptured("questLookups")
|
|
61
|
+
return entry
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
-- "Falla Sagewind, The Barrens 48.2, 32.8" for a quest giver, finisher or objective target.
|
|
65
|
+
function QuestLookup.describeTarget(target)
|
|
66
|
+
local parts = { target.name or (target.kind .. " " .. tostring(target.id)) }
|
|
67
|
+
local where = type(target.locations) == "table" and target.locations[1]
|
|
68
|
+
if where then
|
|
69
|
+
local place = where.zone or "unknown zone"
|
|
70
|
+
if where.inInstance then
|
|
71
|
+
place = place .. " (inside the instance)"
|
|
72
|
+
elseif where.x and where.y then
|
|
73
|
+
place = place .. " " .. where.x .. ", " .. where.y
|
|
74
|
+
end
|
|
75
|
+
parts[#parts + 1] = place
|
|
76
|
+
if (target.spawnCount or 1) > 1 then parts[#parts + 1] = target.spawnCount .. " spawn points" end
|
|
77
|
+
elseif target.kind == "item" then
|
|
78
|
+
parts[#parts + 1] = "item"
|
|
79
|
+
end
|
|
80
|
+
return table.concat(parts, ", ")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
local function describeTargets(targets)
|
|
84
|
+
if type(targets) ~= "table" or #targets == 0 then return "not in the database" end
|
|
85
|
+
local parts = {}
|
|
86
|
+
for _, target in ipairs(targets) do parts[#parts + 1] = QuestLookup.describeTarget(target) end
|
|
87
|
+
return table.concat(parts, "; ")
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
-- Chat lines for a lookup entry.
|
|
91
|
+
function QuestLookup.lines(entry)
|
|
92
|
+
local lines = {}
|
|
93
|
+
for _, quest in ipairs(entry.quests) do
|
|
94
|
+
lines[#lines + 1] = ("%s (quest %d, level %s)"):format(quest.name or "?", quest.id, tostring(quest.level or "?"))
|
|
95
|
+
lines[#lines + 1] = " starts: " .. describeTargets(quest.startedBy)
|
|
96
|
+
lines[#lines + 1] = " ends: " .. describeTargets(quest.finishedBy)
|
|
97
|
+
end
|
|
98
|
+
for _, npc in ipairs(entry.npcs) do
|
|
99
|
+
lines[#lines + 1] = "NPC " .. QuestLookup.describeTarget(npc)
|
|
100
|
+
end
|
|
101
|
+
if #lines == 0 then lines[1] = "Nothing found for \"" .. entry.query .. "\" (use the exact quest or NPC name, or an ID)." end
|
|
102
|
+
return lines
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
Snapshot.addSection("questDb", collectQuestDb)
|
|
106
|
+
Snapshot.addWindowSection("questLookups")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
-- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
|
|
3
|
+
|
|
4
|
+
-- Sections questOffer and questTurnIn (from the window): the quest an NPC is just offering (QUEST_DETAIL),
|
|
5
|
+
-- and the reward choices when turning in a quest (QUEST_COMPLETE). We keep only the latest of each.
|
|
6
|
+
-- The addon accepts, turns in and chooses nothing; it only reads what the window already shows.
|
|
7
|
+
|
|
8
|
+
local _, ns = ...
|
|
9
|
+
local plain, firstValue = ns.Compat.plain, ns.Compat.firstValue
|
|
10
|
+
|
|
11
|
+
local function questGiverName()
|
|
12
|
+
return plain(UnitName("questnpc")) or plain(UnitName("npc"))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
local function nonEmptyText(text)
|
|
16
|
+
if type(text) == "string" and text:find("%S") then return text end
|
|
17
|
+
return nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
-- Shared part of both windows: title, ID, NPC, rewards and time.
|
|
21
|
+
local function questWindow(textPaths)
|
|
22
|
+
local title = firstValue({ "GetTitleText" })
|
|
23
|
+
if not title then return nil end
|
|
24
|
+
return {
|
|
25
|
+
title = title,
|
|
26
|
+
id = firstValue({ "GetQuestID" }),
|
|
27
|
+
text = nonEmptyText(firstValue(textPaths)),
|
|
28
|
+
npc = questGiverName(),
|
|
29
|
+
rewards = ns.QuestRewards.fromGiver(),
|
|
30
|
+
capturedAt = time(),
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
-- Quest offer: text is the quest objectives (GetObjectiveText).
|
|
35
|
+
local function collectQuestOffer()
|
|
36
|
+
return questWindow({ "GetObjectiveText" })
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
-- Quest turn-in: text is the NPC's text at the reward (GetRewardText).
|
|
40
|
+
local function collectQuestTurnIn()
|
|
41
|
+
return questWindow({ "GetRewardText" })
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
ns.Snapshot.addWindowSection("questOffer", collectQuestOffer, { "QUEST_DETAIL" })
|
|
45
|
+
ns.Snapshot.addWindowSection("questTurnIn", collectQuestTurnIn, { "QUEST_COMPLETE" })
|