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)
+15 -7
View File
@@ -67,9 +67,12 @@ pfUI:RegisterModule("nampower", "vanilla", function ()
local spellId = arg2
if eventCode == NORMAL_QUEUED or eventCode == NON_GCD_QUEUED or eventCode == ON_SWING_QUEUED then
-- Get spell texture from SpellInfo (SuperWoW) or GetSpellTexture
-- Get spell texture from GetSpellRec (Nampower) or SpellInfo (SuperWoW fallback)
local texture
if SpellInfo then
if GetSpellRec then
local rec = GetSpellRec(spellId)
texture = rec and rec.spellIconID and GetSpellIconTexture(rec.spellIconID) or nil
elseif SpellInfo then
local _, _, tex = SpellInfo(spellId)
texture = tex
end
@@ -101,7 +104,15 @@ pfUI:RegisterModule("nampower", "vanilla", function ()
local spellId = auras[i]
if spellId and spellId > 0 then
local name, rank, texture
if SpellInfo then
if GetSpellRec then
local rec = GetSpellRec(spellId)
if rec then
name = rec.name
rank = rec.rank
local iconID = rec.spellIconID
texture = iconID and GetSpellIconTexture(iconID) or nil
end
elseif SpellInfo then
name, rank, texture = SpellInfo(spellId)
end
if not name then
@@ -479,9 +490,6 @@ pfUI:RegisterModule("nampower", "vanilla", function ()
end
end
-- NOTE: HoT Detection (AURA_CAST events) removed - OnHotApplied callback was never implemented in libpredict
-- NOTE: Swing Timer removed - GetSwingTimers() was never called anywhere
-- Druid Secondary Mana Bar
-- Shows base mana when druid is in shapeshift form (Bear/Cat uses Rage/Energy)
-- Uses Nampower's GetUnitField to get base mana values
@@ -783,4 +791,4 @@ pfUI:RegisterModule("nampower", "vanilla", function ()
-- Initial update
UpdateTargetSecondaryMana()
end
end)
end)
+8 -1
View File
@@ -307,7 +307,14 @@ pfUI:RegisterModule("superwow", "vanilla", function ()
-- get spell info from spell id
local spell, icon, _
if SpellInfo and SpellInfo(spell_id) then
if GetSpellRec then
local rec = GetSpellRec(spell_id)
if rec then
spell = rec.name
local iconID = rec.spellIconID
icon = iconID and GetSpellIconTexture(iconID) or nil
end
elseif SpellInfo and SpellInfo(spell_id) then
spell, _, icon = SpellInfo(spell_id)
end