From abb06066d5a8af5c2d39f05cca4f0840254bfcdc Mon Sep 17 00:00:00 2001 From: FiskenPoul <123322006+FiskenPoul@users.noreply.github.com> Date: Mon, 13 Jul 2026 13:35:48 +0200 Subject: [PATCH] CTA pre-buff: poll for Battle Command instead of racing a fixed wait MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every single game logged "Failed to find Battle Command, swapping weapons again" — 1182 times in the last log alone, always on the first attempt, always resolved by the very next loop iteration's identical check with no extra wait in between. The skill icon just takes a bit longer than the fixed 0.6-0.8s wait to render on this system; the check was racing it every time. Poll for up to 1.2s instead of a single check after a fixed wait. Catches the skill as soon as it's actually visible rather than always failing once first, and removes the latent risk of the fallback path incorrectly swapping back to the main weapon if timing ever degraded further. --- src/char/i_char.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/char/i_char.py b/src/char/i_char.py index b146f56..f67cd6e 100644 --- a/src/char/i_char.py +++ b/src/char/i_char.py @@ -329,10 +329,20 @@ class IChar: break self._weapon_switch() keyboard.send(Config().char["battle_command"]) - # Skill icon takes ~0.5s to update after the hotkey; checking too early - # fails every first pass and costs a full extra swap cycle per game. - wait(0.6, 0.8) - if skills.is_right_skill_selected(["BC", "BO"]): + # Skill icon takes anywhere from ~0.3s to ~0.9s to update after the + # hotkey. A single fixed-wait-then-check raced this and consistently + # logged a false "failed" (the very next loop pass would see the + # skill just fine, with no extra wait in between) — poll instead so + # we catch it the moment it renders, and only swap weapons again if + # it genuinely never shows up. + found = False + poll_start = time.time() + while time.time() - poll_start < 1.2: + if skills.is_right_skill_selected(["BC", "BO"]): + found = True + break + wait(0.1, 0.15) + if found: switch_success = True break else: