Skip to content

Commit f5c22aa

Browse files
committed
new range for unitframes
1 parent 9b063b7 commit f5c22aa

File tree

12 files changed

+324
-1601
lines changed

12 files changed

+324
-1601
lines changed

Diff for: ElvUI/Core/Defaults/Global.lua

+114-1
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ G.datatexts = {
125125
G.nameplates = {}
126126

127127
G.unitframe = {
128-
aurafilters = {},
129128
aurawatch = {},
129+
aurafilters = {},
130130
raidDebuffIndicator = {
131131
instanceFilter = 'RaidDebuffs',
132132
otherFilter = 'CCDebuffs'
@@ -140,6 +140,119 @@ G.unitframe = {
140140
yOffset = 0,
141141
justifyH = 'CENTER',
142142
attachTextTo = 'Health'
143+
},
144+
rangeCheck = {
145+
FRIENDLY = {
146+
DEATHKNIGHT = {},
147+
DEMONHUNTER = {},
148+
DRUID = {
149+
['8936'] = 'Regrowth'
150+
},
151+
EVOKER = {
152+
['355913'] = 'Emerald Blossom'
153+
},
154+
HUNTER = {},
155+
MAGE = {
156+
['1459'] = 'Arcane Intellect'
157+
},
158+
MONK = {
159+
['116670'] = 'Vivify'
160+
},
161+
PALADIN = {
162+
['85673'] = 'Word of Glory'
163+
},
164+
PRIEST = {
165+
['17'] = E.Retail and 'Power Word: Shield' or nil,
166+
['2050'] = not E.Retail and 'Lesser Heal' or nil
167+
},
168+
ROGUE = {
169+
['36554'] = E.Retail and 'Shadowstep' or nil,
170+
['921'] = E.Retail and 'Pick Pocket' or nil
171+
},
172+
SHAMAN = {
173+
['8004'] = 'Healing Surge'
174+
},
175+
WARLOCK = {
176+
['5697'] = 'Unending Breath'
177+
},
178+
WARRIOR = {}
179+
},
180+
ENEMY = {
181+
DEATHKNIGHT = {
182+
['49576'] = 'Death Grip'
183+
},
184+
DEMONHUNTER = {
185+
['278326'] = 'Consume Magic'
186+
},
187+
DRUID = {
188+
['8921'] = 'Moonfire'
189+
},
190+
EVOKER = {
191+
['362969'] = 'Azure Strike'
192+
},
193+
HUNTER = {
194+
['75'] = 'Auto Shot'
195+
},
196+
MAGE = {
197+
['2139'] = 'Counterspell'
198+
},
199+
MONK = {
200+
['115546'] = 'Provoke'
201+
},
202+
PALADIN = {
203+
['20473'] = 'Holy Shock',
204+
['20271'] = 'Judgement'
205+
},
206+
PRIEST = {
207+
['589'] = 'Shadow Word: Pain'
208+
},
209+
ROGUE = {
210+
['36554'] = 'Shadowstep'
211+
},
212+
SHAMAN = {
213+
['8042'] = 'Earth Shock',
214+
['188196'] = E.Retail and 'Lightning Bolt' or nil,
215+
['403'] = not E.Retail and 'Lightning Bolt' or nil
216+
},
217+
WARLOCK = {
218+
['234153'] = E.Retail and 'Drain Life' or nil,
219+
['348'] = not E.Retail and 'Immolate' or nil,
220+
},
221+
WARRIOR = {
222+
['355'] = 'Taunt'
223+
}
224+
},
225+
RESURRECT = {
226+
DEATHKNIGHT = {
227+
['61999'] = 'Raise Ally'
228+
},
229+
DEMONHUNTER = {},
230+
DRUID = {
231+
['50769'] = 'Revive'
232+
},
233+
EVOKER = {
234+
['361227'] = 'Return'
235+
},
236+
HUNTER = {},
237+
MAGE = {},
238+
MONK = {
239+
['115178'] = 'Resuscitate'
240+
},
241+
PALADIN = {
242+
['7328'] = 'Redemption'
243+
},
244+
PRIEST = {
245+
['2006'] = 'Resurrection'
246+
},
247+
ROGUE = {},
248+
SHAMAN = {
249+
['2008'] = 'Ancestral Spirit'
250+
},
251+
WARLOCK = {
252+
['20707'] = not E.Classic and 'Soulstone' or nil
253+
},
254+
WARRIOR = {}
255+
}
143256
}
144257
}
145258

Diff for: ElvUI/Core/General/Tags.lua

-24
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ local NP = E:GetModule('NamePlates')
33
local ElvUF = E.oUF
44
local Tags = ElvUF.Tags
55

6-
local RangeCheck = E.Libs.RangeCheck
76
local Translit = E.Libs.Translit
87
local translitMark = '!'
98

@@ -239,26 +238,6 @@ end
239238
-- Looping
240239
------------------------------------------------------------------------
241240

242-
for _, vars in ipairs({'',':min',':max'}) do
243-
E:AddTag(format('range%s', vars), 0.1, function(unit)
244-
if UnitIsConnected(unit) and not UnitIsUnit(unit, 'player') then
245-
local minRange, maxRange = RangeCheck:GetRange(unit, true)
246-
247-
if vars == ':min' then
248-
if minRange then
249-
return format('%d', minRange)
250-
end
251-
elseif vars == ':max' then
252-
if maxRange then
253-
return format('%d', maxRange)
254-
end
255-
elseif minRange or maxRange then
256-
return format('%s - %s', minRange or '??', maxRange or '??')
257-
end
258-
end
259-
end)
260-
end
261-
262241
for textFormat in pairs(E.GetFormattedTextStyles) do
263242
local tagFormat = strlower(gsub(textFormat, '_', '-'))
264243
E:AddTag(format('health:%s', tagFormat), 'UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_FLAGS_CHANGED', function(unit)
@@ -1658,9 +1637,6 @@ E.TagInfo = {
16581637
['quest:full'] = { category = 'Quest', description = "Quest full" },
16591638
['quest:text'] = { category = 'Quest', description = "Quest text" },
16601639
-- Range
1661-
['range'] = { category = 'Range', description = "Displays the range" },
1662-
['range:min'] = { category = 'Range', description = "Displays the min range" },
1663-
['range:max'] = { category = 'Range', description = "Displays the max range" },
16641640
['distance'] = { category = 'Range', description = "Displays the distance" },
16651641
['nearbyplayers:4'] = { category = 'Range', description = "Displays all players within 4 yards" },
16661642
['nearbyplayers:8'] = { category = 'Range', description = "Displays all players within 8 yards" },

Diff for: ElvUI/Core/Modules/UnitFrames/Elements/Range.lua

+86-26
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,114 @@
11
local E, L, V, P, G = unpack(ElvUI)
22
local UF = E:GetModule('UnitFrames')
3-
local RangeCheck = E.Libs.RangeCheck
43

5-
local UnitCanAttack = UnitCanAttack
4+
local next = next
5+
local tonumber = tonumber
6+
7+
local UnitInPhase = UnitInPhase
68
local UnitInRange = UnitInRange
7-
local UnitIsConnected = UnitIsConnected
89
local UnitIsPlayer = UnitIsPlayer
9-
local UnitIsUnit = UnitIsUnit
10-
local UnitInPhase = UnitInPhase
10+
local UnitCanAttack = UnitCanAttack
11+
local UnitIsConnected = UnitIsConnected
12+
local UnitIsDeadOrGhost = UnitIsDeadOrGhost
13+
local IsSpellKnownOrOverridesKnown = IsSpellKnownOrOverridesKnown
14+
15+
local IsSpellInRange = C_Spell.IsSpellInRange
1116
local UnitPhaseReason = UnitPhaseReason
1217

13-
local function getMaxRange(unit)
14-
local minRange, maxRange = RangeCheck:GetRange(unit, true, true)
15-
return (not minRange) or maxRange
18+
local list = {}
19+
UF.RangeSpells = list
20+
21+
function UF:UpdateRangeList(db)
22+
local spells = {}
23+
for spell, value in next, db do
24+
if value then
25+
local id = tonumber(spell)
26+
if not id then -- support spells by name
27+
local _, _, _, _, _, _, spellID = E:GetSpellInfo(spell)
28+
if spellID then
29+
id = spellID
30+
end
31+
end
32+
33+
if id and IsSpellKnownOrOverridesKnown(id) then
34+
spells[id] = true
35+
end
36+
end
37+
end
38+
39+
return spells
1640
end
1741

18-
local function friendlyIsInRange(realUnit)
42+
function UF:UpdateRangeSpells()
43+
local db = E.global.unitframe.rangeCheck
44+
if db then
45+
list[1] = UF:UpdateRangeList(db.RESURRECT[E.myclass])
46+
list[2] = UF:UpdateRangeList(db.ENEMY[E.myclass])
47+
list[3] = UF:UpdateRangeList(db.FRIENDLY[E.myclass])
48+
end
49+
end
50+
51+
function UF:UnitSpellRange(unit, spells)
52+
for spell in next, spells do
53+
local range = IsSpellInRange(spell, unit)
54+
if range ~= nil then
55+
return range
56+
end
57+
end
58+
end
59+
60+
function UF:UnitInSpellsRange(unit, which)
61+
local spells = list[which]
62+
local range = next(spells) and UF:UnitSpellRange(unit, spells)
63+
if range ~= nil then
64+
return range
65+
end
66+
67+
return true -- no spells assume range is maxed
68+
end
69+
70+
function UF:FriendlyInRange(realUnit)
1971
local unit = E:GetGroupUnit(realUnit) or realUnit
2072

21-
if UnitIsPlayer(unit) and (E.Retail and UnitPhaseReason(unit) or not E.Retail and not UnitInPhase(unit)) then
22-
return false -- is not in same phase
73+
if UnitIsPlayer(unit) then
74+
if E.Retail then
75+
if UnitPhaseReason(unit) then
76+
return false
77+
end
78+
elseif not UnitInPhase(unit) then
79+
return false
80+
end
2381
end
2482

25-
local inRange, checkedRange = UnitInRange(unit)
26-
if checkedRange and not inRange then
83+
local range, checked = UnitInRange(unit)
84+
if checked and not range then
2785
return false -- blizz checked and said the unit is out of range
2886
end
2987

30-
return getMaxRange(unit)
88+
return UF:UnitInSpellsRange(unit, 3)
3189
end
3290

3391
function UF:UpdateRange(unit)
34-
if not self.Fader then return end
35-
local alpha
92+
local element = self.Fader
93+
if not element then return end
3694

37-
unit = unit or self.unit
95+
if not unit then
96+
unit = self.unit
97+
end
3898

3999
if self.forceInRange or unit == 'player' then
40-
alpha = self.Fader.MaxAlpha
100+
element.RangeAlpha = element.MaxAlpha
41101
elseif self.forceNotInRange then
42-
alpha = self.Fader.MinAlpha
102+
element.RangeAlpha = element.MinAlpha
43103
elseif unit then
44-
if UnitCanAttack('player', unit) or UnitIsUnit(unit, 'pet') then
45-
alpha = (getMaxRange(unit) and self.Fader.MaxAlpha) or self.Fader.MinAlpha
46-
else
47-
alpha = (UnitIsConnected(unit) and friendlyIsInRange(unit) and self.Fader.MaxAlpha) or self.Fader.MinAlpha
104+
if UnitIsDeadOrGhost(unit) then
105+
element.RangeAlpha = UF:UnitInSpellsRange(unit, 1) and element.MaxAlpha or element.MinAlpha
106+
elseif UnitCanAttack('player', unit) then
107+
element.RangeAlpha = UF:UnitInSpellsRange(unit, 2) and element.MaxAlpha or element.MinAlpha
108+
elseif UnitIsConnected(unit) then
109+
element.RangeAlpha = UF:FriendlyInRange(unit) and element.MaxAlpha or element.MinAlpha
48110
end
49111
else
50-
alpha = self.Fader.MaxAlpha
112+
element.RangeAlpha = element.MaxAlpha
51113
end
52-
53-
self.Fader.RangeAlpha = alpha
54114
end

Diff for: ElvUI/Core/Modules/UnitFrames/UnitFrames.lua

+1
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,7 @@ end
10241024

10251025
function UF:PLAYER_ENTERING_WORLD(_, initLogin, isReload)
10261026
UF:RegisterRaidDebuffIndicator()
1027+
UF:UpdateRangeSpells()
10271028

10281029
local _, instanceType = GetInstanceInfo()
10291030
if instanceType == 'raid' then

Diff for: ElvUI/Core/init.lua

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ do
157157
E:AddLib('LAB', 'LibActionButton-1.0-ElvUI')
158158
E:AddLib('LDB', 'LibDataBroker-1.1')
159159
E:AddLib('SimpleSticky', 'LibSimpleSticky-1.0')
160-
E:AddLib('RangeCheck', 'LibRangeCheck-3.0-ElvUI')
161160
E:AddLib('CustomGlow', 'LibCustomGlow-1.0')
162161
E:AddLib('Deflate', 'LibDeflate')
163162
E:AddLib('Masque', 'Masque', true)

Diff for: ElvUI_Libraries/Cata/Libs.xml

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
<Script file='..\Classic\LibClassicSpecs\LibClassicSpecs.lua'/>
2727

28-
<Script file='..\Core\LibRangeCheck-3.0\LibRangeCheck-3.0.lua'/>
2928
<Script file='..\Core\LibAceConfigHelper\LibAceConfigHelper.lua'/>
3029
<Script file='..\Core\LibCustomGlow-1.0\LibCustomGlow-1.0.lua'/>
3130
<Script file='..\Core\LibActionButton-1.0\LibActionButton-1.0.lua'/>

Diff for: ElvUI_Libraries/Classic/Libs.xml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<Script file='..\Classic\LibQuestXP\LibQuestXP.lua'/>
2828
<Script file='..\Classic\LibClassicSpecs\LibClassicSpecs.lua'/>
2929

30-
<Script file='..\Core\LibRangeCheck-3.0\LibRangeCheck-3.0.lua'/>
3130
<Script file='..\Core\LibAceConfigHelper\LibAceConfigHelper.lua'/>
3231
<Script file='..\Core\LibCustomGlow-1.0\LibCustomGlow-1.0.lua'/>
3332
<Script file='..\Core\LibActionButton-1.0\LibActionButton-1.0.lua'/>

Diff for: ElvUI_Libraries/Core/LibRangeCheck-3.0/LICENSE.txt

-21
This file was deleted.

0 commit comments

Comments
 (0)