Hello everyone, I am Mengmeng Xuejie.
~

I have wanted to write an auxiliary script (or cheat?) for a game for a long time. Recently, I have finished most of my work and exams, so I took some time to write a gold farming script for Honor of Kings for everyone to reference.

1. Principle
I think the scripts for games are generally similar. The process we go through while playing games is as follows:

So, when using a script to play the game, we can completely skip the intermediate steps:

Therefore, we only need to:
Press keys at specific moments and locations.
2. Environment Configuration
ADB Tool (to allow the computer to use the phone)
Download link: https://adbshell.com/downloads/
If the download is slow, you can find other resources.
The download configuration will not be elaborated here.
Finally, it should look similar to the image below.

(Optional) Python and IDE
The download configuration will not be elaborated here, and it should look similar to the image below.

3. Steps to Farm Gold
1. Connect the data cable to the computer and enter the phone’s developer mode (if you don’t know how, just search it on Baidu).
2. Start ADB
Error 1: Port 5037 is occupied, just close the corresponding process.

netstat -ano | findstr "5037"
taskkill /pid (process_id) -f
Error 2: Missing DLL, or not in developer mode, just move the DLL.

Optional (0. Find the directory where adb is downloaded, and place adb.exe and AdbWinApi.dll in C:\WINDOWS\System32)
1. Copy the adb.exe file from C:\WINDOWS\System32 to C:\Windows\SysWOW64.
2. Copy the AdbWinApi.dll file from C:\WINDOWS\System32 to C:\Windows\SysWOW64.
3. Open Honor of Kings (if you are not a developer, skip to step 5), take a bunch of screenshots, and check the pixel points.

You can see the pixel point for Wanxiang Tiangong (1755, 793), and use the command adb shell input tap 1755 793 to click on Wanxiang Tiangong.
The following is similar:

Pixel point (211, 275)

Pixel point (1231, 557)

Pixel points (800, 567) (1393, 475) (1677, 675) (1791, 939)

Pixel point (1697, 861)

Pixel point (2175, 45)

Click automatically (2117, 39)
(No image)
Wait 60 seconds, skip (2175, 45)
(No image)
Wait 10 seconds and click the screen to continue (1000, 500)

Challenge again (2001, 1011)

Just keep looping.
4. The code is as follows:
# -*- coding: utf-8 -*-
# @Author : daruida
# @Time : 2021/1/8 15:38
import os
from time import sleep
# Click method
def click_screen(x, y):
os.system('adb shell input tap {} {}'.format(x, y))
def repeat(zidong):
print('Starting challenge')
# Leveling up
click_screen(1697, 861)
sleep(10)
# Skip
print('Click to skip')
click_screen(2175, 45)
sleep(1)
# Automatic
if zidong == 0:
print('Click to auto')
click_screen(2117, 39)
zidong = 1
# Finished
sleep(60)
print('Finished')
# Skip
click_screen(2175, 45)
sleep(10)
# Challenge completed
print('Challenge completed\n\n')
click_screen(1000, 500)
sleep(1)
# Challenge again
print('Challenge again\n\n')
click_screen(2001, 1011)
sleep(1)
repeat(zidong)
if __name__ == '__main__':
zidong = 0
print('Gold farming initialization....')
click_screen(1755, 793) # Wanxiang Tiangong
sleep(1)
click_screen(211, 275) # Adventure gameplay
sleep(1)
click_screen(1231, 557) # Challenge
sleep(2)
print('Tongtian Tower\n')
click_screen(1393, 475) # Tongtian Tower
sleep(1)
click_screen(1677, 675) # Master level
sleep(1)
click_screen(1791, 939) # Next
print('Gold farming repeat phase...')
repeat(zidong)
Of course… if the phone’s network speed is fast, or if the speed of play is fast, you can shorten the sleep time…
5. Package as exe
pyinstaller -F xxxx.py

6. After connecting the phone, open to the Honor of Kings initialization screen and run the exe.
(If there is an error, just run it again.)
4. Testing
My combination:Sun Ben + Kuang Tie + Xiao Jin Jin…Automatically finishes in 1 minute… can earn over 1000 gold in 1 hour.Of course, if other combinations take too long, feel free to discuss potential errors with me.Farm gold while sleeping, or while watching Bilibili, isn’t that great?
Mengmeng Xuejie has prepared a diversified course system, waiting for you to unlock.
If you are interested in Python, and want to learn more, you can click the image to learn. This is a systematic free nanny-level video tutorial, theory + practice, suitable for beginners!↓↓↓
– End –
Want to improve your skills and career development?
Recommended free courses:Linux Cloud Computing | Java Development | HarmonyOS | Python Data Analysis | Internet of Things | Network Security | Game Concept Art | Software Testing | Unity Game Development | PMP Project Management | HTML5 Frontend Development | All-Media Operations | UI/UX Design | Film Editing | C++ | Big Data | Computer Level 2