Changed Spellinfo into GetSpellRec for nampower only support

Changed Spellinfo into GetSpellRec for nampower only support
This commit is contained in:
Meow
2026-02-17 01:29:27 +01:00
parent 22b6f37d56
commit 221f015677
3 changed files with 71 additions and 39 deletions
+48 -31
View File
@@ -50,44 +50,61 @@ pfUI:RegisterModule("mouseover", "vanilla", function ()
end
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
-- 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)
end
-- Clear mouseover unit
SetMouseoverUnit()
else
-- The spelltarget can't be used here, we need to switch
-- and restore the target during spell cast
TargetUnit(unit)
end
-- 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)
if func then
func()
else
-- write temporary unit name
pfUI.uf.mouseover.unit = 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
-- The spelltarget can't be used here, we need to switch
-- and restore the target during spell cast
TargetUnit(unit)
end
-- cast without self cast cvar setting
-- to allow spells to use spelltarget
NoSelfCast(msg)
if func then
func()
else
-- write temporary unit name
pfUI.uf.mouseover.unit = unit
-- set spell target to unitstring (or selfcast)
if SpellIsTargeting() then SpellTargetUnit(unitstr or "player") end
-- cast without self cast cvar setting
-- to allow spells to use spelltarget
NoSelfCast(msg)
-- clean up spell target in error case
if SpellIsTargeting() then SpellStopTargeting() end
-- set spell target to unitstring (or selfcast)
if SpellIsTargeting() then SpellTargetUnit(unitstr or "player") end
-- remove temporary mouseover unit
pfUI.uf.mouseover.unit = nil
end
-- clean up spell target in error case
if SpellIsTargeting() then SpellStopTargeting() end
if restore_target then
TargetLastTarget()
-- remove temporary mouseover unit
pfUI.uf.mouseover.unit = nil
end
if restore_target then
TargetLastTarget()
end
end
end
end)