Refine combat approach timing and always run mouse loot
This commit is contained in:
35
auto_bot.py
35
auto_bot.py
@@ -207,6 +207,7 @@ class AutoBot:
|
||||
enable_mouse_loot=True,
|
||||
turn_error_key=None,
|
||||
turn_error_hold_sec=None,
|
||||
distance_interact_pause_sec=None,
|
||||
):
|
||||
self.last_tab_time = 0
|
||||
self.last_interaction_time = 0
|
||||
@@ -226,6 +227,12 @@ class AutoBot:
|
||||
self.turn_error_key = (turn_error_key or 's').strip().lower() or 's'
|
||||
self.combat_signal_retry_sec = 1.0
|
||||
self.turn_error_hold_sec = float(turn_error_hold_sec) if turn_error_hold_sec is not None else 0.8
|
||||
self.distance_interact_pause_until = 0.0
|
||||
self.distance_interact_brake_pending = False
|
||||
self.distance_interact_pause_sec = (
|
||||
float(distance_interact_pause_sec) if distance_interact_pause_sec is not None else 1.0
|
||||
)
|
||||
self.distance_interact_brake_sec = 0.08
|
||||
self._last_mouse_path_scale_signature = None
|
||||
|
||||
def execute_disengage_loot(self):
|
||||
@@ -307,8 +314,6 @@ class AutoBot:
|
||||
score_threshold=0.7,
|
||||
return_on_first_click=False,
|
||||
):
|
||||
if random.random() < 0.1:
|
||||
return False
|
||||
hwnd = win32gui.FindWindow(None, WIN_TITLE)
|
||||
if not hwnd:
|
||||
return False
|
||||
@@ -397,7 +402,6 @@ class AutoBot:
|
||||
score_threshold=0.7,
|
||||
return_on_first_click=False,
|
||||
)
|
||||
if random.random() < 0.1: return False
|
||||
hwnd = win32gui.FindWindow(None, WIN_TITLE)
|
||||
if not hwnd: return False
|
||||
|
||||
@@ -514,6 +518,8 @@ class AutoBot:
|
||||
is_new_target = (target_hp > self.last_target_hp + 5)
|
||||
if is_new_target:
|
||||
self._has_braked_for_target = False
|
||||
self.distance_interact_brake_pending = False
|
||||
self.distance_interact_pause_until = 0.0
|
||||
|
||||
# 1. 刹车逻辑
|
||||
if not self._has_braked_for_target and 0 < target_hp < self.last_target_hp:
|
||||
@@ -522,6 +528,20 @@ class AutoBot:
|
||||
hw_ctrl.keyUp('s')
|
||||
self._has_braked_for_target = True
|
||||
|
||||
if self.distance_interact_brake_pending:
|
||||
if current_time < self.distance_interact_pause_until:
|
||||
self.last_target_hp = target_hp
|
||||
self._was_in_combat_or_target = True
|
||||
return
|
||||
hw_ctrl.keyDown('s')
|
||||
time.sleep(self.distance_interact_brake_sec)
|
||||
hw_ctrl.keyUp('s')
|
||||
self.distance_interact_brake_pending = False
|
||||
self.distance_interact_pause_until = 0.0
|
||||
self.last_target_hp = target_hp
|
||||
self._was_in_combat_or_target = True
|
||||
return
|
||||
|
||||
# 2. 根据战斗信号执行纠偏动作
|
||||
if (
|
||||
combat_error_signal == 100
|
||||
@@ -529,6 +549,11 @@ class AutoBot:
|
||||
):
|
||||
hw_ctrl.press(KEY_LOOT)
|
||||
self.last_interaction_time = current_time
|
||||
self.distance_interact_pause_until = current_time + self.distance_interact_pause_sec
|
||||
self.distance_interact_brake_pending = True
|
||||
self.last_target_hp = target_hp
|
||||
self._was_in_combat_or_target = True
|
||||
return
|
||||
|
||||
if (
|
||||
combat_error_signal == 50
|
||||
@@ -552,6 +577,8 @@ class AutoBot:
|
||||
self.last_target_hp = 0
|
||||
self.last_turn_signal_time = 0.0
|
||||
self.last_interaction_time = 0.0
|
||||
self.distance_interact_brake_pending = False
|
||||
self.distance_interact_pause_until = 0.0
|
||||
self._has_braked_for_target = False
|
||||
return
|
||||
|
||||
@@ -559,6 +586,8 @@ class AutoBot:
|
||||
self.last_target_hp = 0
|
||||
self.last_turn_signal_time = 0.0
|
||||
self.last_interaction_time = 0.0
|
||||
self.distance_interact_brake_pending = False
|
||||
self.distance_interact_pause_until = 0.0
|
||||
self._has_braked_for_target = False
|
||||
|
||||
self.tab_no_target_count = min(self.tab_no_target_count, 5)
|
||||
|
||||
Reference in New Issue
Block a user