申请会员ID:ivan21
1、申 请 I D : ivan212、个人邮箱:314315035@qq.com
最近云顶之弈小蜜蜂活动,网上查了下都不好用。就用python自己写了个简单的挂机脚本。打包成exe文件,直接运行
ps: 一直在论坛上下载东西,刚好自己弄了个挂机的脚本,想着分享给别人。申请不过的话,就等13号在注册咯
脚本比较简单,没有修改游戏文件、没有操作内存、没有修改游戏数据。只是做了图片匹配和鼠标动作
首先需要安装好需要用到的库,如下图
i
import os
import random
import time
import cv2
import pyautogui
import win32api
import win32con
from PIL import ImageGrab
from pykeyboard import *
from pymouse import *
from pynput.mouse import Controller
脚本的功能
+ 自动寻找并接受对局
+ 多阵容随机切换
+ 自动升人口
+ 自动捡装备
+ 自动给英雄上装备
+ 自动卖英雄
+ 死亡后自动退出
+ 用户可自行扩展阵容,使用版本英雄变化,自己搭配阵容
+ 手动设置挂机时间,挂机满x小时,自动关闭脚本,并5分钟后退出(关闭脚本页面可退出关机)
# 设置挂机时长
print("请输入挂机时长?单位小时,范围1-24之间整数")
print("输入后按enter结束")
useHour = input()
try:
useHour = int(useHour)
except Exception:
print("输入错误,默认挂机:3小时")
useHour = 3
if useHour > 24 or useHour < 1:
useHour = 3
一、准备进入游戏,通过判断是否有开始游戏、接受等图片,获取坐标,鼠标点击左边
for i in range(len(leftClickIcon)):
theight, twidth = leftClickIcon.shape[:2]
result = cv2.matchTemplate(target, leftClickIcon, cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
if min_val < threashLeft:
if i < 1:
# 判断是否已经运行x小时
t = time.time()
if t - startTime > gameTime:
gaming = False
break
startNewGame()# 判断是否开启一局新游戏
leftClick(min_loc + twidth // 2 + X_START, min_loc + theight // 2 + Y_START)
二、进入游戏后
有四个逻辑判断,购买英雄,捡装备,出售不要英雄,给英雄携带装备 .
【购买英雄】和【捡装备】逻辑很简单,获取坐标,控制鼠标点击就可以了。
【出售不要英雄】和【给英雄携带装备】就麻烦很多,涉及到拖拽,怎么获取拖拽前和拖拽后的坐标?
# 判断是否在游戏中
if judgeInGame():
# 左键购买旗子
for i in range(len(buyHeroIcon)):
theight, twidth = buyHeroIcon.shape[:2]
result = cv2.matchTemplate(target, buyHeroIcon, cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
if min_val < threashLeft:
leftClick(min_loc + twidth // 2 + X_START, min_loc + theight // 2 + Y_START)
# 右键点击的装备
for i in range(len(rightClickIcon)):
theight, twidth = rightClickIcon.shape[:2]
result = cv2.matchTemplate(target, rightClickIcon, cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
if min_val < threashRight:
rightClick(min_loc + twidth // 2 + X_START, min_loc + theight // 2 + Y_START)
time.sleep(0.1)
moveToSpace()
# 自动上装备
t = time.time()
if t - lastItemTime > 10:
dst = random.randint(0, len(heroItem) - 1)
drag(x1, y1, x2], y2])
time.sleep(0.1)
moveToSpace()
index += 1
lastItemTime = t
t = time.time()
interval = 42 + random.randint(1, 10)
if t - lastFTime > interval:# 42秒钟升级一次
for i in range(len(leftClickDelayIcon)):
theight, twidth = leftClickDelayIcon.shape[:2]
result = cv2.matchTemplate(target, leftClickDelayIcon, cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
if min_val < threashLeftDelay:
leftClick(min_loc + twidth // 2 + X_START, min_loc + theight // 2 + Y_START)
time.sleep(0.1)
moveToSpace()
lastFTime = t
# 查看英雄信息必须放到每个循环最后,或出售英雄
t = time.time()
if t - lastJudgeHeroTime > 4:# 4秒钟查看一次英雄
target2 = target
result = cv2.matchTemplate(target2, flags, cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
result = cv2.matchTemplate(target2, flags, cv2.TM_SQDIFF_NORMED)
min_val_2, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
if min_val < 0.2 or min_val_2 < 0.15 and inPlaceHeroNum < len(isHeroInPlace):
judgeHeroIndex = (judgeHeroIndex + 1) % len(heroPosX)
while judgeHeroIndex < len(isHeroInPlace) and judgeHeroIndex > placeNum:
judgeHeroIndex = (judgeHeroIndex + 1) % len(isHeroInPlace)
rightClick(heroPosX, heroPosY)
needJudgeHero = True
lastJudgeHeroTime = t
else:
judgeWatcherIndex = (judgeWatcherIndex + 1) % len(watcherPosX)
rightClick(watcherPosX, watcherPosY)
needJudgeWatcher = True
lastJudgeHeroTime = t
三、结束一盘后,清空游戏数据,并初始化默认参数,随机一个新的阵容
def startNewGame():
for i in range(len(isHeroInPlace)):
isHeroInPlace = False
isPosReady = False
global inPlaceHeroNum
global placeNum
inPlaceHeroNum = 0
placeNum = 1
global currentIndex
currentIndex = random.randint(0, maxZr - 1)
selectTeam()
print("新的一局,当前阵容:", currentIndex + 1)
四、每盘结束后,判断脚本已运行时间,如果大于设置挂机时间,退出脚本,并5分钟后关闭电脑。否则就继续下一盘
print("脚本结束,5分钟后准备关机")
time.sleep(300)# 一分钟后准备关机
os.system('shutdown -a')
os.system('shutdown /s /t 60')
五、执行打包命令,将依赖环境一起打包成exe文件,直接运行即可
pyinstaller -F ivan.py
【开放注册公告】吾爱破解论坛2022年3月13日十四周年开放注册公告
https://www.52pojie.cn/thread-1596731-1-1.html
周日自己来注册。
页:
[1]