|
| 1 | +import pyautogui |
| 2 | +import pydirectinput |
| 3 | +import time |
| 4 | +import random |
| 5 | + |
| 6 | +def main(): |
| 7 | + """ |
| 8 | + Main function for the program |
| 9 | + """ |
| 10 | + |
| 11 | + # Finds all Windows with the title "New World" |
| 12 | + newWorldWindows = pyautogui.getWindowsWithTitle("New World") |
| 13 | + |
| 14 | + # Find the Window titled exactly "New World" (typically the actual game) |
| 15 | + for window in newWorldWindows: |
| 16 | + if window.title == "New World": |
| 17 | + newWorldWindow = window |
| 18 | + break |
| 19 | + |
| 20 | + # Select that Window |
| 21 | + newWorldWindow.activate() |
| 22 | + |
| 23 | + # Move your mouse to the center of the game window |
| 24 | + centerW = newWorldWindow.left + (newWorldWindow.width/2) |
| 25 | + centerH = newWorldWindow.top + (newWorldWindow.height/2) |
| 26 | + pyautogui.moveTo(centerW, centerH) |
| 27 | + |
| 28 | + # Clicky Clicky |
| 29 | + time.sleep(.1) |
| 30 | + pyautogui.click() |
| 31 | + time.sleep(.1) |
| 32 | + |
| 33 | + # Seconds to move foward |
| 34 | + fowardMoveTotal = 20 |
| 35 | + |
| 36 | + # Current seconds foward moved |
| 37 | + currentFoward = 0 |
| 38 | + |
| 39 | + # Go right or left |
| 40 | + flip = 1 |
| 41 | + |
| 42 | + # Turn 90 degrees, value will be different for you, im on a 4k monitor |
| 43 | + flipMouseMove = 2000 |
| 44 | + |
| 45 | + # Making tuple with data from the window for later use |
| 46 | + region = (newWorldWindow.left, newWorldWindow.top, newWorldWindow.width, newWorldWindow.height) |
| 47 | + |
| 48 | + # Main bot loop, runs forever use CTRL+C to turn it off |
| 49 | + while True: |
| 50 | + # Find that image on screen, in that region, with a confidence of 65% |
| 51 | + if pyautogui.locateOnScreen("imgs/e0.png", grayscale=True, confidence=.65, region=region) is not None: |
| 52 | + pyautogui.press('e') |
| 53 | + time.sleep(1) |
| 54 | + continue |
| 55 | + |
| 56 | + # Do I got to explain? |
| 57 | + pyautogui.press('=') |
| 58 | + |
| 59 | + # Randomly move foward 0 - 1.5 seconds |
| 60 | + temp = 1.5 * random.random() |
| 61 | + currentFoward += temp |
| 62 | + time.sleep(temp) |
| 63 | + |
| 64 | + # Brah, you know |
| 65 | + pyautogui.press('=') |
| 66 | + |
| 67 | + # Flippy flip if you hitty hit the max move time (fowardMoveTotal) |
| 68 | + if currentFoward >= fowardMoveTotal: |
| 69 | + # Reset the move foward |
| 70 | + currentFoward = 0 |
| 71 | + |
| 72 | + # Move the mouse 90 degrees |
| 73 | + pydirectinput.move(flipMouseMove * flip, 1, relative=True) |
| 74 | + |
| 75 | + # Move Foward 1.5 secs |
| 76 | + pyautogui.press('=') |
| 77 | + time.sleep(1.5) |
| 78 | + pyautogui.press('=') |
| 79 | + |
| 80 | + # Move the mouse 90 degrees |
| 81 | + pydirectinput.move(flipMouseMove * flip, 1, relative=True) |
| 82 | + |
| 83 | + # Flippy flippy the value. Evil math. |
| 84 | + flip *= -1 |
| 85 | + |
| 86 | + # Sleeping for the animation |
| 87 | + time.sleep(.1) |
| 88 | + |
| 89 | + |
| 90 | +# Runs the main function |
| 91 | +if __name__ == '__main__': |
| 92 | + main() |
0 commit comments