Files
pfUI/modules/mouseover.lua
T
shagu 961b186491 mouseover: detect self cast to avoid target switch
If a self cast is detected, the SpellTargetUnit() function will
be used to avoid a target change. Auto-attacks now continue on
self casts because the target has no longer to be changed.
2023-02-05 14:05:38 +01:00

45 lines
1.0 KiB
Lua

pfUI:RegisterModule("mouseover", "vanilla", function ()
pfUI.uf.mouseover = CreateFrame("Frame", "pfMouseOver", UIParent)
_G.SLASH_PFCAST1, _G.SLASH_PFCAST2 = "/pfcast", "/pfmouse"
function SlashCmdList.PFCAST(msg)
local func = loadstring(msg or "")
local oldt = true
local unit = "mouseover"
if not UnitExists(unit) then
local frame = GetMouseFocus()
if frame.label and frame.id then
unit = frame.label .. frame.id
elseif UnitExists("target") then
unit = "target"
elseif GetCVar("autoSelfCast") == "1" then
unit = "player"
else
return
end
end
if UnitIsUnit("target", unit) then
oldt = nil
elseif not func and UnitIsUnit("player", unit) then
SpellTargetUnit("player")
oldt = nil
else
TargetUnit(unit)
end
if func then
func()
else
CastSpellByName(msg)
end
if oldt then
if pfUI.uf.target then
pfUI.uf.target.noanim = "yes"
end
TargetLastTarget()
end
end
end)