Untitled
unknown
plain_text
a month ago
3.3 kB
7
Indexable
import pytesseract import pyautogui import pydirectinput import keyboard import time import re from PIL import Image import datetime # Tesseract install path pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe' # Coordinates for trunk / inventory region TRUNK_X = 2000 TRUNK_Y = 100 TRUNK_W = 800 TRUNK_H = 500 FISH_NAMES = ["trout", "catfish", "bass", "rainbow trout"] def get_fishing_prompt_key(screenshot): """ Looks for "Press X to reel in your catch". e.g. matches letter -> "to reel i[mn]" """ text = pytesseract.image_to_string(screenshot).lower() match = re.search(r'([a-z])[^a-z]{0,3}to reel i[mn]', text) if match: return match.group(1) return None def check_trunk_for_fish(): trunk_screenshot = pyautogui.screenshot(region=(TRUNK_X, TRUNK_Y, TRUNK_W, TRUNK_H)) trunk_text = pytesseract.image_to_string(trunk_screenshot).lower() lines = [line.strip() for line in trunk_text.split('\n') if line.strip()] # 1) Find the index of "heavy pistol" hp_index = None for i, txt in enumerate(lines): if "heavy pistol" in txt: hp_index = i break # 2) Skip everything up to + including "heavy pistol" # so the next item after heavy pistol is now lines[0]. if hp_index is not None: lines = lines[hp_index + 1:] # Now lines[0] is physically just below "heavy pistol", # but we WANT it to be "line 1" to match in-game indexing. for i, line in enumerate(lines): for fish in FISH_NAMES: if fish in line: # Our code "labels" this as i, but in the game we want i+1 # because the line *under* heavy pistol is effectively line 1 real_line = i + 1 print(f"Found {fish} in trunk on line {real_line}...") # Press DOWN real_line times for _ in range(real_line): pydirectinput.press('down') time.sleep(0.05) # Press ENTER twice pydirectinput.press('enter') time.sleep(0.05) pydirectinput.press('enter') time.sleep(0.05) def main(): print("Auto fishing prompt watcher started. Press ESC to stop.") while True: # Check for ESC to exit if keyboard.is_pressed('esc'): print("Stopped.") break # 1) Check for fishing prompt at bottom center screen_width, screen_height = pyautogui.size() prompt_region = (screen_width // 2 - 200, screen_height - 100, 400, 100) screenshot = pyautogui.screenshot(region=prompt_region) key = get_fishing_prompt_key(screenshot) if key: print(f"Detected fishing prompt key: {key}") # Use pydirectinput for hooking that key press too: pydirectinput.press(key) # Delay to simulate holding or allow game to process time.sleep(1.5) # 2) Check trunk for fish check_trunk_for_fish() # Small delay so we don’t OCR too frequently time.sleep(0.5) if __name__ == "__main__": main()
Editor is loading...
Leave a Comment