Use ClassicAPI macro spell range checks
This commit is contained in:
@@ -11,18 +11,29 @@ local module = ShaguTweaks:register({
|
||||
enabled = nil,
|
||||
})
|
||||
|
||||
local function SpellRange(spellID)
|
||||
if not spellID or not API or not API.IsSpellInRange then return end
|
||||
|
||||
local inRange = API.IsSpellInRange(spellID, "target")
|
||||
if inRange ~= nil then
|
||||
return inRange and 1 or 0
|
||||
end
|
||||
end
|
||||
|
||||
local function GetActionRange(action)
|
||||
-- ClassicAPI can resolve a real spell/item action and run the same
|
||||
-- range-only engine test directly against the target unit. This avoids
|
||||
-- relying on the old action-slot heuristic for normal spell buttons.
|
||||
-- ClassicAPI resolves the action to its real spell/item/macro descriptor.
|
||||
-- For macros, resolve the macro's cached primary spell before testing range;
|
||||
-- Vanilla IsActionInRange() commonly returns nil for macro action slots.
|
||||
if API and API.GetActionInfo then
|
||||
local actionType, id = API.GetActionInfo(action)
|
||||
|
||||
if actionType == "spell" and id and API.IsSpellInRange then
|
||||
local inRange = API.IsSpellInRange(id, "target")
|
||||
if inRange ~= nil then
|
||||
return inRange and 1 or 0
|
||||
end
|
||||
if actionType == "spell" and id then
|
||||
local result = SpellRange(id)
|
||||
if result ~= nil then return result end
|
||||
elseif actionType == "macro" and id and API.GetMacroSpell then
|
||||
local _, _, spellID = API.GetMacroSpell(id)
|
||||
local result = SpellRange(spellID)
|
||||
if result ~= nil then return result end
|
||||
elseif actionType == "item" and id and API.IsItemInRange then
|
||||
local inRange = API.IsItemInRange(id, "target")
|
||||
if inRange ~= nil then
|
||||
@@ -31,8 +42,8 @@ local function GetActionRange(action)
|
||||
end
|
||||
end
|
||||
|
||||
-- Macros, unresolved bag-item actions and older ClassicAPI versions keep
|
||||
-- Vanilla's native action-slot range check as the compatibility fallback.
|
||||
-- Unresolved macros/items and older ClassicAPI versions retain the native
|
||||
-- action-slot check as a compatibility fallback.
|
||||
return IsActionInRange(action)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user