Fix: Handle EMP debuff in opsi that limits fleet steps

This commit is contained in:
LmeSzinc 2022-04-01 18:32:39 +08:00
parent f0cdb96cb6
commit 9b3544e1ac
7 changed files with 59 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -10,6 +10,7 @@ FLEET_3 = Button(area={'cn': (183, 643, 212, 673), 'en': (289, 655, 303, 681), '
FLEET_4 = Button(area={'cn': (185, 646, 210, 672), 'en': (288, 655, 304, 681), 'jp': (181, 643, 214, 675), 'tw': (185, 646, 210, 672)}, color={'cn': (175, 205, 248), 'en': (197, 226, 252), 'jp': (144, 186, 245), 'tw': (175, 205, 248)}, button={'cn': (185, 646, 210, 672), 'en': (288, 655, 304, 681), 'jp': (181, 643, 214, 675), 'tw': (185, 646, 210, 672)}, file={'cn': './assets/cn/os/FLEET_4.png', 'en': './assets/en/os/FLEET_4.png', 'jp': './assets/jp/os/FLEET_4.png', 'tw': './assets/cn/os/FLEET_4.png'})
FLEET_BAR = Button(area={'cn': (145, 414, 345, 616), 'en': (145, 414, 345, 616), 'jp': (145, 414, 346, 617), 'tw': (145, 414, 346, 616)}, color={'cn': (152, 171, 192), 'en': (144, 161, 179), 'jp': (150, 168, 188), 'tw': (152, 172, 194)}, button={'cn': (145, 414, 345, 616), 'en': (145, 414, 345, 616), 'jp': (145, 414, 346, 617), 'tw': (145, 414, 346, 616)}, file={'cn': './assets/cn/os/FLEET_BAR.png', 'en': './assets/en/os/FLEET_BAR.png', 'jp': './assets/jp/os/FLEET_BAR.png', 'tw': './assets/tw/os/FLEET_BAR.png'})
FLEET_CHOOSE = Button(area={'cn': (270, 636, 345, 699), 'en': (144, 636, 238, 699), 'jp': (245, 642, 329, 691), 'tw': (247, 642, 337, 690)}, color={'cn': (112, 189, 245), 'en': (119, 165, 239), 'jp': (122, 187, 245), 'tw': (118, 183, 237)}, button={'cn': (270, 636, 345, 699), 'en': (144, 636, 238, 699), 'jp': (245, 642, 329, 691), 'tw': (247, 642, 337, 690)}, file={'cn': './assets/cn/os/FLEET_CHOOSE.png', 'en': './assets/en/os/FLEET_CHOOSE.png', 'jp': './assets/jp/os/FLEET_CHOOSE.png', 'tw': './assets/tw/os/FLEET_CHOOSE.png'})
FLEET_EMP_DEBUFF = Button(area={'cn': (137, 144, 175, 167), 'en': (137, 144, 175, 167), 'jp': (137, 144, 175, 167), 'tw': (137, 144, 175, 167)}, color={'cn': (180, 167, 191), 'en': (180, 167, 191), 'jp': (180, 167, 191), 'tw': (180, 167, 191)}, button={'cn': (137, 144, 175, 167), 'en': (137, 144, 175, 167), 'jp': (137, 144, 175, 167), 'tw': (137, 144, 175, 167)}, file={'cn': './assets/cn/os/FLEET_EMP_DEBUFF.png', 'en': './assets/en/os/FLEET_EMP_DEBUFF.png', 'jp': './assets/jp/os/FLEET_EMP_DEBUFF.png', 'tw': './assets/tw/os/FLEET_EMP_DEBUFF.png'})
GLOBE_GOTO_MAP = Button(area={'cn': (37, 29, 83, 75), 'en': (37, 29, 83, 75), 'jp': (37, 29, 83, 75), 'tw': (37, 29, 83, 75)}, color={'cn': (112, 119, 157), 'en': (112, 119, 157), 'jp': (112, 119, 157), 'tw': (112, 119, 157)}, button={'cn': (37, 29, 83, 75), 'en': (37, 29, 83, 75), 'jp': (37, 29, 83, 75), 'tw': (37, 29, 83, 75)}, file={'cn': './assets/cn/os/GLOBE_GOTO_MAP.png', 'en': './assets/en/os/GLOBE_GOTO_MAP.png', 'jp': './assets/jp/os/GLOBE_GOTO_MAP.png', 'tw': './assets/tw/os/GLOBE_GOTO_MAP.png'})
MAP_EXIT = Button(area={'cn': (1147, 637, 1280, 699), 'en': (1148, 641, 1280, 699), 'jp': (1147, 637, 1280, 699), 'tw': (1147, 639, 1280, 703)}, color={'cn': (47, 35, 42), 'en': (32, 20, 20), 'jp': (58, 34, 34), 'tw': (55, 46, 43)}, button={'cn': (1147, 637, 1280, 699), 'en': (1148, 641, 1280, 699), 'jp': (1147, 637, 1280, 699), 'tw': (1147, 639, 1280, 703)}, file={'cn': './assets/cn/os/MAP_EXIT.png', 'en': './assets/en/os/MAP_EXIT.png', 'jp': './assets/jp/os/MAP_EXIT.png', 'tw': './assets/tw/os/MAP_EXIT.png'})
MAP_GOTO_GLOBE = Button(area={'cn': (1069, 641, 1260, 695), 'en': (1069, 641, 1260, 691), 'jp': (1064, 636, 1265, 699), 'tw': (1069, 641, 1260, 694)}, color={'cn': (212, 140, 140), 'en': (212, 140, 140), 'jp': (207, 132, 132), 'tw': (213, 143, 143)}, button={'cn': (1069, 641, 1260, 695), 'en': (1069, 641, 1260, 691), 'jp': (1064, 636, 1265, 699), 'tw': (1069, 641, 1260, 694)}, file={'cn': './assets/cn/os/MAP_GOTO_GLOBE.png', 'en': './assets/en/os/MAP_GOTO_GLOBE.png', 'jp': './assets/jp/os/MAP_GOTO_GLOBE.png', 'tw': './assets/tw/os/MAP_GOTO_GLOBE.png'})

View File

@ -2,6 +2,7 @@ from module.base.button import Button
from module.config.utils import get_os_reset_remain
from module.exception import MapWalkError, ScriptError
from module.logger import logger
from module.os.assets import FLEET_EMP_DEBUFF
from module.os.map import OSMap
from module.ui.ui import page_os
@ -54,7 +55,7 @@ class OSGlobe(OSMap):
# self.map_init()
self.hp_reset()
self.handle_fleet_repair(revert=False)
self.handle_after_auto_search()
# Exit from special zones types, only SAFE and DANGEROUS are acceptable.
if self.is_in_special_zone():
@ -67,7 +68,7 @@ class OSGlobe(OSMap):
self.handle_ash_beacon_attack()
else:
self.run_auto_search()
self.handle_fleet_repair(revert=False)
self.handle_after_auto_search()
def get_current_zone_from_globe(self):
"""
@ -259,6 +260,48 @@ class OSGlobe(OSMap):
'the low resolve debuff')
return False
def handle_fleet_emp_debuff(self):
"""
EMP debuff limits fleet step to 1 and messes auto search up.
It can be solved by moving fleets on map meaninglessly.
Returns:
bool: If solved
"""
if self.is_in_special_zone():
logger.info('OS is in a special zone type, skip handle_fleet_emp_debuff')
return False
def has_emp_debuff():
return self.appear(FLEET_EMP_DEBUFF, offset=(50, 20))
for trial in range(5):
if not has_emp_debuff():
logger.info('No EMP debuff on current fleet')
return trial > 0
current = self.get_fleet_current_index()
logger.hr(f'Solve EMP debuff on fleet {current}')
self.globe_goto(self.zone_nearest_azur_port(self.zone))
logger.info('Find a fleet without EMP debuff')
for fleet in [1, 2, 3, 4]:
self.fleet_set(fleet)
if has_emp_debuff():
logger.info(f'Fleet {fleet} is under EMP debuff')
continue
else:
logger.info(f'Fleet {fleet} is not under EMP debuff')
break
logger.info('Solve EMP debuff by going somewhere else')
self.port_goto()
self.fleet_set(current)
logger.warning('Failed to solve EMP debuff after 5 trial, assume solved')
return True
def action_point_limit_override(self):
"""
Override user config at the end of every month.
@ -285,3 +328,11 @@ class OSGlobe(OSMap):
else:
logger.info('Not close to OpSi reset')
return False
def handle_after_auto_search(self):
logger.hr('After auto search', level=2)
solved = False
solved |= self.handle_fleet_repair(revert=False)
solved |= self.handle_fleet_emp_debuff()
logger.info(f'Handle after auto search finished, solved={solved}')
return solved

View File

@ -76,7 +76,7 @@ class OperationSiren(OSGlobe):
recon_scan=False,
submarine_call=self.config.OpsiFleet_Submarine and result != 'pinned_at_archive_zone')
self.run_auto_search()
self.handle_fleet_repair(revert=False)
self.handle_after_auto_search()
self.config.check_task_switch()
return True
@ -132,7 +132,7 @@ class OperationSiren(OSGlobe):
recon_scan=False,
submarine_call=self.config.OpsiFleet_Submarine)
self.run_auto_search()
if not self.handle_fleet_repair(revert=False):
if not self.handle_after_auto_search():
self.globe_goto(self.zone_nearest_azur_port(zone=zone))
self.config.check_task_switch()
else:
@ -148,7 +148,7 @@ class OperationSiren(OSGlobe):
recon_scan=False,
submarine_call=self.config.OpsiFleet_Submarine)
self.run_auto_search()
self.handle_fleet_repair(revert=False)
self.handle_after_auto_search()
self.config.check_task_switch()
def _os_explore_task_delay(self):
@ -226,7 +226,7 @@ class OperationSiren(OSGlobe):
self.run_auto_search()
self.config.OpsiExplore_LastZone = zone
logger.info(f'Zone cleared: {self.name_to_zone(zone)}')
self.handle_fleet_repair(revert=False)
self.handle_after_auto_search()
self.config.check_task_switch()
if zone == order[-1]:
end()
@ -270,7 +270,7 @@ class OperationSiren(OSGlobe):
self.run_auto_search()
self.map_exit()
self.handle_fleet_repair(revert=False)
self.handle_after_auto_search()
def os_obscure(self):
while 1: