forked from dnsfour/AverageItemLevel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.lua
More file actions
674 lines (623 loc) · 23.3 KB
/
core.lua
File metadata and controls
674 lines (623 loc) · 23.3 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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
local addonName, addon = ...
local E = addon:Eve()
local CACHE_TIMEOUT = 5 -- seconds to keep stale information before issuing a new inspect
local print = function()
end -- lazy debug print
local GuidCache = {} -- [guid] = {ilevel, specName, timestamp}
local ActiveGUID -- unit passed to NotifyInspect before INSPECT_READY fires
local ScannedGUID -- actually-inspected unit from INSPECT_READY
local INSPECT_TIMEOUT = 1.5 -- safety cap on how often the api will allow us to call NotifyInspect without issues
-- lowering INSPECT_TIMEOUT will result in the function silently failing without firing the inspection event
-- LOADING_ILVL = "Retrieving Data"
local LOADING_ILVL = RETRIEVING_DATA -- format("%s %s", (LFG_LIST_LOADING or "Loading"):gsub("%.", ""), ITEM_LEVEL_ABBR or "iLvl")
-- ILVL_PENDING = "Inspect Pending"
local ILVL_PENDING = format("%s %s", INSPECT, strlower(CLUB_FINDER_PENDING or "Pending"))
-- If we see someone cast a covenant spell add their covenant to tooltip
local CovenantCache = {} -- [guid] = covenantID
local CovenantColors = {
-- Kyrian White
[1] = "e6e0e7",
-- Venthyr Red
[2] = "f71010",
-- Night Fae Blue
[3] = "41fafe",
-- Necrolord Green
[4] = "18efa5"
}
local CovenantIcons = {
-- Kyrian
[1] = 3586266,
-- Venthyr
[2] = 3586270,
-- Night Fae
[3] = 3586268,
-- Necrolord
[4] = 3586267
}
local CovenantSpells = {
-- Kyrian
[324739] = 1,
[312202] = 1,
[306830] = 1,
[326434] = 1,
[308491] = 1,
[307443] = 1,
[310454] = 1,
[304971] = 1,
[325013] = 1,
[323547] = 1,
[324386] = 1,
[312321] = 1,
[307865] = 1,
[328266] = 1,
[333950] = 1,
[329791] = 1,
-- Venthyr
[300728] = 2,
[311648] = 2,
[317009] = 2,
[323546] = 2,
[326860] = 2,
[314793] = 2,
[316958] = 2,
[323673] = 2,
[323654] = 2,
[320674] = 2,
[321792] = 2,
[317320] = 2,
[324149] = 2,
[340159] = 2,
[331586] = 2,
[336239] = 2,
-- Night Fae
[310143] = 3,
[324128] = 3,
[323639] = 3,
[323764] = 3,
[328231] = 3,
[314791] = 3,
[327104] = 3,
[328620] = 3,
[327661] = 3,
[328305] = 3,
[328923] = 3,
[325640] = 3,
[325886] = 3,
[319217] = 3,
[325066] = 3,
[322721] = 3,
[324701] = 3,
-- Necrolord
[324631] = 4,
[315443] = 4,
[329554] = 4,
[325727] = 4,
[325028] = 4,
[324220] = 4,
[325216] = 4,
[328204] = 4,
[324724] = 4,
[328547] = 4,
[326059] = 4,
[325289] = 4,
[324143] = 4,
[323074] = 4,
[342156] = 4,
[326514] = 4
}
local function GetUnitIDFromGUID(guid)
local _, _, _, _, _, name = GetPlayerInfoByGUID(guid)
if UnitExists(name) then -- unit is in our group and can use its name as a unit ID
return name, name
elseif UnitGUID("mouseover") == guid then -- unit is under our cursor
return "mouseover", name
elseif UnitGUID("target") == guid then -- unit is our target
return "target", name
elseif GetCVar("nameplateShowFriends") == "1" then -- friendly nameplates are visible
for i = 1, 30 do
local unitID = "nameplate" .. i
local nameplateGUID = UnitGUID(unitID)
if nameplateGUID then
if nameplateGUID == guid then
return unitID, name
end
else
break
end
end
else -- scan every group member's target (this is probably overkill)
local numMembers = GetNumGroupMembers()
if numMembers > 0 then
local unitPrefix = IsInRaid() and "raid" or "party"
if unitPrefix == "party" then
numMembers = numMembers - 1
end
for i = 1, numMembers do
local unitID = unitPrefix .. i .. "-target"
local targetGUID = UnitGUID(unitID)
if targetGUID == guid then
return unitID, name
end
end
end
end
-- no convenient unit ID is available, we tried
return nil, name
end
local function ColorGradient(perc, r1, g1, b1, r2, g2, b2)
if perc >= 1 then
local r, g, b = r2, g2, b2 -- select(select('#', ...) - 2, ...)
return r, g, b
elseif perc <= 0 then
local r, g, b = r1, g1, b1
return r, g, b
end
-- local num = 2 -- select('#', ...) / 3
-- local segment, relperc = math.modf(perc) --*(num-1))
-- local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...)
return r1 + (r2 - r1) * perc, g1 + (g2 - g1) * perc, b1 + (b2 - b1) * perc
end
local function ColorDiff(a, b)
local diff = a - b
local perc = diff / 30
local r, g, b
if perc < 0 then -- higher ilevel than us
perc = perc * -1
r, g, b = ColorGradient(perc, 1, 1, 0, 0, 1, 0)
else
r, g, b = ColorGradient(perc, 1, 1, 0, 1, 0, 0)
end
return r, g, b
end
local ItemLevelPattern1 = ITEM_LEVEL:gsub("%%d", "(%%d+)")
local ItemLevelPattern2 = ITEM_LEVEL_ALT:gsub("([()])", "%%%1"):gsub("%%d", "(%%d+)")
local TwoHanders = {
-- item types that are two handed, as returned as the 4th result from GetItemInfoInstant
["INVTYPE_RANGED"] = true,
["INVTYPE_RANGEDRIGHT"] = true,
["INVTYPE_2HWEAPON"] = true
}
local InventorySlots = {}
for i = 1, 17 do
if i ~= 4 then -- ignore shirt, tabard is 19
tinsert(InventorySlots, i)
end
end
local function IsArtifact(itemLink)
return itemLink:find("|cffe6cc80") -- this is probably a horrible way to find whether it's an artifact
end
local function IsLegendary(itemLink)
-- return false
return itemLink:find('|cffff8000')
end
local function IsCached(itemLink) -- we can't get the correct level of an artifact until all of its relics have been cached
local cached = true
local _, itemID, _, relic1, relic2, relic3 = strsplit(":", itemLink)
print(strsplit(":", itemLink))
if not GetDetailedItemLevelInfo(itemID) then
cached = false
end
if IsArtifact(itemLink) then
if relic1 and relic1 ~= "" and not GetDetailedItemLevelInfo(relic1) then
cached = false
end
if relic2 and relic2 ~= "" and not GetDetailedItemLevelInfo(relic2) then
cached = false
end
if relic3 and relic3 ~= "" and not GetDetailedItemLevelInfo(relic3) then
cached = false
end
end
print(cached)
return cached
end
local Sekret = "|Hilvl|h"
local function AddLine(sekret, leftText, rightText, r1, g1, b1, r2, g2, b2, dontShow)
-- if GameTooltip:IsVisible() then
if not r1 then
r1, g1, b1, r2, g2, b2 = 1, 1, 0, 1, 1, 0
end
leftText = sekret .. leftText
for i = 2, GameTooltip:NumLines() do
local leftStr = _G["GameTooltipTextLeft" .. i]
local text = leftStr and leftStr:IsShown() and leftStr:GetText()
if text and text:find(sekret) then
-- edit line
local rightStr = _G['GameTooltipTextRight' .. i]
leftStr:SetText(leftText)
rightStr:SetText(rightText)
if r1 and g1 and b1 then
leftStr:SetTextColor(r1, g1, b1)
end
if r2 and g2 and b2 then
rightStr:SetTextColor(r2, g2, b2)
end
return
end
end
if not dontShow or GameTooltip:IsShown() then
GameTooltip:AddDoubleLine(leftText, rightText, r1, g1, b1, r2, g2, b2)
GameTooltip:Show()
end
-- end
end
-- OnTooltipSetUnit: NotifyInspect(unit)
-- on INSPECT_READY do
-- for each slot, tooltip:SetInventoryItem(unit, slot)
-- OnTooltipSetItem: if IsCached then update slot item level
-- when all items are accounted for, update tooltip
local SlotCache = {} -- [slot] = itemLevel or false
local ItemCache = {} -- [slot] = itemLink
local TestTips = {}
-- for i, slot in pairs(InventorySlots) do this throws exception and i don`t know how and when it shows
for i, slot in pairs({}) do
local tip = CreateFrame("GameTooltip", "AverageItemLevelTooltip" .. slot, nil, "GameTooltipTemplate")
tip:SetOwner(WorldFrame, "ANCHOR_NONE")
TestTips[slot] = tip
tip.slot = slot
tip:SetScript("OnTooltipSetItem", function(self)
local slot = self.slot
local _, itemLink = self:GetItem()
local tipName = self:GetName()
if self.itemLink then
itemLink = self.itemLink
end
if itemLink then
local isCached = IsCached(itemLink)
if isCached then
for i = 2, self:NumLines() do
local str = _G[tipName .. "TextLeft" .. i]
local text = str and str:GetText()
if text then
local ilevel = text:match(ItemLevelPattern1)
if not ilevel then
ilevel = text:match(ItemLevelPattern2)
end
if ilevel then
SlotCache[slot] = tonumber(ilevel)
ItemCache[slot] = itemLink
end
end
end
end
end
local finished = true
local totalItemLevel = 0
for slot, ilevel in pairs(SlotCache) do
if not ilevel then
finished = false
break
else
if slot ~= 16 and slot ~= 17 then
totalItemLevel = totalItemLevel + ilevel
end
end
end
if finished then
local weaponLevel = 0
local isDual = false
if SlotCache[16] and SlotCache[17] then -- we have 2 weapons
isDual = true
if IsArtifact(ItemCache[16]) or IsArtifact(ItemCache[17]) then -- take the higher of the 2 weapons and double it
local ilevelMain = SlotCache[16]
local ilevelOff = SlotCache[17]
weaponLevel = ilevelMain > ilevelOff and ilevelMain or ilevelOff
totalItemLevel = totalItemLevel + (weaponLevel * 2)
else
local ilevelMain = SlotCache[16]
local ilevelOff = SlotCache[17]
totalItemLevel = totalItemLevel + ilevelMain + ilevelOff
if ilevelMain > ilevelOff then
weaponLevel = ilevelMain
else
weaponLevel = ilevelOff
end
end
elseif SlotCache[16] then -- main hand only
local _, _, _, weaponType = GetItemInfoInstant(ItemCache[16])
local ilevelMain = SlotCache[16]
weaponLevel = ilevelMain
if TwoHanders[weaponType] then -- 2 handed, count it twice
totalItemLevel = totalItemLevel + (ilevelMain * 2)
else
totalItemLevel = totalItemLevel + ilevelMain
end
elseif SlotCache[17] then -- off hand only?
local ilevelOff = SlotCache[17]
totalItemLevel = totalItemLevel + ilevelOff
weaponLevel = ilevelOff
end
if weaponLevel >= 900 and ScannedGUID ~= UnitGUID("player") then
weaponLevel = weaponLevel + 15
if isDual then
totalItemLevel = totalItemLevel + 15
else
totalItemLevel = totalItemLevel + 30
end
end
local averageItemLevel = totalItemLevel / 16
-- should we just return the cache for this GUID?
local guid = ScannedGUID
if not GuidCache[guid] then
GuidCache[guid] = {}
end
-- GuidCache[guid].specName = specName
GuidCache[guid].ilevel = averageItemLevel
GuidCache[guid].weaponLevel = weaponLevel
GuidCache[guid].neckLevel = SlotCache[2]
-- GuidCache[guid].levelText = levelText
GuidCache[guid].timestamp = GetTime()
-- todo: figure out why this can fire multiple times
wipe(GuidCache[guid].legos)
for slot, link in pairs(ItemCache) do
if IsLegendary(link) then
tinsert(GuidCache[guid].legos, link)
end
end
E("ItemScanComplete", guid, GuidCache[guid])
end
end)
end
local function GetTooltipGUID()
-- if GameTooltip:IsVisible() then
local _, unitID = GameTooltip:GetUnit()
local guid = unitID and UnitGUID(unitID)
if UnitIsPlayer(unitID) and CanInspect(unitID) then
return guid
end
-- end
end
local f = CreateFrame("frame", nil, GameTooltip)
local ShouldInspect = false
local LastInspect = 0
local FailTimeout = 1
f:SetScript("OnUpdate", function(self, elapsed)
local _, unitID = GameTooltip:GetUnit()
local guid = unitID and UnitGUID(unitID)
if not guid or (InspectFrame and InspectFrame:IsVisible()) then
return
end
local timeSince = GetTime() - LastInspect
if ShouldInspect and (ActiveGUID == guid or (timeSince >= INSPECT_TIMEOUT)) then
ShouldInspect = false
-- inspect whoever's in the tooltip and set to a unit we can inspect
if ActiveGUID ~= guid then -- todo: make sure this isn't going to be a problem
local cache = GuidCache[guid]
if cache and GetTime() - cache.timestamp <= CACHE_TIMEOUT then -- rescan only if enough time has elapsed
print("Still cached")
elseif CanInspect(unitID) then
NotifyInspect(unitID)
end
end
elseif ShouldInspect and (timeSince < INSPECT_TIMEOUT) then -- we are waiting for another inspection to time out before starting a new one
if unitID and UnitIsPlayer(unitID) and CanInspect(unitID) and not GuidCache[guid] then
AddLine(Sekret, ILVL_PENDING, format('%.1fs', INSPECT_TIMEOUT - (GetTime() - LastInspect)), 0.6, 0.6, 0.6,
0.6, 0.6, 0.6)
end
else
-- todo: handle the tooltip being visible with no attempt at inspecting the unit
if ActiveGUID then
if guid == ActiveGUID then
if timeSince <= FailTimeout then
AddLine(Sekret, LOADING_ILVL, format('%d%%', timeSince / FailTimeout * 100), 0.6, 0.6, 0.6, 0.6,
0.6, 0.6)
else
AddLine(Sekret, LOADING_ILVL, FAILED or 'Failed', 0.6, 0.6, 0.6, 0.6, 0.6, 0.6)
ActiveGUID = nil
end
else
ActiveGUID = nil
-- inspected guid doesn't match who the tooltip is displaying
if timeSince > FailTimeout and CanInspect(unitID) then
NotifyInspect(unitID) -- reissue notification attempt
end
end
end
end
end)
hooksecurefunc("NotifyInspect", function(unitID)
print("NotifyInspect!", unitID, UnitGUID(unitID), (select(6, GetPlayerInfoByGUID(UnitGUID(unitID)))))
if not GuidCache[UnitGUID(unitID)] then
ActiveGUID = UnitGUID(unitID)
end
LastInspect = GetTime()
end)
hooksecurefunc("ClearInspectPlayer", function()
ActiveGUID = nil
end)
local function DoInspect()
ShouldInspect = true
end
local function DecorateTooltip(guid)
local cache = GuidCache[guid]
if not cache then
print("no cache?")
return
end
if GetTooltipGUID() == guid then -- make sure we're looking at the same unit
-- AddLine(STAT_AVERAGE_ITEM_LEVEL, cache.ilevel, 1, 1, 0, 1, 1, 1, true)
local ourMaxItemLevel, ourEquippedItemLevel = GetAverageItemLevel()
local averageItemLevel = (cache.ilevel or 0) > 0 and cache.ilevel or cache.itemLevel or 0
-- local weaponLevel = cache.weaponLevel or 0
-- local neckLevel = cache.neckLevel or 0
local r1, g1, b1 = ColorDiff(ourEquippedItemLevel, averageItemLevel)
-- local ourNeck = GetInventoryItemLink("player", 2)
-- local ourNeckLevel = GetDetailedItemLevelInfo(ourNeck or "") or 0
--[[
local ourWeaponMain = GetInventoryItemLink('player', 16)
local ourWeaponOff = GetInventoryItemLink('player', 17)
local ourWeaponLevel = 0
if ourWeaponOff and ourWeaponMain then -- dual wielding
local mainLevel = GetDetailedItemLevelInfo(ourWeaponMain)
local offLevel = GetDetailedItemLevelInfo(ourWeaponOff)
if mainLevel > offLevel then
ourWeaponLevel = mainLevel
else
ourWeaponLevel = offLevel
end
elseif ourWeaponMain then
ourWeaponLevel = GetDetailedItemLevelInfo(ourWeaponMain)
elseif ourWeaponOff then
ourWeaponLevel = GetDetailedItemLevelInfo(ourWeaponOff)
end
--]]
AddLine(Sekret, cache.specName and cache.specName or " ",
format("%s %.1f", ITEM_LEVEL_ABBR or "iLvl", averageItemLevel), r1, g1, b1, r1, g1, b1)
if CovenantCache[guid] then
local covenantID = CovenantCache[guid]
local covenantData = C_Covenants.GetCovenantData(covenantID)
local covenantColor = CovenantColors[covenantID]
local covenantIcon = CovenantIcons[covenantID]
AddLine("|Hcovenant|h",
format("%s |cff%s%s|r", CreateTextureMarkup(covenantIcon, 64, 64, 16, 16, 0.05, 0.95, 0.05, 0.95),
covenantColor, covenantData.name), " ")
end
-- Show Mythic+ score
local mythicScore = cache.mythicPlus and cache.mythicPlus.currentSeasonScore and
cache.mythicPlus.currentSeasonScore or 0
if mythicScore > 0 then
local mythicLabel = mythicScore
local bestRun = 0
for _, run in pairs(cache.mythicPlus.runs or {}) do
if run.finishedSuccess and run.bestRunLevel > bestRun then
bestRun = run.bestRunLevel
end
end
if bestRun > 0 then
mythicLabel = mythicScore .. " " .. "|c00ffff99+" .. bestRun .. "|r"
end
local color = C_ChallengeMode.GetDungeonScoreRarityColor(mythicScore) or HIGHLIGHT_FONT_COLOR
AddLine("|HmythicPlus|h", DUNGEON_SCORE, mythicLabel, 1, 1, 0.6, color:GetRGB())
else
-- AddLine("|HmythicPlus|h", DUNGEON_SCORE, "None", 1, 1, 0, 0.6, 0.6, 0.6)
end
-- Add legendaries to tooltip
-- for i, lego in ipairs(cache.legos) do
-- AddLine("|Hlego" .. i .. "|h", "|cffff8000Legendary|r", lego, 1, 1, 1, 1, 1, 1)
-- end
else
print("tooltip GUID does not match expected guid")
end
end
local function ScanUnit(unitID)
print("SCANNING UNIT", unitID)
ScannedGUID = UnitGUID(unitID)
wipe(SlotCache)
wipe(ItemCache)
wipe(GuidCache[ScannedGUID].legos)
local numEquipped = 0
for i, slot in pairs(InventorySlots) do
if GetInventoryItemTexture(unitID, slot) then -- we have an item in this slot
SlotCache[slot] = false
print("GetInventoryItemTexture", slot, GetInventoryItemTexture(unitID, slot))
numEquipped = numEquipped + 1
end
end
if numEquipped > 0 then
for slot in pairs(SlotCache) do
TestTips[slot].itemLink = GetInventoryItemLink(unitID, slot)
-- print('GetInveotryItemLink', TestTips[slot].itemLink, slot)
TestTips[slot]:SetOwner(WorldFrame, "ANCHOR_NONE")
TestTips[slot]:SetInventoryItem(unitID, slot)
end
else -- they don't appear to be wearing anything, return nothing
local guid = ScannedGUID
if not GuidCache[guid] then
GuidCache[guid] = {}
end
GuidCache[guid].ilevel = 0
GuidCache[guid].weaponLevel = 0
GuidCache[guid].timestamp = GetTime()
E("ItemScanComplete", guid, GuidCache[guid])
end
end
function E:INSPECT_READY(guid)
print("INSPECT_READY")
ActiveGUID = nil
local unitID, name = GetUnitIDFromGUID(guid)
if unitID then
print("INSPECT_READY", unitID, name)
local classDisplayName, class = UnitClass(unitID)
local colors = class and RAID_CLASS_COLORS[class]
local specID = GetInspectSpecialization(unitID)
local specName, role, _ -- = GuidCache[guid].specName
if not specName and specID and specID ~= 0 then
specID, specName, _, _, role = GetSpecializationInfoByID(specID, UnitSex(unitID))
-- Default to class name if unit has no spec
if not specName or specName == "" then
specName = classDisplayName
end
-- Apply class color to spec name
if colors then
specName = "|c" .. colors.colorStr .. specName .. "|r"
end
-- Add role texture for player spec
if role then
local roleTexture
if role == "TANK" then
roleTexture = CreateAtlasMarkup("roleicon-tiny-tank")
elseif role == "DAMAGER" then
roleTexture = CreateAtlasMarkup("roleicon-tiny-dps")
elseif role == "HEALER" then
roleTexture = CreateAtlasMarkup("roleicon-tiny-healer")
end
if roleTexture then
specName = format("%s %s", roleTexture, specName)
end
end
end
if not GuidCache[guid] then
GuidCache[guid] = {
ilevel = 0,
weaponLevel = 0,
timestamp = 0,
legos = {},
mythicPlus = {}
}
end
local cache = GuidCache[guid]
cache.specID = specID
cache.class = class
cache.classDisplayName = classDisplayName
cache.specName = specName
cache.itemLevel = C_PaperDollInfo.GetInspectItemLevel(unitID)
cache.mythicPlus = C_PlayerInfo.GetPlayerMythicPlusRatingSummary(unitID) or {}
ScanUnit(unitID)
-- else
-- print(format('No unit ID available to inspect %s', name))
end
end
function E:ItemScanComplete(guid, cache)
print("ItemScanComplete", guid, cache)
-- AddLine(STAT_AVERAGE_ITEM_LEVEL, cache.ilevel, 1, 1, 0, 1, 1, 1, true)
DecorateTooltip(guid)
end
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Unit, function(self)
-- GameTooltip:HookScript("OnTooltipSetUnit", function(self) -- this fires before the tooltip is visible
print("OnTooltipSetUnit")
local _, unitID = self:GetUnit()
local guid = unitID and UnitGUID(unitID)
if guid and UnitIsPlayer(unitID) then
print("OnTooltipSetUnit", guid, UnitName(unitID))
local cache = GuidCache[guid]
if cache then
-- fill tooltip with cached data, but initiate a new scan anyway to update it
-- AddLine(STAT_AVERAGE_ITEM_LEVEL, '???', 1, 0, 0, 1, 0, 0)
DecorateTooltip(guid)
end
if CanInspect(unitID) then
DoInspect()
end
end
end)
-- Covenant spell tracking
local function COMBAT_LOG_EVENT_UNFILTERED(timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags,
destGUID, destName, destFlags, destRaidFlags, spellID, spellName, ...)
local covenantID = CovenantSpells[spellID]
if covenantID then
CovenantCache[sourceGUID] = covenantID
end
end
function E:COMBAT_LOG_EVENT_UNFILTERED()
COMBAT_LOG_EVENT_UNFILTERED(CombatLogGetCurrentEventInfo())
end