import time
from airscript.action import click
import random
import math
from airscript.action import slide
#------------ 配置 -----------------
# 切换场景需要等待的时间 秒 比如回家 传送
change_sleep = 6.5
# 地图坐标 需要根据手机自行配置, 不知道怎么配的可以看看 上面图片菜单下面的多点找色
# 这个是地图的左边层数的坐标点,前五层都要
map_point1 = [[286,722],[286,877 ],[286,1040],[286,1164],[286,1323]]
# 这个是每层对应的传送点坐标,取前三个就行
map_point2 = [[799,725],[799,984],[799,1203 ]]
# 回城家的坐标 右下角那个回家按钮
home = [1110,2332]
# 传送台,打开地图的坐标, 这个坐标必须是传送初始化的时候那个位置对于的坐标
_map = [728,1104]
# 移动摇杆的中心坐标
point = [622,2049]
# 第一个树精战斗时间
master1= 1
# 第二个树精战斗时间
master2 = 3.5
# 牛头人战斗时间
master3 = 1.5
# 机器人战斗时间
master4 = 2
#-------------- 配置结束------------
# 获取方向坐标
def next_coordinate(x, y, angle_degrees):
# 长度
h = 400
angle_radians = math.radians(angle_degrees)
next_x = x + h * math.cos(angle_radians)
next_y = y + h * math.sin(angle_radians)
return next_x, next_y
# 操作移动方法
# random_angle 角度 西 为0(360)度 南为 90度 以此类推
# time : 移动多少秒
def go(random_angle,time):
x1,y1 = next_coordinate(*point,random_angle)
slide(*point,x1,y1,time*1000)
# 回家
def goHome():
click(*home)
time.sleep(change_sleep)
def jump(p1,p2):
# 点击地图
click(*_map)
time.sleep(0.5)
# 跳转地图
click(*map_point1[p1-1])
time.sleep(0.5)
click(*map_point2[p2-1])
time.sleep(change_sleep)
tag = False
def m1_1():
jump(2,1)
if tag:
time.sleep(4.5)
go(350,1.8)
time.sleep(master1)
go(170,1.8)
def m1_2():
jump(3,3)
go(0,1.6)
go(310,2)
time.sleep(master2)
go(130,2)
go(180,1.6)
def m1_3():
jump(2,2)
go(270,0.5)
go(225,3)
go(285,6)
go(225,1.5)
time.sleep(master3)
def m1_4():
go(225,1)
go(270,6.5)
time.sleep(master4)
# 如果在其他地图 先回家
goHome()
print("开始刷金币")
count = 0
while True:
print (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
# 这个actions 列表存的是要打的boss, m1_1 是第一个树精 m1_2 第二个树精 m1_3 牛头 m1_4 机器人,不想打那个就去掉对应的值,去掉的时候逗号也要去掉
actions = [m1_1,m1_2,m1_3,m1_4]
for action in actions:
action()
count = count + 1
print(f"action执行次数:{count}")
# 回家然后传送去王座大厅 刷新boss时间
goHome()
jump(5,1)
tag = True
# 王座跳转时间需要加4.5秒 有个动画
time.sleep(4.5)
windows 版本
```
import math
import time
import pyautogui
import keyboard
import threading
import json
# ------------ 配置 -----------------
# 读取 JSON 文件配置
with open('config.json', 'r', encoding='utf-8') as file:
data = json.load(file)
change_sleep = data.get("change_sleep", 6.5)
map_point1 = data.get("map_point1", [[846, 321], [846, 365], [846, 420], [846, 487], [846, 543]])
map_point2 = data.get("map_point2", [[1010, 333], [1010, 403], [1010, 473]])
home = data.get("home", [1136, 817])
_map = [990, 460]
point = data.get("point", [961, 795])
master1 = data.get("master1", 1)
master2 = data.get("master2", 3)
master3 = data.get("master3", 1.5)
master4 = data.get("master4", 1)
restart_time = data.get("restart_time", 3.5)
click_empty = data.get("click_empty",0)
restart_point = data.get("restart_point", [[1082, 117], [950, 368]])
# -------------- 配置结束------------
# 点击鼠标滑动
def slide(x, y, x1, y1, duration):
pyautogui.moveTo(x, y)
# 模拟按住左键
pyautogui.mouseDown(button='left')
# 移动鼠标,这里只是一个示例,你可以将坐标调整为你想要的位置
pyautogui.moveTo(x1, y1, duration)
# 松开左键
pyautogui.mouseUp(button='left')
def click(x, y):
pyautogui.click(x, y)
def next_coordinate(x, y, angle_degrees):
# 长度
h = 50
angle_radians = math.radians(angle_degrees)
next_x = x + h * math.cos(angle_radians)
next_y = y + h * math.sin(angle_radians)
return next_x, next_y
# 移动
def go(random_angle, time):
x1, y1 = next_coordinate(*point, random_angle)
slide(*point, x1, y1, time)
# 回家
def goHome():
pyautogui.click(*home)
time.sleep(change_sleep)
def restart():
global _map
pyautogui.click(*restart_point[0])
time.sleep(0.3)
pyautogui.click(restart_point[1])
time.sleep(restart_time)
# 从新进入地图 位置会变
_map = data.get("_map2", [1001, 409])
# 新手礼包需要点击空白处跳过
if click_empty != 0:
print("点击空白处")
click(home[0],home[1] - 100)
time.sleep(click_empty)
def jump(p1, p2):
global _map
# 点击地图
click(*_map)
time.sleep(0.2)
# 跳转地图
click(*map_point1[p1 - 1])
time.sleep(0.2)
click(*map_point2[p2 - 1])
time.sleep(change_sleep)
_map = data.get("_map", [990, 460])
def m1_1():
jump(2, 1)
go(350, 1.8)
time.sleep(master1)
go(170, 1.8)
def m1_2():
jump(3, 3)
go(0, 1.6)
go(310, 2)
time.sleep(master2)
go(130, 2)
go(180, 1.6)
def m1_3():
jump(2, 2)
go(270, 0.5)
go(225, 3)
go(285, 6)
go(225, 1.5)
time.sleep(master3)
def m1_4():
go(225, 1)
go(270, 6)
time.sleep(master4)
run_statu = False
def wait():
global run_statu
# 保证打印一次
flag = True
while not run_statu:
if flag:
print("暂停脚本,等待...(按ctrl + f1 开始或暂停脚本)")
flag = False
time.sleep(0.2)
flag = True
def playGame():
global run_status
# 如果在其他地图 先回家
wait()
goHome()
print("开始刷金币")
count = 0
# 添加要打的boss
actions = []
if master1 != 0:
actions.append(m1_1)
if master2 != 0:
actions.append(m1_2)
if master3 != 0:
actions.append(m1_3)
if master4 != 0:
actions.append(m1_4)
while True:
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
for action in actions:
wait()
action()
count = count + 1
print(f"action执行次数:{count}")
# 回家然后传送去王座大厅 刷新boss时间
wait()
restart()
# 创建线程实例并启动线程
thread1 = threading.Thread(target=playGame)
thread1.start()
def on_press(event):
global run_statu
if event.event_type == keyboard.KEY_DOWN and keyboard.is_pressed('f1') and keyboard.is_pressed('ctrl'):
run_statu = not run_statu
if (run_statu):
print("开始执行脚本!")
else:
print("暂停脚本,等待上一步动作完成后可接管鼠标!")
def thread2():
# 设置监听器
keyboard.hook(on_press)
# 进入监听状态
keyboard.wait()
# 创建线程
my_thread2 = threading.Thread(target=thread2)
# 启动线程
my_thread2.start()
my_thread2.join()
```
配置json
```
{
"1.":"切换场景需要等待的时间 秒 比如回家 传送",
"click_empty": 5,
"2.":"地图坐标 需要自行配置,1920*1080可以不改试试, 不知道怎么取的可以使用微信的截图功能(鼠标下面的POS就是坐标点)",
"map_point1": [[846, 321], [846, 365],[846, 420],[846, 487],[846, 543]],
"3.":"这个是每层对应的传送点坐标,取前三个就行",
"map_point2": [[1010, 333], [1010, 403], [1010, 473]],
"4.":"回城家的坐标 右下角那个回家按钮",
"home": [1174, 872],
"5.":"传送台,打开地图的坐标, 这个坐标必须是传送初始化的时候那个位置对于的坐标",
"_map": [1000, 450],
"6.":"传送台第二个坐标, 这个是因为我重新启动游戏后,桌标点会变,如果重启后坐标点不变,就和_map 设置同一个坐标就行了",
"_map2": [1000, 380],
"7.":"移动摇杆的中心坐标",
"point": [961, 795],
"8.": "重新进入游戏的等待时间",
"restart_time": 3.5,
"9.":"第一个树精战斗时间 不打可以设置0",
"master1": 0.8,
"10.":"第二个树精战斗时间 不打可以设置0",
"master2": 2,
"11.":"牛头人战斗时间 不打可以设置0",
"master3": 1.5,
"12.":"机器人战斗时间 不打可以设置0",
"master4": 1,
"13": "重启按钮 有两个地方 先按右上角三个点 再点重启",
"restart_point": [[1088,39],[988,291]],
"14":"是否点击空白点, 0 代表不点击, 非0代表点击后睡眠时间",
"change_sleep": 6
}
```
有问题 去贴吧:tieba.baidu.com/p/893289566…