Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] remove stack indication from effect name in order to display correct … #1253

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions api/unitframes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,9 @@ function pfUI.uf.OnLeave()
end

function pfUI.uf.OnClick()
if not this.label and this.unitname then
if not this.label and this.guid then
TargetUnit(this.guid)
elseif not this.label and this.unitname then
TargetByName(this.unitname, true)
else
pfUI.uf:ClickAction(arg1)
Expand Down Expand Up @@ -2005,7 +2007,13 @@ end
function pfUI.uf:ClickAction(button)
local label = this.label or ""
local id = this.id or ""
local unitstr = label .. id
local unitstr

if this.guid then
unitstr = this.guid
else
unitstr = label .. id
end
local showmenu = button == "RightButton" and true or nil
if SpellIsTargeting() and button == "RightButton" then
SpellStopTargeting()
Expand Down
41 changes: 36 additions & 5 deletions libs/libdebuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ local scanner = libtipscan:GetScanner("libdebuff")
local _, class = UnitClass("player")
local lastspell

libdebuff.objects = {}
libdebuff.pending = {}

function libdebuff:GetDuration(effect, rank)
if L["debuffs"][effect] then
local rank = rank and tonumber((string.gsub(rank, RANK, ""))) or 0
local rank = L["debuffs"][effect][rank] and rank or libdebuff:GetMaxRank(effect)
rank = rank and tonumber((string.gsub(rank, RANK, ""))) or 0
rank = L["debuffs"][effect][rank] and rank or libdebuff:GetMaxRank(effect)
local duration = L["debuffs"][effect][rank]

if effect == L["dyndebuffs"]["Rupture"] then
Expand Down Expand Up @@ -107,6 +110,7 @@ end

function libdebuff:AddEffect(unit, unitlevel, effect, duration)
if not unit or not effect then return end
effect = string.gsub(effect, " %(%d+%)", "") -- remove stack indication from effect name in order to display correct expiration time for things like Fire Vulnerability
unitlevel = unitlevel or 0
if not libdebuff.objects[unit] then libdebuff.objects[unit] = {} end
if not libdebuff.objects[unit][unitlevel] then libdebuff.objects[unit][unitlevel] = {} end
Expand All @@ -128,6 +132,8 @@ libdebuff:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE")
libdebuff:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE")
libdebuff:RegisterEvent("CHAT_MSG_SPELL_FAILED_LOCALPLAYER")
libdebuff:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE")
libdebuff:RegisterEvent("CHAT_MSG_SPELL_PARTY_DAMAGE")
libdebuff:RegisterEvent("CHAT_MSG_SPELL_FRIENDLYPLAYER_DAMAGE")
libdebuff:RegisterEvent("PLAYER_TARGET_CHANGED")
libdebuff:RegisterEvent("SPELLCAST_STOP")
libdebuff:RegisterEvent("UNIT_AURA")
Expand All @@ -143,9 +149,6 @@ libdebuff.rp = { SPELLIMMUNESELFOTHER, IMMUNEDAMAGECLASSSELFOTHER,
SPELLDODGEDSELFOTHER, SPELLDEFLECTEDSELFOTHER, SPELLREFLECTSELFOTHER,
SPELLPARRIEDSELFOTHER, SPELLLOGABSORBSELFOTHER }

libdebuff.objects = {}
libdebuff.pending = {}

-- Gather Data by Events
libdebuff:SetScript("OnEvent", function()
-- paladin seal refresh
Expand Down Expand Up @@ -196,6 +199,20 @@ libdebuff:SetScript("OnEvent", function()

-- Update Pending Spells
elseif event == "CHAT_MSG_SPELL_FAILED_LOCALPLAYER" or event == "CHAT_MSG_SPELL_SELF_DAMAGE" then
-- update fire vulnerability
if arg1 then
spell, unit = cmatch(arg1, SPELLLOGSELFOTHER)

if not unit then
spell, unit = cmatch(arg1, SPELLLOGCRITSELFOTHER)
end

if unit and spell == "Scorch" then
local unitlevel = UnitName("target") == unit and UnitLevel("target") or 0
libdebuff:AddEffect(unit, unitlevel, "Fire Vulnerability")
end
end

-- Remove pending spell
for _, msg in pairs(libdebuff.rp) do
local effect = cmatch(arg1, msg)
Expand All @@ -209,6 +226,20 @@ libdebuff:SetScript("OnEvent", function()
return
end
end
elseif event == "CHAT_MSG_SPELL_FRIENDLYPLAYER_DAMAGE" or event == "CHAT_MSG_SPELL_PARTY_DAMAGE" then
-- update fire vulnerability
if arg1 then
_, spell, unit = cmatch(arg1, SPELLLOGOTHEROTHER)

if not unit then
_, spell, unit = cmatch(arg1, SPELLLOGCRITOTHEROTHER)
end

if unit and spell == "Scorch" then
local unitlevel = UnitName("target") == unit and UnitLevel("target") or 0
libdebuff:AddEffect(unit, unitlevel, "Fire Vulnerability")
end
end
elseif event == "SPELLCAST_STOP" then
QueueFunction(libdebuff.PersistPending)
end
Expand Down
187 changes: 109 additions & 78 deletions modules/focus.lua
Original file line number Diff line number Diff line change
@@ -1,96 +1,127 @@
pfUI:RegisterModule("focus", "vanilla:tbc", function ()
-- do not go further on disabled UFs
if C.unitframes.disable == "1" then return end

pfUI.uf.focus = pfUI.uf:CreateUnitFrame("Focus", nil, C.unitframes.focus, .2)
pfUI.uf.focus:UpdateFrameSize()
pfUI.uf.focus:SetPoint("BOTTOMLEFT", UIParent, "BOTTOM", 220, 220)
UpdateMovable(pfUI.uf.focus)
pfUI.uf.focus:Hide()

pfUI.uf.focustarget = pfUI.uf:CreateUnitFrame("FocusTarget", nil, C.unitframes.focustarget, .2)
pfUI.uf.focustarget:UpdateFrameSize()
pfUI.uf.focustarget:SetPoint("BOTTOMLEFT", pfUI.uf.focus, "TOP", 0, 10)
UpdateMovable(pfUI.uf.focustarget)
pfUI.uf.focustarget:Hide()
pfUI:RegisterModule("focus", "vanilla:tbc", function()
-- do not go further on disabled UFs
if C.unitframes.disable == "1" then
return
end

pfUI.uf.focus = pfUI.uf:CreateUnitFrame("Focus", nil, C.unitframes.focus, .2)
pfUI.uf.focus:UpdateFrameSize()
pfUI.uf.focus:SetPoint("BOTTOMLEFT", UIParent, "BOTTOM", 220, 220)
UpdateMovable(pfUI.uf.focus)
pfUI.uf.focus:Hide()

pfUI.uf.focustarget = pfUI.uf:CreateUnitFrame("FocusTarget", nil, C.unitframes.focustarget, .2)
pfUI.uf.focustarget:UpdateFrameSize()
pfUI.uf.focustarget:SetPoint("BOTTOMLEFT", pfUI.uf.focus, "TOP", 0, 10)
UpdateMovable(pfUI.uf.focustarget)
pfUI.uf.focustarget:Hide()
end)

-- register focus emulation commands for vanilla
if pfUI.client > 11200 then return end
if pfUI.client > 11200 then
return
end

function pfUI:SetFocus(msg)
if not pfUI.uf or not pfUI.uf.focus then
return
end

if msg ~= "" then
pfUI.uf.focus.unitname = strlower(msg)
elseif UnitName("target") then
pfUI.uf.focus.unitname = strlower(UnitName("target"))
else
pfUI.uf.focus.unitname = nil
pfUI.uf.focus.label = nil
end
local _, guid = UnitExists("target")
pfUI.uf.focus.guid = guid
end

function pfUI:SetFocusGuid(guid)
if not pfUI.uf or not pfUI.uf.focus then
return
end

pfUI.uf.focus.guid = guid
pfUI.uf.focus.unitname = strlower(UnitName(guid))
end

function pfUI:ClearFocus()
if pfUI.uf and pfUI.uf.focus then
pfUI.uf.focus.unitname = nil
pfUI.uf.focus.label = nil
end
end

function pfUI:CastFocus(msg)
if not pfUI.uf.focus or not pfUI.uf.focus:IsShown() or not pfUI.uf.focus.unitname then
UIErrorsFrame:AddMessage(SPELL_FAILED_BAD_TARGETS, 1, 0, 0)
return
end

local skiptarget = false
local player = UnitIsUnit("target", "player")

if pfUI.uf.focus.guid then
CastSpellByName(msg, pfUI.uf.focus.guid)
elseif pfUI.uf.focus.label and UnitIsUnit("target", pfUI.uf.focus.label .. pfUI.uf.focus.id) then
skiptarget = true
else
pfScanActive = true
if pfUI.uf.focus.label and pfUI.uf.focus.id then
TargetUnit(pfUI.uf.focus.label .. pfUI.uf.focus.id)
else
TargetByName(pfUI.uf.focus.unitname, true)
end

if strlower(UnitName("target")) ~= strlower(pfUI.uf.focus.unitname) then
TargetLastTarget()
UIErrorsFrame:AddMessage(SPELL_FAILED_BAD_TARGETS, 1, 0, 0)
return
end
pfScanActive = nil
end

local func = loadstring(msg or "")
if func then
func()
else
CastSpellByName(msg)
end
end

function pfUI:SwapFocus()
if not pfUI.uf or not pfUI.uf.focus then
return
end

local currentUnitName = strlower(UnitName("target"))
local exists, currentUnitGUID = UnitExists("target")
if exists and currentUnitName and pfUI.uf.focus.guid then
TargetUnit(pfUI.uf.focus.guid)
pfUI.uf.focus.unitname = currentUnitName
pfUI.uf.focus.guid = currentUnitGUID
end
end

SLASH_PFFOCUS1, SLASH_PFFOCUS2 = '/focus', '/pffocus'
function SlashCmdList.PFFOCUS(msg)
if not pfUI.uf or not pfUI.uf.focus then return end

if msg ~= "" then
pfUI.uf.focus.unitname = strlower(msg)
elseif UnitName("target") then
pfUI.uf.focus.unitname = strlower(UnitName("target"))
else
pfUI.uf.focus.unitname = nil
pfUI.uf.focus.label = nil
end
pfUI:SetFocus(msg)
end

SLASH_PFCLEARFOCUS1, SLASH_PFCLEARFOCUS2 = '/clearfocus', '/pfclearfocus'
function SlashCmdList.PFCLEARFOCUS(msg)
if pfUI.uf and pfUI.uf.focus then
pfUI.uf.focus.unitname = nil
pfUI.uf.focus.label = nil
end
pfUI:ClearFocus()
end

SLASH_PFCASTFOCUS1, SLASH_PFCASTFOCUS2 = '/castfocus', '/pfcastfocus'
function SlashCmdList.PFCASTFOCUS(msg)
if not pfUI.uf.focus or not pfUI.uf.focus:IsShown() or not pfUI.uf.focus.unitname then
UIErrorsFrame:AddMessage(SPELL_FAILED_BAD_TARGETS, 1, 0, 0)
return
end

local skiptarget = false
local player = UnitIsUnit("target", "player")

if pfUI.uf.focus.label and UnitIsUnit("target", pfUI.uf.focus.label .. pfUI.uf.focus.id) then
skiptarget = true
else
pfScanActive = true
if pfUI.uf.focus.label and pfUI.uf.focus.id then
TargetUnit(pfUI.uf.focus.label .. pfUI.uf.focus.id)
else
TargetByName(pfUI.uf.focus.unitname, true)
end

if strlower(UnitName("target")) ~= strlower(pfUI.uf.focus.unitname) then
pfScanActive = nil
TargetLastTarget()
UIErrorsFrame:AddMessage(SPELL_FAILED_BAD_TARGETS, 1, 0, 0)
return
end
end

local func = loadstring(msg or "")
if func then
func()
else
CastSpellByName(msg)
end

if skiptarget == false then
pfScanActive = nil
if player then
TargetUnit("player")
else
TargetLastTarget()
end
end
pfUI:CastFocus(msg)
end

SLASH_PFSWAPFOCUS1, SLASH_PFSWAPFOCUS2 = '/swapfocus', '/pfswapfocus'
function SlashCmdList.PFSWAPFOCUS(msg)
if not pfUI.uf or not pfUI.uf.focus then return end

local oldunit = UnitExists("target") and strlower(UnitName("target"))
if oldunit and pfUI.uf.focus.unitname then
TargetByName(pfUI.uf.focus.unitname)
pfUI.uf.focus.unitname = oldunit
end
pfUI:SwapFocus()
end