King of Glory to brush gold coins (implemented by python+adb)

I want to write an auxiliary script ( or plug-in? ) for a game for a long time. In the past few days, the work and exams have been almost completed, and I have spared time to write a script for brushing gold coins of the glory of the king for your reference.
Insert picture description here

principle

I think that the scripts of the game should be the same.
The flow of our game is like this:

按键
发技能
怪掉血
怪死亡后通关
获得奖励

Then use the script to play the game, you can completely omit the intermediate steps:

按键
获得奖励

So all we need is:
press the button at a specific moment, at a specific location, and that's it.

Environment configuration

1. ADB tool (to let the computer use the mobile phone)
download address: https://adbshell.com/downloads/
If it is slow, then find other resources to
download the configuration will not go into details... (If you can’t, you can comment or talk to me in private)
In the end, it will appear similar to the figure below. Insert picture description here
2. (You don't need it) Python and IDE
download configuration will not be repeated... (If you can't, you can comment or talk to me privately) At
last, it will appear similar to the following picture.
Insert picture description here

Steps of swiping gold coins

1. Connect the data cable to the computer and enter the mobile developer mode (Baidu is
fine if you can’t) 2. Start adb

Error 1: Port 5037 is occupied, just close the corresponding process
Insert picture description here

netstat -ano | findstr "5037"
taskkill /pid (进程号) -f

Error 2: Lack of DLL, or did not enter the developer mode, just move the DLL
Insert picture description here

可选(0.找到下载adb的目录,把adb.exe,AdbWinApi.dll放到C:\WINDOWS\System32下)

1.将本机C:\WINDOWS\System32下的adb.exe文件复制到C:\Windows\SysWOW64下。
 
2.将本机C:\WINDOWS\System32下的AdbWinApi.dll文件复制到C:\Windows\SysWOW64下。

3. Open the King of Glory ( if you are not a developer, you can go to 5 ) , cut a bunch of pictures, and check the pixels
Insert picture description hereto see the Vientiane Tiangong pixels (1755, 793), click on Vientiane by the adb shell input tap 1755 793 command work.
The following is the same:
Insert picture description herepixel (211,275)
Insert picture description herepixel (1231,557)
Insert picture description here
pixel (800,567) (1393,475) (1677,675) (1791,939)
Insert picture description herepixel (1697,861)

Insert picture description herePixels (2175, 45)

Insert picture description hereClick Automatic (2117, 39)

(No picture)
Wait for 60s, skip (2175, 45)

(No picture)
Wait 10 seconds to click on the screen to continue (1000, 500)
Insert picture description hereand challenge again (2001, 1011) and
Insert picture description here
continue to cycle.

4. The code is as follows:

# -*- coding: utf-8 -*-
# @Author  : daruida
# @Time    : 2021/1/8 15:38
import os
from time import sleep


# 点击方法
def click_screen(x, y):
    os.system('adb shell input tap {} {}'.format(x, y))


def repeat(zidong):
    print('开始挑战')
    # 闯关
    click_screen(1697, 861)
    sleep(10)

    # 跳过
    print('点击跳过')
    click_screen(2175, 45)
    sleep(1)

    # 自动
    if zidong == 0:
        print('点击自动')
        click_screen(2117, 39)
        zidong = 1

    # 打完
    sleep(60)
    print('打完了')

    # 跳过
    click_screen(2175, 45)
    sleep(10)

    # 挑战完成
    print('挑战完成\n\n')
    click_screen(1000, 500)
    sleep(1)

    # 再次挑战
    print('再次挑战\n\n')
    click_screen(2001, 1011)
    sleep(1)
    repeat(zidong)

if __name__ == '__main__':
    zidong = 0
    print('刷金币初始化....')
    click_screen(1755, 793)  # 万象天宫
    sleep(1)
    click_screen(211, 275)   # 冒险玩法
    sleep(1)
    click_screen(1231, 557)  # 挑战
    sleep(2)
    print('通天塔\n')
    click_screen(1393, 475)  # 通天塔
    sleep(1)
    click_screen(1677, 675)  # 大师级别
    sleep(1)
    click_screen(1791, 939)  # 下一步
    print('刷金币重复阶段...')
    repeat(zidong)

Of course... if the mobile phone network is fast, or the call speed is fast, you can shorten the sleep time...

4. Package as exe
pyinstaller -F xxxx.py
Insert picture description here
5. After linking the phone, open the king initialization interface and run the exe
(if something goes wrong, just run it again)

test

My combination: Ben Sun + Crazy Iron + Xiaojinjin...
Automatically finish playing in 1min...1000+ gold coins in 1h
Of course, if other combinations take too long to play, you can discuss with me that it might go wrong.

Wouldn’t it be beautiful to swipe gold coins while sleeping, or swipe gold coins while watching station B~
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42882717/article/details/112345924