New build script + bg farming bot v1
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.6 KiB |
BIN
assets/icons/Deserter.jpg
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/icons/WaitingForBg.jpg
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/labels/AlteracValleyLabel.jpg
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
assets/menus/EnterBgButton.jpg
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
assets/menus/JoinBGWindow.jpg
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
assets/menus/JoinBattleButton.jpg
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
assets/menus/LeaveMatchButton.jpg
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/menus/PlayerVsPlayerTab.jpg
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/menus/RandomEpicBGButton.jpg
Normal file
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.3 MiB |
111
bots/battleground/battlegroundAgent.py
Normal file
|
|
@ -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()
|
||||||
|
|
@ -13,8 +13,8 @@ class FishingAgent:
|
||||||
self.fishingIconImg = cv.imread("assets/fishing/FishIcon.jpg", cv.IMREAD_GRAYSCALE)
|
self.fishingIconImg = cv.imread("assets/fishing/FishIcon.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
self.fishingThread = None
|
self.fishingThread = None
|
||||||
self.logger = Logger("Fishing Agent")
|
self.logger = Logger("Fishing Agent")
|
||||||
self.monitor = monitor
|
|
||||||
self.lureLoc = None
|
self.lureLoc = None
|
||||||
|
self.monitor = monitor
|
||||||
self.player = player
|
self.player = player
|
||||||
self.fail = 0
|
self.fail = 0
|
||||||
self.retry = 0
|
self.retry = 0
|
||||||
|
|
@ -52,32 +52,33 @@ class FishingAgent:
|
||||||
if (self.retry > 4):
|
if (self.retry > 4):
|
||||||
self.fail += 1
|
self.fail += 1
|
||||||
self.logger.log("Took too long to find lure, retrying fishing from the beginning")
|
self.logger.log("Took too long to find lure, retrying fishing from the beginning")
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
self.logger.log("Trying again in 1 second...")
|
self.logger.log("Trying again in 1 second...")
|
||||||
self.retry += 1
|
self.retry += 1
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.findLure()
|
self.findLure()
|
||||||
time.sleep(0.5)
|
else:
|
||||||
self.lureLoc = res
|
time.sleep(0.5)
|
||||||
pyautogui.moveTo(self.lureLoc[0], self.lureLoc[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)
|
||||||
|
res = self.monitor.findMatch(self.fishingBobberImg)
|
||||||
|
if (res != -1):
|
||||||
|
self.lureLoc = res
|
||||||
while True:
|
while True:
|
||||||
self.retry += 1
|
self.retry += 1
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
res = self.monitor.findMatch(self.fishingBobberImg)
|
res = self.monitor.findMatch(self.fishingBobberImg)
|
||||||
print(self.lureLoc)
|
|
||||||
print(res)
|
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)
|
time.sleep(0.2)
|
||||||
pyautogui.click()
|
pyautogui.click()
|
||||||
time.sleep(0.5)
|
|
||||||
return
|
return
|
||||||
elif (self.retry > 200):
|
elif (self.retry > 150):
|
||||||
self.retry = 0
|
self.retry = 0
|
||||||
self.fail += 1
|
self.fail += 1
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ class IdlingAgent:
|
||||||
self.monitor = monitor
|
self.monitor = monitor
|
||||||
|
|
||||||
def checkIdleTime(self):
|
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
|
elapsedTime = time.time() - self.idleTime
|
||||||
if (elapsedTime > 10):
|
if (elapsedTime > 60):
|
||||||
self.logger.log("Jumping to avoid being afk...")
|
self.logger.log("Jumping to avoid being afk...")
|
||||||
pyautogui.press("space")
|
pyautogui.press("space")
|
||||||
self.idleTime = time.time()
|
self.idleTime = time.time()
|
||||||
|
|
|
||||||
9
build.ps1
Normal file
|
|
@ -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 ..;
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from core.Monitor import Monitor
|
from core.Monitor import Monitor
|
||||||
|
from bots.battleground.battlegroundAgent import BattlegroundAgent
|
||||||
from bots.fishing.FishingAgent import FishingAgent
|
from bots.fishing.FishingAgent import FishingAgent
|
||||||
from bots.idling.IdlingAgent import IdlingAgent
|
from bots.idling.IdlingAgent import IdlingAgent
|
||||||
from core.Player import Player, PLAYER_STATE
|
from core.Player import Player, PLAYER_STATE
|
||||||
|
|
@ -9,6 +10,7 @@ class MainAgent:
|
||||||
self.playerAgent = Player(self.monitor)
|
self.playerAgent = Player(self.monitor)
|
||||||
self.idlingBot = IdlingAgent(self.monitor, self.playerAgent)
|
self.idlingBot = IdlingAgent(self.monitor, self.playerAgent)
|
||||||
self.fishingBot = FishingAgent(self.monitor, self.playerAgent)
|
self.fishingBot = FishingAgent(self.monitor, self.playerAgent)
|
||||||
|
self.bgFarming = BattlegroundAgent(self.monitor, self.playerAgent)
|
||||||
self.monitor.startScreenCaptureThread()
|
self.monitor.startScreenCaptureThread()
|
||||||
# Start idling agent at the construction of the mainAgent for now
|
# Start idling agent at the construction of the mainAgent for now
|
||||||
self.idlingBot.run()
|
self.idlingBot.run()
|
||||||
|
|
@ -17,4 +19,6 @@ class MainAgent:
|
||||||
self.playerAgent.changeState(PLAYER_STATE.FISHING)
|
self.playerAgent.changeState(PLAYER_STATE.FISHING)
|
||||||
self.fishingBot.run()
|
self.fishingBot.run()
|
||||||
|
|
||||||
|
def startBgBot(self):
|
||||||
|
self.playerAgent.changeState(PLAYER_STATE.BG_FARMING)
|
||||||
|
self.bgFarming.run()
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class Monitor:
|
||||||
|
|
||||||
matchRatio = max_val * 100
|
matchRatio = max_val * 100
|
||||||
self.logger.log(matchRatio)
|
self.logger.log(matchRatio)
|
||||||
if (matchRatio < 60):
|
if (matchRatio < 50):
|
||||||
self.logger.log("Cannot find matching result...")
|
self.logger.log("Cannot find matching result...")
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from core.Logger import Logger
|
||||||
|
|
||||||
CONNECT_STATUS = Enum('CONNECT_STATUS', ["CONNECTED", "CONNECTING", "DISCONNECTED"])
|
CONNECT_STATUS = Enum('CONNECT_STATUS', ["CONNECTED", "CONNECTING", "DISCONNECTED"])
|
||||||
CLASSES = Enum('CLASSES', ['DRUID', 'MAGE', 'HUNTER', 'PRIEST'])
|
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:
|
class Player:
|
||||||
def __init__(self, monitor) -> None:
|
def __init__(self, monitor) -> None:
|
||||||
|
|
@ -35,8 +35,5 @@ class Player:
|
||||||
pyautogui.click()
|
pyautogui.click()
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def changeState(self, newState):
|
def changeState(self, newState):
|
||||||
self.state = newState
|
self.state = newState
|
||||||
|
|
@ -12,6 +12,7 @@ class CLIAgent:
|
||||||
def printMenu(self):
|
def printMenu(self):
|
||||||
print("Enter a command:")
|
print("Enter a command:")
|
||||||
print("\tH\tHelp.")
|
print("\tH\tHelp.")
|
||||||
|
print("\tBG\tStart the bg farming agent.")
|
||||||
print("\tF\tStart the fishing agent.")
|
print("\tF\tStart the fishing agent.")
|
||||||
print("\tQ\tQuit.")
|
print("\tQ\tQuit.")
|
||||||
print("$>> ", end='')
|
print("$>> ", end='')
|
||||||
|
|
@ -24,8 +25,9 @@ class CLIAgent:
|
||||||
userInput = input()
|
userInput = input()
|
||||||
userInput = str.lower(userInput).strip()
|
userInput = str.lower(userInput).strip()
|
||||||
|
|
||||||
if (userInput == "f"):
|
if (userInput == "bg"):
|
||||||
self.logger.log("Starting Fishing bot...")
|
self.mainAgent.startBgBot()
|
||||||
|
elif (userInput == "f"):
|
||||||
self.mainAgent.startFishBot()
|
self.mainAgent.startFishBot()
|
||||||
elif (userInput == "h"):
|
elif (userInput == "h"):
|
||||||
self.printMenu()
|
self.printMenu()
|
||||||
|
|
|
||||||
44
wowxel.spec
Normal file
|
|
@ -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',
|
||||||
|
)
|
||||||