Skip to content

Commit

Permalink
Continuous Walking updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Qfc9 committed Dec 11, 2021
1 parent 57b0fe7 commit 925dcc9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 26 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pip install PyAutoGUI
pip install PyDirectInput
pip install Pillow
pip install opencv-python
pip install mss
pip install numpy
```

New World must be installed and running..... But you know this already right?
Expand Down
Binary file added imgs/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/waiting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 61 additions & 26 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
import pydirectinput
import time
import random
import mss
import numpy as np
from PIL import Image
import gc

def main():
"""
Main function for the program
"""

# Finds all Windows with the title "New World"
newWorldWindows = pyautogui.getWindowsWithTitle("New World")

Expand All @@ -31,7 +34,7 @@ def main():
time.sleep(.1)

# Auto Run Key
autowalkKey = '='
autowalkKey = '0'

# Seconds to move foward
fowardMoveTotal = 20
Expand All @@ -43,51 +46,83 @@ def main():
flip = 1

# Turn 90 degrees, value will be different for you, im on a 4k monitor
flipMouseMove = 2000
flipMouseMove = 3500

# If the bot has stopped moving
stopped = False

# Making tuple with data from the window for later use
region = (newWorldWindow.left, newWorldWindow.top, newWorldWindow.width, newWorldWindow.height)
mssRegion = {"mon": 1, "top": newWorldWindow.top, "left": newWorldWindow.left + round(newWorldWindow.width/3), "width": round(newWorldWindow.width/3)*2, "height": newWorldWindow.height}

# Prep screenshots, walk forward and log time
sct = mss.mss()
pyautogui.press(autowalkKey)
startTime = time.time()

# Main bot loop, runs forever use CTRL+C to turn it off
while True:
# Get Screenshot and reset unstuck tracker
sctImg = Image.fromarray(np.array(sct.grab(mssRegion)))
stuckTracker = 0

# Find that image on screen, in that region, with a confidence of 65%
if pyautogui.locateOnScreen("imgs/e0.png", grayscale=True, confidence=.65, region=region) is not None:
if pyautogui.locate("imgs/e0.png", sctImg, grayscale=True, confidence=.8) is not None:
# If not stopped, stop
if not stopped:
pyautogui.press(autowalkKey)

stopped = True
pyautogui.press('e')
time.sleep(1)
continue
print("Pressing e")
time.sleep(1.2)

# Get a new Screenshot
sctImg = Image.fromarray(np.array(sct.grab(mssRegion)))

# Check if the 'q' image is on screen
while pyautogui.locate("imgs/1.png", sctImg, grayscale=True, confidence=.8) is None:
time.sleep(.5)
sctImg = Image.fromarray(np.array(sct.grab(mssRegion)))
print("Waiting...")
gc.collect()

# Do I got to explain?
pyautogui.press(autowalkKey)
# If stuckTracker gets to 15, move the mouse
if stuckTracker == 15:
pydirectinput.move(5, 0, relative=True)
stuckTracker = 0

# Randomly move foward 0 - 1.5 seconds
temp = 1.5 * random.random()
currentFoward += temp
time.sleep(temp)
stuckTracker += 1

# Brah, you know
pyautogui.press(autowalkKey)
print("Done waiting")
continue

# If bot is stopped, make the bot move again
if stopped:
pyautogui.press(autowalkKey)
stopped = False
startTime = time.time()

# Calculated how much the bot has moved forward
currentFoward += (time.time() - startTime)
startTime = time.time()

# Flippy flip if you hitty hit the max move time (fowardMoveTotal)
if currentFoward >= fowardMoveTotal:
# Reset the move foward
currentFoward = 0

# Move the mouse 90 degrees
pydirectinput.move(flipMouseMove * flip, 1, relative=True)

# Move Foward 1.5 secs
pyautogui.press(autowalkKey)
time.sleep(1.5)
pyautogui.press(autowalkKey)

# Move the mouse 90 degrees
pydirectinput.move(flipMouseMove * flip, 1, relative=True)
for i in range(0, flipMouseMove, round(flipMouseMove/5)):
# Moving the mouse a 5th of the total move amount
pydirectinput.move(round(flipMouseMove/5) * flip, 0, relative=True)
# Wait for .3 seconds
time.sleep(.3)

# Flippy flippy the value. Evil math.
flip *= -1

# Sleeping for the animation
time.sleep(.1)
# Garbage man
gc.collect()


# Runs the main function
Expand Down

0 comments on commit 925dcc9

Please sign in to comment.