Skip to content

Commit

Permalink
刷大世界boss死了, 自动传送治疗
Browse files Browse the repository at this point in the history
  • Loading branch information
ok-oldking committed Jul 20, 2024
1 parent ddc9747 commit 05703ee
Show file tree
Hide file tree
Showing 7 changed files with 448 additions and 411 deletions.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
771 changes: 399 additions & 372 deletions assets/_annotations.coco.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def calculate_pc_exe_path(running_path):
'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
},
Expand Down
45 changes: 20 additions & 25 deletions src/task/BaseCombatTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -42,10 +46,12 @@ def __init__(self):

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)
Expand All @@ -57,6 +63,8 @@ def combat_once(self, wait_combat_time=180, wait_before=2):
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:
Expand All @@ -79,27 +87,6 @@ def run_in_circle_to_find_echo(self, circle_count=3):
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
Expand Down Expand Up @@ -141,11 +128,19 @@ def switch_next_char(self, current_char, post_action=None, free_intro=False, tar
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
Expand Down
9 changes: 2 additions & 7 deletions src/task/FarmEchoTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,13 @@ def choose_level(self, start):
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,
Expand Down
30 changes: 25 additions & 5 deletions src/task/FarmWorldBossTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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__)

Expand Down Expand Up @@ -88,6 +88,9 @@ def teleport(self, boss_name):
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)

Expand Down Expand Up @@ -119,19 +122,31 @@ def scroll_down_a_page(self):

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)
if targets:
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)
Expand All @@ -150,7 +165,12 @@ def run(self):
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')
Expand Down

0 comments on commit 05703ee

Please sign in to comment.