mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-26 05:50:50 +00:00
possible fix for swingtimer.lua
- Added slam and more check mechanics for swing timer.
This commit is contained in:
+36
-12
@@ -163,6 +163,11 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function ()
|
|||||||
CreateBackdrop(pfUI.swingtimer.ranged)
|
CreateBackdrop(pfUI.swingtimer.ranged)
|
||||||
CreateBackdropShadow(pfUI.swingtimer.ranged)
|
CreateBackdropShadow(pfUI.swingtimer.ranged)
|
||||||
|
|
||||||
|
-- Slam spell IDs (all ranks) - resets swing timer from now, not chained
|
||||||
|
local slamSpellIDs = {
|
||||||
|
[1464] = true, [8820] = true, [11604] = true, [11605] = true,
|
||||||
|
}
|
||||||
|
|
||||||
-- HS/Cleave queue state
|
-- HS/Cleave queue state
|
||||||
local hsQueued = false
|
local hsQueued = false
|
||||||
local cleaveQueued = false
|
local cleaveQueued = false
|
||||||
@@ -277,7 +282,7 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function StartSwing(isOffhand)
|
local function StartSwing(isOffhand, resetFromNow)
|
||||||
local now = GetTime()
|
local now = GetTime()
|
||||||
|
|
||||||
-- always refresh speeds to catch haste buffs/debuffs
|
-- always refresh speeds to catch haste buffs/debuffs
|
||||||
@@ -293,14 +298,16 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if isOffhand and swingState.offhand.speed > 0 then
|
if isOffhand and swingState.offhand.speed > 0 then
|
||||||
-- Continue from previous nextSwing to avoid timer jumps
|
-- resetFromNow: hard reset (e.g. Slam) - always start from now
|
||||||
local base = (swingState.offhand.swinging and swingState.offhand.nextSwing > (now - 0.5)) and swingState.offhand.nextSwing or now
|
-- otherwise: chain from previous nextSwing to avoid timer jumps
|
||||||
|
local base = (not resetFromNow and swingState.offhand.swinging and swingState.offhand.nextSwing > (now - 0.5)) and swingState.offhand.nextSwing or now
|
||||||
swingState.offhand.nextSwing = base + swingState.offhand.speed
|
swingState.offhand.nextSwing = base + swingState.offhand.speed
|
||||||
swingState.offhand.swinging = true
|
swingState.offhand.swinging = true
|
||||||
if sw_showoh then pfUI.swingtimer.offhand:Show() end
|
if sw_showoh then pfUI.swingtimer.offhand:Show() end
|
||||||
else
|
else
|
||||||
-- Continue from previous nextSwing to avoid timer jumps on HS/normal swing
|
-- resetFromNow: hard reset (e.g. Slam) - always start from now
|
||||||
local base = (swingState.mainhand.swinging and swingState.mainhand.nextSwing > (now - 0.5)) and swingState.mainhand.nextSwing or now
|
-- otherwise: chain from previous nextSwing to avoid timer jumps on HS/normal swing
|
||||||
|
local base = (not resetFromNow and swingState.mainhand.swinging and swingState.mainhand.nextSwing > (now - 0.5)) and swingState.mainhand.nextSwing or now
|
||||||
swingState.mainhand.nextSwing = base + swingState.mainhand.speed
|
swingState.mainhand.nextSwing = base + swingState.mainhand.speed
|
||||||
swingState.mainhand.swinging = true
|
swingState.mainhand.swinging = true
|
||||||
pfUI.swingtimer.mainhand:Show()
|
pfUI.swingtimer.mainhand:Show()
|
||||||
@@ -507,6 +514,10 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function ()
|
|||||||
pfUI.libdebuff_spell_go_hooks["swingtimer"] = function(spellId)
|
pfUI.libdebuff_spell_go_hooks["swingtimer"] = function(spellId)
|
||||||
if RANGED_SPELLIDS[spellId] then
|
if RANGED_SPELLIDS[spellId] then
|
||||||
StartRangedSwing()
|
StartRangedSwing()
|
||||||
|
elseif slamSpellIDs[spellId] then
|
||||||
|
-- Slam resets the swing timer hard from now (not chained from previous nextSwing)
|
||||||
|
hsQueued = false; cleaveQueued = false
|
||||||
|
StartSwing(false, true)
|
||||||
elseif hsSpellIDs[spellId] then
|
elseif hsSpellIDs[spellId] then
|
||||||
hsQueued = false; cleaveQueued = false
|
hsQueued = false; cleaveQueued = false
|
||||||
StartSwing(false)
|
StartSwing(false)
|
||||||
@@ -539,20 +550,33 @@ pfUI:RegisterModule("swingtimer", "vanilla:tbc", function ()
|
|||||||
StartSwing(isOffhand)
|
StartSwing(isOffhand)
|
||||||
|
|
||||||
elseif event == "AUTO_ATTACK_OTHER" then
|
elseif event == "AUTO_ATTACK_OTHER" then
|
||||||
if not swingState.mainhand.swinging then return end
|
-- arg1=attackerGuid, arg2=targetGuid, arg3=totalDamage, arg4=hitInfo, arg5=victimState
|
||||||
|
-- We want: someone attacked the player (targetGuid == playerGUID) and the player parried
|
||||||
local targetGuid = arg2
|
local targetGuid = arg2
|
||||||
if not targetGuid or not playerGUID then return end
|
if not targetGuid or not playerGUID then return end
|
||||||
if targetGuid ~= playerGUID then return end
|
if targetGuid ~= playerGUID then return end
|
||||||
local victimState = arg5 or 0
|
local victimState = arg5 or 0
|
||||||
|
-- VICTIMSTATE_PARRY = 3
|
||||||
|
-- Vanilla parry mechanic: resets swing timer to 60% of weapon speed,
|
||||||
|
-- but only if the remaining time is more than 40% of weapon speed (otherwise no change)
|
||||||
if victimState == 3 then
|
if victimState == 3 then
|
||||||
local now = GetTime()
|
local now = GetTime()
|
||||||
|
local speed = swingState.mainhand.speed
|
||||||
local remaining = swingState.mainhand.nextSwing - now
|
local remaining = swingState.mainhand.nextSwing - now
|
||||||
local reduction = swingState.mainhand.speed * 0.4
|
local parryReset = speed * 0.6
|
||||||
local minRemaining = swingState.mainhand.speed * 0.2
|
local threshold = speed * 0.4
|
||||||
local newRemaining = remaining - reduction
|
-- Only apply reset if it would actually reduce the remaining time
|
||||||
if newRemaining < minRemaining then newRemaining = minRemaining end
|
if remaining > parryReset then
|
||||||
if newRemaining < remaining then
|
swingState.mainhand.nextSwing = now + parryReset
|
||||||
swingState.mainhand.nextSwing = now + newRemaining
|
swingState.mainhand.swinging = true
|
||||||
|
pfUI.swingtimer.mainhand:Show()
|
||||||
|
pfUI.swingtimer:Show()
|
||||||
|
elseif remaining <= 0 and threshold > 0 then
|
||||||
|
-- swing already fired but parry came in: reset to parryReset
|
||||||
|
swingState.mainhand.nextSwing = now + parryReset
|
||||||
|
swingState.mainhand.swinging = true
|
||||||
|
pfUI.swingtimer.mainhand:Show()
|
||||||
|
pfUI.swingtimer:Show()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user