Repository navigation
Expand file tree
/
Copy pathsets.lua
More file actions
442 lines (397 loc) · 17.6 KB
/
Copy pathsets.lua
File metadata and controls
442 lines (397 loc) · 17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
--[[ WoWUtils Plus — Tier-Set-Verteilung (Grundlage).
Was hier passiert:
* **Token erkennen.** RCLootCouncil fuehrt eine globale Tabelle `RCTokenTable`
(Token-Item-ID -> Ausruestungsslot, z.B. "HeadSlot"). Sie wird von RCL mit jedem
Patch gepflegt — wir lesen sie nur, wir pflegen nichts.
* **Wer hat schon einen Token bekommen.** Die RCL-Loot-Historie merkt sich je Vergabe
`tierToken = true`. Aus dem Item wird der Slot.
* **Vault.** Ueber `WowUtilsAPI.GetVault(Name-Realm)` liegen die Truhen der Gilde vor,
je Eintrag mit Item und `picked` (abgeholt oder nicht).
* **Merker.** WowUtils haelt die Truhe nur fuer die laufende Woche. Abgeholte Teile
schreiben wir in unsere eigenen SavedVariables, damit die Info den Reset ueberlebt.
🔴 Es wird nichts geraten: was wir nicht wissen, bleibt leer.
]]
local addonName, ns = ...
-- ---------------------------------------------------------------------------
-- Die fuenf Tier-Slots
-- ---------------------------------------------------------------------------
--- Reihenfolge wie in der Spalte: H S C G L
ns.SET_SLOTS = {
{ key = "kopf", brief = "H", name = "Kopf", rcl = "HeadSlot" },
{ key = "schulter", brief = "S", name = "Schulter", rcl = "ShoulderSlot" },
{ key = "brust", brief = "C", name = "Brust", rcl = "ChestSlot" },
{ key = "haende", brief = "G", name = "Hände", rcl = "HandsSlot" },
{ key = "beine", brief = "L", name = "Beine", rcl = "LegsSlot" },
}
--- Ausruestungsslot-Nummer -> unser Slot-Schluessel.
--- 5 und 20 sind beides Brust (5 = Brust, 20 = Robe).
local INV_ZU_SLOT = {
[1] = "kopf", [3] = "schulter", [5] = "brust", [20] = "brust",
[7] = "beine", [10] = "haende",
}
local RCL_ZU_SLOT = {}
for _, s in ipairs(ns.SET_SLOTS) do RCL_ZU_SLOT[s.rcl] = s.key end
function ns.SlotName(key)
for _, s in ipairs(ns.SET_SLOTS) do if s.key == key then return s.name end end
return tostring(key)
end
-- ---------------------------------------------------------------------------
-- Token-Erkennung (ueber RCLs eigene Tabelle)
-- ---------------------------------------------------------------------------
--- Slot-Schluessel eines Tokens, oder nil wenn das Item kein Token ist.
--- @param itemId number?
--- @return string? slotKey
local function tokenSlot(itemId)
if not itemId then return nil end
local tabelle = _G.RCTokenTable
if type(tabelle) ~= "table" then return nil end
local rcl = tabelle[tonumber(itemId)]
if not rcl then return nil end
return RCL_ZU_SLOT[rcl] -- nil bei "MultiSlots"/"Trinket"/alten Slots
end
ns.TokenSlot = tokenSlot
--- Ist das aktuelle Item im Fenster ein Tier-Token, und welcher Slot?
--- @return string? slotKey, number? itemId
function ns.TokenImFenster()
local item = ns.ItemImFenster and ns.ItemImFenster()
if not item then return nil end
local itemId = item.itemID
if not itemId and item.link and C_Item and C_Item.GetItemInfoInstant then
itemId = C_Item.GetItemInfoInstant(item.link)
end
return tokenSlot(itemId), itemId
end
-- ---------------------------------------------------------------------------
-- Merker: abgeholte Vault-Teile ueber den Reset hinaus behalten
-- ---------------------------------------------------------------------------
local function merker()
WowUtilsPlusDB = WowUtilsPlusDB or {}
WowUtilsPlusDB.sets = WowUtilsPlusDB.sets or {}
return WowUtilsPlusDB.sets
end
--- Einen abgeholten Vault-Eintrag dauerhaft notieren (nur wenn noch nicht da).
local function merken(schluessel, slot, s)
if not (schluessel and slot and s and s.itemId) then return end
local m = merker()
m[schluessel] = m[schluessel] or {}
if m[schluessel][slot] and m[schluessel][slot].itemId == s.itemId then return end
m[schluessel][slot] = {
itemId = s.itemId,
link = s.itemLink,
name = s.itemLink and s.itemLink:match("%[(.-)%]") or nil,
stufe = s.itemLevel,
seit = (s.picked and time()) or nil,
}
end
-- ---------------------------------------------------------------------------
-- Vault
-- ---------------------------------------------------------------------------
--- Der Stand der Truhe eines Kandidaten, je Tier-Slot.
--- @param kandidat string "Name-Realm"
--- @return table? { [slotKey] = { itemId, link, name, stufe, abgeholt } }
function ns.VaultStand(kandidat)
if not (WowUtilsAPI and WowUtilsAPI.GetVault and kandidat) then return nil end
local ok, vault = pcall(WowUtilsAPI.GetVault, kandidat)
if not ok or type(vault) ~= "table" then return nil end
local stand, gefunden = {}, false
for _, e in pairs(vault) do
local slot = INV_ZU_SLOT[tonumber(e.itemLocationId) or -1]
if slot and e.itemId and tonumber(e.itemId) > 2 then
gefunden = true
stand[slot] = {
itemId = e.itemId,
link = e.itemLink,
name = e.itemLink and e.itemLink:match("%[(.-)%]") or nil,
stufe = e.itemLevel,
abgeholt = e.picked and true or false,
}
if e.picked then merken(kandidat, slot, e) end
end
end
return gefunden and stand or nil
end
--- Was wir aus der Truhe dauerhaft mitgeschrieben haben (auch alte Wochen).
--- @return table { [slotKey] = { itemId, name, stufe, seit } }
function ns.VaultMerker(kandidat)
local m = merker()
return m[kandidat]
end
-- ---------------------------------------------------------------------------
-- Token aus der RCL-Loot-Historie
-- ---------------------------------------------------------------------------
--- Alle Tier-Token, die ein Kandidat laut Historie bekommen hat.
--- @param kandidat string "Name-Realm"
--- @return table? { [slotKey] = { name, datum, link } }
function ns.TokenAusHistorie(kandidat)
local RCL = ns.RCL
if not (RCL and RCL.GetHistoryDB) or not kandidat then return nil end
local ok, db = pcall(RCL.GetHistoryDB, RCL)
if not ok or type(db) ~= "table" then return nil end
local liste = db[kandidat]
if type(liste) ~= "table" then return nil end
local stand, gefunden = {}, false
for _, e in ipairs(liste) do
-- 🔴 Nicht auf RCLs Merker `tierToken` allein verlassen: aeltere Eintraege (oder von
-- einem Client mit aelterer RCL-Fassung uebernommen) haben ihn nicht. Das Item selbst
-- gegen RCTokenTable zu pruefen ist die verlaesslichere Quelle.
if e.lootWon then
local itemId = C_Item and C_Item.GetItemInfoInstant and C_Item.GetItemInfoInstant(e.lootWon)
local slot = tokenSlot(itemId)
if slot then
gefunden = true
-- der neueste Eintrag gewinnt (Historie ist chronologisch)
stand[slot] = {
name = e.lootWon:match("%[(.-)%]"),
datum = e.date,
link = e.lootWon,
}
end
end
end
return gefunden and stand or nil
end
-- ---------------------------------------------------------------------------
-- Tier-Erkennung: gehoert ein Item zu einem Klassen-Tier-Set?
--
-- 🔴 Der Weg wurde im Spiel gemessen (04.10.2026), nicht geraten:
-- C_Item.GetSetBonusesForSpecializationByItemID(specID, itemID)
-- — Argument-Reihenfolge ist specID ZUERST.
-- Gemessen an einem Evoker-Tier-Teil: Treffer bei genau den drei Evoker-Specs.
-- An einem DK-Tier-Teil: Treffer bei genau der einen DK-Spec.
-- An einem klassenlosen Set („Bite of Zul'jan"): Treffer bei ALLEN Specs.
-- ---------------------------------------------------------------------------
--- Alle Spezialisierungen aller Klassen — aus dem Spiel, nicht fest verdrahtet.
local function alleSpez()
local liste = {}
if not (GetNumSpecializationsForClassID and GetSpecializationInfoForClassID) then
return liste
end
for klasse = 1, 13 do
local anzahl = GetNumSpecializationsForClassID(klasse) or 0
for i = 1, anzahl do
local id = GetSpecializationInfoForClassID(klasse, i)
if id then liste[#liste + 1] = id end
end
end
return liste
end
local function specListe()
if not ns.specCache then ns.specCache = alleSpez() end
return ns.specCache
end
ns.tierCache = {}
--- Ist das Item ein Tier-Teil? nil = nicht feststellbar.
--- Zwei Bedingungen: es MUSS Set-Boni geben, und es darf NICHT fuer alle Specs welche
--- geben — sonst ist es ein klassenloses Set.
function ns.IstTierTeil(itemId)
itemId = tonumber(itemId)
if not itemId or not (C_Item and C_Item.GetSetBonusesForSpecializationByItemID) then
return nil
end
local gemerkt = ns.tierCache[itemId]
if gemerkt ~= nil then return gemerkt end
local liste = specListe()
if #liste == 0 then return nil end
local treffer = 0
for _, spec in ipairs(liste) do
-- 🔴 Nicht `select("#", …)` zaehlen: liefert die Funktion ein einzelnes `nil`,
-- zaehlt das als 1 Rueckgabe und waere ein falscher Treffer. Den Wert selbst pruefen.
local ok, bonis = pcall(C_Item.GetSetBonusesForSpecializationByItemID, spec, itemId)
if ok and bonis ~= nil then
treffer = treffer + 1
if treffer >= #liste then break end
end
end
local ist = (treffer > 0 and treffer < #liste)
ns.tierCache[itemId] = ist
return ist
end
-- ---------------------------------------------------------------------------
-- Angezogene Tier-Teile
-- ---------------------------------------------------------------------------
--- Ausruestungsslots im Spiel. Bestaetigt per GetInventorySlotInfo (04.10.2026).
local UNIT_SLOTS = { kopf = 1, schulter = 3, brust = 5, haende = 10, beine = 7 }
--- Unit-Kennung zu einem Kandidatennamen ("Name-Realm") finden.
function ns.UnitFuerName(name)
if not name then return nil end
local kurz = name:match("^([^%-]+)") or name
if UnitName and UnitName("player") == kurz then return "player" end
if IsInRaid and IsInRaid() and GetNumGroupMembers then
for i = 1, GetNumGroupMembers() do
local u = "raid" .. i
if UnitName(u) == kurz then return u end
end
elseif IsInGroup and IsInGroup() and GetNumGroupMembers then
for i = 1, GetNumGroupMembers() - 1 do
local u = "party" .. i
if UnitName(u) == kurz then return u end
end
end
return nil
end
--- Angezogene Tier-Teile eines Kandidaten. nil = nichts gefunden (oder nicht pruefbar).
--- 🔴 Funktioniert nur fuer Leute in der Gruppe/im Raid — ausserhalb steht nichts da,
--- statt etwas Falsches.
function ns.Angezogen(kandidat)
local unit = ns.UnitFuerName(kandidat)
if not unit or not GetInventoryItemLink then return nil end
local stand, gefunden = {}, false
for _, s in ipairs(ns.SET_SLOTS) do
local link = GetInventoryItemLink(unit, UNIT_SLOTS[s.key])
if link then
local itemId = C_Item and C_Item.GetItemInfoInstant and C_Item.GetItemInfoInstant(link)
if ns.IstTierTeil(itemId) then
gefunden = true
stand[s.key] = { zustand = "angezogen", itemId = itemId, link = link,
name = link:match("%[(.-)%]") }
end
end
end
-- 🔴 Ohne aktives Untersuchen liefert das Spiel für Mitspieler GAR NICHTS (gemessen 05.10.2026:
-- 0 von 19 Slots). Fehlt hier alles, die Person zur Untersuchung anmelden — die Antwort kommt
-- 1–2 s später und lässt die Zelle neu zeichnen.
if not gefunden and ns.InspectAnfordern then ns.InspectAnfordern(unit) end
return gefunden and stand or nil
end
-- ---------------------------------------------------------------------------
-- Zusammenfassung fuer die Spalte
-- ---------------------------------------------------------------------------
--- Was wissen wir zu den fuenf Slots eines Kandidaten?
--- @param kandidat string "Name-Realm"
--- @return table { [slotKey] = { zustand = "token"|"vault"|"merker", … } }, number anzahl
function ns.SetStand(kandidat)
local stand, anzahl = {}, 0
-- Angezogen hat Vorrang: was er traegt, weiss er sicher.
local angezogen = ns.Angezogen(kandidat)
if angezogen then
for slot, d in pairs(angezogen) do stand[slot] = d end
end
local token = ns.TokenAusHistorie(kandidat)
if token then
for slot, d in pairs(token) do
if not stand[slot] then
stand[slot] = { zustand = "token", name = d.name, datum = d.datum, link = d.link }
end
end
end
local vault = ns.VaultStand(kandidat)
if vault then
for slot, d in pairs(vault) do
if not stand[slot] then
stand[slot] = { zustand = d.abgeholt and "vault" or "vault-offen",
name = d.name, link = d.link, stufe = d.stufe }
end
end
end
local gemerkt = ns.VaultMerker(kandidat)
if gemerkt then
for slot, d in pairs(gemerkt) do
stand[slot] = stand[slot] or { zustand = "vault", name = d.name, link = d.link,
stufe = d.stufe }
end
end
for _ in pairs(stand) do anzahl = anzahl + 1 end
return stand, anzahl
end
-- ---------------------------------------------------------------------------
-- Fremde Ausrüstung: das Spiel rückt sie nur nach aktivem Untersuchen heraus.
--
-- 🔴 Gemessen (05.10.2026): ohne Untersuchen liefert `GetInventoryItemLink` für einen Mitspieler
-- **0 von 19** Slots; mit Untersuchen alle **5 von 5** Tier-Slots.
-- 🔴 **`NotifyInspect` will eine EINHEIT** (`"raid5"`, `"target"`) — **keine GUID**. Mit einer GUID
-- passiert still gar nichts: kein Fehler, kein Ereignis. Genau daran sind zwei Messläufe
-- gescheitert.
-- 🔴 Der Server **drosselt**; bei Drosselung kommt **kein** `INSPECT_READY`. Deshalb ein Ziel nach
-- dem anderen, mit Zeitschranke und wenigen Wiederholungen — und niemals in einer Schleife.
-- 🔴 `INSPECT_READY` **vor** dem Aufruf registrieren, sonst ist die Antwort vorbei.
-- ---------------------------------------------------------------------------
local INSPECT_MAX = 3 -- Versuche je Person
local INSPECT_LIMIT = 2.5 -- Sekunden auf die Antwort warten
local INSPECT_RUHE = 900 -- Sekunden, bis dieselbe Person erneut untersucht wird
local INSPECT_PAUSE = 60 -- Pause nach endgueltigem Fehlschlag
ns.Inspect = {
liste = {}, -- wartende Einheiten, in der Reihenfolge des Auftretens
drin = {}, -- Einheit steht schon in der Liste
laeuft = nil, -- { unit, guid, seit, versuche }
fertig = {}, -- guid -> Zeitpunkt der letzten Untersuchung
pause = {}, -- guid -> ab wann es wieder erlaubt ist
}
--- Fenster neu zeichnen lassen, damit die Zelle das eben Gelernte zeigt.
local function fensterNeuZeichnen()
local rcl = _G.RCL
if not (rcl and rcl.GetActiveModule) then return end
local ok, v = pcall(rcl.GetActiveModule, rcl, "votingframe")
if not ok or not v then
ok, v = pcall(function() return rcl:GetModule("RCVotingFrame", true) end)
end
if ok and v and v.Update then pcall(function() v:Update() end) end
end
--- Eine Person zur Untersuchung anmelden. Tut nichts, wenn sie nicht in der Gruppe ist.
function ns.InspectAnfordern(unit)
if not unit or unit == "player" then return end
if type(NotifyInspect) ~= "function" or type(UnitGUID) ~= "function" then return end
if ns.Inspect.drin[unit] then return end
if ns.Inspect.laeuft and ns.Inspect.laeuft.unit == unit then return end
if UnitExists and not UnitExists(unit) then return end
local guid = UnitGUID(unit)
if not guid then return end
local jetzt = GetTime()
if ns.Inspect.fertig[guid] and (jetzt - ns.Inspect.fertig[guid]) < INSPECT_RUHE then return end
if ns.Inspect.pause[guid] and jetzt < ns.Inspect.pause[guid] then return end
ns.Inspect.drin[unit] = true
ns.Inspect.liste[#ns.Inspect.liste + 1] = unit
end
local function naechsteStarten()
local unit = table.remove(ns.Inspect.liste, 1)
while unit and UnitExists and not UnitExists(unit) do
ns.Inspect.drin[unit] = nil
unit = table.remove(ns.Inspect.liste, 1)
end
if not unit then return end
local guid = UnitGUID(unit)
if not guid then
ns.Inspect.drin[unit] = nil
return
end
ns.Inspect.laeuft = { unit = unit, guid = guid, seit = GetTime(), versuche = 1 }
pcall(NotifyInspect, unit)
end
--- Ein Takt je Sekunde: naechstes Ziel starten bzw. auf Antwort warten und nachfassen.
function ns.InspectTakt()
local l = ns.Inspect.laeuft
if l and (GetTime() - l.seit) > INSPECT_LIMIT then
if l.versuche < INSPECT_MAX then
l.versuche = l.versuche + 1
l.seit = GetTime()
pcall(NotifyInspect, l.unit)
else
ns.Inspect.pause[l.guid] = GetTime() + INSPECT_PAUSE
ns.Inspect.drin[l.unit] = nil
ns.Inspect.laeuft = nil
end
end
if not ns.Inspect.laeuft and #ns.Inspect.liste > 0 then
naechsteStarten()
end
end
local inspectRahmen = CreateFrame("Frame")
inspectRahmen:RegisterEvent("INSPECT_READY")
inspectRahmen:SetScript("OnEvent", function(_, _, guid)
local l = ns.Inspect.laeuft
if not l then return end
if guid and tostring(guid) ~= l.guid then return end
ns.Inspect.fertig[l.guid] = GetTime()
ns.Inspect.drin[l.unit] = nil
ns.Inspect.laeuft = nil
fensterNeuZeichnen()
end)
local inspectTakt
inspectTakt = C_Timer.NewTicker(1, function()
local ok, err = pcall(ns.InspectTakt)
if not ok then ns.inspectFehler = tostring(err) end
end)
-- Fassungs-Merker: beweist nach dem /reload, dass diese Fassung wirklich geladen wurde.
C_Timer.After(3, function()
WowUtilsPlusDB = WowUtilsPlusDB or {}
WowUtilsPlusDB.inspectFassung = "inspektion-1"
end)