mirror of
https://github.com/sui-feng-cb/AzurLaneAutoScript1.git
synced 2026-07-24 06:08:10 +08:00
Merge branch 'dev'
This commit is contained in:
@@ -349,8 +349,8 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
|
||||
self.submarine_call_reset()
|
||||
submarine_mode = 'do_not_use'
|
||||
if self.config.Submarine_Fleet:
|
||||
submarine_mode = self.config.Submarine_Mode
|
||||
force_call = battle[0] == battle[1] - 1 if battle is not None else False
|
||||
submarine_mode = self.config.Submarine_CallMode
|
||||
is_boss = battle[0] == battle[1] - 1 if battle is not None else False
|
||||
self.combat_auto_reset()
|
||||
self.combat_manual_reset()
|
||||
self.device.stuck_record_clear()
|
||||
@@ -364,7 +364,7 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
|
||||
exp_confirm_timer = Timer(1, count=2)
|
||||
for _ in self.loop():
|
||||
|
||||
if self.handle_submarine_call(submarine_mode, call=force_call):
|
||||
if self.handle_submarine_call(call_mode=submarine_mode, is_boss=is_boss):
|
||||
continue
|
||||
if self.handle_combat_auto(auto):
|
||||
continue
|
||||
@@ -444,6 +444,13 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
|
||||
if self.is_auto_search_running():
|
||||
self._auto_search_status_confirm = False
|
||||
break
|
||||
if self.is_combat_loading():
|
||||
logger.info('Next battle already started')
|
||||
break
|
||||
if self.handle_retirement():
|
||||
self.map_offensive_auto_search()
|
||||
# Map offensive ends at is_combat_loading
|
||||
break
|
||||
if self.is_in_auto_search_menu() or self._handle_auto_search_menu_missing():
|
||||
raise CampaignEnd
|
||||
|
||||
@@ -455,10 +462,10 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
|
||||
if self.handle_get_ship():
|
||||
continue
|
||||
if not self._sinking and self.handle_auto_search_map_option():
|
||||
self._auto_search_status_confirm = False
|
||||
continue
|
||||
# bunch of popup handlers
|
||||
if self.handle_popup_confirm('AUTO_SEARCH_COMBAT_STATUS'):
|
||||
self._auto_search_status_confirm = True
|
||||
continue
|
||||
if self.handle_urgent_commission():
|
||||
get_urgent_commission = True
|
||||
|
||||
@@ -354,11 +354,12 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
|
||||
|
||||
return False
|
||||
|
||||
def combat_execute(self, auto='combat_auto', submarine='do_not_use', drop=None):
|
||||
def combat_execute(self, auto='combat_auto', submarine='do_not_use', is_boss=False, drop=None):
|
||||
"""
|
||||
Args:
|
||||
auto (str): ['combat_auto', 'combat_manual', 'stand_still_in_the_middle', 'hide_in_bottom_left']
|
||||
submarine (str): ['do_not_use', 'hunt_only', 'every_combat']
|
||||
submarine (str): do_not_use, boss_only, every_combat
|
||||
is_boss (bool): True on BOSS battle
|
||||
drop (DropImage):
|
||||
"""
|
||||
logger.info('Combat execute')
|
||||
@@ -385,7 +386,7 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
|
||||
if auto != 'combat_auto' and self.auto_mode_checked and self.is_combat_executing():
|
||||
if self.handle_combat_weapon_release():
|
||||
continue
|
||||
if self.handle_submarine_call(submarine):
|
||||
if self.handle_submarine_call(call_mode=submarine, is_boss=is_boss):
|
||||
continue
|
||||
# bunch of popup handlers
|
||||
if self.handle_popup_confirm('COMBAT_EXECUTE'):
|
||||
@@ -635,7 +636,7 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
|
||||
if self.handle_in_map_with_enemy_searching(drop=drop):
|
||||
break
|
||||
|
||||
def combat(self, balance_hp=None, emotion_reduce=None, auto_mode=None, submarine_mode=None,
|
||||
def combat(self, balance_hp=None, emotion_reduce=None, auto_mode=None, submarine_mode=None, is_boss=False,
|
||||
save_get_items=None, expected_end=None, fleet_index=1):
|
||||
"""
|
||||
Execute a combat.
|
||||
@@ -645,7 +646,8 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
|
||||
balance_hp (bool):
|
||||
emotion_reduce (bool):
|
||||
auto_mode (str): combat_auto, combat_manual, stand_still_in_the_middle, hide_in_bottom_left
|
||||
submarine_mode (str): do_not_use, hunt_only, every_combat
|
||||
submarine_mode (str): do_not_use, boss_only, every_combat
|
||||
is_boss (bool): True on BOSS battle
|
||||
save_get_items (bool, DropImage):
|
||||
expected_end (str, callable):
|
||||
fleet_index (int): 1 or 2
|
||||
@@ -657,7 +659,7 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
|
||||
if submarine_mode is None:
|
||||
submarine_mode = 'do_not_use'
|
||||
if self.config.Submarine_Fleet:
|
||||
submarine_mode = self.config.Submarine_Mode
|
||||
submarine_mode = self.config.Submarine_CallMode
|
||||
self.battle_status_click_interval = 7 if save_get_items else 0
|
||||
|
||||
# if not hasattr(self, 'emotion'):
|
||||
@@ -673,7 +675,7 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
|
||||
self.combat_preparation(
|
||||
balance_hp=balance_hp, emotion_reduce=emotion_reduce, auto=auto_mode, fleet_index=fleet_index)
|
||||
self.combat_execute(
|
||||
auto=auto_mode, submarine=submarine_mode, drop=drop)
|
||||
auto=auto_mode, submarine=submarine_mode, drop=drop, is_boss=is_boss)
|
||||
self.combat_status(
|
||||
drop=drop, expected_end=expected_end)
|
||||
# self.handle_map_after_combat_story()
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
from module.base.base import ModuleBase
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import color_similar, crop, get_color, image_color_count
|
||||
from module.combat.assets import *
|
||||
from module.logger import logger
|
||||
|
||||
# BOSS detection areas
|
||||
# Classic UI: BOSS avatar frame right border
|
||||
BOSS_AVATAR_FRAME_RIGHT = (301, 15, 302, 80)
|
||||
BOSS_AVATAR_FRAME_COLOR = (24, 28, 24)
|
||||
# New UI: BOSS HP bar bottom border, middle-left portion
|
||||
# Color targets deep blue themes; need adjustment for other color schemes
|
||||
# BOSS_HP_BAR_BORDER = (420, 48, 620, 50)
|
||||
# BOSS_HP_BAR_COLOR = (31, 39, 61)
|
||||
|
||||
|
||||
class SubmarineCall(ModuleBase):
|
||||
submarine_call_flag = False
|
||||
submarine_call_timer = Timer(5)
|
||||
submarine_call_timer = Timer(8)
|
||||
submarine_call_click_timer = Timer(1)
|
||||
|
||||
def submarine_call_reset(self):
|
||||
@@ -16,18 +26,38 @@ class SubmarineCall(ModuleBase):
|
||||
self.submarine_call_timer.reset()
|
||||
self.submarine_call_flag = False
|
||||
|
||||
def handle_submarine_call(self, submarine='do_not_use', call=False):
|
||||
def boss_appeared(self):
|
||||
"""
|
||||
Detect whether BOSS has appeared by checking stable BOSS UI elements.
|
||||
"""
|
||||
# New UI: BOSS HP bar bottom border
|
||||
# avg = get_color(self.device.image, BOSS_HP_BAR_BORDER)
|
||||
# if color_similar(avg, BOSS_HP_BAR_COLOR, threshold=40):
|
||||
# return True
|
||||
# Classic UI: BOSS avatar frame right border
|
||||
frame = crop(self.device.image, BOSS_AVATAR_FRAME_RIGHT, copy=False)
|
||||
if image_color_count(frame, color=BOSS_AVATAR_FRAME_COLOR, threshold=200, count=50):
|
||||
return True
|
||||
return False
|
||||
|
||||
def handle_submarine_call(self, call_mode='do_not_use', is_boss=False):
|
||||
"""
|
||||
Args:
|
||||
call_mode (str): do_not_use, boss_only, every_combat
|
||||
is_boss (bool): True on BOSS battle
|
||||
|
||||
Returns:
|
||||
str: If call.
|
||||
bool: If clicked submarine call button.
|
||||
"""
|
||||
if self.submarine_call_flag:
|
||||
return False
|
||||
if call and submarine == 'boss_only':
|
||||
pass
|
||||
else:
|
||||
if submarine in ['do_not_use', 'hunt_only', 'boss_only', 'hunt_and_boss']:
|
||||
self.submarine_call_flag = True
|
||||
if call_mode == 'do_not_use' or (call_mode == 'boss_only' and not is_boss):
|
||||
self.submarine_call_flag = True
|
||||
return False
|
||||
|
||||
if self.config.Submarine_Timing == 'wait_for_boss' and is_boss:
|
||||
if not self.boss_appeared():
|
||||
self.submarine_call_timer.reset()
|
||||
return False
|
||||
if self.submarine_call_timer.reached():
|
||||
logger.info('Submarine call timer reached')
|
||||
|
||||
Reference in New Issue
Block a user