Skip to content

Commit

Permalink
自动战斗 拾取支持 宽屏如21:9
Browse files Browse the repository at this point in the history
  • Loading branch information
ok-oldking committed Aug 1, 2024
1 parent 52ee67e commit 8066b79
Show file tree
Hide file tree
Showing 13 changed files with 461 additions and 460 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
892 changes: 446 additions & 446 deletions assets/_annotations.coco.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def calculate_pc_exe_path(running_path):
<strong>使用本软件可能会导致账号被封。</strong> 请在了解风险后再使用。
</p>
""",
'supported_screen_ratio': '16:9',
'screenshots_folder': "screenshots",
'gui_title': 'OK-WW', # Optional
# 'coco_feature_folder': get_path(__file__, 'assets/coco_feature'), # required if using feature detection
Expand Down
5 changes: 3 additions & 2 deletions src/char/BaseChar.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ def is_con_full(self):
return self.get_current_con() == 1

def get_current_con(self):
box = self.task.box_of_screen(1422 / 3840, 1939 / 2160, 1566 / 3840, 2076 / 2160, name='con_full')
box = self.task.box_of_screen_scaled(3840, 2160, 1422, 1939, to_x=1566, to_y=2076, name='con_full',
hcenter=True)
box.confidence = 0

max_area = 0
Expand Down Expand Up @@ -447,7 +448,7 @@ def get_current_con(self):
return percent

def is_forte_full(self):
box = self.task.box_of_screen(2251 / 3840, 1993 / 2160, 2311 / 3840, 2016 / 2160, name='forte_full')
box = self.task.box_of_screen_scaled(3840, 2160, 2251, 1993, 2311, 2016, name='forte_full', hcenter=True)
white_percent = self.task.calculate_color_percentage(forte_white_color, box)
# num_labels, stats = get_connected_area_by_color(box.crop_frame(self.task.frame), forte_white_color,
# connectivity=8)
Expand Down
6 changes: 3 additions & 3 deletions src/combat/CombatCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def recent_liberation(self):
return time.time() - self.last_liberation < 0.3

def check_count_down(self):
count_down_area = self.box_of_screen(1820 / 3840, 266 / 2160, 2100 / 3840,
340 / 2160, name="check_count_down")
count_down_area = self.box_of_screen_scaled(3840, 2160, 1820, 266, 2100,
340, name="check_count_down", hcenter=True)
count_down = self.calculate_color_percentage(text_white_color,
count_down_area)

Expand Down Expand Up @@ -212,7 +212,7 @@ def check_health_bar(self):
return self.find_boss_lv_text()

def find_boss_lv_text(self):
texts = self.ocr(box=self.box_of_screen(1269 / 3840, 10 / 2160, 2533 / 3840, 140 / 2160),
texts = self.ocr(box=self.box_of_screen(1269 / 3840, 10 / 2160, 2533 / 3840, 140 / 2160, hcenter=True),
target_height=540, name='boss_lv_text')
boss_lv_texts = find_boxes_by_name(texts,
[re.compile(r'(?i)^L[V].*')])
Expand Down
2 changes: 1 addition & 1 deletion src/task/AutoPickTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run(self):
self.sleep(0.2)

def trigger(self):
if f := self.find_one('pick_up_f', box=self.f_search_box,
if f := self.find_one('pick_up_f_hcenter_vcenter', box=self.f_search_box,
threshold=0.8):
dialog_search = f.copy(x_offset=f.width * 2, width_offset=f.width * 2, height_offset=f.height * 2,
y_offset=-f.height,
Expand Down
4 changes: 2 additions & 2 deletions src/task/BaseCombatTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def switch_next_char(self, current_char, post_action=None, free_intro=False, tar
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)
confirm = self.wait_feature('revive_confirm_hcenter_vcenter', 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)
Expand Down Expand Up @@ -233,7 +233,7 @@ def send_key_and_wait_f(self, direction, raise_if_not_found, time_out, running=F
return f_found

def handle_claim_button(self):
if self.wait_feature('claim_cancel_button', raise_if_not_found=False, horizontal_variance=0.05,
if self.wait_feature('claim_cancel_button_hcenter_vcenter', raise_if_not_found=False, horizontal_variance=0.05,
vertical_variance=0.1, time_out=1.5, threshold=0.8):
self.sleep(0.5)
self.send_key('esc')
Expand Down
4 changes: 2 additions & 2 deletions src/task/BaseWWTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def set_check_monthly_card(self, next_day=False):

@property
def f_search_box(self):
f_search_box = self.get_box_by_name('pick_up_f')
f_search_box = self.get_box_by_name('pick_up_f_hcenter_vcenter')
f_search_box = f_search_box.copy(x_offset=-f_search_box.width / 2,
width_offset=f_search_box.width,
height_offset=f_search_box.height * 9,
Expand All @@ -83,7 +83,7 @@ def f_search_box(self):
return f_search_box

def find_f_with_text(self, target_text=None):
f = self.find_one('pick_up_f', box=self.f_search_box, threshold=0.8)
f = self.find_one('pick_up_f_hcenter_vcenter', box=self.f_search_box, threshold=0.8)
if f and target_text:
search_text_box = f.copy(x_offset=f.width * 5, width_offset=f.width * 7, height_offset=1.5 * f.height,
y_offset=-0.8 * f.height, name='search_text_box')
Expand Down
7 changes: 4 additions & 3 deletions src/task/FarmWorldBossTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ def teleport_to_boss(self, boss_name):
self.wait_feature('gray_teleport', raise_if_not_found=True, time_out=200,
pre_action=lambda: self.click_box(proceeds[index], relative_x=-1), wait_until_before_delay=5)
self.sleep(1)
teleport = self.wait_click_feature('custom_teleport', box=self.box_of_screen(0.48, 0.45, 0.54, 0.58),
teleport = self.wait_click_feature('custom_teleport_hcenter_vcenter',
box=self.box_of_screen(0.48, 0.45, 0.54, 0.58),
raise_if_not_found=False, threshold=0.8, time_out=2)
if not teleport:
self.click_relative(0.5, 0.5)
self.click_relative(0.5, 0.5, hcenter=True)
self.sleep(0.5)
self.wait_click_feature('gray_custom_way_point', box=self.box_of_screen(0.62, 0.48, 0.70, 0.86),
raise_if_not_found=True, threshold=0.75, time_out=2)
Expand All @@ -96,7 +97,7 @@ def click_fast_travel(self):

def wait_book(self):
gray_book_boss = self.wait_until(
lambda: self.find_one('gray_book_boss', vertical_variance=1, horizontal_variance=0.05,
lambda: self.find_one('gray_book_boss', vertical_variance=0.8, horizontal_variance=0.05,
threshold=0.7, canny_lower=50,
canny_higher=150) or self.find_one(
'gray_book_boss_highlight',
Expand Down

0 comments on commit 8066b79

Please sign in to comment.