Fix fishing agent

This commit is contained in:
srose 2024-09-12 10:05:08 -04:00
parent db5b3a521c
commit 3fffad6a99

View File

@ -25,7 +25,8 @@ class FishingAgent:
def castLure(self):
self.retry = 0
pyautogui.moveTo(2,3)
self.lureLoc = None
pyautogui.moveTo(50,50)
self.logger.log("Casting Lure.")
res = self.monitor.findMatchAndMoveToPosition(self.fishingIconImg)
if (res == -1):
@ -39,6 +40,7 @@ class FishingAgent:
self.logger.log("Moving cursor to Lure.")
time.sleep(2)
res = self.monitor.findMatch(self.fishingBobberImg)
if (res == -1):
if (self.retry > 4):
self.logger.log("Took too to find lure long, retrying fishing from the beginning")
@ -48,9 +50,9 @@ class FishingAgent:
self.retry += 1
time.sleep(1)
self.findLure()
time.sleep(0.5)
self.lureLoc = res
time.sleep(0.2)
pyautogui.moveTo(res[0], res[1])
pyautogui.moveTo(self.lureLoc[0], self.lureLoc[1])
self.watchLure()
def watchLure(self):
@ -60,12 +62,15 @@ class FishingAgent:
self.retry += 1
time.sleep(0.1)
res = self.monitor.findMatch(self.fishingBobberImg)
print(self.lureLoc)
print(res)
if (res != -1 and abs(res[1] - self.lureLoc[1]) > 20):
time.sleep(0.2)
pyautogui.click()
time.sleep(0.5)
return
elif (self.retry > 200):
self.retry = 0
return
def run(self):