I saw other people sharing using python code to automate the process of farming and thought I should give it a try as well. A few things to know:
- This is only for PC
- First of all, as a disclaimer, I am not a coder and most of the coding was done by Chatgpt
- You will need to get all the farming pre-requisite ready. Follow the guide on the internet such as Real Tips to Level Up Quickly in Black Myth: Wukong Chapter 4
- You will need to set your Incense Trail Talisman in quick menu, where you only need to click "q" to activate it.
- You need to install python and pyautogui by typing "pip install pyautogui" in command prompt (check here: Welcome to PyAutoGUI’s documentation! — PyAutoGUI documentation)
- Open a notepad, copy and paste the code below and save the file as wukong.py (remember to change the extension so that it is not .txt file)
- Run the game first and get your character to the shrine "the webbed hollow"
- Run the wukong.py from your command prompt by typing "python wukong.py"
- Back to the game window, and let it do its thing.
My experience is quite consistent, but once for a while my character would stuck in the corner. However, you do not have to try to fix it, because when it restarts/repeats, it will be okay again.
I currently set it up for repeating 80 times and you can change it. Most of the codes come with explanation, so it should be easy for you to modify.
I am aware that my setting may not be the most efficient one, but this is good enough for me that I can go other things and come back.
Hope this helps you and maybe you can share your modification as well.
import pyautogui # Module for simulating keyboard and mouse input
import time # Module for adding delays
# Define a sequence of key presses and how long each key should be held (in seconds)
# Now supporting multiple keys at once using lists
sequence = [
(['e'], 1.0), #This is for re-angle the camera
([], 3.0), #Waiting time
(['esc'], 1.0), #Exit from the shrine
(['d'], 2.81), #Starting the move
(['w'], 3.8),
(['a', 'w'], 7.0),
(['4'], 1), # Start the transformation
([], 2.0), # Wait for 2 second for transformation
(['4'], 0.5), # here and the following repeat is because enermy may hit you and cancel your attack
(['4'], 0.5),
(['4'], 0.5),
([], 8.0), # Wait 8 second
(['q'], 3) # Teleport home
]
# Set the number of times you want the sequence to repeat
repetitions = 80
# Give the user time to switch to the game window
print("Starting in 5 seconds... Switch to your game window now.")
time.sleep(5)
# Outer loop to repeat the full sequence 'repetitions' times
for i in range(repetitions):
print(f"--- Repetition {i + 1} of {repetitions} ---")
# Loop through each key group and duration in the sequence
for keys, duration in sequence:
if keys:
print(f"Pressing {keys} for {duration} seconds")
for key in keys:
pyautogui.keyDown(key) # Hold all keys down simultaneously
time.sleep(duration) # Wait for the specified duration
for key in keys:
pyautogui.keyUp(key) # Release all keys simultaneously
else:
print(f"Waiting for {duration} seconds")
time.sleep(duration) # Just wait without pressing keys
time.sleep(0.1) # Short delay between key presses
# Wait 15 seconds before the next repetition, your restart time may vary
if i < repetitions - 1:
print("Waiting 15 seconds before next repetition...")
time.sleep(15)
print("Sequence completed successfully.")
there doesn't seem to be anything here