Add: Semi-auto for operation siren

- Fix: Clicking on HOME button when skipping story
- TODO: [EN][JP] Replace assets in os_combat and os_handler
This commit is contained in:
LmeSzinc 2020-12-23 18:48:41 +08:00
parent 4a8ae72ef3
commit 57822607e1
39 changed files with 222 additions and 0 deletions

View File

@ -213,5 +213,11 @@ class AzurLaneAutoScript:
az.device.screenshot()
az.retire_ships(amount=2000)
def os_semi_auto(self):
from module.daemon.os_daemon import AzurLaneDaemon
az = AzurLaneDaemon(self.config, device=self.device)
az.daemon()
# alas = AzurLaneAutoScript()
# alas.reward()

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -205,6 +205,9 @@ non_s3_enemy_withdraw_tolerance = 0
ammo_pick_up_124 = 3
command = c124_leveling
[Os_semi_auto]
enable_os_semi_story_skip = yes
[EmotionRecord]
fleet_1_emotion = 119
fleet_1_savetime = 2020-01-01_00:00:00

View File

@ -475,6 +475,11 @@ def main(ini_name=''):
c_12_4.add_argument('--非大型敌人撤退忍耐', default=default('--非大型敌人撤退忍耐'), choices=['0', '1', '2', '10'], help='没有大型之后还会打多少战, 不挑敌人选10', gooey_options={'label_color': '#4B5F83'})
c_12_4.add_argument('--拣弹药124', default=default('--拣弹药124'), choices=['2', '3', '4', '5'], help='多少战后拣弹药', gooey_options={'label_color': '#4B5F83'})
# ==========OS semi auto==========
os_semi_parser = subs.add_parser('大世界辅助点击')
os_semi = os_semi_parser.add_argument_group('大世界辅助点击', '辅助点击战斗准备和战斗结算', gooey_options={'label_color': '#931D03'})
os_semi.add_argument('--大世界跳过剧情', default=default('--大世界跳过剧情'), choices=['', ''], help='注意, 这会自动点击地图交互的选项', gooey_options={'label_color': '#4B5F83'})
args = parser.parse_args()
# Convert option from chinese to english.

View File

@ -541,6 +541,11 @@ def main(ini_name=''):
c_12_4.add_argument('--ammo_pick_up_124', default=default('--ammo_pick_up_124'),
choices=['2', '3', '4', '5'], help='How many battles before pick ammo, the recommended is 3', gooey_options={'label_color': '#4B5F83'})
# ==========OS semi auto==========
os_semi_parser = subs.add_parser('os_semi_auto')
os_semi = os_semi_parser.add_argument_group('os_semi_auto', 'Start and finish combat automatically', gooey_options={'label_color': '#931D03'})
os_semi.add_argument('--enable_os_semi_story_skip', default=default('--enable_os_semi_story_skip'), choices=['yes', 'no'], help='Note that this will automatically choose the options in map events', gooey_options={'label_color': '#4B5F83'})
args = parser.parse_args()
# Convert option from chinese to english.

View File

@ -541,6 +541,11 @@ def main(ini_name=''):
c_12_4.add_argument('--ammo_pick_up_124', default=default('--ammo_pick_up_124'),
choices=['2', '3', '4', '5'], help='How many battles before pick ammo, the recommended is 3', gooey_options={'label_color': '#4B5F83'})
# ==========OS semi auto==========
os_semi_parser = subs.add_parser('os_semi_auto')
os_semi = os_semi_parser.add_argument_group('os_semi_auto', 'Start and finish combat automatically', gooey_options={'label_color': '#931D03'})
os_semi.add_argument('--enable_os_semi_story_skip', default=default('--enable_os_semi_story_skip'), choices=['yes', 'no'], help='Note that this will automatically choose the options in map events', gooey_options={'label_color': '#4B5F83'})
args = parser.parse_args()
# Convert option from chinese to english.

View File

@ -476,6 +476,11 @@ def main(ini_name=''):
c_12_4.add_argument('--非大型敵人撤退忍耐', default=default('--非大型敵人撤退忍耐'), choices=['0', '1', '2', '10'], help ='沒有大型之後還會打多少戰, 不挑敵人選10', gooey_options={'label_color': '#4B5F83'})
c_12_4.add_argument('--撿彈藥124', default=default('--撿彈藥124'), choices=['2', '3', '4', '5'], help='多少戰後撿彈藥', gooey_options={'label_color': '#4B5F83'})
# ==========OS semi auto==========
# os_semi_parser = subs.add_parser('大世界輔助點擊')
# os_semi = os_semi_parser.add_argument_group('大世界輔助點擊', '輔助點擊戰鬥準備和戰鬥結算', gooey_options={'label_color': '#931D03'})
# os_semi.add_argument('--大世界跳過劇情', default=default('--大世界跳過劇情'), choices=['是', '否'], help='注意, 這會自動點擊地圖交互的選項', gooey_options={'label_color': '#4B5F83'})
args = parser.parse_args()
# Convert option from chinese to english.

View File

@ -481,6 +481,11 @@ class AzurLaneConfig:
C124_NON_S3_WITHDRAW_TOLERANCE = 0
C124_AMMO_PICK_UP = 3
"""
Os_semi_auto
"""
ENABLE_OS_SEMI_STORY_SKIP = True
def create_folder(self):
for folder in [self.ASSETS_FOLDER, self.PERSPECTIVE_ERROR_LOG_FOLDER, self.ERROR_LOG_FOLDER]:
if folder and not os.path.exists(folder):
@ -733,6 +738,10 @@ class AzurLaneConfig:
self.C124_NON_S3_WITHDRAW_TOLERANCE = int(option['non_s3_enemy_withdraw_tolerance'])
self.C124_AMMO_PICK_UP = int(option['ammo_pick_up_124'])
# OS semi auto
option = config['Os_semi_auto']
self.ENABLE_OS_SEMI_STORY_SKIP = to_bool(option['enable_os_semi_story_skip'])
def get_server_timezone(self):
if self.SERVER == 'en':
return -7

View File

@ -45,6 +45,7 @@ dic_true_eng_to_eng = {
'c7-2_mystery_farming': 'c72_mystery_farming',
'c12-2_leveling': 'c122_leveling',
'c12-4_leveling': 'c124_leveling',
'os_semi_auto': 'os_semi_auto',
# Argument
'enable_stop_condition': 'enable_stop_condition',
@ -222,6 +223,7 @@ dic_true_eng_to_eng = {
'non_s3_enemy_withdraw_tolerance': 'non_s3_enemy_withdraw_tolerance',
'ammo_pick_up_124': 'ammo_pick_up_124',
'default_serial_list': 'default_serial_list',
'enable_os_semi_story_skip': 'enable_os_semi_story_skip',
# Option
'yes': 'yes',
@ -307,6 +309,7 @@ dic_chi_to_eng = {
'7-2三战拣垃圾': 'c72_mystery_farming',
'12-2打中型练级': 'c122_leveling',
'12-4打大型练级': 'c124_leveling',
'大世界辅助点击': 'os_semi_auto',
# Argument
'启用停止条件': 'enable_stop_condition',
@ -484,6 +487,7 @@ dic_chi_to_eng = {
'非大型敌人撤退忍耐': 'non_s3_enemy_withdraw_tolerance',
'拣弹药124': 'ammo_pick_up_124',
'默认serial列表': 'default_serial_list',
'大世界跳过剧情': 'enable_os_semi_story_skip',
# Option
'': 'yes',
@ -569,6 +573,7 @@ dic_tchi_to_eng = {
'7-2三戰撿垃圾': 'c72_mystery_farming',
'12-2打中型練級': 'c122_leveling',
'12-4打大型練級': 'c124_leveling',
'大世界輔助點擊': 'os_semi_auto',
# Argument
'啟用停止條件': 'enable_stop_condition',
@ -746,6 +751,7 @@ dic_tchi_to_eng = {
'非大型敵人撤退忍耐': 'non_s3_enemy_withdraw_tolerance',
'撿彈藥124': 'ammo_pick_up_124',
'默認serial列表': 'default_serial_list',
'大世界跳過劇情': 'enable_os_semi_story_skip',
# Option
'': 'yes',

View File

@ -0,0 +1,55 @@
from module.campaign.campaign_base import CampaignBase
from module.daemon.assets import *
from module.exception import *
from module.os_combat.assets import *
from module.os_combat.combat import Combat
from module.os_handler.map_event import MapEventHandler
class AzurLaneDaemon(Combat, MapEventHandler):
def daemon(self):
self.config.ENABLE_GAME_STUCK_HANDLER = False
self.device.config.ENABLE_GAME_STUCK_HANDLER = False
while 1:
self.device.screenshot()
# If is running a combat, do nothing.
if self.is_combat_executing():
continue
# Combat
if self.combat_appear():
self.combat_preparation()
try:
if self.handle_battle_status(save_get_items=False):
self.combat_status(save_get_items=False, expected_end='no_searching')
continue
except CampaignEnd:
continue
# Map operation
# Map preparation
# Retire
pass
# Emotion
pass
# Urgent commission
if self.handle_urgent_commission(save_get_items=False):
continue
# Story
if self.config.ENABLE_OS_SEMI_STORY_SKIP:
self.story_skip()
self.handle_map_get_items()
self.handle_map_archives()
# End
# No end condition, stop it manually.
return True

View File

@ -137,15 +137,23 @@ class InfoHandler(ModuleBase):
return True
if self.appear_then_click(STORY_CHOOSE, offset=True, interval=2):
self.story_popup_timout.reset()
self.interval_reset(STORY_SKIP)
self.interval_reset(STORY_LETTERS_ONLY)
return True
if self.appear_then_click(STORY_CHOOSE_2, offset=True, interval=2):
self.story_popup_timout.reset()
self.interval_reset(STORY_SKIP)
self.interval_reset(STORY_LETTERS_ONLY)
return True
if self.appear_then_click(STORY_CHOOSE_LONG, offset=True, interval=2):
self.story_popup_timout.reset()
self.interval_reset(STORY_SKIP)
self.interval_reset(STORY_LETTERS_ONLY)
return True
if self.appear_then_click(STORY_CHOOSE_LONG_2, offset=True, interval=2):
self.story_popup_timout.reset()
self.interval_reset(STORY_SKIP)
self.interval_reset(STORY_LETTERS_ONLY)
return True
if self.appear_then_click(STORY_SKIP, offset=True, interval=2):
self.story_popup_timout.reset()

View File

@ -0,0 +1,8 @@
from module.base.button import Button
from module.base.template import Template
# This file was automatically generated by dev_tools.button_extract.
# Don't modify it manually.
BATTLE_PREPARATION = Button(area={'cn': (1031, 624, 1228, 682), 'en': (1031, 624, 1228, 682), 'jp': (1031, 624, 1228, 682), 'tw': (1031, 624, 1228, 682)}, color={'cn': (216, 159, 83), 'en': (216, 159, 83), 'jp': (216, 159, 83), 'tw': (216, 159, 83)}, button={'cn': (1031, 624, 1228, 682), 'en': (1031, 624, 1228, 682), 'jp': (1031, 624, 1228, 682), 'tw': (1031, 624, 1228, 682)}, file={'cn': './assets/cn/os_combat/BATTLE_PREPARATION.png', 'en': './assets/en/os_combat/BATTLE_PREPARATION.png', 'jp': './assets/jp/os_combat/BATTLE_PREPARATION.png', 'tw': './assets/tw/os_combat/BATTLE_PREPARATION.png'})
SIREN_PREPARATION = Button(area={'cn': (1043, 638, 1240, 698), 'en': (1043, 638, 1240, 698), 'jp': (1043, 638, 1240, 698), 'tw': (1043, 638, 1240, 698)}, color={'cn': (136, 94, 111), 'en': (136, 94, 111), 'jp': (136, 94, 111), 'tw': (136, 94, 111)}, button={'cn': (1043, 638, 1240, 698), 'en': (1043, 638, 1240, 698), 'jp': (1043, 638, 1240, 698), 'tw': (1043, 638, 1240, 698)}, file={'cn': './assets/cn/os_combat/SIREN_PREPARATION.png', 'en': './assets/en/os_combat/SIREN_PREPARATION.png', 'jp': './assets/jp/os_combat/SIREN_PREPARATION.png', 'tw': './assets/tw/os_combat/SIREN_PREPARATION.png'})

View File

@ -0,0 +1,68 @@
from module.combat.assets import *
from module.combat.combat import Combat as Combat_
from module.logger import logger
from module.os_combat.assets import *
from module.os_handler.enemy_searching import EnemySearchingHandler
class Combat(Combat_, EnemySearchingHandler):
def combat_appear(self):
"""
Returns:
bool: If enter combat.
"""
# if self.config.ENABLE_MAP_FLEET_LOCK and not self.is_in_map():
# if self.is_combat_loading():
# return True
if self.appear(BATTLE_PREPARATION):
return True
if self.appear(SIREN_PREPARATION):
return True
if self.appear(BATTLE_PREPARATION_WITH_OVERLAY) and self.handle_combat_automation_confirm():
return True
return False
def combat_preparation(self, balance_hp=False, emotion_reduce=False, auto='combat_auto', fleet_index=1):
"""
Args:
balance_hp (bool):
emotion_reduce (bool):
auto (str):
fleet_index (int):
"""
logger.info('Combat preparation.')
if emotion_reduce:
self.emotion.wait(fleet=fleet_index)
if balance_hp:
self.hp_balance()
while 1:
self.device.screenshot()
if self.appear(BATTLE_PREPARATION):
if self.handle_combat_automation_set(auto=auto == 'combat_auto'):
continue
# if self.handle_retirement():
# continue
# if self.handle_combat_low_emotion():
# continue
# if balance_hp and self.handle_emergency_repair_use():
# continue
if self.appear_then_click(BATTLE_PREPARATION, interval=2):
continue
if self.appear_then_click(SIREN_PREPARATION, interval=2):
continue
if self.handle_popup_confirm('ENHANCED_ENEMY'):
continue
if self.handle_combat_automation_confirm():
continue
if self.handle_story_skip():
continue
# End
if self.is_combat_executing():
if emotion_reduce:
self.emotion.reduce(fleet_index)
break

View File

@ -0,0 +1,10 @@
from module.base.button import Button
from module.base.template import Template
# This file was automatically generated by dev_tools.button_extract.
# Don't modify it manually.
CLICK_SAFE_AREA = Button(area={'cn': (1104, 169, 1214, 284), 'en': (1104, 169, 1214, 284), 'jp': (1104, 169, 1214, 284), 'tw': (1104, 169, 1214, 284)}, color={'cn': (96, 114, 142), 'en': (96, 114, 142), 'jp': (96, 114, 142), 'tw': (96, 114, 142)}, button={'cn': (1104, 169, 1214, 284), 'en': (1104, 169, 1214, 284), 'jp': (1104, 169, 1214, 284), 'tw': (1104, 169, 1214, 284)}, file={'cn': './assets/cn/os_handler/CLICK_SAFE_AREA.png', 'en': './assets/en/os_handler/CLICK_SAFE_AREA.png', 'jp': './assets/jp/os_handler/CLICK_SAFE_AREA.png', 'tw': './assets/tw/os_handler/CLICK_SAFE_AREA.png'})
GET_OS_STATUS = Button(area={'cn': (538, 191, 742, 227), 'en': (538, 191, 742, 227), 'jp': (538, 191, 742, 227), 'tw': (538, 191, 742, 227)}, color={'cn': (166, 195, 246), 'en': (166, 195, 246), 'jp': (166, 195, 246), 'tw': (166, 195, 246)}, button={'cn': (538, 191, 742, 227), 'en': (538, 191, 742, 227), 'jp': (538, 191, 742, 227), 'tw': (538, 191, 742, 227)}, file={'cn': './assets/cn/os_handler/GET_OS_STATUS.png', 'en': './assets/en/os_handler/GET_OS_STATUS.png', 'jp': './assets/jp/os_handler/GET_OS_STATUS.png', 'tw': './assets/tw/os_handler/GET_OS_STATUS.png'})
IN_MAP = Button(area={'cn': (936, 638, 1037, 697), 'en': (936, 638, 1037, 697), 'jp': (936, 638, 1037, 697), 'tw': (936, 638, 1037, 697)}, color={'cn': (239, 192, 111), 'en': (239, 192, 111), 'jp': (239, 192, 111), 'tw': (239, 192, 111)}, button={'cn': (936, 638, 1037, 697), 'en': (936, 638, 1037, 697), 'jp': (936, 638, 1037, 697), 'tw': (936, 638, 1037, 697)}, file={'cn': './assets/cn/os_handler/IN_MAP.png', 'en': './assets/en/os_handler/IN_MAP.png', 'jp': './assets/jp/os_handler/IN_MAP.png', 'tw': './assets/tw/os_handler/IN_MAP.png'})
MAP_ARCHIVES = Button(area={'cn': (1180, 353, 1280, 411), 'en': (1180, 353, 1280, 411), 'jp': (1180, 353, 1280, 411), 'tw': (1180, 353, 1280, 411)}, color={'cn': (134, 255, 255), 'en': (134, 255, 255), 'jp': (134, 255, 255), 'tw': (134, 255, 255)}, button={'cn': (1180, 353, 1280, 411), 'en': (1180, 353, 1280, 411), 'jp': (1180, 353, 1280, 411), 'tw': (1180, 353, 1280, 411)}, file={'cn': './assets/cn/os_handler/MAP_ARCHIVES.png', 'en': './assets/en/os_handler/MAP_ARCHIVES.png', 'jp': './assets/jp/os_handler/MAP_ARCHIVES.png', 'tw': './assets/tw/os_handler/MAP_ARCHIVES.png'})

View File

@ -0,0 +1,7 @@
from module.handler.enemy_searching import EnemySearchingHandler as EnemySearchingHandler_
from module.os_handler.assets import *
class EnemySearchingHandler(EnemySearchingHandler_):
def is_in_map(self):
return self.appear(IN_MAP)

View File

@ -0,0 +1,22 @@
from module.combat.assets import *
from module.handler.info_handler import InfoHandler
from module.os_handler.assets import *
class MapEventHandler(InfoHandler):
def handle_map_get_items(self):
if self.appear(GET_ITEMS_1) or self.appear(GET_ITEMS_2) or self.appear(GET_ITEMS_3):
self.device.click(CLICK_SAFE_AREA)
return True
if self.appear(GET_OS_STATUS):
self.device.click(CLICK_SAFE_AREA)
return True
return False
def handle_map_archives(self):
if self.appear(MAP_ARCHIVES, interval=5):
self.device.click(CLICK_SAFE_AREA)
return True
return False