From ed4971922659f851e76204407afa767766c111fe Mon Sep 17 00:00:00 2001 From: pepopo978 <149287158+pepopo978@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:13:57 -0800 Subject: [PATCH 01/10] remove stack indication from effect name in order to display correct expiration time --- libs/libdebuff.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/libdebuff.lua b/libs/libdebuff.lua index f9f9bacf..3a0c3093 100644 --- a/libs/libdebuff.lua +++ b/libs/libdebuff.lua @@ -109,6 +109,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 From e4ce74a32d3d0f80be1a8a2e4363e9d8b918bedd Mon Sep 17 00:00:00 2001 From: pepopo978 <149287158+pepopo978@users.noreply.github.com> Date: Thu, 25 Jan 2024 17:49:12 -0800 Subject: [PATCH 02/10] Refresh fire vulnerability properly at 5 stacks --- libs/libdebuff.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libs/libdebuff.lua b/libs/libdebuff.lua index 3a0c3093..1e0cfa34 100644 --- a/libs/libdebuff.lua +++ b/libs/libdebuff.lua @@ -131,6 +131,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") @@ -199,6 +201,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) @@ -212,6 +228,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 From ce46887017b5028be879923e282df761edbc47b4 Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Thu, 25 Apr 2024 09:05:45 -0700 Subject: [PATCH 03/10] rearrange --- libs/libdebuff.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/libdebuff.lua b/libs/libdebuff.lua index 1e0cfa34..a7755083 100644 --- a/libs/libdebuff.lua +++ b/libs/libdebuff.lua @@ -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 @@ -148,9 +151,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 From b19eccf9d9e023eed1015c5629624b666c4ce931 Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Sat, 11 May 2024 14:05:34 -0700 Subject: [PATCH 04/10] make focus use guid --- api/unitframes.lua | 12 ++++++++++-- modules/focus.lua | 17 +++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index a2b0ba57..99100a6e 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -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) @@ -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() diff --git a/modules/focus.lua b/modules/focus.lua index e4b9f1b4..f8cc8a5d 100644 --- a/modules/focus.lua +++ b/modules/focus.lua @@ -29,6 +29,8 @@ function SlashCmdList.PFFOCUS(msg) pfUI.uf.focus.unitname = nil pfUI.uf.focus.label = nil end + local _, guid = UnitExists("target") + pfUI.uf.focus.guid = guid end SLASH_PFCLEARFOCUS1, SLASH_PFCLEARFOCUS2 = '/clearfocus', '/pfclearfocus' @@ -49,7 +51,9 @@ function SlashCmdList.PFCASTFOCUS(msg) 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 + if pfUI.uf.focus.guid then + TargetUnit(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 @@ -88,9 +92,14 @@ 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 + 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 + elseif exists and currentUnitName and pfUI.uf.focus.unitname then TargetByName(pfUI.uf.focus.unitname) - pfUI.uf.focus.unitname = oldunit + pfUI.uf.focus.unitname = currentUnitName end end From 1a230bf6dd243c7045b1d7b1f30510e6e21d4a3b Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Sat, 11 May 2024 14:06:16 -0700 Subject: [PATCH 05/10] remove old swap logic --- modules/focus.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/focus.lua b/modules/focus.lua index f8cc8a5d..9b6c3441 100644 --- a/modules/focus.lua +++ b/modules/focus.lua @@ -98,8 +98,5 @@ function SlashCmdList.PFSWAPFOCUS(msg) TargetUnit(pfUI.uf.focus.guid) pfUI.uf.focus.unitname = currentUnitName pfUI.uf.focus.guid = currentUnitGUID - elseif exists and currentUnitName and pfUI.uf.focus.unitname then - TargetByName(pfUI.uf.focus.unitname) - pfUI.uf.focus.unitname = currentUnitName end end From f570cf348d7a171097cc9d2226f55107c577c71c Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Mon, 13 May 2024 09:49:48 -0700 Subject: [PATCH 06/10] reduce update frequency on a bunch of stuff --- api/unitframes.lua | 15 ++++++++++----- modules/cooldown.lua | 4 ++-- modules/nameplates.lua | 8 ++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 99100a6e..45d5206e 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -27,7 +27,7 @@ local glow2 = { local maxdurations = {} local function BuffOnUpdate() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .2 end + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end local timeleft = GetPlayerBuffTimeLeft(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HELPFUL")) local texture = GetPlayerBuffTexture(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HELPFUL")) local start = 0 @@ -45,6 +45,7 @@ local function BuffOnUpdate() end local function TargetBuffOnUpdate() + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end local name, rank, icon, count, duration, timeleft = _G.UnitBuff("target", this.id) if duration and timeleft then CooldownFrame_SetTimer(this.cd, GetTime() + timeleft - duration, duration, 1) @@ -113,7 +114,7 @@ local function BuffOnClick() end local function DebuffOnUpdate() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .2 end + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end local timeleft = GetPlayerBuffTimeLeft(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HARMFUL")) local texture = GetPlayerBuffTexture(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HARMFUL")) local start = 0 @@ -154,7 +155,7 @@ end local visibilityscan = CreateFrame("Frame", "pfUnitFrameVisibility", UIParent) visibilityscan.frames = {} visibilityscan:SetScript("OnUpdate", function() - if ( this.limit or 1) > GetTime() then return else this.limit = GetTime() + .2 end + if ( this.limit or 1) > GetTime() then return else this.limit = GetTime() + 0.5 end for frame in pairs(this.frames) do frame:UpdateVisibility() end end) @@ -188,6 +189,7 @@ end pfUI.uf.glow = CreateFrame("Frame") pfUI.uf.glow:SetScript("OnUpdate", function() + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end local fpsmod = GetFramerate() / 30 if not this.val or this.val >= .8 then this.mod = -0.01 / fpsmod @@ -201,6 +203,7 @@ pfUI.uf.glow.mod = 0 pfUI.uf.glow.val = 0 function pfUI.uf.glow.UpdateGlowAnimation() + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end this:SetAlpha(pfUI.uf.glow.val) end @@ -909,6 +912,8 @@ function pfUI.uf.OnEvent() end function pfUI.uf.OnUpdate() + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .1 end + -- update combat feedback if this.feedbackText then CombatFeedback_OnUpdate(arg1) end @@ -1057,11 +1062,11 @@ function pfUI.uf.OnUpdate() end -- trigger eventless actions (online/offline/range) - if not this.lastTick then this.lastTick = GetTime() + (this.tick or .2) end + if not this.lastTick then this.lastTick = GetTime() + (this.tick or .5) end if this.lastTick and this.lastTick < GetTime() then local unitstr = this.label .. this.id - this.lastTick = GetTime() + (this.tick or .2) + this.lastTick = GetTime() + (this.tick or .5) -- target target has a huge delay, make sure to not tick during range checks -- by waiting for a stable name over three ticks otherwise aborting the update. diff --git a/modules/cooldown.lua b/modules/cooldown.lua index a4ca7b6b..d20f66fa 100644 --- a/modules/cooldown.lua +++ b/modules/cooldown.lua @@ -18,9 +18,9 @@ pfUI:RegisterModule("cooldown", "vanilla:tbc", function () end end - if not this.next then this.next = GetTime() + .1 end + if not this.next then this.next = GetTime() + .5 end if this.next > GetTime() then return end - this.next = GetTime() + .1 + this.next = GetTime() + .5 -- fix own alpha value (should be inherited, but somehow isn't always) this:SetAlpha(parent:GetAlpha()) diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 007964ec..25ec76b3 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -736,6 +736,8 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () end nameplates.OnUpdate = function(frame) + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end + local update local frame = frame or this local nameplate = frame.nameplate @@ -761,12 +763,6 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () nameplate:SetAlpha(tonumber(C.nameplates.notargalpha)) end - -- use timer based updates - if not nameplate.tick or nameplate.tick < GetTime() then - nameplate.tick = GetTime() + .2 - update = true - end - -- queue update on visual target update if nameplate.cache.target ~= target then nameplate.cache.target = target From da013f5eacb38d8fe6a816a535ab95dda5a6d1eb Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Mon, 13 May 2024 17:56:42 -0700 Subject: [PATCH 07/10] improve cooldown frame update --- modules/cooldown.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/cooldown.lua b/modules/cooldown.lua index d20f66fa..cc7be5eb 100644 --- a/modules/cooldown.lua +++ b/modules/cooldown.lua @@ -18,9 +18,9 @@ pfUI:RegisterModule("cooldown", "vanilla:tbc", function () end end - if not this.next then this.next = GetTime() + .5 end + if not this.next then this.next = GetTime() + .1 end if this.next > GetTime() then return end - this.next = GetTime() + .5 + this.next = GetTime() + .1 -- fix own alpha value (should be inherited, but somehow isn't always) this:SetAlpha(parent:GetAlpha()) @@ -29,6 +29,10 @@ pfUI:RegisterModule("cooldown", "vanilla:tbc", function () -- calculating remaining time as it should be local remaining = this.duration - (GetTime() - this.start) if remaining >= 0 then + -- slow down updates for long cds + if remaining > 5 then + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end + end this.text:SetText(GetColoredTimeString(remaining)) else this:Hide() @@ -45,6 +49,10 @@ pfUI:RegisterModule("cooldown", "vanilla:tbc", function () local remaining = cdEndTime - time if remaining >= 0 then + -- slow down updates for long cds + if remaining > 5 then + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end + end this.text:SetText(GetColoredTimeString(remaining)) else this:Hide() From cb2408df99ed247232e86621873519e9d59583dd Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Sat, 18 May 2024 21:04:46 -0700 Subject: [PATCH 08/10] revert some of the reduced updated changes --- modules/cooldown.lua | 13 +++---------- modules/nameplates.lua | 8 ++++++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/modules/cooldown.lua b/modules/cooldown.lua index a21d1295..45e26c62 100644 --- a/modules/cooldown.lua +++ b/modules/cooldown.lua @@ -19,8 +19,9 @@ pfUI:RegisterModule("cooldown", "vanilla:tbc", function () end end - -- only run every 0.1 seconds from here on - if ( this.tick or .1) > GetTime() then return else this.tick = GetTime() + .1 end + if not this.next then this.next = GetTime() + .1 end + if this.next > GetTime() then return end + this.next = GetTime() + .1 -- fix own alpha value (should be inherited, but somehow isn't always) if this:GetAlpha() ~= parent:GetAlpha() then @@ -31,10 +32,6 @@ pfUI:RegisterModule("cooldown", "vanilla:tbc", function () -- calculating remaining time as it should be local remaining = this.duration - (GetTime() - this.start) if remaining >= 0 then - -- slow down updates for long cds - if remaining > 5 then - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end - end this.text:SetText(GetColoredTimeString(remaining)) else this:Hide() @@ -51,10 +48,6 @@ pfUI:RegisterModule("cooldown", "vanilla:tbc", function () local remaining = cdEndTime - time if remaining >= 0 then - -- slow down updates for long cds - if remaining > 5 then - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end - end this.text:SetText(GetColoredTimeString(remaining)) else this:Hide() diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 25ec76b3..007964ec 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -736,8 +736,6 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () end nameplates.OnUpdate = function(frame) - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end - local update local frame = frame or this local nameplate = frame.nameplate @@ -763,6 +761,12 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () nameplate:SetAlpha(tonumber(C.nameplates.notargalpha)) end + -- use timer based updates + if not nameplate.tick or nameplate.tick < GetTime() then + nameplate.tick = GetTime() + .2 + update = true + end + -- queue update on visual target update if nameplate.cache.target ~= target then nameplate.cache.target = target From ac0ca01259f7cd76948b6e3fb8f081f058d5f8ab Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Sun, 19 May 2024 08:20:32 -0700 Subject: [PATCH 09/10] revert other onupdate changes --- api/unitframes.lua | 15 +++++---------- modules/cooldown.lua | 5 ++--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 45d5206e..99100a6e 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -27,7 +27,7 @@ local glow2 = { local maxdurations = {} local function BuffOnUpdate() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .2 end local timeleft = GetPlayerBuffTimeLeft(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HELPFUL")) local texture = GetPlayerBuffTexture(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HELPFUL")) local start = 0 @@ -45,7 +45,6 @@ local function BuffOnUpdate() end local function TargetBuffOnUpdate() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end local name, rank, icon, count, duration, timeleft = _G.UnitBuff("target", this.id) if duration and timeleft then CooldownFrame_SetTimer(this.cd, GetTime() + timeleft - duration, duration, 1) @@ -114,7 +113,7 @@ local function BuffOnClick() end local function DebuffOnUpdate() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .2 end local timeleft = GetPlayerBuffTimeLeft(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HARMFUL")) local texture = GetPlayerBuffTexture(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HARMFUL")) local start = 0 @@ -155,7 +154,7 @@ end local visibilityscan = CreateFrame("Frame", "pfUnitFrameVisibility", UIParent) visibilityscan.frames = {} visibilityscan:SetScript("OnUpdate", function() - if ( this.limit or 1) > GetTime() then return else this.limit = GetTime() + 0.5 end + if ( this.limit or 1) > GetTime() then return else this.limit = GetTime() + .2 end for frame in pairs(this.frames) do frame:UpdateVisibility() end end) @@ -189,7 +188,6 @@ end pfUI.uf.glow = CreateFrame("Frame") pfUI.uf.glow:SetScript("OnUpdate", function() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end local fpsmod = GetFramerate() / 30 if not this.val or this.val >= .8 then this.mod = -0.01 / fpsmod @@ -203,7 +201,6 @@ pfUI.uf.glow.mod = 0 pfUI.uf.glow.val = 0 function pfUI.uf.glow.UpdateGlowAnimation() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end this:SetAlpha(pfUI.uf.glow.val) end @@ -912,8 +909,6 @@ function pfUI.uf.OnEvent() end function pfUI.uf.OnUpdate() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .1 end - -- update combat feedback if this.feedbackText then CombatFeedback_OnUpdate(arg1) end @@ -1062,11 +1057,11 @@ function pfUI.uf.OnUpdate() end -- trigger eventless actions (online/offline/range) - if not this.lastTick then this.lastTick = GetTime() + (this.tick or .5) end + if not this.lastTick then this.lastTick = GetTime() + (this.tick or .2) end if this.lastTick and this.lastTick < GetTime() then local unitstr = this.label .. this.id - this.lastTick = GetTime() + (this.tick or .5) + this.lastTick = GetTime() + (this.tick or .2) -- target target has a huge delay, make sure to not tick during range checks -- by waiting for a stable name over three ticks otherwise aborting the update. diff --git a/modules/cooldown.lua b/modules/cooldown.lua index 45e26c62..43b8ef91 100644 --- a/modules/cooldown.lua +++ b/modules/cooldown.lua @@ -19,9 +19,8 @@ pfUI:RegisterModule("cooldown", "vanilla:tbc", function () end end - if not this.next then this.next = GetTime() + .1 end - if this.next > GetTime() then return end - this.next = GetTime() + .1 + -- only run every 0.1 seconds from here on + if ( this.tick or .1) > GetTime() then return else this.tick = GetTime() + .1 end -- fix own alpha value (should be inherited, but somehow isn't always) if this:GetAlpha() ~= parent:GetAlpha() then From 0b682396055bac8014c1312655d6ef8d8eeab1bb Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Tue, 21 May 2024 11:54:30 -0700 Subject: [PATCH 10/10] fix castfocus --- modules/focus.lua | 193 ++++++++++++++++++++++++++-------------------- 1 file changed, 109 insertions(+), 84 deletions(-) diff --git a/modules/focus.lua b/modules/focus.lua index 9b6c3441..b2b5ec80 100644 --- a/modules/focus.lua +++ b/modules/focus.lua @@ -1,102 +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 - local _, guid = UnitExists("target") - pfUI.uf.focus.guid = guid + 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.guid then - TargetUnit(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 - 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 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 + pfUI:SwapFocus() end