fix CountEnemiesMatching to use UnitXP rather than Nampower for range results for multiple units

This commit is contained in:
Jrc13245
2026-02-09 16:50:49 -05:00
parent 3e923ae61d
commit 529f4d1e06
+34
View File
@@ -5679,7 +5679,17 @@ CleveRoids.Keywords = {
-- Check for count mode: [inrange:Multi-Shot>1]
if type(args) == "table" and args.operator and args.amount then
local spellName = args.name or conditionals.action
-- Resolve spell range once outside the loop for UnitXP distance checks
-- IsSpellInRange may return stale results during UnitXP target iteration
local spellId = API.GetSpellIdFromName(spellName)
local spellRange = spellId and API.GetSpellRange(spellId)
local count = CleveRoids.CountEnemiesMatching(function(unit)
if spellRange and spellRange > 0 and CleveRoids.hasUnitXP then
local distance = UnitXP("distanceBetween", "player", unit)
if distance then
return distance <= spellRange
end
end
local result = API.IsSpellInRange(spellName, unit)
return result == 1
end)
@@ -5705,7 +5715,15 @@ CleveRoids.Keywords = {
-- Check for count mode: [noinrange:Multi-Shot>1]
if type(args) == "table" and args.operator and args.amount then
local spellName = args.name or conditionals.action
local spellId = API.GetSpellIdFromName(spellName)
local spellRange = spellId and API.GetSpellRange(spellId)
local count = CleveRoids.CountEnemiesMatching(function(unit)
if spellRange and spellRange > 0 and CleveRoids.hasUnitXP then
local distance = UnitXP("distanceBetween", "player", unit)
if distance then
return distance > spellRange
end
end
local result = API.IsSpellInRange(spellName, unit)
return result == 0
end)
@@ -5731,7 +5749,15 @@ CleveRoids.Keywords = {
-- Check for count mode: [outrange:Multi-Shot>1]
if type(args) == "table" and args.operator and args.amount then
local spellName = args.name or conditionals.action
local spellId = API.GetSpellIdFromName(spellName)
local spellRange = spellId and API.GetSpellRange(spellId)
local count = CleveRoids.CountEnemiesMatching(function(unit)
if spellRange and spellRange > 0 and CleveRoids.hasUnitXP then
local distance = UnitXP("distanceBetween", "player", unit)
if distance then
return distance > spellRange
end
end
local result = API.IsSpellInRange(spellName, unit)
return result == 0
end)
@@ -5757,7 +5783,15 @@ CleveRoids.Keywords = {
-- Check for count mode: [nooutrange:Multi-Shot>1]
if type(args) == "table" and args.operator and args.amount then
local spellName = args.name or conditionals.action
local spellId = API.GetSpellIdFromName(spellName)
local spellRange = spellId and API.GetSpellRange(spellId)
local count = CleveRoids.CountEnemiesMatching(function(unit)
if spellRange and spellRange > 0 and CleveRoids.hasUnitXP then
local distance = UnitXP("distanceBetween", "player", unit)
if distance then
return distance <= spellRange
end
end
local result = API.IsSpellInRange(spellName, unit)
return result == 1
end)