-
Notifications
You must be signed in to change notification settings - Fork 1
/
HonorAssistToolTip.lua
72 lines (52 loc) · 2.94 KB
/
HonorAssistToolTip.lua
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
local addonName, addonTable = ...
HonorAssist = addonTable
local currentPlayerFaction, _ = UnitFactionGroup("player")
GameTooltip:HookScript("OnTooltipSetUnit", function(self)
local frameUnit = nil
if UnitIsPlayer("mouseover") then
frameUnit ="mouseover"
elseif string.match(GetMouseFocus():GetName():lower(), "targettargettarget") then
frameUnit = "targettargettarget"
elseif string.match(GetMouseFocus():GetName():lower(), "targettarget") then
frameUnit = "targettarget"
elseif string.match(GetMouseFocus():GetName():lower(), "target") then
frameUnit = "target"
end
if frameUnit ~= nil and UnitIsPlayer(frameUnit) then
playerData = {}
playerData.Faction, _ = UnitFactionGroup(frameUnit)
playerData.Level = UnitLevel(frameUnit)
-- TODO need to make this dynamic based on players level (the level cap to show honor)
-- IE only show for players that would give you honor not assuming player is MAX level
if HonorAssistDEBUG then
print("This is frameUnit " .. " Frame: " .. GetMouseFocus():GetName() .. " playerData.Faction: " .. playerData.Faction .. " playerData.Level: ".. playerData.Level)
end
if currentPlayerFaction ~= playerData.Faction and tonumber(playerData.Level) > 47 then
playerData.Rank = UnitPVPRank(frameUnit)
playerData.Name = UnitName(frameUnit)
playerData.baseHealth = ( UnitHealth(frameUnit) / UnitHealthMax(frameUnit) )
HonorAssist:AddHonorLinesToTooltip(self, playerData)
end
end
end)
function HonorAssist:AddHonorLinesToTooltip(tooltip, playerData)
if HonorAssistDEBUG then
print("OnTooltipSetUnit playerName: " .. playerData.Name .. " baseHealth: " .. playerData.baseHealth .. " playerLevel: " .. playerData.Level .. " playerRank: " .. playerData.Rank)
end
local dailyKillCount, totalKillCount = HonorAssist:GetPlayerDailyKillCount(playerData.Name)
if HonorAssistDEBUG then
print("OnTooltipSetUnit dailyKillCount: " .. dailyKillCount .. " totalKillCount: " .. totalKillCount)
end
local honorPercentLeft, realisticHonor = HonorAssist:GetPlayerEstimatedHonor(dailyKillCount, playerData.baseHealth, playerData.Level, playerData.Rank)
-- TODO: Modify algo for spliting honor with nearby raid members
if honorPercentLeft > 0 then
tooltip:AddLine("|cff00ff00Honor Value : " .. "|cFF00FFFF" .. honorPercentLeft * 100 .. "%", 1, 1, 1)
tooltip:AddLine("|cff00ff00Estimated Honor : " .. "|cFF00FFFF" .. HonorAssist:Round(realisticHonor), 1, 1, 1)
else
tooltip:AddLine("|cffff0000NO HONOR", 1, 1, 1)
end
-- TODO: Add in toggle for viewing daily kills
tooltip:AddLine("Daily kills : " .. "|cFF40FB40" .. tostring(dailyKillCount), 1, 1, 1)
-- TODO: Add in toggle for viewing total kills
tooltip:AddLine("Lifetime kills : " .. "|cFF0088FF" .. tostring(totalKillCount), 1, 1, 1)
end