Add humanReaction
This commit is contained in:
parent
0b8d761a37
commit
154bdbbd9f
|
|
@ -6,6 +6,7 @@ import cv2 as cv
|
||||||
import pyautogui
|
import pyautogui
|
||||||
from core.Logger import Logger
|
from core.Logger import Logger
|
||||||
from core.Player import PLAYER_STATE
|
from core.Player import PLAYER_STATE
|
||||||
|
from core.utils import addHumanReaction
|
||||||
|
|
||||||
class FishingAgent:
|
class FishingAgent:
|
||||||
def __init__(self, monitor, player) -> None:
|
def __init__(self, monitor, player) -> None:
|
||||||
|
|
@ -58,24 +59,24 @@ class FishingAgent:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.findLure()
|
self.findLure()
|
||||||
else:
|
else:
|
||||||
time.sleep(0.5)
|
addHumanReaction()
|
||||||
pyautogui.moveTo(res[0], res[1])
|
pyautogui.moveTo(res[0], res[1])
|
||||||
self.watchLure()
|
self.watchLure()
|
||||||
|
|
||||||
def watchLure(self):
|
def watchLure(self):
|
||||||
self.retry = 0
|
self.retry = 0
|
||||||
self.logger.log("Waiting for fish...")
|
self.logger.log("Waiting for fish...")
|
||||||
time.sleep(0.4)
|
addHumanReaction()
|
||||||
res = self.monitor.findMatch(self.fishingBobberImg)
|
res = self.monitor.findMatch(self.fishingBobberImg)
|
||||||
if (res != -1):
|
if (res != -1):
|
||||||
self.lureLoc = res
|
self.lureLoc = res
|
||||||
while True:
|
while True:
|
||||||
self.retry += 1
|
self.retry += 1
|
||||||
time.sleep(0.1)
|
addHumanReaction()
|
||||||
res = self.monitor.findMatch(self.fishingBobberImg)
|
res = self.monitor.findMatch(self.fishingBobberImg)
|
||||||
print(res)
|
print(res)
|
||||||
if (res == -1 or abs(res[1] - self.lureLoc[1]) > 20):
|
if (res == -1 or abs(res[1] - self.lureLoc[1]) > 20):
|
||||||
time.sleep(0.2)
|
addHumanReaction()
|
||||||
pyautogui.click()
|
pyautogui.click()
|
||||||
return
|
return
|
||||||
elif (self.retry > 150):
|
elif (self.retry > 150):
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import pyautogui
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
from core.Logger import Logger
|
from core.Logger import Logger
|
||||||
|
from core.utils import addHumanReaction
|
||||||
|
|
||||||
FPS_REPORT_DELAY = 3
|
FPS_REPORT_DELAY = 3
|
||||||
|
|
||||||
|
|
@ -79,21 +80,21 @@ class Monitor:
|
||||||
point = self.findMatch(template, method)
|
point = self.findMatch(template, method)
|
||||||
if (point == -1):
|
if (point == -1):
|
||||||
return -1
|
return -1
|
||||||
time.sleep(0.2)
|
addHumanReaction()
|
||||||
pyautogui.moveTo(point[0], point[1])
|
pyautogui.moveTo(point[0], point[1])
|
||||||
time.sleep(0.15)
|
addHumanReaction()
|
||||||
|
|
||||||
def findMatchAndClickIfAvailable(self, template, onFound = None, onNotFound = None):
|
def findMatchAndClickIfAvailable(self, template, onFound = None, onNotFound = None):
|
||||||
res = self.findMatchAndMoveToPosition(template)
|
res = self.findMatchAndMoveToPosition(template)
|
||||||
|
|
||||||
if (res == -1):
|
if (res == -1):
|
||||||
time.sleep(0.3)
|
addHumanReaction()
|
||||||
if isfunction(onNotFound) is True:
|
if isfunction(onNotFound) is True:
|
||||||
return onNotFound(res)
|
return onNotFound(res)
|
||||||
else:
|
else:
|
||||||
time.sleep(0.1)
|
addHumanReaction()
|
||||||
pyautogui.click()
|
pyautogui.click()
|
||||||
time.sleep(0.15)
|
addHumanReaction()
|
||||||
if (isfunction(onFound) is True):
|
if (isfunction(onFound) is True):
|
||||||
return onFound(res)
|
return onFound(res)
|
||||||
|
|
||||||
|
|
|
||||||
6
core/utils.py
Normal file
6
core/utils.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import time
|
||||||
|
import random
|
||||||
|
|
||||||
|
def addHumanReaction():
|
||||||
|
delay = random.uniform(0.1, 0.4)
|
||||||
|
time.sleep(delay)
|
||||||
Loading…
Reference in New Issue
Block a user