0
0
mirror of https://github.com/ok-oldking/ok-wuthering-waves.git synced 2025-06-05 08:25:28 +00:00

刷大世界boss死了, 自动传送治疗

This commit is contained in:
firedcto@gmail.com 2024-07-20 21:35:17 +08:00
parent ddc9747992
commit 05703ee509
7 changed files with 546 additions and 509 deletions

File diff suppressed because it is too large Load Diff

View File

@ -41,11 +41,11 @@ config = {
'min_size': (1600, 900)
},
'analytics': {
'report_url': 'https://okreport.ok-script.com/report'
'report_url': 'http://okreportcn.ok-script.com/report'
},
'update': {
'releases_url': 'https://api.github.com/repos/ok-oldking/ok-wuthering-waves/releases?per_page=15',
'proxy_url': 'https://gh.ok-script.com/',
'proxy_url': 'http://okreportcn.ok-script.com/',
'exe_name': 'ok-ww.exe',
'use_proxy': True
},

View File

@ -22,6 +22,10 @@ class NotInCombatException(Exception):
pass
class CharDeadException(NotInCombatException):
pass
key_config_option = ConfigOption('Game Hotkey Config', {
'Echo Key': 'q',
'Liberation Key': 'r',
@ -42,10 +46,12 @@ class BaseCombatTask(BaseTask, FindFeature, OCR, CombatCheck):
self.char_texts = ['char_1_text', 'char_2_text', 'char_3_text']
def raise_not_in_combat(self, message):
def raise_not_in_combat(self, message, exception_type=None):
logger.error(message)
self.reset_to_false(reason=message)
raise NotInCombatException(message)
if exception_type is None:
exception_type = NotInCombatException
raise exception_type(message)
def combat_once(self, wait_combat_time=180, wait_before=2):
self.wait_until(lambda: self.in_combat(), time_out=wait_combat_time, raise_if_not_found=True)
@ -57,6 +63,8 @@ class BaseCombatTask(BaseTask, FindFeature, OCR, CombatCheck):
try:
logger.debug(f'combat_once loop {self.chars}')
self.get_current_char().perform()
except CharDeadException as e:
raise e
except NotInCombatException as e:
logger.info(f'combat_once out of combat break {e}')
if self.debug:
@ -79,27 +87,6 @@ class BaseCombatTask(BaseTask, FindFeature, OCR, CombatCheck):
return True
total_index += 1
# @property
# def frame(self):
# frame = super().frame
# if frame is not None:
# start = time.time()
# # if cv2.countNonZero(cv2.split(frame)) == 0:
# means, stddevs = cv2.meanStdDev(frame)
#
# # Check if all channel means are very close to zero (black)
# all_black_means = np.all(np.isclose(means, 0.0, atol=1e-3))
#
# # Check if all channel standard deviations are low (uniform)
# low_stddevs = np.all(stddevs[0] < 1e-3)
#
# # Return True if all channels are black and uniform
# if all_black_means and low_stddevs:
# logger.error('got a pure black frame!')
# return self.next_frame()
# logger.debug(f'black check:{time.time() - start}')
# return frame
def switch_next_char(self, current_char, post_action=None, free_intro=False, target_low_con=False):
max_priority = Priority.MIN
switch_to = None
@ -141,11 +128,19 @@ class BaseCombatTask(BaseTask, FindFeature, OCR, CombatCheck):
self.send_key(switch_to.index + 1)
last_click = now
in_team, current_index, size = self.in_team()
if not in_team or now - start > 10:
if not in_team:
if self.debug:
self.screenshot(f'not in team while switching chars_{current_char}_to_{switch_to} {now - start}')
confirm = self.wait_feature('revive_confirm', threshold=0.8, time_out=3)
if confirm:
self.log_info(f'char dead')
self.raise_not_in_combat(f'char dead', exception_type=CharDeadException)
else:
self.raise_not_in_combat(
f'not in team while switching chars_{current_char}_to_{switch_to}')
if now - start > 10:
self.raise_not_in_combat(
f'not in team while switching chars_{current_char}_to_{switch_to}, {now - start}')
f'switch too long failed chars_{current_char}_to_{switch_to}, {now - start}')
if current_index != switch_to.index:
has_intro = free_intro if free_intro else current_char.is_con_full()
switch_to.has_intro = has_intro

View File

@ -79,18 +79,13 @@ class FarmEchoTask(BaseCombatTask):
y = 0.17
x = 0.15
distance = 0.08
# for i in range(4):
# if i < start:
# continue
logger.info(f'choose level {start}')
self.click_relative(x, y + (start - 1) * distance)
self.sleep(0.5)
# self.click_relative(x, y + (start - 1) * distance)
self.wait_click_feature('gray_button_challenge', raise_if_not_found=True, use_gray_scale=True,
click_after_delay=0.5)
# self.sleep(1)
# confirm_button = self.find_one('gray_confirm_exit_button', use_gray_scale=True, threshold=0.7)
self.wait_click_feature('gray_confirm_exit_button', relative_x=-1, raise_if_not_found=False,
use_gray_scale=True, time_out=3, click_after_delay=0.5, threshold=0.8)
self.wait_click_feature('gray_start_battle', relative_x=-1, raise_if_not_found=True,

View File

@ -2,7 +2,7 @@ import time
from ok.feature.Feature import Feature
from ok.logging.Logger import get_logger
from src.task.BaseCombatTask import BaseCombatTask
from src.task.BaseCombatTask import BaseCombatTask, CharDeadException
logger = get_logger(__name__)
@ -88,6 +88,9 @@ class FarmWorldBossTask(BaseCombatTask):
self.wait_click_feature('gray_custom_way_point', box=self.box_of_screen(0.62, 0.48, 0.70, 0.66),
raise_if_not_found=True,
use_gray_scale=True, threshold=0.75, time_out=2)
self.click_fast_travel()
def click_fast_travel(self):
travel = self.wait_feature('fast_travel_custom', raise_if_not_found=True, threshold=0.75)
self.click_box(travel, relative_x=1.5)
@ -119,12 +122,9 @@ class FarmWorldBossTask(BaseCombatTask):
self.click_relative(0.5, 0.5)
self.sleep(0.1)
# count = 0
while True:
if time.time() - start > 20:
raise Exception("scroll to long")
# if count % 10 == 0:
# count += 1
self.scroll_relative(0.5, 0.5, -1)
self.sleep(0.1)
targets = self.find_feature('target_box', box=target_box, template=source_template)
@ -132,6 +132,21 @@ class FarmWorldBossTask(BaseCombatTask):
self.log_info(f'scroll to targets {targets} successfully')
break
def teleport_to_heal(self):
self.info['Death Times'] = self.info.get('Death Times', 0) + 1
self.send_key('esc')
self.sleep(1)
self.log_info('click m to open the map')
self.send_key('m')
self.sleep(2)
self.click_relative(0.68, 0.05)
self.sleep(1)
self.click_relative(0.37, 0.42)
travel = self.wait_feature('gray_teleport', raise_if_not_found=True, use_gray_scale=True, time_out=3)
self.click_box(travel, relative_x=1.5)
self.wait_in_team_and_world(time_out=20)
self.sleep(2)
def run(self):
if not self.check_main():
self.log_error('must be in game world and in teams', notify=True)
@ -150,7 +165,12 @@ class FarmWorldBossTask(BaseCombatTask):
self.sleep(2)
logger.info('Crownless walk to f')
self.walk_until_f(raise_if_not_found=True, time_out=4, backward_time=1)
self.combat_once()
try:
self.combat_once()
except CharDeadException:
logger.info(f'char dead try teleport to heal')
self.teleport_to_heal()
continue
logger.info(f'farm echo combat end')
if boss_name == 'Bell-Borne Geochelone':
logger.info(f'sleep for the Boss model to disappear')