diff --git a/assets/fishing/bobbers/Bobber2.jpg b/assets/fishing/bobbers/Bobber2.jpg index 9bc9534..3359de5 100644 Binary files a/assets/fishing/bobbers/Bobber2.jpg and b/assets/fishing/bobbers/Bobber2.jpg differ diff --git a/assets/icons/Deserter.jpg b/assets/icons/Deserter.jpg new file mode 100644 index 0000000..b64bd76 Binary files /dev/null and b/assets/icons/Deserter.jpg differ diff --git a/assets/icons/WaitingForBg.jpg b/assets/icons/WaitingForBg.jpg new file mode 100644 index 0000000..17dd276 Binary files /dev/null and b/assets/icons/WaitingForBg.jpg differ diff --git a/assets/labels/AlteracValleyLabel.jpg b/assets/labels/AlteracValleyLabel.jpg new file mode 100644 index 0000000..17401a9 Binary files /dev/null and b/assets/labels/AlteracValleyLabel.jpg differ diff --git a/assets/menus/EnterBgButton.jpg b/assets/menus/EnterBgButton.jpg new file mode 100644 index 0000000..d4abde4 Binary files /dev/null and b/assets/menus/EnterBgButton.jpg differ diff --git a/assets/menus/JoinBGWindow.jpg b/assets/menus/JoinBGWindow.jpg new file mode 100644 index 0000000..8e1a8e6 Binary files /dev/null and b/assets/menus/JoinBGWindow.jpg differ diff --git a/assets/menus/JoinBattleButton.jpg b/assets/menus/JoinBattleButton.jpg new file mode 100644 index 0000000..e22f687 Binary files /dev/null and b/assets/menus/JoinBattleButton.jpg differ diff --git a/assets/menus/LeaveMatchButton.jpg b/assets/menus/LeaveMatchButton.jpg new file mode 100644 index 0000000..4922e4f Binary files /dev/null and b/assets/menus/LeaveMatchButton.jpg differ diff --git a/assets/menus/PlayerVsPlayerTab.jpg b/assets/menus/PlayerVsPlayerTab.jpg new file mode 100644 index 0000000..1643209 Binary files /dev/null and b/assets/menus/PlayerVsPlayerTab.jpg differ diff --git a/assets/menus/RandomEpicBGButton.jpg b/assets/menus/RandomEpicBGButton.jpg new file mode 100644 index 0000000..86111dd Binary files /dev/null and b/assets/menus/RandomEpicBGButton.jpg differ diff --git a/assets/screenshot.jpg b/assets/screenshot.jpg index da7c838..e75b8a3 100644 Binary files a/assets/screenshot.jpg and b/assets/screenshot.jpg differ diff --git a/bots/battleground/battlegroundAgent.py b/bots/battleground/battlegroundAgent.py new file mode 100644 index 0000000..6d0c75f --- /dev/null +++ b/bots/battleground/battlegroundAgent.py @@ -0,0 +1,111 @@ +from threading import Thread +from enum import Enum +import time +import cv2 as cv +import pyautogui +from core.Logger import Logger +from core.Player import PLAYER_STATE + +BG_STATUS = Enum('BG_STATUS', ['IDLE', 'IN_QUEUE', 'IN_BG', 'LOADING']) + +class BattlegroundAgent: + def __init__(self, monitor, player) -> None: + self.battlegroundThread = None + self.logger = Logger("Battleground Agent") + self.groupFinderIcon = cv.imread("assets/icons/GroupFinder.jpg", cv.IMREAD_GRAYSCALE) + self.pvpTab = cv.imread("assets/menus/PlayerVsPlayerTab.jpg", cv.IMREAD_GRAYSCALE) + self.randomEpicBgButton = cv.imread("assets/menus/RandomEpicBGButton.jpg", cv.IMREAD_GRAYSCALE) + self.joinBattleButton = cv.imread("assets/menus/JoinBattleButton.jpg", cv.IMREAD_GRAYSCALE) + self.deserterIcon = cv.imread("assets/icons/Deserter.jpg", cv.IMREAD_GRAYSCALE) + self.joinBgWindow = cv.imread("assets/menus/JoinBGWindow.jpg", cv.IMREAD_GRAYSCALE) + self.enterBgButton = cv.imread("assets/menus/EnterBgButton.jpg", cv.IMREAD_GRAYSCALE) + self.leaveBgButton = cv.imread("assets/menus/LeaveMatchButton.jpg", cv.IMREAD_GRAYSCALE) + self.status = BG_STATUS.IDLE + self.monitor = monitor + self.player = player + + def startBGFarming(self): + pyautogui.press("esc") + self.player.checkConnection() + while self.player.state is PLAYER_STATE.BG_FARMING: + self.status = BG_STATUS.IDLE + if (self.isDeserter() is False): + self.tagInBg() + else: + self.logger.log("Deserter debuff found, waiting for debuff to disapear before tagging to bg...") + # self.inBgRoutine() + time.sleep(3) + + def isDeserter(self): + res = self.monitor.findMatch(self.deserterIcon) + if (res == -1): + return False + return True + + def tagInBg(self): + pyautogui.moveTo(50,50) + self.logger.log("Tagging in random epic bg...") + time.sleep(0.2) + self.monitor.findMatchAndMoveToPosition(self.groupFinderIcon) + pyautogui.click() + time.sleep(0.2) + self.monitor.findMatchAndMoveToPosition(self.pvpTab) + pyautogui.click() + time.sleep(0.2) + self.monitor.findMatchAndMoveToPosition(self.randomEpicBgButton) + pyautogui.click() + time.sleep(0.2) + self.monitor.findMatchAndMoveToPosition(self.joinBattleButton) + pyautogui.click() + self.status = BG_STATUS.IN_QUEUE + self.waitForBg() + + def waitForBg(self): + self.logger.log("Waiting for bg to start...") + while self.status == BG_STATUS.IN_QUEUE: + res = self.monitor.findMatch(self.joinBgWindow) + if (res != -1): + self.logger.log("Bg started joining the game...") + time.sleep(0.2) + self.monitor.findMatchAndMoveToPosition(self.enterBgButton) + pyautogui.click() + self.status = BG_STATUS.LOADING + time.sleep(1) + self.inBgRoutine() + + + def checkEndOfBg(self): + res = self.monitor.findMatch(self.leaveBgButton) + if (res != -1): + self.logger.log("End of bg detected, leaving...") + time.sleep(0.2) + pyautogui.move(res[0], res[1]) + time.sleep(0.3) + self.status = BG_STATUS.IDLE + pyautogui.click() + time.sleep(10) + + def inBgRoutine(self): + self.logger.log("BG in progress...") + self.status = BG_STATUS.IN_BG + while self.status == BG_STATUS.IN_BG: + pyautogui.keyDown("up") + self.checkEndOfBg() + time.sleep(0.1) + + + + def run(self): + self.logger.log("Starting battlegroung thread in 3 seconds...") + time.sleep(1) + self.logger.log("Starting battlegroung thread in 2 seconds...") + time.sleep(1) + self.logger.log("Starting battlegroung thread in 1 seconds...") + time.sleep(1) + + self.battlegroundThread = Thread( + target=self.startBGFarming, + args=(), + name="battleground thread", + daemon=True) + self.battlegroundThread.start() \ No newline at end of file diff --git a/bots/fishing/FishingAgent.py b/bots/fishing/FishingAgent.py index b5ebdc3..f373c5a 100644 --- a/bots/fishing/FishingAgent.py +++ b/bots/fishing/FishingAgent.py @@ -13,8 +13,8 @@ class FishingAgent: self.fishingIconImg = cv.imread("assets/fishing/FishIcon.jpg", cv.IMREAD_GRAYSCALE) self.fishingThread = None self.logger = Logger("Fishing Agent") - self.monitor = monitor self.lureLoc = None + self.monitor = monitor self.player = player self.fail = 0 self.retry = 0 @@ -52,32 +52,33 @@ class FishingAgent: if (self.retry > 4): self.fail += 1 self.logger.log("Took too long to find lure, retrying fishing from the beginning") - return else: self.logger.log("Trying again in 1 second...") self.retry += 1 time.sleep(1) self.findLure() - time.sleep(0.5) - self.lureLoc = res - pyautogui.moveTo(self.lureLoc[0], self.lureLoc[1]) - self.watchLure() + else: + time.sleep(0.5) + pyautogui.moveTo(res[0], res[1]) + self.watchLure() def watchLure(self): self.retry = 0 self.logger.log("Waiting for fish...") + time.sleep(0.4) + res = self.monitor.findMatch(self.fishingBobberImg) + if (res != -1): + self.lureLoc = res while True: 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]) > 10): + if (res == -1 or abs(res[1] - self.lureLoc[1]) > 20): time.sleep(0.2) pyautogui.click() - time.sleep(0.5) return - elif (self.retry > 200): + elif (self.retry > 150): self.retry = 0 self.fail += 1 return diff --git a/bots/idling/IdlingAgent.py b/bots/idling/IdlingAgent.py index 882e610..5fc6cdf 100644 --- a/bots/idling/IdlingAgent.py +++ b/bots/idling/IdlingAgent.py @@ -13,9 +13,9 @@ class IdlingAgent: self.monitor = monitor def checkIdleTime(self): - while self.player.state is PLAYER_STATE.IDLE: + while self.player.state in (PLAYER_STATE.IDLE, PLAYER_STATE.BG_FARMING): elapsedTime = time.time() - self.idleTime - if (elapsedTime > 10): + if (elapsedTime > 60): self.logger.log("Jumping to avoid being afk...") pyautogui.press("space") self.idleTime = time.time() diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..747c412 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,9 @@ +pyinstaller --clean -y -n "wowxel" --add-data="assets;assets" --add-data="config.json;." main.py; +cd dist/wowxel/; +mv ./_internal/assets .; +mv ./_internal/config.json .; +cd ..; +rm ./wowxel.zip; +Compress-Archive -Path ./wowxel -DestinationPath ./wowxel.zip; +explorer .; +cd ..; \ No newline at end of file diff --git a/core/MainAgent.py b/core/MainAgent.py index d396805..90ce1c6 100644 --- a/core/MainAgent.py +++ b/core/MainAgent.py @@ -1,4 +1,5 @@ from core.Monitor import Monitor +from bots.battleground.battlegroundAgent import BattlegroundAgent from bots.fishing.FishingAgent import FishingAgent from bots.idling.IdlingAgent import IdlingAgent from core.Player import Player, PLAYER_STATE @@ -9,6 +10,7 @@ class MainAgent: self.playerAgent = Player(self.monitor) self.idlingBot = IdlingAgent(self.monitor, self.playerAgent) self.fishingBot = FishingAgent(self.monitor, self.playerAgent) + self.bgFarming = BattlegroundAgent(self.monitor, self.playerAgent) self.monitor.startScreenCaptureThread() # Start idling agent at the construction of the mainAgent for now self.idlingBot.run() @@ -17,4 +19,6 @@ class MainAgent: self.playerAgent.changeState(PLAYER_STATE.FISHING) self.fishingBot.run() - + def startBgBot(self): + self.playerAgent.changeState(PLAYER_STATE.BG_FARMING) + self.bgFarming.run() diff --git a/core/Monitor.py b/core/Monitor.py index 20b5810..aa56b47 100644 --- a/core/Monitor.py +++ b/core/Monitor.py @@ -56,7 +56,7 @@ class Monitor: matchRatio = max_val * 100 self.logger.log(matchRatio) - if (matchRatio < 60): + if (matchRatio < 50): self.logger.log("Cannot find matching result...") return -1 diff --git a/core/Player.py b/core/Player.py index 4babfbf..51a0ad4 100644 --- a/core/Player.py +++ b/core/Player.py @@ -7,7 +7,7 @@ from core.Logger import Logger CONNECT_STATUS = Enum('CONNECT_STATUS', ["CONNECTED", "CONNECTING", "DISCONNECTED"]) CLASSES = Enum('CLASSES', ['DRUID', 'MAGE', 'HUNTER', 'PRIEST']) -PLAYER_STATE = Enum('STATE', ['IDLE', 'FISHING', 'FARMING']) +PLAYER_STATE = Enum('STATE', ['IDLE', 'FISHING', 'FARMING', 'BG_FARMING']) class Player: def __init__(self, monitor) -> None: @@ -35,8 +35,5 @@ class Player: pyautogui.click() time.sleep(5) - - - def changeState(self, newState): self.state = newState \ No newline at end of file diff --git a/core/cli/CliAgent.py b/core/cli/CliAgent.py index 6af3307..a241cd3 100644 --- a/core/cli/CliAgent.py +++ b/core/cli/CliAgent.py @@ -12,6 +12,7 @@ class CLIAgent: def printMenu(self): print("Enter a command:") print("\tH\tHelp.") + print("\tBG\tStart the bg farming agent.") print("\tF\tStart the fishing agent.") print("\tQ\tQuit.") print("$>> ", end='') @@ -24,8 +25,9 @@ class CLIAgent: userInput = input() userInput = str.lower(userInput).strip() - if (userInput == "f"): - self.logger.log("Starting Fishing bot...") + if (userInput == "bg"): + self.mainAgent.startBgBot() + elif (userInput == "f"): self.mainAgent.startFishBot() elif (userInput == "h"): self.printMenu() diff --git a/wowxel.spec b/wowxel.spec new file mode 100644 index 0000000..fde07ce --- /dev/null +++ b/wowxel.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['main.py'], + pathex=[], + binaries=[], + datas=[('assets', 'assets'), ('config.json', '.')], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + [], + exclude_binaries=True, + name='wowxel', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) +coll = COLLECT( + exe, + a.binaries, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='wowxel', +)