Initial Commit

This commit is contained in:
2023-04-14 11:31:20 -04:00
commit 7d24e5628c
19 changed files with 225 additions and 0 deletions

View File

@@ -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)

View File

@@ -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')

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

BIN
Images/fishing.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
Images/fullinv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

BIN
Images/invscreen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
Images/notfishing.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
Images/shrimp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
Images/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

0
README.md Normal file
View File

32
Testing file.py Normal file
View File

@@ -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()

83
fishing.py Normal file
View File

@@ -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')

8
main.py Normal file
View File

@@ -0,0 +1,8 @@
import pyautogui
import random
###Try locating depending on color instead, doing specific images doesn't seem to work.

13
mouseLocation.py Normal file
View File

@@ -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')