-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFastTOT.lua
More file actions
60 lines (53 loc) · 1.86 KB
/
Copy pathFastTOT.lua
File metadata and controls
60 lines (53 loc) · 1.86 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
-- This addon utilizes SuperWoW's guid-based events to update the target of target frame instead of updating every frame.
if not SUPERWOW_VERSION then
DEFAULT_CHAT_FRAME:AddMessage("FastTOT requires SuperWoW to work.")
return
end
local ok, result = pcall(GetCVar, "PB_FilterGuidEvents")
if result == "1" then
DEFAULT_CHAT_FRAME:AddMessage("FastTOT requires you to disable \"Filter GUID Events\" in PerfBoost.")
return
end
local incompatibleAddons = {"pfUI", "-DragonflightReloaded", "-Dragonflight3", "DragonflightUI-Reforged"}
local loadFrame = CreateFrame("Frame")
loadFrame:RegisterEvent("VARIABLES_LOADED")
loadFrame:SetScript("OnEvent", function()
for _, addon in ipairs(incompatibleAddons) do
if IsAddOnLoaded(addon) then
DEFAULT_CHAT_FRAME:AddMessage("FastTOT is not compatible with "..addon..".")
return
end
end
loadFrame:UnregisterAllEvents()
FastTOT_Initialize()
end)
function FastTOT_Initialize()
TargetofTargetFrame:SetScript("OnUpdate", nil)
local function UpdateTargetofTarget()
local prevThis = this
this = TargetofTargetFrame
TargetofTarget_OnUpdate()
this = prevThis
end
local currentTOT
local TOTScanner = function()
local exists, guid = UnitExists("targettarget")
if currentTOT ~= guid then
currentTOT = guid
UpdateTargetofTarget()
end
end
local f = CreateFrame("Frame", "FastTOTHandler")
f:RegisterEvent("PLAYER_TARGET_CHANGED")
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("UNIT_AURA")
f:SetScript("OnEvent", function()
if event == "PLAYER_TARGET_CHANGED" then
f:SetScript("OnUpdate", UnitExists("target") and TOTScanner)
return
end
if UnitIsUnit(arg1, "targettarget") then
UpdateTargetofTarget()
end
end)
end