fix: CTA pre-buff no longer depends on broken BC/BO skill templates
Removed the visual skill check (is_right_skill_selected BC/BO) that always failed because the BC.png/BO.png templates do not match D2R icons. New flow: switch weapon, cast BC, cast BO, buff, switch back. Only verifies swap-back by matching the original skill icon via template matching.
This commit is contained in:
+20
-32
@@ -157,7 +157,8 @@ class IChar:
|
||||
while time.time() - check_success_start < 2:
|
||||
if success_func is None or success_func():
|
||||
return True
|
||||
Logger.error(f"Wanted to select {template_type}, but could not find it")
|
||||
elapsed = time.time() - start
|
||||
Logger.error(f"select_by_template: could not find {template_type} after {elapsed:.1f}s (timeout={timeout}s, threshold={threshold})")
|
||||
return False
|
||||
|
||||
def skill_is_charged(self, img: np.ndarray = None) -> bool:
|
||||
@@ -303,38 +304,25 @@ class IChar:
|
||||
return False
|
||||
|
||||
def _pre_buff_cta(self):
|
||||
# Save current skill img
|
||||
# Save current skill img before swapping
|
||||
skill_before = cut_roi(grab(), Config().ui_roi["skill_right"])
|
||||
# Try to switch weapons and select bo until we find the skill on the right skill slot
|
||||
start = time.time()
|
||||
switch_sucess = False
|
||||
while time.time() - start < 4:
|
||||
keyboard.send(Config().char["weapon_switch"])
|
||||
wait(0.3, 0.35)
|
||||
keyboard.send(Config().char["battle_command"])
|
||||
wait(0.1,0.2)
|
||||
if skills.is_right_skill_selected(["BC", "BO"]):
|
||||
switch_sucess = True
|
||||
break
|
||||
else:
|
||||
Logger.warning("Failed to find Battle Command, swapping weapons again.")
|
||||
skill_before = cut_roi(grab(), Config().ui_roi["skill_right"])
|
||||
# Switch to CTA weapon and cast Battle Command
|
||||
keyboard.send(Config().char["weapon_switch"])
|
||||
wait(0.3, 0.35)
|
||||
keyboard.send(Config().char["battle_command"])
|
||||
wait(0.1, 0.2)
|
||||
# Cast Battle Command (right click)
|
||||
mouse.click(button="right")
|
||||
wait(self._cta_cast_duration, self._cta_cast_duration)
|
||||
# Select and cast Battle Orders
|
||||
self._select_skill(skill = "battle_orders", mouse_click_type="right", delay=(0.1, 0.2))
|
||||
mouse.click(button="right")
|
||||
wait(self._cta_cast_duration, self._cta_cast_duration)
|
||||
if Config().char["buff_with_cta"]:
|
||||
self.cast_buffs(self._cta_cast_duration)
|
||||
wait(0.08, 0.08)
|
||||
|
||||
if not switch_sucess:
|
||||
Logger.error("You dont have Battle Command bound, or you do not have CTA. Ending CTA buff")
|
||||
return False
|
||||
else:
|
||||
# We switched succesfully, let's pre buff
|
||||
mouse.click(button="right")
|
||||
wait(self._cta_cast_duration, self._cta_cast_duration)
|
||||
self._select_skill(skill = "battle_orders", mouse_click_type="right", delay=(0.1, 0.2))
|
||||
mouse.click(button="right")
|
||||
wait(self._cta_cast_duration, self._cta_cast_duration)
|
||||
if Config().char["buff_with_cta"]:
|
||||
self.cast_buffs(self._cta_cast_duration)
|
||||
wait(0.08,0.08) #Give extra time after last cast to allow weapon switch to be available
|
||||
|
||||
# Make sure the switch back to the original weapon is good
|
||||
# Switch back to original weapon - verify by matching skill icon
|
||||
start = time.time()
|
||||
switch_sucess = False
|
||||
while time.time() - start < 4:
|
||||
@@ -346,7 +334,7 @@ class IChar:
|
||||
switch_sucess = True
|
||||
break
|
||||
else:
|
||||
Logger.warning("Failed to switch weapon, try again")
|
||||
Logger.warning("Failed to switch weapon back, try again")
|
||||
wait(0.5)
|
||||
return switch_sucess
|
||||
|
||||
|
||||
Reference in New Issue
Block a user