commit 7d24e5628c5cd2a1e74de64c99b540a156d86448 Author: jerick Date: Fri Apr 14 11:31:20 2023 -0400 Initial Commit diff --git a/##More Basic testing for fishing.py b/##More Basic testing for fishing.py new file mode 100644 index 0000000..d49a0d4 --- /dev/null +++ b/##More Basic testing for fishing.py @@ -0,0 +1,54 @@ +##More Basic testing for fishing +import pyautogui as pag +from random import randint, uniform +import cv2 +import numpy +import math +import time +import sys + +class FishBot(object): + def __init__(self): + pass + + def random_coordinate(self, location): + #Moves cursor to random locaction still above the object to be clicked + x = randint(location[0], location[0]+location[2]) + y = randint(location[1], location[1]+location[3]) + time = self.travel_time(x, y) + + return pag.moveTo(x, y, time) + + + def fishLoop(self): + #check if inventory is full + pag.screenshot('Images/shrimp.png', region=(1575, 1689, 305, 411)) + screen = cv2.imread('Images/shrimp.png') + template = cv2.imread('Images/fullinv.png') + res = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED) + threshold = .80 + loc = numpy.where(res >= threshold) + if len(loc[0]) > 0: + invResult = True + + else: + invResult = False + #Move to Random Coordinate where shrimps are + ##need to add some variance, misses clicks, doesn't move in a + ###straight line too fast + #Shrimp location + location1 = (580, 1954, 60, 60) + + #Now add a little variance to the x and y coordinates + ##The location is in a tuple, these are immutable so it must be converted into a list to be changed + ###Then converted back + locationList = list(location1) + modifiedx = randint(0,35) + modifiedy = randint(0,35) + locationList[0] = locationList[0] + modifiedx + print (locationList) + locationList[1] = locationList[1] + modifiedy + modifiedLocation = tuple(locationList) + pag.moveTo(modifiedLocation, 2) + pag.click() + self.random_wait(0.05, 0.1) \ No newline at end of file diff --git a/#Image Recognition Testing.py b/#Image Recognition Testing.py new file mode 100644 index 0000000..480d115 --- /dev/null +++ b/#Image Recognition Testing.py @@ -0,0 +1,35 @@ +import cv2 +import numpy as np +import pyautogui as pag + +##Inventory Count + +# Take a screenshot and store it in a numpy array +screenshot = np.array(pag.screenshot(region = (0, 1079, 1920, 1080))) + +screenshot = cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY) + +# Load the image to be searched for in grayscale +image_to_search = cv2.imread('Images/shrimp.png', 0) + +# Get the dimensions of the image to be searched for +h, w = image_to_search.shape[::-1] + +# Use cv2.matchTemplate() to find the template image within the screenshot +result = cv2.matchTemplate(screenshot, image_to_search, cv2.TM_CCOEFF_NORMED) + +# Set a threshold value to count only those template images that have a high enough correlation +threshold = 0.9 +counter = 0 + +loc = np.where(result >= threshold) +for pt in zip(*loc[::-1]): + cv2.rectangle(screenshot, pt, (pt[0] + w, pt[1] + h), (0, 0, 255), 2) + counter += 1 + +print(counter) + +if counter == 27: + print('Inventory full, time to drop') +else: + print('Inventory not full, keep fishing') \ No newline at end of file diff --git a/.screenshot2023-0407_13-49-35-134001.png b/.screenshot2023-0407_13-49-35-134001.png new file mode 100644 index 0000000..e38d9d4 Binary files /dev/null and b/.screenshot2023-0407_13-49-35-134001.png differ diff --git a/.screenshot2023-0407_13-53-50-554837.png b/.screenshot2023-0407_13-53-50-554837.png new file mode 100644 index 0000000..8ed96a1 Binary files /dev/null and b/.screenshot2023-0407_13-53-50-554837.png differ diff --git a/.screenshot2023-0407_20-17-36-473071.png b/.screenshot2023-0407_20-17-36-473071.png new file mode 100644 index 0000000..0fa9691 Binary files /dev/null and b/.screenshot2023-0407_20-17-36-473071.png differ diff --git a/.screenshot2023-0413_16-20-18-185931.png b/.screenshot2023-0413_16-20-18-185931.png new file mode 100644 index 0000000..06a3e9e Binary files /dev/null and b/.screenshot2023-0413_16-20-18-185931.png differ diff --git a/.screenshot2023-0413_20-36-51-424621.png b/.screenshot2023-0413_20-36-51-424621.png new file mode 100644 index 0000000..ec02b30 Binary files /dev/null and b/.screenshot2023-0413_20-36-51-424621.png differ diff --git a/.screenshot2023-0413_20-36-56-591189.png b/.screenshot2023-0413_20-36-56-591189.png new file mode 100644 index 0000000..9343f30 Binary files /dev/null and b/.screenshot2023-0413_20-36-56-591189.png differ diff --git a/Images/fishing.png b/Images/fishing.png new file mode 100644 index 0000000..e22aa10 Binary files /dev/null and b/Images/fishing.png differ diff --git a/Images/fullinv.png b/Images/fullinv.png new file mode 100644 index 0000000..360c159 Binary files /dev/null and b/Images/fullinv.png differ diff --git a/Images/invscreen.png b/Images/invscreen.png new file mode 100644 index 0000000..e8c9b1c Binary files /dev/null and b/Images/invscreen.png differ diff --git a/Images/notfishing.png b/Images/notfishing.png new file mode 100644 index 0000000..186ebdb Binary files /dev/null and b/Images/notfishing.png differ diff --git a/Images/shrimp.png b/Images/shrimp.png new file mode 100644 index 0000000..91ed1fe Binary files /dev/null and b/Images/shrimp.png differ diff --git a/Images/test.png b/Images/test.png new file mode 100644 index 0000000..619631d Binary files /dev/null and b/Images/test.png differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Testing file.py b/Testing file.py new file mode 100644 index 0000000..36e35f9 --- /dev/null +++ b/Testing file.py @@ -0,0 +1,32 @@ +##Testing file +import pyautogui as pag +from random import randint, uniform +import cv2 +import numpy +import math +import time +import sys + +#Build a list of acceptable x and y locations and pass them to the moveto function +##how to do this without having to pass a sequence, because for some reason the library does not like them + +location1x = 580 +location1y = 1954 + +#Now add a little variance to the x and y coordinates +modifiedx = randint(0,35) + location1x +modifiedy = randint(0,35) + location1y + +#Also add the chance to misclick +misclick = randint(0,10) + +#20% Chance to misclick +if misclick <= 2: + location1x = location1x + 50 + location1y = location1y + 50 + print('Misclick calculated') +else: + print('Clicking Normally') + +pag.moveTo(location1x, location1y, 0.70) +pag.click() diff --git a/fishing.py b/fishing.py new file mode 100644 index 0000000..4a6c754 --- /dev/null +++ b/fishing.py @@ -0,0 +1,83 @@ +import pyautogui as pag +from random import randint, uniform +import cv2 +import numpy as np +import math +import time +import sys + +#For Fishing +##https://zaxrosenberg.com/how-to-write-a-runescape-autoclicker-with-python-part-ii/ + +def inventoryCount(): + + ##Inventory Count + + # Take a screenshot and store it in a numpy array + screenshot = np.array(pag.screenshot(region = (0, 1079, 1920, 1080))) + + screenshot = cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY) + + # Load the image to be searched for in grayscale + image_to_search = cv2.imread('Images/shrimp.png', 0) + + # Get the dimensions of the image to be searched for + h, w = image_to_search.shape[::-1] + + # Use cv2.matchTemplate() to find the template image within the screenshot + result = cv2.matchTemplate(screenshot, image_to_search, cv2.TM_CCOEFF_NORMED) + + # Set a threshold value to count only those template images that have a high enough correlation + threshold = 0.9 + counter = 0 + + loc = np.where(result >= threshold) + for pt in zip(*loc[::-1]): + cv2.rectangle(screenshot, pt, (pt[0] + w, pt[1] + h), (0, 0, 255), 2) + counter += 1 + + print(counter) + + if counter == 27: + print('Inventory full, time to drop') + else: + print('Inventory not full, keep fishing') + +#Function to check if we are currently fishing +def checkIfFishing(): + # Take a screenshot and store it in a numpy array + screenshot = np.array(pag.screenshot(region = (0, 1079, 1920, 1080))) + + screenshot = cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY) + + # Load the image to be searched for in grayscale + image_to_search = cv2.imread('Images/fishing.png', 0) + + # Get the dimensions of the image to be searched for + h, w = image_to_search.shape[::-1] + + # Use cv2.matchTemplate() to find the template image within the screenshot + #This checks if the green Fishing icon is being displayed in the top left + result = cv2.matchTemplate(screenshot, image_to_search, cv2.TM_CCOEFF_NORMED) + + # Set a threshold value to count only those template images that have a high enough correlation + threshold = 0.8 + #Assume we are not fishing until proven otherwise + Fishing = False + + + loc = np.where(result >= threshold) + for pt in zip(*loc[::-1]): + cv2.rectangle(screenshot, pt, (pt[0] + w, pt[1] + h), (0, 0, 255), 2) + Fishing = True + + print(Fishing) + + if Fishing: + print('Currently Fishing') + else: + print('Not Fishing') + +#Function for finding the fishing spots +def fishingSpots(): + print('Searching for fishing spot') diff --git a/main.py b/main.py new file mode 100644 index 0000000..86ecca1 --- /dev/null +++ b/main.py @@ -0,0 +1,8 @@ +import pyautogui +import random + +###Try locating depending on color instead, doing specific images doesn't seem to work. + + + + diff --git a/mouseLocation.py b/mouseLocation.py new file mode 100644 index 0000000..c2e09fc --- /dev/null +++ b/mouseLocation.py @@ -0,0 +1,13 @@ +#! python3 + +#This displays the location of the mouse in a loop +import pyautogui, sys +print('Press Ctrl-C to quit.') +try: + while True: + x, y = pyautogui.position() + positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4) + print(positionStr, end='') + print('\b' * len(positionStr), end='', flush=True) +except KeyboardInterrupt: + print('\n') \ No newline at end of file