diff --git a/modules/hunterbar.lua b/modules/hunterbar.lua index b6de6e24..9cb5da87 100644 --- a/modules/hunterbar.lua +++ b/modules/hunterbar.lua @@ -23,51 +23,24 @@ pfUI:RegisterModule("hunterbar", "vanilla", function () return end - local onMeleeBar = (_G.CURRENT_ACTIONBAR_PAGE == 1) - local onRangedBar = (_G.CURRENT_ACTIONBAR_PAGE == 9) + local wingclipInRange = IsSpellInRange(WINGCLIP_ID, "target") + local arcaneshotInRange = IsSpellInRange(ARCANESHOT_ID, "target") - -- IsSpellInRange returns: 1 = in range, 0 = out of range, -1 = not applicable - -- IsSpellUsable returns: usable(0/1), outOfMana(0/1) - -- We only swap when the *destination* condition is fully confirmed. - - if onMeleeBar then - -- Currently on melee bar → switch to ranged bar only when: - -- • Wing Clip is OUT of range (we are far enough away) - -- • Arcane Shot IS in range (ranged attack would actually land) - -- • Arcane Shot is usable (not dead / phase / etc.) - local wingclipInRange = IsSpellInRange(WINGCLIP_ID, "target") - local arcaneshotInRange = IsSpellInRange(ARCANESHOT_ID, "target") - local arcaneshotUsable = IsSpellUsable(ARCANESHOT_ID) - - if wingclipInRange == 0 and arcaneshotInRange == 1 and arcaneshotUsable == 1 then - if this.lastPage ~= 9 then - this.lastPage = 9 - _G.CURRENT_ACTIONBAR_PAGE = 9 - ChangeActionBarPage() - end + -- swap to ranged bar: out of melee range AND arcane shot (8yd) in range + if wingclipInRange == 0 and arcaneshotInRange == 1 then + if this.lastPage ~= 9 then + this.lastPage = 9 + _G.CURRENT_ACTIONBAR_PAGE = 9 + ChangeActionBarPage() end - elseif onRangedBar then - -- Currently on ranged bar → switch back to melee bar only when: - -- • Wing Clip IS in range (we are close enough to melee) - -- • Wing Clip is usable (not dead / phase / etc.) - -- • Arcane Shot is OUT of range (fully in melee – belt-and-suspenders) - local wingclipInRange = IsSpellInRange(WINGCLIP_ID, "target") - local wingclipUsable = IsSpellUsable(WINGCLIP_ID) - local arcaneshotInRange = IsSpellInRange(ARCANESHOT_ID, "target") - - if wingclipInRange == 1 and wingclipUsable == 1 and arcaneshotInRange == 0 then - if this.lastPage ~= 1 then - this.lastPage = 1 - _G.CURRENT_ACTIONBAR_PAGE = 1 - ChangeActionBarPage() - end + -- swap to melee bar: in melee range AND arcane shot (8yd) out of range + elseif wingclipInRange == 1 and arcaneshotInRange == 0 then + if this.lastPage ~= 1 then + this.lastPage = 1 + _G.CURRENT_ACTIONBAR_PAGE = 1 + ChangeActionBarPage() end - - else - -- Player manually switched to a different page → stop tracking - -- until they return to page 1 or 9. - this.lastPage = nil end end) end) \ No newline at end of file