CTA pre-buff: poll for Battle Command instead of racing a fixed wait
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.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user