From 529f4d1e069437d1b5ca1163435149633edef9bb Mon Sep 17 00:00:00 2001 From: Jrc13245 Date: Mon, 9 Feb 2026 16:50:49 -0500 Subject: [PATCH] fix CountEnemiesMatching to use UnitXP rather than Nampower for range results for multiple units --- Conditionals.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Conditionals.lua b/Conditionals.lua index 2e9e4bc..9d2363b 100644 --- a/Conditionals.lua +++ b/Conditionals.lua @@ -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)