-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathfilter.lua
More file actions
138 lines (108 loc) · 3.12 KB
/
filter.lua
File metadata and controls
138 lines (108 loc) · 3.12 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
if not Cursive.nampower then
return
end
local filter = {
}
filter.attackable = function(unit)
return UnitCanAttack("player", unit) and true or false
end
filter.player = function(unit)
return UnitIsPlayer(unit) and true or false
end
filter.notplayer = function(unit)
return not UnitIsPlayer(unit) and true or false
end
filter.infight = function(unit)
return UnitAffectingCombat(unit) and true or false
end
filter.hascurse = function(unit)
return Cursive.curses:HasAnyCurse(unit) and true or false
end
filter.alive = function(unit)
return not UnitIsDead(unit) and true or false
end
filter.range = function(unit)
if IsSpellInRange then
-- 16707 is hex which has 45 yd range
return IsSpellInRange(16707, unit) == 1 and true or false
else
return CheckInteractDistance(unit, 4) and true or false
end
end
filter.icon = function(unit)
return GetRaidTargetIndex(unit) and true or false
end
filter.normal = function(unit)
local elite = UnitClassification(unit)
return elite == "normal" and true or false
end
filter.elite = function(unit)
local elite = UnitClassification(unit)
return (elite == "elite" or elite == "rareelite") and true or false
end
filter.hostile = function(unit)
return UnitIsEnemy("player", unit) and true or false
end
filter.notignored = function(unit)
if not Cursive.db.profile.ignorelist or table.getn(Cursive.db.profile.ignorelist) == 0 then
return true
end
local unitName = UnitName(unit)
if not unitName then
return true
end
for _, str in ipairs(Cursive.db.profile.ignorelist) do
if string.find(string.lower(unitName), string.lower(str), nil, not Cursive.db.profile.ignorelistuseregex) then
return false
end
end
return true
end
Cursive.filter = filter
function Cursive:ShouldDisplayGuid(guid)
-- never display units that don't exist
if not UnitExists(guid) then
return false
end
-- never display dead units
if not Cursive.filter.alive(guid) then
return false
end
local _, targetGuid = UnitExists("target")
-- always show target if attackable
if (targetGuid == guid) and filter.attackable(guid) then
return true
end
-- always show raid marks if attackable and not in combat or this guid is affecting combat
if filter.icon(guid) and filter.attackable(guid) and (not UnitAffectingCombat("player") or UnitAffectingCombat(guid)) then
return true
end
if Cursive.db.profile.filterincombat and not filter.infight(guid) then
return false
end
if Cursive.db.profile.filterhascurse and not filter.hascurse(guid) then
return false
end
if Cursive.db.profile.filterhostile and not filter.hostile(guid) then
return false
end
if Cursive.db.profile.filterattackable and not filter.attackable(guid) then
return false
end
if Cursive.db.profile.filterrange and not filter.range(guid) then
return false
end
if Cursive.db.profile.filterraidmark and not filter.icon(guid) then
return false
end
if Cursive.db.profile.filterplayer and not filter.player(guid) then
return false
end
if Cursive.db.profile.filternotplayer and not filter.notplayer(guid) then
return false
end
if Cursive.db.profile.filterignored and not filter.notignored(guid) then
return false
end
return true
end