Skip to content

Commit

Permalink
adapt scripts (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeon0 authored Nov 15, 2023
1 parent c99648d commit ff007a9
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions config/game_1920x1080.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ sort_icon=1220,666,63,62
; for scripts
core_skill=1094,981,47,47
skill4=967,981,47,47
skill3=904,981,49,49
rel_skill_cd=6,4,22,12
mini_map_visible=1719,123,60,60
hud_detection=702,978,59,53
Expand Down
1 change: 1 addition & 0 deletions config/game_2560x1080.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ rel_fav_flag=3,3,10,10
sort_icon=1860,666,63,62
core_skill=1734,981,47,47
skill4=1607,981,47,47
skill3=904,981,49,49
rel_skill_cd=6,4,22,12
mini_map_visible=2359,123,60,60
hud_detection=702,978,59,53
Expand Down
1 change: 1 addition & 0 deletions config/game_2560x1440.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ rel_fav_flag=4,4,13,13
sort_icon=1626,888,84,82
core_skill=1458,1308,62,62
skill4=1289,1308,62,62
skill3=1205,1308,65,65
rel_skill_cd=8,5,29,16
mini_map_visible=2292,164,80,80
hud_detection=936,1304,78,70
Expand Down
1 change: 1 addition & 0 deletions config/game_3440x1440.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ rel_fav_flag=4,4,13,13
sort_icon=2506,888,84,82
core_skill=2338,1308,62,62
skill4=2169,1308,62,62
skill3=1205,1308,65,65
rel_skill_cd=8,5,29,16
mini_map_visible=3172,164,80,80
hud_detection=936,1304,78,70
Expand Down
1 change: 1 addition & 0 deletions config/game_3840x2160.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ rel_fav_flag=6,6,20,20
sort_icon=2440,1332,126,124
core_skill=2188,1962,94,94
skill4=1934,1962,94,94
skill3=1808,1962,98,98
rel_skill_cd=12,8,44,24
mini_map_visible=3438,246,120,120
hud_detection=1404,1956,118,106
Expand Down
1 change: 1 addition & 0 deletions config/game_5120x1440.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ rel_fav_flag=4,4,13,13
sort_icon=3786,888,84,82
core_skill=3618,1308,62,62
skill4=3449,1308,62,62
skill3=1605,1308,65,65
rel_skill_cd=8,5,29,16
mini_map_visible=4452,164,80,80
hud_detection=1336,1304,78,70
Expand Down
1 change: 1 addition & 0 deletions config/params.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ run_scripts=
; Hotkey to open inventory
inventory=i
skill4=4
skill3=3
health_pot=q

[advanced_options]
Expand Down
1 change: 1 addition & 0 deletions src/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def filter_items(self):
self.loot_filter_thread.start()
self.filter_button.config(text="stop")
finally:
self.filter_button.config(text="filter")
lock.release()
else:
return
Expand Down
14 changes: 10 additions & 4 deletions src/scripts/rogue_tb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ def run_rogue_tb():
while True:
img = Cam().grab()
if hud.is_ingame(img):
ready = hud.is_skill_ready(img)
ready4 = hud.is_skill_ready(img)
ready3 = hud.is_skill_ready(img, "skill3")
imbued = hud.is_imbued(img)
if ready and not imbued:
keyboard.send(Config().char["skill4"])
Logger.debug("Casting imbuement")
# Logger.debug(f"imbued: {imbued} s3: {ready3} s4: {ready4}")
if not imbued:
if ready4:
keyboard.send(Config().char["skill4"])
Logger.debug("Casting imbuement (skill4)")
elif ready3:
keyboard.send(Config().char["skill3"])
Logger.debug("Casting imbuement (skill3)")
wait(0.1, 0.15)


Expand Down
18 changes: 9 additions & 9 deletions src/ui/hud.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def is_skill_ready(img: np.ndarray = None, roi_name: str = "skill4") -> bool:
cropped = crop(cropped, Config().ui_roi["rel_skill_cd"])
mask, _ = color_filter(cropped, Config().colors[f"skill_cd"], False)
# at least half of the row must be filled
target_sum = (mask.shape[0] * mask.shape[1] * 255) * 0.8
target_sum = (mask.shape[0] * mask.shape[1] * 255) * 0.85
cd_sum = np.sum(mask)
ready = avg_saturation > 100 and cd_sum < target_sum
ready = avg_saturation > 90 and cd_sum < target_sum
return ready

@staticmethod
Expand All @@ -50,7 +50,7 @@ def is_imbued(img: np.ndarray = None, roi_name: str = "core_skill") -> bool:
cropped = crop(img, roi)
mask, _ = color_filter(cropped, Config().colors[color], False)
# at least half of the row must be filled
target_sum = (mask.shape[0] * mask.shape[1] * 255) * 0.3
target_sum = (mask.shape[0] * mask.shape[1] * 255) * 0.35
cd_sum = np.sum(mask)
if cd_sum > target_sum:
return True
Expand All @@ -63,14 +63,14 @@ def get_health(img: np.ndarray = None) -> float:
sobel_y = cv2.Sobel(cut_img, cv2.CV_64F, 0, 1, ksize=3)
_, binary = cv2.threshold(np.abs(sobel_y), 100, 255, cv2.THRESH_BINARY)
blue, green, red = cv2.split(binary)
lines_red = cv2.HoughLinesP(red.astype(np.uint8), 1, math.pi / 2, 2, None, 30, 1)
lines_green = cv2.HoughLinesP(green.astype(np.uint8), 1, math.pi / 2, 2, None, 30, 1)
# lines_red = cv2.HoughLinesP(red.astype(np.uint8), 1, math.pi / 2, 2, None, 30, 1)
# lines_green = cv2.HoughLinesP(green.astype(np.uint8), 1, math.pi / 2, 2, None, 30, 1)
combined = cv2.bitwise_or(red, green)
lines_combined = cv2.HoughLinesP(combined.astype(np.uint8), 1, math.pi / 2, 2, None, 30, 1)
lines_blue = cv2.HoughLinesP(blue.astype(np.uint8), 1, math.pi / 2, 2, None, 30, 1)
lines = []
if lines_red is not None:
lines.extend(lines_red)
if lines_green is not None:
lines.extend(lines_green)
if lines_combined is not None:
lines.extend(lines_combined)
if lines_blue is not None:
lines.extend(lines_blue)
# for line in lines[0]:
Expand Down

0 comments on commit ff007a9

Please sign in to comment.