Report abuse

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
local SetUnitAura, SetUnitBuff, SetUnitDebuff = _G.GameTooltip.SetUnitAura, _G.GameTooltip.SetUnitBuff, _G.GameTooltip.SetUnitDebuff

local tconcat = _G.table.concat
local tinsert = _G.tinsert
local wipe = _G.wipe
local UnitName = _G.UnitName
local UnitClass = _G.UnitClass
local UnitVehicleSeatInfo = _G.UnitVehicleSeatInfo
local UnitAura = _G.UnitAura
local names = {}

local colors = setmetatable({}, {__index = function(t, class)
	local c = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]
	if c then
		t[class] = ("ff%02x%02x%02x"):format(c.r * 255, c.g * 255, c.b * 255)
	else
		t[class] = "ffffffff"
	end
	return t[class]
end })

local function hook(original, ...)
	original(...)
	
	wipe(names)
	local _, unitid, id, filter = ...
	if original == SetUnitBuff then
		filter = "HELPFUL"
	elseif original == SetUnitDebuff then
		filter = "HARMFUL"
	end
	
	local _, _, _, _, _, _, _, caster = UnitAura(unitid, id, filter)
	if caster then
		local name, class
		_, name = UnitVehicleSeatInfo(caster, 1) 
		if name then
			_, class = UnitClass(name)
			tinsert(names, ("|c%s%s|r"):format(colors[class], name))
			
			_, name = UnitVehicleSeatInfo(caster, 2) 
			if name then
				_, class = UnitClass(name)
				tinsert(names, ("|c%s%s|r"):format(colors[class], name))
			end
		else
			_, class = UnitClass(caster)
			tinsert(names, ("|c%s%s|r"):format(colors[class], UnitName(caster)))
		end
		GameTooltip:AddLine(tconcat(names, ", "))
		GameTooltip:Show()
	end
end

 -- Install the hooks
GameTooltip.SetUnitAura = function( ... )
	hook( SetUnitAura, ... )
end
GameTooltip.SetUnitBuff = function( ... )
	hook( SetUnitBuff, ... )
end
GameTooltip.SetUnitDebuff = function( ... )
	hook( SetUnitDebuff, ... )
end