From 154bdbbd9ff9760bfc4b99ae5e9327ec876d7e54 Mon Sep 17 00:00:00 2001 From: srose Date: Thu, 10 Oct 2024 20:29:15 -0400 Subject: [PATCH] Add humanReaction --- bots/fishing/FishingAgent.py | 9 +++++---- core/Monitor.py | 11 ++++++----- core/utils.py | 6 ++++++ 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 core/utils.py diff --git a/bots/fishing/FishingAgent.py b/bots/fishing/FishingAgent.py index 8c8307c..12a547e 100644 --- a/bots/fishing/FishingAgent.py +++ b/bots/fishing/FishingAgent.py @@ -6,6 +6,7 @@ import cv2 as cv import pyautogui from core.Logger import Logger from core.Player import PLAYER_STATE +from core.utils import addHumanReaction class FishingAgent: def __init__(self, monitor, player) -> None: @@ -58,24 +59,24 @@ class FishingAgent: time.sleep(1) self.findLure() else: - time.sleep(0.5) + addHumanReaction() pyautogui.moveTo(res[0], res[1]) self.watchLure() def watchLure(self): self.retry = 0 self.logger.log("Waiting for fish...") - time.sleep(0.4) + addHumanReaction() res = self.monitor.findMatch(self.fishingBobberImg) if (res != -1): self.lureLoc = res while True: self.retry += 1 - time.sleep(0.1) + addHumanReaction() res = self.monitor.findMatch(self.fishingBobberImg) print(res) if (res == -1 or abs(res[1] - self.lureLoc[1]) > 20): - time.sleep(0.2) + addHumanReaction() pyautogui.click() return elif (self.retry > 150): diff --git a/core/Monitor.py b/core/Monitor.py index e8db162..e63e7b4 100644 --- a/core/Monitor.py +++ b/core/Monitor.py @@ -6,6 +6,7 @@ import pyautogui import numpy as np import cv2 as cv from core.Logger import Logger +from core.utils import addHumanReaction FPS_REPORT_DELAY = 3 @@ -79,21 +80,21 @@ class Monitor: point = self.findMatch(template, method) if (point == -1): return -1 - time.sleep(0.2) + addHumanReaction() pyautogui.moveTo(point[0], point[1]) - time.sleep(0.15) + addHumanReaction() def findMatchAndClickIfAvailable(self, template, onFound = None, onNotFound = None): res = self.findMatchAndMoveToPosition(template) if (res == -1): - time.sleep(0.3) + addHumanReaction() if isfunction(onNotFound) is True: return onNotFound(res) else: - time.sleep(0.1) + addHumanReaction() pyautogui.click() - time.sleep(0.15) + addHumanReaction() if (isfunction(onFound) is True): return onFound(res) diff --git a/core/utils.py b/core/utils.py new file mode 100644 index 0000000..fd5b9aa --- /dev/null +++ b/core/utils.py @@ -0,0 +1,6 @@ +import time +import random + +def addHumanReaction(): + delay = random.uniform(0.1, 0.4) + time.sleep(delay)