84 lines
2.5 KiB
Python
84 lines
2.5 KiB
Python
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')
|