From a2d449cd5945b095ebca6d34a631798e961e9968 Mon Sep 17 00:00:00 2001 From: Meow <30401521+me0wg4ming@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:55:18 +0100 Subject: [PATCH] fixed /pfcast to use mouseover properly again fixed /pfcast to use mouseover properly again --- modules/mouseover.lua | 87 ++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/modules/mouseover.lua b/modules/mouseover.lua index 246b3710..8b91e387 100644 --- a/modules/mouseover.lua +++ b/modules/mouseover.lua @@ -50,61 +50,54 @@ pfUI:RegisterModule("mouseover", "vanilla", function () end end - -- Nampower/SuperWoW: Use SetMouseoverUnit for cleaner mouseover handling - if SetMouseoverUnit and not UnitIsUnit("target", unit) then - -- Set the mouseover unit so macros like [@mouseover] work correctly - SetMouseoverUnit(unit) - - -- Cast spell (no target toggle needed!) - if func then - func() - else - CastSpellByName(msg) + -- Nampower: CastSpellByName supports a second unit parameter directly. + -- Use it when available to avoid a target switch entirely. + if not func and GetNampowerVersion then + local resolvedUnit = GetUnitString(unit) + if resolvedUnit then + CastSpellByName(msg, resolvedUnit) + return end - - -- Clear mouseover unit - SetMouseoverUnit() + end + + -- If target and mouseover are friendly units, we can't use spell target as it + -- would cast on the target instead of the mouseover. However, if the mouseover + -- is friendly and the target is not, we can try to obtain the best unitstring + -- for the later SpellTargetUnit() call. + local unitstr = not UnitCanAssist("player", "target") and UnitCanAssist("player", unit) and GetUnitString(unit) + + if UnitIsUnit("target", unit) or (not func and unitstr) then + -- no target change required, we can either use spell target + -- or the unit is already our current target. + restore_target = false else - -- Fallback: Legacy method with target toggle - -- If target and mouseover are friendly units, we can't use spell target as it - -- would cast on the target instead of the mouseover. However, if the mouseover - -- is friendly and the target is not, we can try to obtain the best unitstring - -- for the later SpellTargetUnit() call. - local unitstr = not UnitCanAssist("player", "target") and UnitCanAssist("player", unit) and GetUnitString(unit) + -- The spelltarget can't be used here, we need to switch + -- and restore the target during spell cast + TargetUnit(unit) + end - if UnitIsUnit("target", unit) or (not func and unitstr) then - -- no target change required, we can either use spell target - -- or the unit is already our current target. - restore_target = false - else - -- The spelltarget can't be used here, we need to switch - -- and restore the target during spell cast - TargetUnit(unit) - end + if func then + func() + else + -- write temporary unit name + pfUI.uf.mouseover.unit = unit - if func then - func() - else - -- write temporary unit name - pfUI.uf.mouseover.unit = unit + -- cast without self cast cvar setting + -- to allow spells to use spelltarget + NoSelfCast(msg) - -- cast without self cast cvar setting - -- to allow spells to use spelltarget - NoSelfCast(msg) + -- set spell target to unitstring (or selfcast) + if SpellIsTargeting() then SpellTargetUnit(unitstr or "player") end - -- set spell target to unitstring (or selfcast) - if SpellIsTargeting() then SpellTargetUnit(unitstr or "player") end + -- clean up spell target in error case + if SpellIsTargeting() then SpellStopTargeting() end - -- clean up spell target in error case - if SpellIsTargeting() then SpellStopTargeting() end + -- remove temporary mouseover unit + pfUI.uf.mouseover.unit = nil + end - -- remove temporary mouseover unit - pfUI.uf.mouseover.unit = nil - end - - if restore_target then - TargetLastTarget() - end + if restore_target then + TargetLastTarget() end end end)