@@ -5,223 +5,119 @@ local RangeAlt = Grid2.statusPrototype:new("rangealt")
55
66local Grid2 = Grid2
77local tonumber = tonumber
8- local tostring = tostring
9- local IsInInstance = IsInInstance
108local UnitIsUnit = UnitIsUnit
11- local UnitInRange = UnitInRange
129local UnitCanAttack = UnitCanAttack
13- local UnitCanAssist = UnitCanAssist
1410local InCombatLockdown = InCombatLockdown
1511local UnitIsDeadOrGhost = UnitIsDeadOrGhost
16- local CheckInteractOriginal = CheckInteractDistance
1712local CheckInteractDistance = CheckInteractDistance
18- local CheckHostileDistance = CheckInteractDistance
19- local UnitPhaseReason = UnitPhaseReason or Grid2 .Dummy
20-
21- local grouped_units = Grid2 .grouped_units
2213local playerClass = Grid2 .playerClass
23- local isRangeAvail = false -- all versions for now
24-
2514local GetSpellInfo = Grid2 .API .GetSpellInfo
2615local IsSpellInRange = Grid2 .API .IsSpellInRange
2716
2817---- ---------------------------------------------------------------------
29- -- CheckInteractDistance() replacements
18+ -- Check Range Spells Info
3019---- ---------------------------------------------------------------------
31-
32- if not isRangeAvail then
33- -- range spells data
20+ local spellHostile , spellFriendly = nil , nil
21+ do
22+ local function IVS ( spellID ) return IsPlayerSpell ( spellID ) and spellID end
3423 local getHostile , getFriendly
35- local function IVS (spellID ) return IsPlayerSpell (spellID ) and spellID end
36- if Grid2 .isWoW90 then -- retail
37- if playerClass == ' DRUID' then
38- getHostile = function () return 8921 end -- Moonfire
39- getFriendly = function () return 8936 end -- Regrowth
40- elseif playerClass == ' PRIEST' then
41- getHostile = function () return 585 end -- Smite
42- getFriendly = function () return 2061 end -- Flash Heal
43- elseif playerClass == ' SHAMAN' then
44- getHostile = function () return 188196 end -- Lightning Bolt
45- getFriendly = function () return 8004 end -- Healing Surge
46- elseif playerClass == ' PALADIN' then
47- getHostile = function () return 62124 end -- Hand of Reckoning
48- getFriendly = function () return 19750 end -- Flash of light
49- elseif playerClass == ' MONK' then
50- getHostile = function () return 115546 end -- Provoke
51- getFriendly = function () return 116670 end -- Vivify
52- elseif playerClass == ' EVOKER' then
53- getHostile = function () return 361469 end -- Living flame
54- getFriendly = function () return 355913 end -- Emerald Blossom
55- elseif playerClass == ' WARLOCK' then
56- getHostile = function () return 686 end -- Shadow Bolt
57- getFriendly = function () return 20707 end -- Soulstone
58- elseif playerClass == ' WARRIOR' then
59- getHostile = function () return 355 end -- Taunt
60- getFriendly = function () return nil end -- no avail
61- elseif playerClass == ' DEMONHUNTER' then
62- getHostile = function () return 185123 end -- Throw Glaive
63- getFriendly = function () return nil end -- no avail
64- elseif playerClass == ' HUNTER' then
65- getHostile = function () return IVS (193455 ) or IVS (19434 ) or IVS (132031 ) end -- Cobra Shot, Aimed Short, Steady shot
66- getFriendly = function () return nil end -- no avail
67- elseif playerClass == ' ROGUE' then
68- getHostile = function () return IVS (36554 ) or IVS (6770 ) end -- Shadowstep, Sap
69- getFriendly = function () return IVS (36554 ) end -- Shadowstep
70- elseif playerClass == ' DEATHKNIGHT' then
71- getHostile = function () return IVS (47541 ) or IVS (49576 ) end -- Death Coil, Death Grip
72- getFriendly = function () return IVS (47541 ) end -- Death Coil
73- elseif playerClass == ' MAGE' then
74- getHostile = function () return IVS (116 ) or IVS (30451 ) or IVS (133 ) end -- Frostbolt, Arcane Blast, Fireball
75- getFriendly = function () return 1459 end -- Arcane intellect
76- end
77- else -- classic
78- if playerClass == ' DRUID' then
79- getHostile = function () return 5176 end -- Wrath
80- getFriendly = function () return 5185 end -- Healing Touchaw
81- elseif playerClass == ' PRIEST' then
82- getHostile = function () return 585 end -- Smite
83- getFriendly = function () return 2050 end -- Lesser Heal
84- elseif playerClass == ' SHAMAN' then
85- getHostile = function () return 403 end -- Lightning Bolt
86- getFriendly = function () return 331 end -- Healing Wave
87- elseif playerClass == ' PALADIN' then
88- getHostile = function () return IVS (20271 ) end -- Judgement
89- getFriendly = function () return 635 end -- Holy Light
90- elseif playerClass == ' WARLOCK' then
91- getHostile = function () return 686 end -- Shadow Bolt
92- getFriendly = function () return IVS (20707 ) end -- Soulstone
93- elseif playerClass == ' WARRIOR' then
94- getHostile = function () return IVS (355 ) or IVS (772 ) end -- Taunt, Rend
95- getFriendly = function () return nil end -- no avail
96- elseif playerClass == ' HUNTER' then
97- getHostile = function () return IVS (3044 ) or IVS (1978 ) end -- Arcane Shot, Serpent Sting
98- getFriendly = function () return nil end -- no avail
99- elseif playerClass == ' ROGUE' then
100- getHostile = function () return IVS (1752 ) end -- Sinister Strike
101- getFriendly = function () return nil end -- no avail
102- elseif playerClass == ' MAGE' then
103- getHostile = function () return IVS (116 ) or IVS (133 ) end -- Frostbolt, Fireball
104- getFriendly = function () return IVS (1459 ) end -- Arcane intellect
105- elseif playerClass == ' DEATHKNIGHT' then
106- getHostile = function () return IVS (47541 ) or IVS (49576 ) end -- Death Coil, Death Grip
107- getFriendly = function () return IVS (47541 ) end -- Death Coil
108- elseif playerClass == ' MONK' then
109- getHostile = function () return 115546 end -- Provoke
110- getFriendly = function () return 116670 end -- Vivify
111- end
24+ if playerClass == ' DRUID' then
25+ getHostile = function () return 8921 end -- Moonfire
26+ getFriendly = function () return 8936 end -- Regrowth
27+ elseif playerClass == ' PRIEST' then
28+ getHostile = function () return 585 end -- Smite
29+ getFriendly = function () return 2061 end -- Flash Heal
30+ elseif playerClass == ' SHAMAN' then
31+ getHostile = function () return 188196 end -- Lightning Bolt
32+ getFriendly = function () return 8004 end -- Healing Surge
33+ elseif playerClass == ' PALADIN' then
34+ getHostile = function () return 62124 end -- Hand of Reckoning
35+ getFriendly = function () return 19750 end -- Flash of light
36+ elseif playerClass == ' MONK' then
37+ getHostile = function () return 115546 end -- Provoke
38+ getFriendly = function () return 116670 end -- Vivify
39+ elseif playerClass == ' EVOKER' then
40+ getHostile = function () return 361469 end -- Living flame
41+ getFriendly = function () return 355913 end -- Emerald Blossom
42+ elseif playerClass == ' WARLOCK' then
43+ getHostile = function () return 686 end -- Shadow Bolt
44+ getFriendly = function () return 20707 end -- Soulstone
45+ elseif playerClass == ' WARRIOR' then
46+ getHostile = function () return 355 end -- Taunt
47+ getFriendly = function () return nil end -- no avail
48+ elseif playerClass == ' DEMONHUNTER' then
49+ getHostile = function () return 185123 end -- Throw Glaive
50+ getFriendly = function () return nil end -- no avail
51+ elseif playerClass == ' HUNTER' then
52+ getHostile = function () return IVS (193455 ) or IVS (19434 ) or IVS (132031 ) end -- Cobra Shot, Aimed Short, Steady shot
53+ getFriendly = function () return nil end -- no avail
54+ elseif playerClass == ' ROGUE' then
55+ getHostile = function () return IVS (36554 ) or IVS (6770 ) end -- Shadowstep, Sap
56+ getFriendly = function () return IVS (36554 ) end -- Shadowstep
57+ elseif playerClass == ' DEATHKNIGHT' then
58+ getHostile = function () return IVS (47541 ) or IVS (49576 ) end -- Death Coil, Death Grip
59+ getFriendly = function () return IVS (47541 ) end -- Death Coil
60+ elseif playerClass == ' MAGE' then
61+ getHostile = function () return IVS (116 ) or IVS (30451 ) or IVS (133 ) end -- Frostbolt, Arcane Blast, Fireball
62+ getFriendly = function () return 1459 end -- Arcane intellect
11263 end
113-
114- -- update range spells, called from Grid2.lua
115- local spellHostile , spellFriendly = nil , nil
64+ -- update range spells, called from GridCore.lua
11665 function Grid2 :UpdatePlayerRangeSpells ()
11766 spellHostile = GetSpellInfo ( getHostile () )
11867 spellFriendly = GetSpellInfo ( getFriendly () )
11968 end
120-
121- -- overrided functions
122- CheckHostileDistance = function (unit )
123- return spellHostile == nil or IsSpellInRange (spellHostile , unit ) == 1
124- end
125-
126- CheckInteractDistance = function (unit )
127- if UnitCanAttack (' player' , unit ) then
128- return spellHostile == nil or IsSpellInRange (spellHostile , unit ) == 1
129- elseif spellFriendly then
130- return IsSpellInRange (spellFriendly , unit ) == 1
131- else
132- return InCombatLockdown () or CheckInteractOriginal (unit ,4 )
133- end
134- end
135-
136- if Grid2 .secretsEnabled then -- midnight
137- UnitInRange = CheckInteractDistance
138- end
139-
14069end
14170
14271---- --------------------------------------------------------------------
14372-- Range status
14473---- ---------------------------------------------------------------------
14574
146- local worldRange40 -- special case to be able to see in range grouped players of the other faction in open world
14775local friendlySpell -- friendly spell configured by the user (spell name)
76+
14877local hostileSpell -- hostile spell configured by the user (spell name)
14978
150- local rezSpellID = ({ -- classic has the same spellIDs
151- DRUID = 20484 ,
152- PRIEST = 2006 ,
153- PALADIN = 7328 ,
154- SHAMAN = 2008 ,
155- MONK = 115178 ,
156- DEATHKNIGHT = 61999 ,
157- WARLOCK = 20707 ,
158- EVOKER = 361227 ,
159- })[playerClass ]
160- local rezSpell = rezSpellID and GetSpellInfo (rezSpellID )
79+ local playerCanHeal = ({DRUID = true ,PRIEST = true ,SHAMAN = true ,PALADIN = true ,MONK = true ,EVOKER = true })[playerClass ]
80+
81+ local rezSpellID = ({DRUID = 20484 ,PRIEST = 2006 ,PALADIN = 7328 ,SHAMAN = 2008 ,MONK = 115178 ,DEATHKNIGHT = 61999 ,WARLOCK = 20707 ,EVOKER = 361227 })[playerClass ]
16182
162- local rangeSpellID = ({
163- DRUID = Grid2 .isClassic and 774 or 8936 ,
164- PRIEST = Grid2 .isClassic and 2050 or 2061 ,
165- SHAMAN = Grid2 .isClassic and 25357 or 8004 ,
166- PALADIN = Grid2 .isClassic and 635 or 19750 ,
167- MONK = 116670 ,
168- EVOKER = 355913 ,
169- })[playerClass ]
170- local rangeSpell = rangeSpellID and GetSpellInfo (rangeSpellID )
83+ local rezSpell = rezSpellID and GetSpellInfo (rezSpellID )
17184
17285local Ranges = {
17386 [99 ] = UnitIsVisible ,
174- [10 ] = isRangeAvail and function (unit )
175- return CheckInteractDistance (unit ,3 )
176- end or nil ,
177- [28 ] = isRangeAvail and function (unit )
178- return CheckInteractDistance (unit ,4 )
179- end or nil ,
18087 [38 ] = function (unit )
18188 if UnitIsUnit (unit ," player" ) then
18289 return true
183- elseif grouped_units [unit ] and unit ~= ' pet' then
184- return UnitInRange (unit )
90+ elseif UnitCanAttack (' player' , unit ) then
91+ return spellHostile == nil or IsSpellInRange (spellHostile , unit ) == 1
92+ elseif spellFriendly then
93+ return IsSpellInRange (spellFriendly , unit ) == 1
18594 else
186- return CheckInteractDistance ( unit , 4 ) -- 28 yards for non grouped units: target/focus/bossX or when solo (because UnitInRange() does not work for pet when solo )
95+ return InCombatLockdown () or CheckInteractDistance ( unit , 4 )
18796 end
18897 end ,
18998 [" heal" ] = function (unit )
190- if UnitPhaseReason (unit ) then
191- return
192- elseif UnitIsUnit (unit ,' player' ) then
99+ if UnitIsUnit (unit , ' player' ) then
193100 return true
194101 elseif UnitCanAttack (' player' , unit ) then
195- return CheckHostileDistance (unit ,4 ) -- 28y for enemies
196- elseif worldRange40 and grouped_units [unit ] then
197- return UnitInRange (unit )
102+ return spellHostile == nil or IsSpellInRange (spellHostile , unit ) == 1
198103 else
199- return IsSpellInRange (UnitIsDeadOrGhost (unit ) and rezSpell or rangeSpell , unit ) == 1
104+ return IsSpellInRange (UnitIsDeadOrGhost (unit ) and rezSpell or spellFriendly , unit ) == 1
200105 end
201106 end ,
202107 [" spell" ] = function (unit )
203- if not UnitPhaseReason (unit ) then
204- if not UnitCanAttack (' player' , unit ) then
205- if UnitIsUnit (unit ,' player' ) then
206- return true
207- elseif worldRange40 and grouped_units [unit ] then
208- return UnitInRange (unit )
209- elseif rezSpell and UnitIsDeadOrGhost (unit ) then
210- return IsSpellInRange (rezSpell ,unit )== 1
211- elseif friendlySpell then
212- return IsSpellInRange (friendlySpell ,unit )== 1
213- end
214- elseif hostileSpell then
215- local range = IsSpellInRange (hostileSpell ,unit )
216- if range then
217- return range == 1
218- else
219- return CheckHostileDistance (unit ,4 ) -- 28y for enemies
220- end
221- else
222- return CheckHostileDistance (unit ,4 ) -- 28y for enemies
108+ if not UnitCanAttack (' player' , unit ) then
109+ if UnitIsUnit (unit ,' player' ) then
110+ return true
111+ elseif rezSpell and UnitIsDeadOrGhost (unit ) then
112+ return IsSpellInRange (rezSpell , unit ) == 1
113+ elseif friendlySpell then
114+ return IsSpellInRange (friendlySpell , unit ) == 1
223115 end
116+ elseif hostileSpell then
117+ local range = IsSpellInRange (hostileSpell , unit )
118+ if range then return range == 1 end
224119 end
120+ return spellHostile == nil or IsSpellInRange (spellHostile , unit ) == 1
225121 end ,
226122}
227123
@@ -231,7 +127,6 @@ local function Update(timer)
231127 local UnitRangeCheck = self .UnitRangeCheck
232128 hostileSpell = self .hostileSpell
233129 friendlySpell = self .friendlySpell
234- worldRange40 = self .worldRange40 and not IsInInstance ()
235130 for unit in Grid2 :IterateRosterUnits () do
236131 local value = UnitRangeCheck (unit ) and 1 or false
237132 if value ~= cache [unit ] then
@@ -293,10 +188,9 @@ function Range:UpdateDB()
293188 local dbr = dbx .ranges and dbx .ranges [playerClass ] or dbx
294189 self .hostileSpell = dbr .hostileSpellID and GetSpellInfo (dbr .hostileSpellID )
295190 self .friendlySpell = dbr .friendlySpellID and GetSpellInfo (dbr .friendlySpellID )
296- self .curRange = tonumber (dbr .range ) or (dbr .range == ' spell' and ' spell' ) or (rangeSpell and ' heal' ) or 38
191+ self .curRange = tonumber (dbr .range ) or (dbr .range == ' spell' and ' spell' ) or (playerCanHeal and ' heal' ) or 38
297192 self .UnitRangeCheck = Ranges [self .curRange ] or Ranges [38 ]
298193 self .curAlpha = dbx .default or 0.25
299- self .worldRange40 = dbx .worldRange40
300194 self .timer = self .timer or Grid2 :CreateTimer ( Update )
301195 if self .timer then
302196 self .timer :SetDuration (dbx .elapsed or 0.25 )
@@ -336,4 +230,4 @@ Grid2.setupFunc["rangealt"] = function(baseKey, dbx)
336230 return RangeAlt
337231end
338232
339- Grid2 :DbSetStatusDefaultValue ( " rangealt" , {type = " rangealt" , color1 = {r = 1 , g = 0 , b = 0 , a = 1 }, range = ( isRangeAvail and 28 or 38 ) , default = 0.25 , elapsed = 0.5 } )
233+ Grid2 :DbSetStatusDefaultValue ( " rangealt" , {type = " rangealt" , color1 = {r = 1 , g = 0 , b = 0 , a = 1 }, range = 38 , default = 0.25 , elapsed = 0.5 } )
0 commit comments