Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 5018e56

Browse files
committed
1.0.3.8
- Better Navigation Pathing - Fixed E.G.O Usage Issues - Dynamic waiting time for connection related stuff - Added Fullstop Office Pack
1 parent 0f29abb commit 5018e56

File tree

11 files changed

+98
-14
lines changed

11 files changed

+98
-14
lines changed

config/f4.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pictures/mirror/packs/f4/miracle.png
44
pictures/mirror/packs/f4/envy.png
55
pictures/mirror/packs/f4/warp.png
66
pictures/mirror/packs/f4/tearful.png
7+
pictures/mirror/packs/f4/fullstop.png
78
pictures/mirror/packs/f4/time.png
89
pictures/mirror/packs/f4/pride.png
910
pictures/mirror/packs/f4/yield.png

pictures/general/connection.png

9.4 KB
Loading

pictures/general/connection_o.png

17.9 KB
Loading

pictures/mirror/general/node_1.png

24.1 KB
Loading

pictures/mirror/general/node_2.png

19 KB
Loading

pictures/mirror/general/node_3.png

24.6 KB
Loading
36.8 KB
Loading

sirsquirrel.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from src.core import pre_md_setup,reconnect
99
from src.common import error_screenshot, element_exist
1010

11+
connection_event = threading.Event()
12+
1113
with open("config/status_selection.txt", "r") as f:
1214
status = [i.strip().lower() for i in f.readlines()]
1315

@@ -37,14 +39,14 @@ def start_exit_listener():
3739
def connection_listener():
3840
reconnect()
3941

40-
# Start the listener in a separate thread
41-
exit_listener_thread = threading.Thread(target=start_exit_listener, daemon=True)
42-
exit_listener_thread.start()
42+
def connection_check():
43+
while True:
44+
while(element_exist("pictures/general/connection.png")):
45+
connection_event.clear()
46+
connection_event.set()
4347

4448
def mirror_dungeon_run(num_runs, logger):
4549
try:
46-
connection_event = threading.Event()
47-
connection_event.set()
4850
run_count = 0
4951
win_count = 0
5052
lose_count = 0
@@ -62,7 +64,7 @@ def mirror_dungeon_run(num_runs, logger):
6264
win_flag, run_complete = MD.mirror_loop()
6365
if element_exist("pictures/general/server_error.png"):
6466
connection_event.clear()
65-
logger.debug("Pausing, Resuming")
67+
logger.debug("Disconnected, Pausing")
6668
connection_listener_thread = threading.Thread(target=connection_listener)
6769
connection_listener_thread.start()
6870
connection_listener_thread.join()
@@ -91,6 +93,14 @@ def main():
9193
update()
9294
parser.add_argument("RunCount", help="How many times you want to run Mirror Dungeons", type=int)
9395
args = parser.parse_args()
96+
97+
connection_event.set()
98+
exit_listener_thread = threading.Thread(target=start_exit_listener, daemon=True)
99+
exit_listener_thread.start()
100+
101+
connection_thread = threading.Thread(target=connection_check)
102+
connection_thread.start()
103+
94104
mirror_dungeon_run(args.RunCount, logger)
95105

96106
if __name__ == "__main__":

src/common.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ def match_image(template_path, threshold=0.8):
9292
# Capture current screen and get dimensions
9393
screenshot = capture_screen()
9494
screenshot_height, screenshot_width = screenshot.shape[:2]
95-
9695
# Calculate scale factor
9796
scale_factor_x = screenshot_width / 2560
9897
scale_factor_y = screenshot_height / 1440
@@ -140,6 +139,61 @@ def match_image(template_path, threshold=0.8):
140139
# Return the list of center coordinates of all found elements or None if no elements found
141140
return []
142141

142+
def greyscale_match_image(template_path, threshold=0.8):
143+
"""Finds the image specified and returns the center coordinates, regardless of screen resolution,
144+
and saves screenshots of each match found."""
145+
146+
# Capture current screen and get dimensions
147+
screenshot = capture_screen()
148+
screenshot_height, screenshot_width = screenshot.shape[:2]
149+
screenshot = cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY)
150+
# Calculate scale factor
151+
scale_factor_x = screenshot_width / 2560
152+
scale_factor_y = screenshot_height / 1440
153+
scale_factor = min(scale_factor_x,scale_factor_y)
154+
# Load and resize the template image according to the scale factor
155+
template = cv2.imread(template_path, cv2.IMREAD_GRAYSCALE)
156+
if template is None:
157+
raise FileNotFoundError(f"Template image '{template_path}' not found.")
158+
159+
template = cv2.resize(template, None, fx=scale_factor, fy=scale_factor, interpolation=cv2.INTER_LINEAR)
160+
template_height, template_width = template.shape[:2]
161+
162+
# Perform template matching
163+
result = cv2.matchTemplate(screenshot, template, cv2.TM_CCOEFF_NORMED)
164+
165+
# Get locations where the match confidence exceeds the threshold
166+
if scale_factor < 0.75:
167+
threshold = threshold-0.05 #Testing for detecting on lower scales
168+
locations = np.where(result >= threshold)
169+
boxes = []
170+
171+
# Loop through all the matching locations and create bounding boxes
172+
for pt in zip(*locations[::-1]): # Switch columns and rows
173+
top_left = pt
174+
bottom_right = (top_left[0] + template_width, top_left[1] + template_height)
175+
boxes.append([top_left[0], top_left[1], bottom_right[0], bottom_right[1]])
176+
177+
boxes = np.array(boxes)
178+
179+
# Apply non-maximum suppression to remove overlapping boxes
180+
filtered_boxes = non_max_suppression_fast(boxes)
181+
182+
# List to hold the center coordinates of all filtered elements
183+
found_elements = []
184+
185+
# Save a screenshot of each matched region
186+
for match_index, (x1, y1, x2, y2) in enumerate(filtered_boxes):
187+
center_x = (x1 + x2) // 2
188+
center_y = (y1 + y2) // 2
189+
found_elements.append((center_x, center_y))
190+
191+
if found_elements:
192+
#save_match_screenshot(screenshot, (x1, y1), (x2, y2), template_path, match_index)
193+
return sorted(found_elements)
194+
# Return the list of center coordinates of all found elements or None if no elements found
195+
return []
196+
143197
def proximity_check(list1, list2, threshold):
144198
close_pairs = set() # To store pairs of coordinates that are close
145199
for coord1 in list1:

src/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def ego_check():
106106
logger.debug("BAD CLASHES FOUND")
107107
for x,y in bad_clashes:
108108
usable_ego = []
109-
common.mouse_move(x-common.scale_x(30),y+common.scale_y(100))
109+
common.mouse_move(x-common.scale_x(55),y+common.scale_y(100))
110110
common.mouse_hold()
111111
egos = common.match_image("pictures/battle/ego/sanity.png")
112112
for i in egos:

0 commit comments

Comments
 (0)