This repository was archived by the owner on Dec 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDispelBorder.lua
More file actions
113 lines (95 loc) · 3.77 KB
/
DispelBorder.lua
File metadata and controls
113 lines (95 loc) · 3.77 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
local _G = getfenv(0)
local locale = GetLocale()
local _, playerClass = UnitClass("player")
local FocusFrameLoaded = IsAddOnLoaded("FocusFrame")
local scantip = CreateFrame("GameTooltip", "DispelBorderScan", nil, "GameTooltipTemplate")
local MAX_TARGET_BUFFS = MAX_TARGET_BUFFS
local STRING_SCHOOL_MAGIC =
locale == "deDE" and "Magie" or
locale == "esES" and "Mágica" or
locale == "esMX" and "Mágica" or
locale == "frFR" and "Magique" or
locale == "koKR" and "마법" or
locale == "zhCN" and "魔法" or
locale == "zhTW" and "魔法" or
locale == "ruRU" and "Магия" or "Magic"
local function SetBorder(index, unit, buffType, isEnemy)
local parent = unit == "target" and "TargetFrameBuff" or "FocusFrameBuff"
local buff = _G[parent .. index]
if not buff then return end
if not buff.stealable then
buff.stealable = buff:CreateTexture(nil, "OVERLAY", nil, 7)
buff.stealable:SetTexture("Interface\\AddOns\\DispelBorder\\UI-TargetingFrame-Stealable")
buff.stealable:SetPoint("CENTER", 0, 0)
buff.stealable:SetBlendMode("ADD")
end
-- Buff size changes depending on amount of buffs shown,
-- so just update it everytime
local width = buff:GetWidth() + 2
buff.stealable:SetWidth(width)
buff.stealable:SetHeight(width)
if isEnemy then
if buffType == STRING_SCHOOL_MAGIC or playerClass == "ROGUE" and buffType == "Enrage" then
return buff.stealable:Show()
end
end
buff.stealable:Hide()
end
local function DebuffButtonUpdate(unitID)
local unit = unitID or this.unit
if not unit or unit == "targettarget" then return end
if not FocusFrameLoaded and unit == "focus" then return end
if not UnitExists(unit) then return end
-- Reattach scantip everytime, if you don't
-- :SetUnitBuff() will randomly stop working after a while
scantip:SetOwner(WorldFrame, "ANCHOR_NONE")
local scantipTextLeft1 = _G.DispelBorderScanTextLeft1
local scantipTextRight1 = _G.DispelBorderScanTextRight1
local isEnemy = UnitIsEnemy("player", unit)
for i = 1, MAX_TARGET_BUFFS do
scantip:ClearLines()
scantipTextRight1:SetText(nil)
scantip:SetUnitBuff(unit, i)
if not scantipTextLeft1:GetText() then return end
SetBorder(i, unit, scantipTextRight1:GetText(), isEnemy)
end
end
local function ClassicUpdateAuras(self)
local unit = self.unit
if not UnitCanAttack("player", unit) then return end
local selfName = self:GetName().."Buff"
for i = 1, 32 do
local name, _, _, debuffType = UnitAura(unit, i, "HELPFUL")
if not name then return end
if debuffType == "Magic" then
_G[selfName..i.."Stealable"]:Show()
end
end
end
if WOW_PROJECT_ID then -- Classic TBC/Era
hooksecurefunc("TargetFrame_UpdateAuras", ClassicUpdateAuras)
elseif GetBuildInfo() == "2.4.3" then -- TBC old
hooksecurefunc("TargetDebuffButton_Update", DebuffButtonUpdate)
if FocusFrameLoaded then
hooksecurefunc("FocusDebuffButton_Update", DebuffButtonUpdate)
end
else -- Vanilla 1.12.1
local orig_TargetDebuffButton_Update = TargetDebuffButton_Update
TargetDebuffButton_Update = function()
orig_TargetDebuffButton_Update()
DebuffButtonUpdate()
end
if FocusFrameLoaded and FocusCore then
FocusCore:OnEvent("UNIT_AURA", function()
local buffData = FocusCore:GetBuffs()
local buffs = buffData.buffs
local isEnemy = FocusCore:GetData("unitIsEnemy")
for i = 1, 5 do
if buffs[i] then
local type = buffs[i].debuffType == "magic" and "Magic" -- fast strupper
SetBorder(i, "focus", type, isEnemy)
end
end
end)
end
end