From 156a988cf5720b3d28b3f45fe5342433c43b0f7b Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Fri, 10 Jan 2025 02:39:46 +0800 Subject: [PATCH] Fix: Skip using emergency repair if all HP is 0 (#4501) --- module/combat/combat.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/module/combat/combat.py b/module/combat/combat.py index 5593ccfb67..5306fb5acc 100644 --- a/module/combat/combat.py +++ b/module/combat/combat.py @@ -237,7 +237,7 @@ def handle_emergency_repair_use(self): if not self.config.HpControl_UseEmergencyRepair: return False - if self.appear_then_click(EMERGENCY_REPAIR_CONFIRM, offset=True): + if self.appear_then_click(EMERGENCY_REPAIR_CONFIRM, offset=True, interval=3): return True if self.appear(BATTLE_PREPARATION, offset=(20, 20)) and self.appear(EMERGENCY_REPAIR_AVAILABLE): # When entering battle_preparation page (or after emergency repairing), @@ -251,16 +251,22 @@ def handle_emergency_repair_use(self): self.wait_until_stable(stable_checker) if not self.appear(EMERGENCY_REPAIR_AVAILABLE): return False + logger.info('EMERGENCY_REPAIR_AVAILABLE') if not len(self.hp): return False + if max(self.hp[:3]) <= 0.001 or max(self.hp[3:]) <= 0.001: + logger.warning(f'Invalid HP to use emergency repair: {self.hp}') + return False + hp = np.array(self.hp) hp = hp[hp > 0.001] if (len(hp) and np.min(hp) < self.config.HpControl_RepairUseSingleThreshold) \ - or np.max(self.hp[:3]) < self.config.HpControl_RepairUseMultiThreshold \ - or np.max(self.hp[3:]) < self.config.HpControl_RepairUseMultiThreshold: + or max(self.hp[:3]) < self.config.HpControl_RepairUseMultiThreshold \ + or max(self.hp[3:]) < self.config.HpControl_RepairUseMultiThreshold: logger.info('Use emergency repair') self.device.click(EMERGENCY_REPAIR_AVAILABLE) + self.interval_clear(EMERGENCY_REPAIR_CONFIRM) return True return False