Use combat error signals for recovery actions
This commit is contained in:
43
auto_bot.py
43
auto_bot.py
@@ -214,12 +214,9 @@ class AutoBot:
|
||||
self.skinning_wait_sec = float(skinning_wait_sec) if skinning_wait_sec is not None else 1.5
|
||||
self.enable_mouse_loot = enable_mouse_loot
|
||||
self.cursor_mgr = CursorManager()
|
||||
self.last_target_damage_time = None
|
||||
self.last_attack_scan_time = 0.0
|
||||
self.attack_stall_scan_threshold = 2.0
|
||||
self.attack_scan_retry_sec = 2.0
|
||||
self.attack_stall_s_hold_sec = 0.5
|
||||
self.min_effective_target_damage_pct = 5
|
||||
self.last_turn_signal_time = 0.0
|
||||
self.combat_signal_retry_sec = 1.0
|
||||
self.turn_error_hold_sec = 0.8
|
||||
self._last_mouse_path_scale_signature = None
|
||||
|
||||
def execute_disengage_loot(self):
|
||||
@@ -495,6 +492,7 @@ class AutoBot:
|
||||
def execute_logic(self, state):
|
||||
current_time = time.time()
|
||||
target_hp = state.get('target_hp', 0)
|
||||
combat_error_signal = int(state.get('combat_error_signal', 255) or 255)
|
||||
|
||||
effective_target = bool(state['target'] and target_hp > 0)
|
||||
in_combat_or_target = bool(state['combat'] or effective_target)
|
||||
@@ -515,25 +513,22 @@ class AutoBot:
|
||||
hw_ctrl.keyUp('s')
|
||||
self._has_braked_for_target = True
|
||||
|
||||
# 2. 只有超过 5% 的明显掉血才算“新的有效掉血”
|
||||
hp_drop_amount = max(0, self.last_target_hp - target_hp)
|
||||
significant_hp_dropped = (
|
||||
self.last_target_hp > 0
|
||||
and hp_drop_amount > self.min_effective_target_damage_pct
|
||||
)
|
||||
if is_new_target or significant_hp_dropped or self.last_target_damage_time is None:
|
||||
self.last_target_damage_time = current_time
|
||||
# 2. 根据战斗信号执行纠偏动作
|
||||
if (
|
||||
combat_error_signal == 100
|
||||
and (current_time - self.last_interaction_time) >= self.combat_signal_retry_sec
|
||||
):
|
||||
hw_ctrl.press(KEY_LOOT)
|
||||
self.last_interaction_time = current_time
|
||||
|
||||
if (
|
||||
state['combat']
|
||||
and self.last_target_damage_time is not None
|
||||
and (current_time - self.last_target_damage_time) >= self.attack_stall_scan_threshold
|
||||
and (current_time - self.last_attack_scan_time) >= self.attack_scan_retry_sec
|
||||
combat_error_signal == 50
|
||||
and (current_time - self.last_turn_signal_time) >= self.combat_signal_retry_sec
|
||||
):
|
||||
hw_ctrl.keyDown('s')
|
||||
time.sleep(self.attack_stall_s_hold_sec)
|
||||
time.sleep(self.turn_error_hold_sec)
|
||||
hw_ctrl.keyUp('s')
|
||||
self.last_attack_scan_time = current_time
|
||||
self.last_turn_signal_time = current_time
|
||||
self.last_target_hp = target_hp
|
||||
if state['combat']:
|
||||
self.execute_combat_logic(state)
|
||||
@@ -546,15 +541,15 @@ class AutoBot:
|
||||
self._was_in_combat_or_target = False
|
||||
self.last_tab_time = current_time + 1.0
|
||||
self.last_target_hp = 0
|
||||
self.last_target_damage_time = None
|
||||
self.last_attack_scan_time = 0.0
|
||||
self.last_turn_signal_time = 0.0
|
||||
self.last_interaction_time = 0.0
|
||||
self._has_braked_for_target = False
|
||||
return
|
||||
|
||||
self._was_in_combat_or_target = False
|
||||
self.last_target_hp = 0
|
||||
self.last_target_damage_time = None
|
||||
self.last_attack_scan_time = 0.0
|
||||
self.last_turn_signal_time = 0.0
|
||||
self.last_interaction_time = 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