Python编写的阴阳师御魂副本自动挂机脚本,仅供学习交流使用
顺手分享一下个人学习python语言后的一点成果
鼠鼠我玩阴阳师也有七年了,见过抓包修改伤害数值,也见过游戏加速,某宝上的各种自动挂机辅助也尝试过。绝大部分的科技鼠鼠都有过被鬼使黑制裁的经历,不得不说阴阳师在反外挂反辅助这方面确实是下了很大功夫,即便所谓的 “物理外挂” 也照样制裁。我认为官方判定辅助的根据之一是固定规律的点击行为,就算很多科技鼠鼠从云手机上的辅助APP转移到安卓虚拟机+windows辅助软件的作弊方式也有一定概率被制裁
运行所需的python版本只要不是太旧的应该没问题,所需的 pyautogui 库在0.9.41版本以上的即可,用 try 函数抓住了图像识别时识别失败会报错的情况。功能还在进一步完善,目前的脚本不支持多开的阴阳师
脚本需要用到参考图,鼠鼠们在拷贝下代码保存成文件后还要手动截图模拟器里的一些图片,图片放在python脚本同一路径下即可。我把需要的一些图片大致放在这,因为考虑到分辨率不同的原因,所以需要鼠鼠们动手在自己电脑上的阴阳师进行截图,截图并不多,代码行也有注释相应功能的图片。需要注意命名和后缀别弄错了
其中的 talk1.png 和 talk.png 分别是战斗过程中上方的聊天图标和打开聊天频道后点击收缩的图标,box.png 就是打开聊天频道下方的输入框,经常玩的鼠鼠应该清楚这些图片。加入这些是为了在一定场数之后随机在公屏上发言,模拟真实玩家的行为。默认设定的是 22倍数的场次会打开对话框向公屏输出内容
import pyautogui
import random
import time
# 单人模式
def auto_one(times):
# 脚本运行时战斗计数,默认为0
num = 0
# 脚本运行总时长计时开始
start = time.time()
while True:
if num != times:
num += 1
time_start = begin(num)
# 点击开始后延迟5s
time.sleep(random.randint(13, 18))
end_one()
else:
print("已成功运行%d次战斗" % num)
break
# 脚本运行总时长计时结束
end = time.time()
time_all = end - start
print("本次脚本使用总耗时", seconds_to_time(time_all))
print("注意查收鬼使黑的来信!")
# 组队模式
def auto_two(times):
# 脚本运行轮次计数,默认为0
num = 0
# 脚本运行总时长计时开始
start = time.time()
while True:
if num != times:
num += 1
time_start = begin(num)
# 点击开始后延迟5s-8s
time.sleep(random.randint(5, 8))
end_tow()
else:
print("已成功进行%d次战斗" % num)
break
# 脚本运行总时长计时结束
end = time.time()
time_all = end - start
print("本次脚本使用总耗时", seconds_to_time(time_all))
print("注意查收鬼使黑的来信!")
# 单人和组队模式开始均使用此函数
def begin(num):
error = 0
while 1:
if pattern == 2:
while 1:
try:
location_begin1 = pyautogui.locateCenterOnScreen('tiaozhan.jpg', confidence=0.7)#组队界面挑战按钮
if location_begin1 is not None:
pyautogui.click(random.randint(location_begin.x, location_begin.x + 1),
random.randint(location_begin.y - 1, location_begin.y),
clicks=random.randint(1, 2),interval=0.2,duration=0.2)
# 记录本次战斗开始时间
time.time()
print("已开始第%d次战斗" % num)
print("等待战斗中.......")
# 返回本次战斗开始时间
if (num % 22)==0 : #当次数到达22的倍数时,会打开对话框打字聊天
talk()
return time_start
except pyautogui.ImageNotFoundException:
error += 1
time.sleep(5)
if error >= 5:
print("错误次数达到5次,脚本异常结束")
return
print("检测失败")
if pattern == 1:
while 1:
try:
# 如果检测到了”单人挑战“按钮
location_begin = pyautogui.locateCenterOnScreen('begin.png', confidence=0.7) #单人挑战按钮
if location_begin is not None:
# 随机延迟1-3s
time.sleep(random.randint(1, 3))
pyautogui.click(random.randint(location_begin.x, location_begin.x + 3),
random.randint(location_begin.y - 3, location_begin.y),
clicks=random.randint(1, 2), interval=0.2, duration=0.3)
# 记录本次战斗开始时间
time_start = time.time()
print("已开始第%d次战斗" % num)
print("等待战斗中.......")
# 返回本次战斗开始时间
time.sleep(random.randint(3, 5))
if (num % 22)==0 : #当次数到达22的倍数时,会打开对话框打字聊天
talk()
return time_start
except pyautogui.ImageNotFoundException:
print("检测失败")
# 单人模式结束
def end_one():
while 1:
try:
location_continue1 = pyautogui.locateCenterOnScreen('continue_tx.png', confidence=0.7)
if location_continue1 is not None:
time.sleep(random.randint(2, 4))
pyautogui.click(random.randint(location_continue1.x , location_continue1.x + 10),
random.randint(location_continue1.y - 8, location_continue1.y),
clicks=random.randint(1, 3),
interval=0.2, duration=0.2)
time.sleep(random.randint(1, 2))
break
except pyautogui.ImageNotFoundException:
print("等待战斗结束2")
# 组队模式结束
def end_tow():
while 1:
try:
location_continue1 = pyautogui.locateCenterOnScreen('continue_tx.png', confidence=0.7)
if location_continue1 is not None:
time.sleep(random.randint(2, 4))
pyautogui.click(random.randint(location_continue1.x , location_continue1.x + 10),
random.randint(location_continue1.y - 8, location_continue1.y),
clicks=random.randint(1, 3),
interval=0.2, duration=0.2)
time.sleep(random.randint(1, 2))
break
except pyautogui.ImageNotFoundException:
print("等待战斗结束2")
上下两部分代码合并一块即可,talk 函数是为了模拟玩家在公屏上发言,具体的发言内容可以自行修改,鼠鼠我把功能弄成逐字输入的方式,并没有设置成一整句话直接粘贴上去
def talk():
try:
location_begin12 = pyautogui.locateCenterOnScreen('talk1.png', confidence=0.8)
if location_begin12 is not None:
pyautogui.click(random.randint(location_begin12.x + 1, location_begin12.x - 1),
random.randint(location_begin12.y - 1, location_begin12.y + 1), clicks=1)
location_begin14 = pyautogui.locateCenterOnScreen('box.jpg', confidence=0.8)
if location_begin14 is not None:
pyautogui.click(random.randint(location_begin14.x + 2, location_begin14.x - 2 ),
random.randint(location_begin14.y - 1, location_begin14.y + 1), clicks=1)
shuliang = random.randint(1, 7)
if shuliang == 1:
pyautogui.typewrite(['今', '天', '给', '的', '御', '魂', '都', '很', '水','enter'], interval=0.2)
if shuliang == 2:
pyautogui.typewrite(['有', '点', '非', '啊', '今', '天', 'enter'], interval=0.2)
if shuliang == 3:
pyautogui.typewrite(['6', '6', '6', 'enter'], interval=0.2)
if shuliang == 4:
pyautogui.typewrite(['年', '年', '有', '余', 'enter'], interval=0.2)
if shuliang == 5:
pyautogui.typewrite(['应', '声', '虫', 'enter'], interval=0.2)
if shuliang == 6:
pyautogui.typewrite(['吸', '点', '欧', '气', 'enter'], interval=0.2)
if shuliang == 7:
pyautogui.typewrite(['牛', '牛', 'enter'], interval=0.2)
location_begin13 = pyautogui.locateCenterOnScreen('talk.png', confidence=0.7)
if location_begin13 is not None:
pyautogui.click(random.randint(location_begin14.x + 1, location_begin14.x - 1 ),
random.randint(location_begin14.y - 1, location_begin14.y + 1), clicks=1)
except pyautogui.ImageNotFoundException:
print("对话失败")
return end_one()
# 将 秒 转换为 时 分 秒
def seconds_to_time(seconds):
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
return ("%d:%02d:%02d" % (h, m, s))
if __name__ == '__main__':
pyautogui.FAILSAFE = True
print("欢迎使用本脚本!!!!")
print("请选择以下对应序号模式")
print("1、单人模式 2、组队模式")
while True:
pattern = int(input())
if (pattern == 1 or pattern == 2):
if pattern == 1:
print("*********************************")
print("已进入单人模式")
elif pattern == 2:
print("*********************************")
print("已进入组队模式")
break
else:
print("输入有误,请输入1或2:")
print("请输入脚本运行次数:")
print("输入-1表示无限循环")
times = int(input())
print("*********************************")
print("即将开始运行,请保证游戏画面存着于屏幕")
if pattern == 1:
auto_one(times)
elif pattern == 2:
auto_two(times)
鼠鼠我想提醒不要一下子刷太猛,场数逐日增加才不容易被鬼使黑制裁。建议在猛刷的前一天先在移动设备上手动刷一些,并且在战斗结算画面时,单击和双击混合。没有辅助是百分百防封的,有时候会很看运气。由于这个脚本是公开的,如果有鼠鼠想长期使用,建议是具备一定的代码基础对里面的一些数值进行修改,或者添加其他的行为来模仿真实玩家的操作。后续可能会加入模拟器后台运行也能被脚本正常识别 以及 不占用鼠标的功能。
如果有疑问欢迎来交流,代码质量一般请别介意。祝点赞的鼠鼠们早日出18速招财头。
作者:进程撕裂者