Closed ghost closed 2 years ago
Awesome! Ill test it out in a bit and let you know if it is all good!
Ok, checked it out. Works BUT changing default settings is not ideal. So I wrote up the fix. Pyautogui kind of sucks, especially when it comes to input. Pydirectinput is better because it hooks into the drivers. So I wrote up a working version with the default alt key.
I still want you to get the credit, so here is the code I wrote up that fixes the issue. Just copy it, push it up, and ill accept it.
import pyautogui
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
"""
# Max cast is 1.9 secs
# Base time it will always cast at
castingBaseTime = 1.0
# Max random amount of time to add to the base
castingRandom = .4
# How long to slack the line
lineSlackTime = 1.5
# Adding randomness to the wait times for the animations
animationSleepTime = .1 + (.1 * random.random())
# Randomly will move right or left to keep from AFKing
moveDirection = ["a", "d"]
# Free cam key
freeCamKey = "alt"
# Finds all Windows with the title "New World"
newWorldWindows = pyautogui.getWindowsWithTitle("New World")
# Find the Window titled exactly "New World" (typically the actual game)
for window in newWorldWindows:
if window.title == "New World":
newWorldWindow = window
break
# Select that Window
newWorldWindow.activate()
# Move your mouse to the center of the game window
centerW = newWorldWindow.left + (newWorldWindow.width/2)
centerH = newWorldWindow.top + (newWorldWindow.height/2)
pyautogui.moveTo(centerW, centerH)
# Clicky Clicky
time.sleep(animationSleepTime)
pyautogui.click()
time.sleep(animationSleepTime)
# Selecting the middle 3rd of the New World Window
mssRegion = {"mon": 1, "top": newWorldWindow.top, "left": newWorldWindow.left + round(newWorldWindow.width/3), "width": round(newWorldWindow.width/3), "height": newWorldWindow.height}
# Starting screenshotting object
sct = mss.mss()
# This should resolve issues with the first cast being short
time.sleep(animationSleepTime * 3)
while True:
# Screenshot
sctImg = Image.fromarray(np.array(sct.grab(mssRegion)))
# Calculating those times
castingTime = castingBaseTime + (castingRandom * random.random())
# Hold the "Free Look" Button
print("Holding Free Look Button")
pydirectinput.keyDown(freeCamKey)
# Like it says, casting
print("Casting Line")
pyautogui.mouseDown()
time.sleep(castingTime)
pyautogui.mouseUp()
# Looking for the fish icon, doing forced garbage collection
while pyautogui.locate("imgs/fishIcon.png", sctImg, grayscale=True, confidence=.6) is None:
gc.collect()
# Screenshot
sctImg = Image.fromarray(np.array(sct.grab(mssRegion)))
# Hooking the fish
print("Fish Hooked")
pyautogui.click()
time.sleep(animationSleepTime)
# Keeps reeling into "HOLD Cast" text shows on screen
while pyautogui.locate("imgs/holdCast.png", sctImg, grayscale=True, confidence=.55) is None:
print("Reeling....")
pyautogui.mouseDown()
# If icon is in the orange area slack the line
if pyautogui.locate("imgs/fishReelingOrange.png", sctImg, grayscale=True, confidence=.75) is not None:
print("Slacking line...")
pyautogui.mouseUp()
time.sleep(lineSlackTime)
# Uses a lot of memory if you don't force collection
gc.collect()
# Screenshot
sctImg = Image.fromarray(np.array(sct.grab(mssRegion)))
# Reel down time
time.sleep(animationSleepTime)
pyautogui.mouseUp()
time.sleep(animationSleepTime)
print("Caught Fish")
# 20% chance to move to avoid AFK timer
if random.randint(1, 5) == 5:
key = moveDirection[random.randint(0, 1)]
pyautogui.keyDown(key)
time.sleep(.1)
pyautogui.keyUp(key)
time.sleep(animationSleepTime)
# Release the "Free Look" Button
print("Released Free Look Button")
pydirectinput.keyUp(freeCamKey)
# Runs the main function
if __name__ == '__main__':
main()
Thanks a lot! Push is coming right away!
What is your discord name? So I can give you champion status
Tag: Python #.0929
Dope, you got it. Just so you know, the role lasts for 1 year from your LAST meaningful contribution. So if you contribute something else later, the expiration date will be moved.
On Sun, Jan 9, 2022 at 1:42 PM Niklas Theiler @.***> wrote:
Tag: Python#929
— Reply to this email directly, view it on GitHub https://github.com/RootKit-Org/Basic-New-World-Fishing-Bot/pull/2#issuecomment-1008352242, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZTE3NOQM3O6BBU2WFFATUVHJKHANCNFSM5LSA2CCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you modified the open/close state.Message ID: @.*** com>
-- From,
Elijah Harmon
Added a feature to auto recenter the screen if you catch a rare fish.
You have to change your keybinding for the "Free Look" button from standard to "B", otherwise it will not work!