-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjournal.lua
More file actions
executable file
·89 lines (77 loc) · 2.74 KB
/
journal.lua
File metadata and controls
executable file
·89 lines (77 loc) · 2.74 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
local _, Viewda = ...
local LPT = LibStub("LibPeriodicTable-3.1")
local reverseBoss = Viewda.Babble.boss:GetReverseLookupTable()
local reverseInstance = Viewda.Babble.subzone:GetReverseLookupTable()
local function UpdateLootChances()
if InCombatLockdown() then return end
local scrollFrame = EncounterJournal.encounter.info.lootScroll
local offset = HybridScrollFrame_GetOffset(scrollFrame)
local itemButtons = scrollFrame.buttons
local index, itemID, slot, armorType, encounterID
local subSet, setName, chance, lootButton, bossName
local numLoot = EJ_GetNumLoot()
local instanceName = EJ_GetInstanceInfo()
local difficulty = EJ_GetDifficulty()
if not EJ_IsValidInstanceDifficulty(difficulty) then
if EJ_InstanceIsRaid() and difficulty < 3 then
difficulty = difficulty + 2
else
difficulty = 1
while difficulty < 10 and not EJ_IsValidInstanceDifficulty(difficulty) do
difficulty = difficulty + 1
end
-- there is no valid difficulty? what the ...?
if difficulty == 10 then return end
end
end
local LPT_table = "InstanceLoot"
if difficulty == DIFFICULTY_RAID_LFR then
LPT_table = "InstanceLootLFR"
elseif difficulty == DIFFICULTY_DUNGEON_HEROIC or difficulty > 4 then
LPT_table = "InstanceLootHeroic"
end
for i = 1, #itemButtons do
index = offset + i
-- name, icon, slot, armorType, itemID, link, encounter
_, _, slot, armorType, itemID, _, encounterID = EJ_GetLootInfoByIndex(index)
if index <= numLoot then
bossName = EJ_GetEncounterInfo(encounterID)
bossName = reverseBoss[bossName]
subSet = (reverseInstance[instanceName] and "."..reverseInstance[instanceName] or "")
subSet = subSet .. (bossName and "."..bossName or "")
setName = LPT_table .. subSet
if subSet and subSet ~= "" and not LPT.sets[setName] then
if LPT.sets["InstanceLootHeroic" .. subSet] then
setName = "InstanceLootHeroic" .. subSet
elseif LPT.sets["InstanceLoot" .. subSet] then
setName = "InstanceLoot" .. subSet
elseif LPT.sets["InstanceLootLFR" .. subSet] then
setName = "InstanceLootLFR" .. subSet
else
setName = nil
end
end
if not setName then
chance = nil
else
for item, value, set in LPT:IterateSet(setName) do
if item == itemID then
if value and tonumber(value) > 0 then
chance = string.format("%.2f%%", value * 0.1)
else
chance = nil
end
break
end
end
end
end
lootButton = itemButtons[i]
lootButton.armorType:SetText(chance or '')
if armorType and armorType ~= '' then
lootButton.slot:SetText((slot ~= '' and slot..', ' or '') .. (armorType or ''))
end
end
end
hooksecurefunc("EncounterJournal_LootUpdate", UpdateLootChances)
hooksecurefunc(EncounterJournal.encounter.info.lootScroll, 'update', UpdateLootChances)