-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombat.lua
More file actions
77 lines (70 loc) · 2.53 KB
/
Copy pathcombat.lua
File metadata and controls
77 lines (70 loc) · 2.53 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
local addonName, ExadTweaks = ...
local Indicator = {}
local asuriFrame = false
local function InCombat(unit)
local _, _, class = UnitClass(unit)
if UnitAffectingCombat(unit) then
return true
else
if (IsActiveBattlefieldArena() and not (class == 1 or class == 2 or class == 4 or class == 11)) then
for i = 1, 5, 1 do
if UnitExists("arenapet" .. i .. "target") then
if UnitIsUnit(unit, "arena" .. i) then
return true
end
end
end
end
end
return false
end
local function CreateCombatIndicatorForUnit(frame)
if not Indicator[frame] then
local ciFrame = frame:CreateTexture(nil, "BORDER")
ciFrame:SetPoint("LEFT", frame, "RIGHT", -25, -5)
ciFrame:SetSize(60, 60)
ciFrame:SetTexture("Interface\\AddOns\\ExadTweaks\\textures\\CombatSwords")
ciFrame:Hide()
Indicator[frame] = ciFrame
frame:HookScript("OnEvent", function(self, event)
if event == "PLAYER_TARGET_CHANGED" or event == "PLAYER_FOCUS_CHANGED" then
if frame:IsShown() then
local unit = frame.unit
Indicator[self]:SetShown(InCombat(unit))
if UnitClassification(unit) ~= "normal" and not asuriFrame then
ciFrame:SetPoint("LEFT", frame, "RIGHT", 0, -5)
else
if asuriFrame and frame == FocusFrame then
ciFrame:SetPoint("LEFT", frame, "LEFT", -100, -14)
return
end
ciFrame:SetPoint("LEFT", frame, "RIGHT", -25, -5)
end
end
end
end)
end
end
local function checkCombat()
for frame, indicator in pairs(Indicator) do
if frame:IsShown() and frame.unit then
indicator:SetShown(InCombat(frame.unit))
else
if indicator:IsShown() then
indicator:Hide()
end
end
end
end
local f = CreateFrame("Frame")
f:SetScript("OnUpdate", checkCombat)
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", function(self, event, ...)
if event == "ADDON_LOADED" and ExadTweaks.db.CombatIndicator and (... == addonName) then
asuriFrame = ExadTweaks.db.AsuriFrame
CreateCombatIndicatorForUnit(TargetFrame)
if FocusFrame then
CreateCombatIndicatorForUnit(FocusFrame)
end
end
end)