From bbf7c95fb98ba79313185e0bd089f4e9c092af9c Mon Sep 17 00:00:00 2001 From: GaboGG Date: Sun, 26 Jul 2026 13:27:24 -0400 Subject: [PATCH] v0.13.7 - Channeling prioritized before buff priority loop - Moved findBestChannelingTarget() BEFORE the BUFF_PRIORITY loop - When Q is pressed and channeling is active, the script now picks the most expensive buff for the channeling charge instead of wasting it on the first buff in priority order (Haste at 32 MP instead of Heartseeker at 175) - Reverted the vitals auto-execute (Q-key workflow, not auto-battle) - All three tiers: channeling check fires after castInitialBuffs but before the regular shouldBuff loop --- scripts/hv-unified.user.js | 20 +++++++++++++++----- scripts/latest.user.js | 20 +++++++++++++++----- src/init.js | 5 ----- src/strategy-engine.js | 15 +++++++++++++++ 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/scripts/hv-unified.user.js b/scripts/hv-unified.user.js index 2ab5c74..ddc8dc9 100644 --- a/scripts/hv-unified.user.js +++ b/scripts/hv-unified.user.js @@ -969,6 +969,11 @@ function strategyNovice() { const ib = castInitialBuffs(); if (ib) return ib; } + // If channeling is active, prioritize most expensive buff for best value + if (STATE.channeling && STATE.mp > 0.10) { + const ch = findBestChannelingTarget(); + if (ch) return ch; + } for (const b of BUFF_PRIORITY) { if (shouldBuff(b.icon, b.minTurns) && STATE.mp > 0.2 && hasSpell(b.spell)) { if (b.icon === 'regen' && STATE.hp >= CFG.cureRegenHP) continue; @@ -1084,6 +1089,11 @@ function strategyAdept() { const ib = castInitialBuffs(); if (ib) return ib; } + // If channeling is active, prioritize most expensive buff for best value + if (STATE.channeling && STATE.mp > 0.10) { + const ch = findBestChannelingTarget(); + if (ch) return ch; + } for (const b of BUFF_PRIORITY) { if (shouldBuff(b.icon, b.minTurns) && STATE.mp > 0.2 && hasSpell(b.spell)) { if (b.icon === 'regen' && STATE.hp >= CFG.cureRegenHP) continue; @@ -1212,6 +1222,11 @@ function strategyVeteran() { const ib = castInitialBuffs(); if (ib) return ib; } + // If channeling is active, prioritize most expensive buff for best value + if (STATE.channeling && STATE.mp > 0.10) { + const ch = findBestChannelingTarget(); + if (ch) return ch; + } for (const b of BUFF_PRIORITY) { if (shouldBuff(b.icon, b.minTurns) && STATE.mp > 0.2 && hasSpell(b.spell)) { if (b.icon === 'regen' && STATE.hp >= CFG.cureRegenHP) continue; @@ -3269,11 +3284,6 @@ function initializeBattle() { const vobs = new MutationObserver(() => { parseBattleState(); logRound(); // Also log on vitals changes (catches end-of-round) - // Auto-execute strategy even without hover — for auto-battle - if (CFG.hoverEnabled && !STATE.interruptHover && !STATE.interruptAlert) { - const a = getSmartAction(); - if (a) executeAction(a); - } refreshUI(); updateConfigButton(); // Check if battle ended (completion pane appeared) diff --git a/scripts/latest.user.js b/scripts/latest.user.js index 2ab5c74..ddc8dc9 100644 --- a/scripts/latest.user.js +++ b/scripts/latest.user.js @@ -969,6 +969,11 @@ function strategyNovice() { const ib = castInitialBuffs(); if (ib) return ib; } + // If channeling is active, prioritize most expensive buff for best value + if (STATE.channeling && STATE.mp > 0.10) { + const ch = findBestChannelingTarget(); + if (ch) return ch; + } for (const b of BUFF_PRIORITY) { if (shouldBuff(b.icon, b.minTurns) && STATE.mp > 0.2 && hasSpell(b.spell)) { if (b.icon === 'regen' && STATE.hp >= CFG.cureRegenHP) continue; @@ -1084,6 +1089,11 @@ function strategyAdept() { const ib = castInitialBuffs(); if (ib) return ib; } + // If channeling is active, prioritize most expensive buff for best value + if (STATE.channeling && STATE.mp > 0.10) { + const ch = findBestChannelingTarget(); + if (ch) return ch; + } for (const b of BUFF_PRIORITY) { if (shouldBuff(b.icon, b.minTurns) && STATE.mp > 0.2 && hasSpell(b.spell)) { if (b.icon === 'regen' && STATE.hp >= CFG.cureRegenHP) continue; @@ -1212,6 +1222,11 @@ function strategyVeteran() { const ib = castInitialBuffs(); if (ib) return ib; } + // If channeling is active, prioritize most expensive buff for best value + if (STATE.channeling && STATE.mp > 0.10) { + const ch = findBestChannelingTarget(); + if (ch) return ch; + } for (const b of BUFF_PRIORITY) { if (shouldBuff(b.icon, b.minTurns) && STATE.mp > 0.2 && hasSpell(b.spell)) { if (b.icon === 'regen' && STATE.hp >= CFG.cureRegenHP) continue; @@ -3269,11 +3284,6 @@ function initializeBattle() { const vobs = new MutationObserver(() => { parseBattleState(); logRound(); // Also log on vitals changes (catches end-of-round) - // Auto-execute strategy even without hover — for auto-battle - if (CFG.hoverEnabled && !STATE.interruptHover && !STATE.interruptAlert) { - const a = getSmartAction(); - if (a) executeAction(a); - } refreshUI(); updateConfigButton(); // Check if battle ended (completion pane appeared) diff --git a/src/init.js b/src/init.js index 633ba4c..d87b1fb 100644 --- a/src/init.js +++ b/src/init.js @@ -85,11 +85,6 @@ function initializeBattle() { const vobs = new MutationObserver(() => { parseBattleState(); logRound(); // Also log on vitals changes (catches end-of-round) - // Auto-execute strategy even without hover — for auto-battle - if (CFG.hoverEnabled && !STATE.interruptHover && !STATE.interruptAlert) { - const a = getSmartAction(); - if (a) executeAction(a); - } refreshUI(); updateConfigButton(); // Check if battle ended (completion pane appeared) diff --git a/src/strategy-engine.js b/src/strategy-engine.js index cf4653c..7a66a37 100644 --- a/src/strategy-engine.js +++ b/src/strategy-engine.js @@ -321,6 +321,11 @@ function strategyNovice() { const ib = castInitialBuffs(); if (ib) return ib; } + // If channeling is active, prioritize most expensive buff for best value + if (STATE.channeling && STATE.mp > 0.10) { + const ch = findBestChannelingTarget(); + if (ch) return ch; + } for (const b of BUFF_PRIORITY) { if (shouldBuff(b.icon, b.minTurns) && STATE.mp > 0.2 && hasSpell(b.spell)) { if (b.icon === 'regen' && STATE.hp >= CFG.cureRegenHP) continue; @@ -436,6 +441,11 @@ function strategyAdept() { const ib = castInitialBuffs(); if (ib) return ib; } + // If channeling is active, prioritize most expensive buff for best value + if (STATE.channeling && STATE.mp > 0.10) { + const ch = findBestChannelingTarget(); + if (ch) return ch; + } for (const b of BUFF_PRIORITY) { if (shouldBuff(b.icon, b.minTurns) && STATE.mp > 0.2 && hasSpell(b.spell)) { if (b.icon === 'regen' && STATE.hp >= CFG.cureRegenHP) continue; @@ -564,6 +574,11 @@ function strategyVeteran() { const ib = castInitialBuffs(); if (ib) return ib; } + // If channeling is active, prioritize most expensive buff for best value + if (STATE.channeling && STATE.mp > 0.10) { + const ch = findBestChannelingTarget(); + if (ch) return ch; + } for (const b of BUFF_PRIORITY) { if (shouldBuff(b.icon, b.minTurns) && STATE.mp > 0.2 && hasSpell(b.spell)) { if (b.icon === 'regen' && STATE.hp >= CFG.cureRegenHP) continue;