mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-06 21:50:00 +00:00
mouseover/libpredict: drop legacy spell-target plumbing
With Nampower as a hard dep, /pfcast for spell names always takes the early CastSpellByName(msg, unit) path. The fallback branch that did the SpellTargetUnit dance (resolve a friendly unit token, disable AutoSelf Cast, call SpellTargetUnit) hasn't been reachable in a while, and it dragged a pile of supporting infrastructure with it. modules/mouseover.lua: - Drop the st_units token list, GetUnitString helper, and the UnitTokenFromGUID rewrite of GetUnitString — all only used by the dead fallback. - Drop the NoSelfCast helper (only the dead fallback called it). - Drop the pfMouseOver frame; its only purpose was to hold a .unit field the dead fallback wrote and libpredict's hook read. - The macro path collapses to: if not the current target, swap target, run the loadstring'd func, restore the previous target. - 99 lines → 34. libs/libpredict.lua: - Drop the dead `local mouseover = pfUI.uf.mouseover.unit` plumbing in the CastSpellByName hook — pfUI.uf.mouseover is gone and the field was permanently nil anyway. The three `target or mouseover or default` fallback chains collapse to `target or default`. Modern mouseover/click-to-cast detection in libpredict goes through pfUI.libpredict_pending_cast (populated by libdebuff from Nampower's SPELL_CAST_EVENT) — that path is GUID-based, server-authoritative, and untouched.
This commit is contained in:
+3
-5
@@ -959,8 +959,6 @@ hooksecurefunc("CastSpellByName", function(effect, target)
|
||||
if not libpredict.sender.enabled then return end
|
||||
local effect, rank = libspell.GetSpellInfo(effect)
|
||||
if not effect then return end
|
||||
local mouseover = pfUI and pfUI.uf and pfUI.uf.mouseover and pfUI.uf.mouseover.unit
|
||||
mouseover = mouseover and UnitCanAssist("player", mouseover) and UnitName(mouseover)
|
||||
|
||||
local default = UnitName("target") and UnitCanAssist("player", "target") and UnitName("target") or UnitName("player")
|
||||
|
||||
@@ -979,13 +977,13 @@ hooksecurefunc("CastSpellByName", function(effect, target)
|
||||
if not libpredict.sender.current_cast then
|
||||
spell_queue[1] = effect
|
||||
spell_queue[2] = effect.. ( rank or "" )
|
||||
spell_queue[3] = target or mouseover or default
|
||||
spell_queue[3] = target or default
|
||||
end
|
||||
|
||||
-- Instant HoTs: libdebuff/Nampower via GetHotDuration, hook method as fallback
|
||||
|
||||
if effect == REJUVENATION then
|
||||
local hotTarget = target or mouseover or default
|
||||
local hotTarget = target or default
|
||||
local now = pfUI.uf.now or GetTime()
|
||||
local key = "Reju" .. hotTarget
|
||||
|
||||
@@ -1002,7 +1000,7 @@ hooksecurefunc("CastSpellByName", function(effect, target)
|
||||
local rankStr = rankNum and tostring(rankNum) or "0"
|
||||
libpredict.sender:SendHealCommMsg("Reju/"..hotTarget.."/"..rejuvDuration.."/"..rankStr.."/")
|
||||
elseif effect == RENEW then
|
||||
local hotTarget = target or mouseover or default
|
||||
local hotTarget = target or default
|
||||
local now = pfUI.uf.now or GetTime()
|
||||
local key = "Renew" .. hotTarget
|
||||
|
||||
|
||||
+9
-75
@@ -1,39 +1,6 @@
|
||||
pfUI:RegisterModule("mouseover", function ()
|
||||
pfUI.uf.mouseover = CreateFrame("Frame", "pfMouseOver", UIParent)
|
||||
|
||||
-- Prepare a list of units that can be used via SpellTargetUnit
|
||||
local st_units = { [1] = "player", [2] = "target", [3] = "mouseover" }
|
||||
for i=1, MAX_PARTY_MEMBERS do table.insert(st_units, "party"..i) end
|
||||
for i=1, MAX_RAID_MEMBERS do table.insert(st_units, "raid"..i) end
|
||||
|
||||
-- Try to find a valid (friendly) unitstring that can be used for
|
||||
-- SpellTargetUnit(unit) to avoid another target switch
|
||||
local function GetUnitString(unit)
|
||||
for index, unitstr in pairs(st_units) do
|
||||
if UnitIsUnit(unit, unitstr) then
|
||||
return unitstr
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Same as CastSpellByName but with disabled AutoSelfCast
|
||||
local function NoSelfCast(spell, onself)
|
||||
local cvar_selfcast = GetCVar("AutoSelfCast")
|
||||
|
||||
if cvar_selfcast ~= "0" then
|
||||
SetCVar("AutoSelfCast", "0")
|
||||
pcall(CastSpellByName, spell, onself)
|
||||
SetCVar("AutoSelfCast", cvar_selfcast)
|
||||
else
|
||||
CastSpellByName(spell, onself)
|
||||
end
|
||||
end
|
||||
|
||||
_G.SLASH_PFCAST1, _G.SLASH_PFCAST2 = "/pfcast", "/pfmouse"
|
||||
function SlashCmdList.PFCAST(msg)
|
||||
local restore_target = true
|
||||
local func = pfUI.api.TryMemoizedFuncLoadstringForSpellCasts(msg)
|
||||
local unit = "mouseover"
|
||||
|
||||
@@ -50,51 +17,18 @@ pfUI:RegisterModule("mouseover", function ()
|
||||
end
|
||||
end
|
||||
|
||||
-- Nampower: CastSpellByName supports a second unit parameter directly.
|
||||
-- unit is already resolved to "mouseover", "target" or "player" at this point.
|
||||
if not func and GetNampowerVersion then
|
||||
-- Spell-name path: Nampower's CastSpellByName takes a second unit
|
||||
-- parameter directly, no target swap dance required.
|
||||
if not func then
|
||||
CastSpellByName(msg, unit)
|
||||
return
|
||||
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
|
||||
-- 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
|
||||
|
||||
-- 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
|
||||
|
||||
-- clean up spell target in error case
|
||||
if SpellIsTargeting() then SpellStopTargeting() end
|
||||
|
||||
-- remove temporary mouseover unit
|
||||
pfUI.uf.mouseover.unit = nil
|
||||
end
|
||||
|
||||
if restore_target then
|
||||
TargetLastTarget()
|
||||
end
|
||||
-- Macro path: switch target so the macro's spell calls land on `unit`,
|
||||
-- then restore.
|
||||
local restore_target = not UnitIsUnit("target", unit)
|
||||
if restore_target then TargetUnit(unit) end
|
||||
func()
|
||||
if restore_target then TargetLastTarget() end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user