diff --git a/assets/combat/EMERGENCY_REPAIR_AVAILABLE.BUTTON.png b/assets/combat/EMERGENCY_REPAIR_AVAILABLE.BUTTON.png new file mode 100644 index 000000000..92aef3a5a Binary files /dev/null and b/assets/combat/EMERGENCY_REPAIR_AVAILABLE.BUTTON.png differ diff --git a/assets/combat/EMERGENCY_REPAIR_AVAILABLE.png b/assets/combat/EMERGENCY_REPAIR_AVAILABLE.png new file mode 100644 index 000000000..9ee30b209 Binary files /dev/null and b/assets/combat/EMERGENCY_REPAIR_AVAILABLE.png differ diff --git a/assets/combat/EMERGENCY_REPAIR_CONFIRM.png b/assets/combat/EMERGENCY_REPAIR_CONFIRM.png new file mode 100644 index 000000000..47f7cc6f8 Binary files /dev/null and b/assets/combat/EMERGENCY_REPAIR_CONFIRM.png differ diff --git a/config/template.ini b/config/template.ini index 785c1da99..5976140be 100644 --- a/config/template.ini +++ b/config/template.ini @@ -37,6 +37,8 @@ hole_fleet_married_3 = no enable_hp_balance = no enable_low_hp_withdraw = no scout_hp_difference_threshold = 0.2 +emergency_repair_single_threshold = 0.3 +emergency_repair_hole_threshold = 0.6 scout_hp_weights = 1000,1000,1000 low_hp_withdraw_threshold = 0.2 enable_retirement = yes diff --git a/module/combat/assets.py b/module/combat/assets.py index fdcaa551d..77c82002b 100644 --- a/module/combat/assets.py +++ b/module/combat/assets.py @@ -15,6 +15,8 @@ BATTLE_STATUS_A = Button(area=(622, 266, 732, 288), color=(235, 227, 111), butto BATTLE_STATUS_S = Button(area=(633, 297, 722, 320), color=(233, 241, 127), button=(1000, 631, 1055, 689), file='./assets/combat/BATTLE_STATUS_S.png') COMBAT_AUTO = Button(area=(136, 573, 167, 604), color=(229, 242, 255), button=(136, 573, 167, 604), file='./assets/combat/COMBAT_AUTO.png') COMBAT_AUTO_SWITCH = Button(area=(18, 38, 36, 56), color=(179, 198, 235), button=(18, 38, 36, 56), file='./assets/combat/COMBAT_AUTO_SWITCH.png') +EMERGENCY_REPAIR_AVAILABLE = Button(area=(106, 533, 119, 540), color=(255, 255, 255), button=(97, 512, 141, 557), file='./assets/combat/EMERGENCY_REPAIR_AVAILABLE.png') +EMERGENCY_REPAIR_CONFIRM = Button(area=(669, 418, 842, 475), color=(94, 143, 204), button=(669, 418, 842, 475), file='./assets/combat/EMERGENCY_REPAIR_CONFIRM.png') EXP_INFO_A = Button(area=(389, 100, 444, 116), color=(236, 231, 116), button=(1000, 631, 1055, 689), file='./assets/combat/EXP_INFO_A.png') EXP_INFO_S = Button(area=(396, 122, 457, 137), color=(233, 241, 127), button=(1000, 631, 1055, 689), file='./assets/combat/EXP_INFO_S.png') GET_ITEMS_1 = Button(area=(538, 217, 741, 253), color=(160, 192, 248), button=(1000, 631, 1055, 689), file='./assets/combat/GET_ITEMS_1.png') diff --git a/module/combat/combat.py b/module/combat/combat.py index d2f33947b..91dfd6159 100644 --- a/module/combat/combat.py +++ b/module/combat/combat.py @@ -101,28 +101,19 @@ class Combat(HPBalancer, EnemySearchingHandler, Retirement, SubmarineCall, Comba while 1: self.device.screenshot() - # Automation. if self.appear(BATTLE_PREPARATION): - # if self.handle_combat_automation_confirm(): - # continue if self.handle_combat_automation_set(auto=auto): continue - - # Retirement if self.handle_retirement(): continue - - # Emotion if self.handle_combat_low_emotion(): continue - - # Combat start + if self.handle_emergency_repair_use(): + continue if self.appear_then_click(BATTLE_PREPARATION, interval=2): continue - if self.handle_combat_automation_confirm(): continue - if self.handle_story_skip(): continue @@ -165,6 +156,21 @@ class Combat(HPBalancer, EnemySearchingHandler, Retirement, SubmarineCall, Comba return False + def handle_emergency_repair_use(self): + if self.appear_then_click(EMERGENCY_REPAIR_CONFIRM, offset=True): + self.device.sleep(0.5) # Animation: hp increase and emergency_repair amount decrease. + return True + if self.appear(EMERGENCY_REPAIR_AVAILABLE): + logger.info('EMERGENCY_REPAIR_AVAILABLE') + if np.min(np.array(self.hp)[np.array(self.hp) > 0.001]) < self.config.EMERGENCY_REPAIR_SINGLE_THRESHOLD \ + or np.max(self.hp[:3]) < self.config.EMERGENCY_REPAIR_HOLE_THRESHOLD \ + or np.max(self.hp[3:]) < self.config.EMERGENCY_REPAIR_HOLE_THRESHOLD: + logger.info('Use emergency repair') + self.device.click(EMERGENCY_REPAIR_AVAILABLE) + return True + + return False + def combat_execute(self, func=None, call_submarine_at_boss=False, save_get_items=False): """ Args: diff --git a/module/config/argparser.py b/module/config/argparser.py index fef005ada..32c5409a9 100644 --- a/module/config/argparser.py +++ b/module/config/argparser.py @@ -185,6 +185,9 @@ def main(ini_name=''): hp_balance = hp.add_argument_group('血量平衡', '') hp_balance.add_argument('--先锋血量平衡阈值', default=default('--先锋血量平衡阈值'), help='血量差值大于阈值时, 换位') hp_balance.add_argument('--先锋血量权重', default=default('--先锋血量权重'), help='先锋肉度有差别时应修改, 格式 1000,1000,1000') + hp_add = hp.add_argument_group('紧急维修', '') + hp_add.add_argument('--紧急维修单人阈值', default=default('--紧急维修单人阈值'), help='单人低于阈值时使用') + hp_add.add_argument('--紧急维修全队阈值', default=default('--紧急维修全队阈值'), help='前排全部或后排全部低于阈值时使用') hp_withdraw = hp.add_argument_group('低血量撤退', '') hp_withdraw.add_argument('--低血量撤退阈值', default=default('--低血量撤退阈值'), help='任意一人血量低于阈值时, 撤退') diff --git a/module/config/config.py b/module/config/config.py index cdd3a8745..6be2fdf0d 100644 --- a/module/config/config.py +++ b/module/config/config.py @@ -95,6 +95,8 @@ class AzurLaneConfig: ENABLE_LOW_HP_WITHDRAW = True SCOUT_HP_DIFFERENCE_THRESHOLD = 0.2 SCOUT_HP_WEIGHTS = [1000, 1000, 1000] + EMERGENCY_REPAIR_SINGLE_THRESHOLD = 0.3 + EMERGENCY_REPAIR_HOLE_THRESHOLD = 0.6 LOW_HP_WITHDRAW_THRESHOLD = 0.2 """ @@ -416,6 +418,8 @@ class AzurLaneConfig: self.ENABLE_LOW_HP_WITHDRAW = to_bool(option['enable_low_hp_withdraw']) self.SCOUT_HP_DIFFERENCE_THRESHOLD = float(option['scout_hp_difference_threshold']) self.SCOUT_HP_WEIGHTS = to_list(option['scout_hp_weights']) + self.EMERGENCY_REPAIR_SINGLE_THRESHOLD = float(option['emergency_repair_single_threshold']) + self.EMERGENCY_REPAIR_HOLE_THRESHOLD = float(option['emergency_repair_hole_threshold']) self.LOW_HP_WITHDRAW_THRESHOLD = float(option['low_hp_withdraw_threshold']) self.ENABLE_SAVE_GET_ITEMS = to_bool(option['enable_drop_screenshot']) self.SCREEN_SHOT_SAVE_FOLDER_BASE = option['drop_screenshot_folder'] diff --git a/module/config/dictionary.py b/module/config/dictionary.py index 64380593e..94f4bd8a7 100644 --- a/module/config/dictionary.py +++ b/module/config/dictionary.py @@ -73,6 +73,8 @@ dic_chi_to_eng = { '启用低血量撤退': 'enable_low_hp_withdraw', '先锋血量平衡阈值': 'scout_hp_difference_threshold', '先锋血量权重': 'scout_hp_weights', + '紧急维修单人阈值': 'emergency_repair_single_threshold', + '紧急维修全队阈值': 'emergency_repair_hole_threshold', '低血量撤退阈值': 'low_hp_withdraw_threshold', '启用退役': 'enable_retirement', '使用一键退役': 'use_one_click_retirement',