fix: optimize shapeshift auto-unshift logic by improving cast event handling, reducing spam intervals, and extending state timeout durations

This commit is contained in:
Bluewhale1337
2026-09-02 18:56:05 +02:00
parent 16bc4d95ee
commit 6760e4e43d
4 changed files with 24 additions and 8 deletions
+1 -1
View File
@@ -186,7 +186,7 @@ function HealBot_OnEvent_UnitAura(this, unit)
local trackedTextures = {}
while true do
local debuff, tmp, debuff_type = UnitDebuff(unit, i, 1)
local debuff, tmp, debuff_type = UnitDebuff(unit, i)
if debuff then
local mapped_type = nil
if debuff_type then
+20 -5
View File
@@ -102,7 +102,7 @@ function HealBot_OnUpdate(this, arg1)
baseSpell = string.gsub(baseSpell, "%s+$", "")
-- Force MVC updates since we guarantee the cast will eventually pierce the server
HealBot_CastFailed = false
HealBot_CastFailed = true -- Trigger first attempt immediately
HealBot_CastingSpell = baseSpell
HealBot_CastingTarget = pendingCast.target
HealBot_Process_HealValue(baseSpell, pendingCast.target)
@@ -119,10 +119,10 @@ function HealBot_OnUpdate(this, arg1)
HealBot_TargetRestoreTimer = 0
end
-- 2. Spam the raw cast silently to guarantee it pierces the server delay
-- 2. Spam the cast until the server explicitly accepts it (firing SPELLCAST_START)
if pendingCast.started then
if not pendingCast.nextSpam or GetTime() >= pendingCast.nextSpam then
pendingCast.nextSpam = GetTime() + 0.15
pendingCast.nextSpam = GetTime() + 0.10
-- Safely suppress UI errors
UIErrorsFrame:UnregisterEvent("UI_ERROR_MESSAGE")
@@ -146,6 +146,8 @@ function HealBot_OnUpdate(this, arg1)
-- Failsafe timeout
if HealBot_PendingShapeshiftCast and GetTime() > pendingCast.expires then
HealBot_PendingShapeshiftCast = nil
HealBot_StopCasting()
HealBot_RecalcHeals()
end
end
@@ -580,10 +582,23 @@ end
-- HealBot_OnEvent_SpellcastStop: Internal utility: HealBot_OnEvent_SpellcastStop
function HealBot_OnEvent_SpellcastStop(this, eventName)
HealBot_IsCasting = false;
HealBot_PendingShapeshiftCast = nil;
if eventName == "SPELLCAST_FAILED" then
if eventName == "SPELLCAST_FAILED" or eventName == "SPELLCAST_INTERRUPTED" then
HealBot_CastFailed = true;
if HealBot_PendingShapeshiftCast then
return;
end
end
if HealBot_PendingShapeshiftCast and eventName == "SPELLCAST_STOP" then
if HealBot_CastFailed or not HealBot_PendingShapeshiftCast.started then
-- This STOP is either the trailing event of a failed/interrupted cast,
-- or it is the STOP event from the unshift spell itself.
-- Do not wipe the queue yet!
return;
end
end
HealBot_PendingShapeshiftCast = nil;
HealBot_StopCasting();
HealBot_RecalcHeals();
if HealBot_IamRessing then
+2 -1
View File
@@ -211,6 +211,7 @@ end
-- HealBot_StopCasting: Internal utility: HealBot_StopCasting
function HealBot_StopCasting()
HealBot_IsCasting = false;
if HealBot_CastingTarget then
if HealBot_HealValue > 0 then
local uname = UnitName(HealBot_CastingTarget)
@@ -325,7 +326,7 @@ function HealBot_CastSpellOnFriend(spell, target)
if formCancelled then
-- ALWAYS put the cast into the Pending queue so the OnUpdate loop can wait for the server
-- to process the unshift before attempting the cast, otherwise we get "You are in shapeshift form".
HealBot_PendingShapeshiftCast = { spell = spell, target = target, targetEnemy = targetEnemy, oldTarget = oldTarget, fireTime = GetTime() + 0.05, expires = GetTime() + 1.0 }
HealBot_PendingShapeshiftCast = { spell = spell, target = target, targetEnemy = targetEnemy, oldTarget = oldTarget, fireTime = GetTime() + 0.05, expires = GetTime() + 2.0 }
return;
end
+1 -1
View File
@@ -83,7 +83,7 @@
</Frames>
<Layers>
<Layer level="ARTWORK">
<FontString name="HealBot_Options_Integrations_NampowerInfo" inherits="GameFontHighlightSmall" justifyH="LEFT" justifyV="TOP" text="Note: For the 1-click Shapeshift auto-unshift to work smoothly, you must DISABLE 'Retry server rejected spells' in Nampower ENABLE Queue Instant Cast Spells and Queue Cast Time Spells.">
<FontString name="HealBot_Options_Integrations_NampowerInfo" inherits="GameFontHighlightSmall" justifyH="LEFT" justifyV="TOP" text="Note: For the 1-click Shapeshift auto-unshift to work smoothly, you must ENABLE 'Retry server rejected spells' in Nampower ENABLE Queue Instant Cast Spells and Queue Cast Time Spells.">
<Size x="330" y="30"/>
<Anchors>
<Anchor point="TOPLEFT">