From b9895471f072fb42e20ed07ac1a70b46ff0b107a Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sun, 21 Jun 2026 02:27:53 -0500 Subject: [PATCH] Add @cursor token for ground-target spells/items @cursor places a ground-target spell or on-use item at the cursor via ClassicAPI's engine-level placement instead of the [mouseuse] reticle- click simulation (so no auto-attack side effect). - ParseMsg flags @cursor as conditionals.atCursor rather than setting a bogus "cursor" unit target, so it doesn't affect help/harm/exists/range checks or pass an invalid token to CastSpellByName. - DoWithConditionals routes atCursor casts through C_Spell.CastAtCursor (spellID resolved from the spell index / GetSpellIdForName) and item uses through C_Item.UseAtCursor. Both fall back to a normal cast/use for non-ground actions. New syntax, so existing macros are unaffected; MacroErrorChecker already accepts @cursor. --- Core.lua | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Core.lua b/Core.lua index e0bb26c..2feaa06 100644 --- a/Core.lua +++ b/Core.lua @@ -2041,7 +2041,15 @@ function CleveRoids.ParseMsg(msg) local _, _, target = string.find(conditionBlock, "(@[^%s,]+)") if target then conditionBlock = CleveRoids.Trim(string.gsub(conditionBlock, target, "")) - conditionals.target = string.sub(target, 2) + local tok = string.sub(target, 2) + -- @cursor is a ground-target directive, not a unit. Flag it so the cast + -- routes through ClassicAPI's CastAtCursor / UseAtCursor, and leave the + -- target at its default (CastAtCursor places at the cursor regardless). + if string.lower(tok) == "cursor" then + conditionals.atCursor = true + else + conditionals.target = tok + end end if conditionBlock and conditionals.action then @@ -2655,7 +2663,25 @@ function CleveRoids.DoWithConditionals(msg, hook, fixEmptyTargetFunc, targetBefo castMsg = msg .. "(" .. rank .. ")" end end - if action == CastSpellByName then + if conditionals.atCursor then + -- @cursor: place a ground-target spell/item at the cursor via + -- ClassicAPI (no AoE-reticle click). Both functions fall back to a + -- normal cast/use for non-ground actions. + if action == CastSpellByName then + local sp = CleveRoids.GetSpell(msg) + local spellId = sp and sp.id + if not spellId and GetSpellIdForName then + spellId = GetSpellIdForName(castMsg) + end + if spellId then + C_Spell.CastAtCursor(spellId) + else + CastSpellByName(castMsg) + end + else + C_Item.UseAtCursor(msg) + end + elseif action == CastSpellByName then -- ! prefix anti-toggle: prevent CastSpellByName from toggling off active spells. -- For Attack/AutoShot/Shoot, use the non-toggling AttackTarget() API. -- For self-buffs/shapeshifts, skip if already active on the player.