fixed /pfcast to use mouseover properly again

fixed /pfcast to use mouseover properly again
This commit is contained in:
Meow
2026-02-17 16:55:18 +01:00
parent 4c780a1036
commit a2d449cd59
+40 -47
View File
@@ -50,61 +50,54 @@ pfUI:RegisterModule("mouseover", "vanilla", function ()
end end
end end
-- Nampower/SuperWoW: Use SetMouseoverUnit for cleaner mouseover handling -- Nampower: CastSpellByName supports a second unit parameter directly.
if SetMouseoverUnit and not UnitIsUnit("target", unit) then -- Use it when available to avoid a target switch entirely.
-- Set the mouseover unit so macros like [@mouseover] work correctly if not func and GetNampowerVersion then
SetMouseoverUnit(unit) local resolvedUnit = GetUnitString(unit)
if resolvedUnit then
-- Cast spell (no target toggle needed!) CastSpellByName(msg, resolvedUnit)
if func then return
func()
else
CastSpellByName(msg)
end end
end
-- Clear mouseover unit
SetMouseoverUnit() -- 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 else
-- Fallback: Legacy method with target toggle -- The spelltarget can't be used here, we need to switch
-- If target and mouseover are friendly units, we can't use spell target as it -- and restore the target during spell cast
-- would cast on the target instead of the mouseover. However, if the mouseover TargetUnit(unit)
-- is friendly and the target is not, we can try to obtain the best unitstring end
-- 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 if func then
-- no target change required, we can either use spell target func()
-- or the unit is already our current target. else
restore_target = false -- write temporary unit name
else pfUI.uf.mouseover.unit = unit
-- The spelltarget can't be used here, we need to switch
-- and restore the target during spell cast
TargetUnit(unit)
end
if func then -- cast without self cast cvar setting
func() -- to allow spells to use spelltarget
else NoSelfCast(msg)
-- write temporary unit name
pfUI.uf.mouseover.unit = unit
-- cast without self cast cvar setting -- set spell target to unitstring (or selfcast)
-- to allow spells to use spelltarget if SpellIsTargeting() then SpellTargetUnit(unitstr or "player") end
NoSelfCast(msg)
-- set spell target to unitstring (or selfcast) -- clean up spell target in error case
if SpellIsTargeting() then SpellTargetUnit(unitstr or "player") end if SpellIsTargeting() then SpellStopTargeting() end
-- clean up spell target in error case -- remove temporary mouseover unit
if SpellIsTargeting() then SpellStopTargeting() end pfUI.uf.mouseover.unit = nil
end
-- remove temporary mouseover unit if restore_target then
pfUI.uf.mouseover.unit = nil TargetLastTarget()
end
if restore_target then
TargetLastTarget()
end
end end
end end
end) end)