This commit is contained in:
2022-04-29 02:06:44 +02:00
parent b187022918
commit ebafbdf4b2
128 changed files with 1619 additions and 0 deletions

BIN
1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
Brown0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
D1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
D2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
D3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
D4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
D5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
D6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
D7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
H1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
H2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
H3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
H4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
candy-c/grid.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

BIN
candy-c/repeat.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
candy-c/reset.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
canny.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

207
combine_main.py Normal file
View File

@@ -0,0 +1,207 @@
import random
from time import time
from window_capture import WindowCapture
from stun_vision import StunVision
import cv2 as cv
import pytesseract
from hsvfilter import HsvFilter
from config_file import UserConfigs
# import pyautogui
import pydirectinput
import keyboard
def run():
# initialize the user-class
config = UserConfigs()
# initialize the StunWindowCapture class
try:
capture_window = WindowCapture(
None, "stun", config)
video_mode = False
except:
# StunWindowCapture.list_window_names()
# print("Game not running, switching to video mode")
# capture_window = cv.VideoCapture("snip_slam.mp4")
video_mode = True
# initialize the StunVision class
vision_stun = StunVision()
# initialize the StunOverlay class
hsv_filter_orange = HsvFilter(10, 156, 0, 17, 255, 255, 0, 0, 0, 0)
hsv_filter_p = HsvFilter(130, 156, 0, 179, 255, 255, 0, 0, 0, 0)
hsv_filter_b = HsvFilter(88, 156, 0, 128, 255, 255, 0, 0, 0, 0)
hsv_filter_g = HsvFilter(34, 156, 0, 74, 255, 255, 0, 0, 0, 0)
hsv_filter_y = HsvFilter(24, 156, 0, 33, 255, 255, 0, 0, 0, 0)
#hsv_filter_0 = HsvFilter(0, 156, 0, 7, 255, 255, 0, 0, 0, 0)
hsv_filter_0 = HsvFilter(0, 0, 0, 179, 255, 255, 255, 0, 0, 0)
hsv_filter_w = HsvFilter(69, 25, 0, 94, 255, 255, 0, 0, 0, 0)
loop_time = time()
event_time = 0.0
pointstore = []
max_results = 0
pause = True
magic_list = {"1": "body", "2": "finding", "3": "mind", "4": "perceiving", "5": "physical", "6": "seeing",
"7": "spiritual"}
tier_list = {"1": "0", "2": "orange", "3": "y", "4": "g", "5": "b", "6": "p"} # , "w"}
hsv_filter_list = {"1": hsv_filter_0, "2": hsv_filter_orange, "3": hsv_filter_y, "4": hsv_filter_g,
"5": hsv_filter_b, "6": hsv_filter_p}
needle_list = []
hsv_list = []
# tmp = []
for key1 in tier_list:
for key2 in magic_list:
needle_list.append(cv.imread("magic/" + magic_list[key2] + "_" + tier_list[key1] + ".jpg",
cv.IMREAD_UNCHANGED))
hsv_list.append(hsv_filter_list[key1])
while True:
if keyboard.is_pressed('p') == True:
pause = True
print('q pressed')
elif keyboard.is_pressed('o') == True:
pause = False
print('o pressed')
if pause:
# cv.waitKey(500)
print("pausing")
continue
if video_mode:
break
else:
try:
# get an updated image of the game
screenshot = capture_window.get_screenshot()
# screenshot = cv.imread("buffbar.jpg")
except:
capture_window.release()
print("Game window not available - shutting down application")
break
#cv.imshow("screenshot", screenshot)
#cv.waitKey(150)
#continue
spawn_1 = vision_stun.find(screenshot, cv.imread("magic/spawn_1.jpg", cv.IMREAD_UNCHANGED), 0.5, 1)
if len(spawn_1) == 1:
spawn_button_active = True
points = vision_stun.get_click_points(spawn_1)
for i in range(0, 200, 1):
pydirectinput.moveTo(points[0][0], points[0][1])
pydirectinput.mouseDown()
w = random.randint(1, 50)
cv.waitKey(30 + w)
pydirectinput.mouseUp()
else:
spawn_0 = vision_stun.find(screenshot, cv.imread("magic/spawn_0.jpg", cv.IMREAD_UNCHANGED), 0.7, 1)
points = vision_stun.get_click_points(spawn_0)
for point in points:
pydirectinput.moveTo(point[0], point[1])
pydirectinput.mouseDown()
cv.waitKey(500)
pydirectinput.mouseUp()
continue
# for needles in needle_list:
for rer in range(0, len(needle_list), 1):
#for needle in needle_list:
# do object detection
# processed_image = vision_stun.apply_hsv_filter(screenshot, hsv_filter)
# screenshot = capture_window.get_screenshot()
#cv.imshow("output_image", needle_list[rer])
#cv.waitKey(150)
while True:
screenshot = capture_window.get_screenshot()
processed_screenshot = vision_stun.apply_hsv_filter(screenshot, hsv_list[rer])
processed_needle = vision_stun.apply_hsv_filter(needle_list[rer], hsv_list[rer])
#cv.imshow("output_image", processed_screenshot)
cv.imshow("output_needle", processed_needle)
cv.waitKey(150)
rectangles = vision_stun.find(processed_screenshot, processed_needle, 0.70, 2)
# draw the detection results onto the original image
#output_image = vision_stun.draw_rectangles(screenshot, rectangles)
#cv.imshow("output_image", output_image)
#cv.waitKey(150)
# only trigger ocr reading if a stun is detected
points = vision_stun.get_click_points(rectangles)
if len(points) == 2:
pydirectinput.moveTo(points[0][0], points[0][1])
pydirectinput.mouseDown()
w = random.randint(1, 100)
cv.waitKey(250 + w)
pydirectinput.moveTo(points[1][0], points[1][1])
pydirectinput.mouseUp()
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
else:
break
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
needles_white = []
needles_white.append(cv.imread("magic/body_w.jpg", cv.IMREAD_UNCHANGED))
needles_white.append(cv.imread("magic/finding_w.jpg", cv.IMREAD_UNCHANGED))
needles_white.append(cv.imread("magic/mind_w.jpg", cv.IMREAD_UNCHANGED))
needles_white.append(cv.imread("magic/perceiving_w.jpg", cv.IMREAD_UNCHANGED))
needles_white.append(cv.imread("magic/physical_w.jpg", cv.IMREAD_UNCHANGED))
needles_white.append(cv.imread("magic/seeing_w.jpg", cv.IMREAD_UNCHANGED))
needles_white.append(cv.imread("magic/spiritual_w.jpg", cv.IMREAD_UNCHANGED))
for needle_w in needles_white:
# do object detection
screenshot = capture_window.get_screenshot()
processed_screenshot = vision_stun.apply_hsv_filter(screenshot,hsv_filter_w)
processed_needle = vision_stun.apply_hsv_filter(needle_w, hsv_filter_w)
rectangles = vision_stun.find(processed_screenshot, processed_needle, 0.7, 1)
# draw the detection results onto the original image
# output_image = vision_stun.draw_rectangles(screenshot, rectangles)
# cv.imshow("output_image", output_image)
# cv.waitKey(150)
points = vision_stun.get_click_points(rectangles)
if len(points) >= 1:
pydirectinput.moveTo(points[0][0], points[0][1])
pydirectinput.mouseDown()
w = random.randint(1, 100)
cv.waitKey(100 + w)
pydirectinput.mouseUp()
screenshot = capture_window.get_screenshot()
rectangles = vision_stun.find(screenshot, cv.imread("magic/collect.jpg", cv.IMREAD_UNCHANGED), 0.8, 1)
points = vision_stun.get_click_points(rectangles)
if len(points) >= 1:
pydirectinput.moveTo(points[0][0], points[0][1])
pydirectinput.mouseDown()
w = random.randint(1, 100)
cv.waitKey(100 + w)
pydirectinput.mouseUp()
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
# debug the loop rate
print('FPS {}'.format(1 / (time() - loop_time)))
loop_time = time()
cv.waitKey(150)
if __name__ == "__main__":
run()

77
config_file.py Normal file
View File

@@ -0,0 +1,77 @@
import os
# daoc chatwindow string:
# ChatWindow2=Wtf,1615,964,780,476,100,100,16,1,0,1
class UserConfigs:
THALOUSER = "Thaloria"
ADWAUSER = "Adwa"
EDDIEUSER = "Eddie"
user: str
def __init__(self):
user_from_env = os.environ.get('PYTHON_USER')
if user_from_env == self.THALOUSER:
self.user = self.THALOUSER
elif user_from_env == self.EDDIEUSER:
self.user = self.EDDIEUSER
else:
self.user = self.ADWAUSER
def returnStunWindowPos(self):
if self.user == self.THALOUSER:
#return [1410, 1128, 402, 22]
return [1800, 1150, 0, 0]
elif self.user == self.ADWAUSER:
return [740, 450, 1625, 985]
elif self.user == self.EDDIEUSER:
return [740, 450, 1625, 985]
else:
pass
def returnPoisonWindowPos(self):
if self.user == self.THALOUSER:
return [740, 442, 1625, 985]
elif self.user == self.ADWAUSER:
return [740, 442, 1625, 985]
elif self.user == self.EDDIEUSER:
return [740, 442, 1625, 985]
else:
pass
def returnPoisonOverlayPos(self):
if self.user == self.THALOUSER:
return '160x160+-900+760'
elif self.user == self.ADWAUSER:
return '160x160+-900+760'
elif self.user == self.EDDIEUSER:
return '160x160+-900+760'
else:
pass
def returnStunOverlayPos(self):
if self.user == self.THALOUSER:
return '160x160+-1360+350'
elif self.user == self.ADWAUSER:
return '160x160+-900+600'
elif self.user == self.EDDIEUSER:
return '160x160+-1360+350'
else:
pass
def returnEnemyPlayerOverlayPos(self):
if self.user == self.THALOUSER:
return '330x45+-900+920'
elif self.user == self.ADWAUSER:
return '160x160+-900+600'
elif self.user == self.EDDIEUSER:
return '330x45+-900+920'
else:
pass
def return_database_ip(self):
if self.user == self.THALOUSER:
return "192.168.178.201"
else:
return "thalo.ddns.net"

BIN
digging.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

164
digging_main.py Normal file
View File

@@ -0,0 +1,164 @@
import random
from time import time
from window_capture import WindowCapture
from stun_vision import StunVision
import cv2 as cv
import pytesseract
from hsvfilter import HsvFilter
from config_file import UserConfigs
#import pyautogui
import pydirectinput
import keyboard
from tresh_util import super_tresh_main, super_tresh_needle
def run():
# initialize the user-class
config = UserConfigs()
# initialize the StunWindowCapture class
try:
capture_window = WindowCapture(
None, "stun", config)
video_mode = False
except:
# StunWindowCapture.list_window_names()
#print("Game not running, switching to video mode")
#capture_window = cv.VideoCapture("snip_slam.mp4")
video_mode = True
# initialize the StunVision class
vision_stun = StunVision()
# initialize the StunOverlay class
hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0)
loop_time = time()
event_time = 0.0
pointstore = []
max_results = 0
pause = True
while True:
if keyboard.is_pressed('p') == True:
pause = True
print('q pressed')
elif keyboard.is_pressed('o') == True:
pause = False
print('o pressed')
if pause:
#cv.waitKey(500)
print("pausing")
continue
if video_mode:
break
else:
try:
# get an updated image of the game
screenshot = capture_window.get_screenshot()
# screenshot = cv.imread("buffbar.jpg")
except:
capture_window.release()
print("Game window not available - shutting down application")
break
#cv.imshow("screenshot", screenshot)
#cv.waitKey(150)
#continue
needles = []
needles.append(cv.imread("wtf.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("Brown0.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("1.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("2.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("3.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("4.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("H1.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("H2.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("H3.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("H4.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("D1.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("D2.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("D4.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("D5.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("D6.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("D7.jpg", cv.IMREAD_UNCHANGED))
for needle in needles:
# do object detection
screenshot = capture_window.get_screenshot()
rectangles = vision_stun.find(screenshot, needle, 0.7, 1)
# draw the detection results onto the original image
if len(rectangles) == 0:
continue
#output_image = vision_stun.draw_rectangles(screenshot, rectangles)
#cv.imshow("output_image", output_image)
#cv.waitKey(150)
# only trigger ocr reading if a stun is detected
points = vision_stun.get_click_points(rectangles)
for point in points:
# 46 + 1 * 30 1410 == 1815 - 405 return [1410, 1128, 402, 22]
# 44 + 1 * 30 1350 == 1790 - 440
# left_border = 402, 432
# right_border = 1812, 1782
# upper_border = 22, 50
# lower_border = 1150, 1120
size = rectangles[0][2] + 1
left = int(round(rectangles[0][0] / size, 0)) # 4
down = int(round(rectangles[0][1] / size, 0)) # 23
offset_left = config.returnStunWindowPos()[2]
offset_down = config.returnStunWindowPos()[3]
# 167 1055 start
# 3x47 left 26x right to 30
# 1x down 22x up to 24
# start 167, end 167 - (47 * 3), step -47
start_left = point[0] - (size * left)
start_up = point[1] - (size * down)
for f in range(start_up, start_up + (size * 24), size):
for i in range(start_left, start_left + (size * 30), size):
pydirectinput.moveTo(i + offset_left, f + offset_down)
pydirectinput.mouseDown()
w = random.randint(1, 100)
cv.waitKey(150 + w)
pydirectinput.mouseUp()
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
screenshot = capture_window.get_screenshot()
rectangles = vision_stun.find(screenshot, cv.imread("ok_button.jpg", cv.IMREAD_UNCHANGED), 0.8, 1)
# draw the detection results onto the original image
output_image = vision_stun.draw_rectangles(screenshot, rectangles)
if len(rectangles) == 1:
pointis = vision_stun.get_click_points(rectangles)
for pointi in pointis:
pydirectinput.moveTo(pointi[0] + offset_left, pointi[1] + offset_down)
pydirectinput.mouseDown()
w = random.randint(1, 100)
cv.waitKey(150 + w)
pydirectinput.mouseUp()
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
# debug the loop rate
print('FPS {}'.format(1 / (time() - loop_time)))
loop_time = time()
cv.waitKey(150)
if __name__ == "__main__":
run()

BIN
equip/bag_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
equip/bag_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
equip/bag_3_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
equip/bag_4_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
equip/bag_5_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
equip/bag_6_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
equip/bag_7_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
equip/book_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
equip/book_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
equip/book_3_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
equip/book_4_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
equip/book_5_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
equip/book_6_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
equip/book_7_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
equip/chest_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
equip/chest_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
equip/chest_3_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
equip/chest_4_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
equip/key_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
equip/key_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
equip/key_3_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
equip/key_4_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
equip/main_screen.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
equip/mush_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
equip/mush_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
equip/mush_3_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
equip/mush_4_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
equip/mush_5_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
equip/mush_6_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
equip/mush_7_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
equip/mush_8_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
equip/mush_e2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
equip/mush_e_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
equip/pot_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
equip/pot_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
equip/pot_3_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
equip/pot_4_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
equip/pot_5_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
equip/pot_6_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

225
equipment_main.py Normal file
View File

@@ -0,0 +1,225 @@
import random
from time import time
from window_capture import WindowCapture
from stun_vision import StunVision
import cv2 as cv
import pytesseract
from hsvfilter import HsvFilter
from config_file import UserConfigs
# import pyautogui
import pydirectinput
import keyboard
from tresh_util import super_tresh_main, super_tresh_needle
def run():
# initialize the user-class
config = UserConfigs()
# initialize the StunWindowCapture class
try:
capture_window = WindowCapture(
None, "stun", config)
video_mode = False
except:
# StunWindowCapture.list_window_names()
# print("Game not running, switching to video mode")
# capture_window = cv.VideoCapture("snip_slam.mp4")
video_mode = True
# initialize the StunVision class
vision_stun = StunVision()
# initialize the StunOverlay class
hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0)
loop_time = time()
event_time = 0.0
pointstore = []
max_results = 0
pause = True
while True:
if keyboard.is_pressed('p') == True:
pause = True
print('q pressed')
elif keyboard.is_pressed('o') == True:
pause = False
print('o pressed')
if pause:
# cv.waitKey(500)
print("pausing")
continue
if video_mode:
break
else:
try:
# get an updated image of the game
screenshot = capture_window.get_screenshot()
# screenshot = cv.imread("buffbar.jpg")
except:
capture_window.release()
print("Game window not available - shutting down application")
break
# cv.imshow("screenshot", screenshot)
# cv.waitKey(150)
# continue
spawn_1 = vision_stun.find(screenshot, cv.imread("equip/mush_e2_32.jpg", cv.IMREAD_UNCHANGED), 0.4, 1)
if len(spawn_1) == 1:
spawn_button_active = True
points = vision_stun.get_click_points(spawn_1)
for i in range(0, 15, 1):
pydirectinput.moveTo(points[0][0], points[0][1])
pydirectinput.mouseDown()
w = random.randint(1, 50)
cv.waitKey(30 + w)
pydirectinput.mouseUp()
if keyboard.is_pressed('p') == True:
pause = True
print('q pressed')
break
else:
spawn_0 = vision_stun.find(screenshot, cv.imread("equip/mush_e_32.jpg", cv.IMREAD_UNCHANGED), 0.7, 1)
points = vision_stun.get_click_points(spawn_0)
for point in points:
pydirectinput.moveTo(point[0], point[1])
pydirectinput.mouseDown()
cv.waitKey(500)
pydirectinput.mouseUp()
if keyboard.is_pressed('p') == True:
pause = True
print('q pressed')
break
continue
needles = []
needles.append(cv.imread("equip/chest_2_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/book_1_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/book_2_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/book_5_32.jpg", cv.IMREAD_UNCHANGED))
#needles.append(cv.imread("equip/key_1_32.jpg", cv.IMREAD_UNCHANGED))
#needles.append(cv.imread("equip/key_2_32.jpg", cv.IMREAD_UNCHANGED))
#needles.append(cv.imread("equip/key_3_32.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("equip/key_4_32.jpg", cv.IMREAD_UNCHANGED))
#needles.append(cv.imread("equip/chest_1_32.jpg", cv.IMREAD_UNCHANGED))
#needles.append(cv.imread("equip/chest_2_32.jpg", cv.IMREAD_UNCHANGED))
#needles.append(cv.imread("equip/chest_3_32.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("equip/chest_4_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/mush_1_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/mush_2_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/mush_3_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/mush_4_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/mush_5_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/mush_6_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/mush_7_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/mush_8_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/pot_1_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/pot_2_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/pot_3_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/pot_4_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/pot_5_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/pot_6_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/bag_1_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/bag_2_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/bag_3_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/bag_4_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/bag_5_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/bag_6_32.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("equip/bag_7_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/book_3_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/book_4_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/book_6_32.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("equip/book_7_32.jpg", cv.IMREAD_UNCHANGED))
hsv = []
hsv.append(HsvFilter(14, 0, 0, 179, 255, 255, 0, 0, 0, 0))
hsv.append(HsvFilter(0, 128, 0, 179, 255, 255, 0, 0, 0, 0))
hsv.append(HsvFilter(49, 0, 0, 179, 255, 255, 0, 0, 0, 0))
hsv.append(HsvFilter(0, 95, 137, 179, 255, 255, 0, 0, 0, 0))
for op in range(1, 50, 1):
hsv.append(HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0))
for rer in range(0, len(needles), 1):
while True:
# do object detection
screenshot = capture_window.get_screenshot()
processed_screenshot = vision_stun.apply_hsv_filter(screenshot, hsv[rer])
processed_needle = vision_stun.apply_hsv_filter(needles[rer], hsv[rer])
rectangles = vision_stun.find(processed_screenshot, processed_needle, 0.8, 5)
# draw the detection results onto the original image
#output_image = vision_stun.draw_rectangles(processed_screenshot, rectangles)
#cv.imshow("output_image", output_image)
#cv.waitKey(150)
if len(rectangles) is not 5:
break
if keyboard.is_pressed('p') == True:
pause = True
print('q pressed')
break
points = vision_stun.get_click_points(rectangles)
check_move(capture_window, vision_stun, [70, 70, rectangles[0][0] + 70, rectangles[0][1]], needles[rer],
hsv[rer],
points[1], [points[0][0] + 70, points[0][1]])
check_move(capture_window, vision_stun, [70, 70, rectangles[0][0], rectangles[0][1] + 70], needles[rer],
hsv[rer],
points[2], [points[0][0], points[0][1] + 70])
check_move(capture_window, vision_stun, [70, 70, rectangles[0][0] + 70, rectangles[0][1] + 70],
needles[rer], hsv[rer],
points[3], [points[0][0] + 70, points[0][1] + 70])
move(points[4], [points[0][0], points[0][1]])
if keyboard.is_pressed('p') == True:
pause = True
print('q pressed')
break
# debug the loop rate
print('FPS {}'.format(1 / (time() - loop_time)))
loop_time = time()
cv.waitKey(150)
def move(point_source, point_dest):
pydirectinput.moveTo(point_source[0], point_source[1])
pydirectinput.mouseDown()
w = random.randint(1, 100)
cv.waitKey(250 + w)
pydirectinput.moveTo(point_dest[0], point_dest[1])
pydirectinput.mouseUp()
cv.waitKey(250 + w)
if keyboard.is_pressed('p') == True:
pause = True
print('q pressed')
def check_move(capture_win, visio, rect, needl, hsv, point_source, point_dest):
screenshot_pos = capture_win.get_screenshot_by_area(rect)
processed_screenshot = visio.apply_hsv_filter(screenshot_pos, hsv)
processed_needle = visio.apply_hsv_filter(needl, hsv)
rectangles2 = visio.find(processed_screenshot, processed_needle, 0.7, 1)
# output_by_area = vision_stun.draw_rectangles(screenshot_pos2, rectangles)
# cv.imshow("output_image_by_area", output_by_area)
# cv.waitKey(150)
if len(rectangles2) == 1:
# pos 2 filled
return
else:
# pos 2 vacant
pass
move(point_source, point_dest)
if keyboard.is_pressed('p') == True:
pause = True
print('q pressed')
if __name__ == "__main__":
run()

53
hsv_main.py Normal file
View File

@@ -0,0 +1,53 @@
import cv2 as cv
import numpy as np
import os
from time import time
from window_capture import WindowCapture
from stun_vision import StunVision
from hsvfilter import HsvFilter
# Change the working directory to the folder this script is in.
# Doing this because I'll be putting the files from each video in their own folder on GitHub
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# initialize the WindowCapture class
wincap = WindowCapture('Albion Online Client')
# initialize the Vision class
vision_limestone = Vision('albion_limestone_processed.jpg')
# initialize the trackbar window
vision_limestone.init_control_gui()
# limestone HSV filter
hsv_filter = HsvFilter(0, 180, 129, 15, 229, 243, 143, 0, 67, 0)
loop_time = time()
while(True):
# get an updated image of the game
screenshot = wincap.get_screenshot()
# pre-process the image
processed_image = vision_limestone.apply_hsv_filter(screenshot, hsv_filter)
# do object detection
rectangles = vision_limestone.find(processed_image, 0.46)
# draw the detection results onto the original image
output_image = vision_limestone.draw_rectangles(screenshot, rectangles)
# display the processed image
cv.imshow('Processed', processed_image)
cv.imshow('Matches', output_image)
# debug the loop rate
print('FPS {}'.format(1 / (time() - loop_time)))
loop_time = time()
# press 'q' with the output window focused to exit.
# waits 1 ms every loop to process key presses
if cv.waitKey(1) == ord('q'):
cv.destroyAllWindows()
break
print('Done.')

16
hsvfilter.py Normal file
View File

@@ -0,0 +1,16 @@
# custom data structure to hold the state of an HSV filter
class HsvFilter:
def __init__(self, hMin=None, sMin=None, vMin=None, hMax=None, sMax=None, vMax=None,
sAdd=None, sSub=None, vAdd=None, vSub=None):
self.hMin = hMin
self.sMin = sMin
self.vMin = vMin
self.hMax = hMax
self.sMax = sMax
self.vMax = vMax
self.sAdd = sAdd
self.sSub = sSub
self.vAdd = vAdd
self.vSub = vSub

BIN
magic/body_0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
magic/body_b.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
magic/body_g.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
magic/body_orange.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
magic/body_p.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
magic/body_w.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
magic/body_y.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
magic/collect.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
magic/finding_0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
magic/finding_b.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
magic/finding_g.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
magic/finding_orange.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
magic/finding_p.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
magic/finding_w.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
magic/finding_y.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
magic/mind_0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
magic/mind_b.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
magic/mind_g.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
magic/mind_orange.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
magic/mind_p.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
magic/mind_w.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
magic/mind_y.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
magic/perceiving_0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
magic/perceiving_b.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
magic/perceiving_g.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
magic/perceiving_orange.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
magic/perceiving_p.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
magic/perceiving_w.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
magic/perceiving_y.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
magic/physical_0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
magic/physical_b.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
magic/physical_g.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
magic/physical_orange.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
magic/physical_p.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Some files were not shown because too many files have changed in this diff Show More