Skip to content

Commit

Permalink
vision mode on vendor items (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeon0 authored Nov 24, 2023
1 parent 43c54bc commit fe380b6
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/game_1920x1080.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ item_descr_off_bottom_edge=52
find_seperator_short_offset_top=300
find_bullet_points_width=39
item_descr_line_height=25
vendor_center_item_x=616

[ui_roi]
rel_descr_search_left=-455,0,60,880
Expand All @@ -32,6 +33,7 @@ stash_menu_icon=296,72,109,48
tab_slots_5=183,142,336,51
rel_fav_flag=3,3,10,10
sort_icon=1220,666,63,62
vendor_text=100,391,94,22
; for scripts
core_skill=1094,981,47,47
skill4=967,981,47,47
Expand Down
2 changes: 2 additions & 0 deletions config/game_2560x1080.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ item_descr_off_bottom_edge=52
find_seperator_short_offset_top=300
find_bullet_points_width=39
item_descr_line_height=25
vendor_center_item_x=616

[ui_roi]
rel_descr_search_left=-455,0,60,880
Expand All @@ -27,6 +28,7 @@ stash_menu_icon=296,72,109,48
tab_slots_5=183,142,336,51
rel_fav_flag=3,3,10,10
sort_icon=1860,666,63,62
vendor_text=100,391,94,22
core_skill=1734,981,47,47
skill4=1607,981,47,47
skill3=904,981,49,49
Expand Down
2 changes: 2 additions & 0 deletions config/game_2560x1440.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ item_descr_off_bottom_edge=69
find_seperator_short_offset_top=400
find_bullet_points_width=52
item_descr_line_height=33
vendor_center_item_x=821

[ui_roi]
rel_descr_search_left=-606,0,80,1173
Expand All @@ -27,6 +28,7 @@ stash_menu_icon=394,96,145,64
tab_slots_5=244,189,448,68
rel_fav_flag=4,4,13,13
sort_icon=1626,888,84,82
vendor_text=133,521,125,29
core_skill=1458,1308,62,62
skill4=1289,1308,62,62
skill3=1205,1308,65,65
Expand Down
2 changes: 2 additions & 0 deletions config/game_3440x1440.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ item_descr_off_bottom_edge=69
find_seperator_short_offset_top=400
find_bullet_points_width=52
item_descr_line_height=33
vendor_center_item_x=821

[ui_roi]
rel_descr_search_left=-606,0,80,1173
Expand All @@ -27,6 +28,7 @@ stash_menu_icon=394,96,145,64
tab_slots_5=244,189,448,68
rel_fav_flag=4,4,13,13
sort_icon=2506,888,84,82
vendor_text=133,521,125,29
core_skill=2338,1308,62,62
skill4=2169,1308,62,62
skill3=1205,1308,65,65
Expand Down
2 changes: 2 additions & 0 deletions config/game_3840x1080.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ item_descr_off_bottom_edge=52
find_seperator_short_offset_top=300
find_bullet_points_width=39
item_descr_line_height=25
vendor_center_item_x=616

[ui_roi]
rel_descr_search_left=-455,0,60,880
Expand All @@ -27,6 +28,7 @@ stash_menu_icon=596,72,109,48
tab_slots_5=483,142,336,51
rel_fav_flag=3,3,10,10
sort_icon=2840,666,63,62
vendor_text=400,391,94,22
core_skill=2714,981,47,47
skill4=2587,981,47,47
skill3=1204,981,49,49
Expand Down
2 changes: 2 additions & 0 deletions config/game_3840x2160.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ item_descr_off_bottom_edge=104
find_seperator_short_offset_top=600
find_bullet_points_width=78
item_descr_line_height=50
vendor_center_item_x=1232

[ui_roi]
rel_descr_search_left=-910,0,120,1760
Expand All @@ -27,6 +28,7 @@ stash_menu_icon=592,144,218,96
tab_slots_5=366,284,672,102
rel_fav_flag=6,6,20,20
sort_icon=2440,1332,126,124
vendor_text=200,782,188,44
core_skill=2188,1962,94,94
skill4=1934,1962,94,94
skill3=1808,1962,98,98
Expand Down
2 changes: 2 additions & 0 deletions config/game_5120x1440.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ item_descr_off_bottom_edge=69
find_seperator_short_offset_top=400
find_bullet_points_width=52
item_descr_line_height=33
vendor_center_item_x=821

[ui_roi]
rel_descr_search_left=-606,0,80,1173
Expand All @@ -27,6 +28,7 @@ stash_menu_icon=794,96,145,64
tab_slots_5=644,189,448,68
rel_fav_flag=4,4,13,13
sort_icon=3786,888,84,82
vendor_text=533,521,125,29
core_skill=3618,1308,62,62
skill4=3449,1308,62,62
skill3=1605,1308,65,65
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/heal.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def heal():
if hud.is_ingame(img) and not inv.is_open():
health = hud.get_health(img)
if health < 0.8:
keyboard.send(Config().char["health_pot"])
keyboard.send("tab")
Logger.debug(f"Healing {health}")

wait(0.3, 0.35)
Expand Down
3 changes: 1 addition & 2 deletions src/scripts/rogue_tb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def run_rogue_tb():
imbued = hud.is_imbued(img)
if not imbued:
if ready4:
keyboard.send(Config().char["skill4"])
Logger.debug("Casting imbuement (skill4)")
keyboard.send("r")
wait(0.1, 0.15)


Expand Down
13 changes: 13 additions & 0 deletions src/scripts/vision_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import tkinter as tk
from config import Config

from utils.ocr.read import image_to_text
from utils.image_operations import crop


def draw_rect(canvas: tk.Canvas, bullet_width, obj, off, color):
offset_loc = np.array(obj.loc) + off
Expand Down Expand Up @@ -46,6 +49,12 @@ def reset_canvas(root, canvas):
root.update()


def is_vendor_open(img: np.ndarray):
cropped = crop(img, Config().ui_roi["vendor_text"])
res = image_to_text(cropped)
return res.text.strip().lower() == "vendor"


def vision_mode():
root = tk.Tk()
root.overrideredirect(True)
Expand Down Expand Up @@ -86,6 +95,10 @@ def vision_mode():
closest_index = np.argmin(distances)
item_center = possible_centers[closest_index]
found, rarity, cropped_descr, item_roi = find_descr(img, item_center)
if not found and is_vendor_open(img):
vendor_item_center = [Config().ui_offsets["vendor_center_item_x"], 0]
found, rarity, cropped_descr, item_roi = find_descr(img, vendor_item_center)

top_left_corner = None if not found else item_roi[:2]
if found:
if (
Expand Down

0 comments on commit fe380b6

Please sign in to comment.