传奇广告查询第一站 同步54.com

defina脚本制作
原创 于2026-01-05 18:07:00发布
30 阅读
0
0

文章目录


前言

本脚本使用python来实现,先准备需要的库

import time import datetime import cv2 from matplotlib import pyplot as plt import pyautogui import tkinter as tk import threading import traceback from PIL import Image,ImageTk 

1.代码块

代码如下(示例):

class wakuang(): def __init__(self): self.caikuang = 'caikuang.png' self.zhencha = 'zhencha.png' self.zijin = 'zijin.png' self.lanjing = 'lanjing.png' self.dinong = 'dinong.png' self.gaonong = 'gaonong.png' self.lanjingkuang = 'lanjingkuang.png' self.confirm_button = 'confirm_button.png' self.myminers = 'myminers.png' self.protection = 'protection.png' self.zhiya = 'zhiya.png' self.queding = 'queding.png' self.tuichu = 'x.png' self.enemy = 'enemy.png' self.fanhui = 'fanhui.png' self.page1 = '1.png' self.drink = 'drink.png' self.usg = 'usg.png' self.backage = 'backage.png' self.minerinfo = 'minerinfo.png' self.zijinkuang = 'zijinkuang.png' self.gaononglanjingkuang = 'gaononglanjingkuang.png' self.dinonglanjingkuang = 'dinonglanjingkuang.png' self.break_program = False self.shouhuo = 'shouhuo.png' self.fail = 'fail.png' self.victory = 'victory.png' self.receive = 'receive.png' def read(self,picture): # 读入图片 big1.png是背景大图; small.png是需要寻找的小图(格式.jpg .png都行) img = cv2.imread("current.png",0) # 0 读入灰度图 img3 = cv2.imread("current.png",1) # 1 读入彩色图 img2 = img.copy() template = cv2.imread(picture,0) w, h = template.shape[::-1] # print(w,h) # 6种算法的列表 methods = 'cv2.TM_CCOEFF_NORMED' img = img2.copy() method = eval(methods) # 应用模板算法,返回一系列指标 res = cv2.matchTemplate(img,template,method) # 从res中挑选最优指标 min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) print(max_val) if max_val > 0.7: # 注意 TM_SQDIFF 或者 TM_SQDIFF_NORMED 算法使用最小值为最优 top_left = max_loc bottom_right = (top_left[0] + w/2, top_left[1] + h/2) # print(bottom_right) return bottom_right else: return None # 显示图片 # cv2.rectangle(img3,top_left, bottom_right, (0,0,255), 2) # 画出矩形框 # plt.axis('off') # 关闭坐标 # img3 = cv2.cvtColor(img3, cv2.COLOR_BGR2RGB) # 颜色转换 # plt.subplot(121),plt.imshow(res,cmap = 'gray') # plt.title('Matching Result'), plt.xticks([]), plt.yticks([]) # plt.subplot(122),plt.imshow(img3) # plt.title('Detected Point'), plt.xticks([]), plt.yticks([]) # plt.suptitle(meth) # plt.show() def compare(self,picture,current_png): # 读入图片 big1.png是背景大图; small.png是需要寻找的小图(格式.jpg .png都行) img = cv2.imread(current_png, 0) # 0 读入灰度图 img2 = img.copy() template = cv2.imread(picture, 0) methods = 'cv2.TM_CCOEFF_NORMED' img = img2.copy() method = eval(methods) # 应用模板算法,返回一系列指标 res = cv2.matchTemplate(img, template, method) # 从res中挑选最优指标 min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) return max_val def run(self,value,value1,value2): time.sleep(2) pyautogui.PAUSE = 0.5 pyautogui.FAILSAFE = True #进入游戏界面截图,点击采矿模式 current_screen = pyautogui.screenshot() current_screen.save('current.png') wakuang = self.read(picture=self.caikuang) if wakuang is not None: pyautogui.click(wakuang) time.sleep(1) else: print('找不到采矿按钮') list_pools = { 'zijin': '紫金矿', 'lanjing': '蓝晶矿', 'dinong': '低浓蓝晶矿', 'gaonong': '高浓蓝晶矿'} kuang = list(list_pools.keys())[list(list_pools.values()).index(value)] kuang = kuang + '.png' list_time = [] count = 0 while True: if self.break_program == True: print('停止运行') break try: # 点击侦查 time.sleep(1) if value2 == 1: self.protect(lenth=int(value1)) #质押收矿 self.miners(lenth=int(value1)) #选矿 self.selection(kuang=kuang) current_screen = pyautogui.screenshot() current_screen.save('current1.png') current_screen.save('current.png') enemy = self.read(picture=self.enemy) if enemy is not None: hero = (enemy[0] + 40, enemy[1] + 500) # print('hero location is {}'.format(hero)) hero_list = [hero] # 一组英雄 if value1 == '1': time.sleep(1) for i in range(6): hero = (hero[0] + 122, hero[1]) hero_list.append(hero) # print('hero list location is {} '.format(hero_list)) for hero in hero_list: pyautogui.click(hero) time.sleep(1) # 开始战斗 fighting = self.read(picture='fighting.png') pyautogui.click(fighting) time.sleep(1) #确认是否进入了战斗画面 current_screen = pyautogui.screenshot() current_screen.save('current2.png') compare_result1 = float(self.compare(picture='fighting.png',current_png='current2.png')) compare_result2 = float(self.compare(picture='fightingscreen.png',current_png='current2.png')) if compare_result1 < compare_result2: print('进入战斗画面') #等待战斗结束 time.sleep(30) while True: current_screen = pyautogui.screenshot() current_screen.save('current.png') victory = float(self.compare(picture=self.victory,current_png='current.png')) fail = float(self.compare(picture=self.fail,current_png='current.png')) if victory > fail and victory > 0.7: print('确认胜利') start = time.time() end = start + float(10800) print('开始计时') confirm_option = self.read(picture=self.confirm_button) pyautogui.click(confirm_option) time.sleep(1) break if fail > victory and fail > 0.7: print('确认攻击失败') confirm_option = self.read(picture=self.confirm_button) pyautogui.click(confirm_option) time.sleep(1) break else: current_screen = pyautogui.screenshot() current_screen.save('current.png') time.sleep(1) fanhui = self.read(picture=self.fanhui) pyautogui.click(fanhui) time.sleep(1) # 二组英雄 if value1 == '2': time.sleep(1) for i in range(8): hero = (hero[0] + 122, hero[1]) hero_list.append(hero) # print('hero list location is {} '.format(hero_list)) #分成两组英雄池 list1 = [] list2 = [] for index, value in enumerate(hero_list): if index % 2 == 0: list1.append(value) else: list2.append(value) for hero in list1: pyautogui.click(hero) time.sleep(1) for hero in list2: pyautogui.click(hero) time.sleep(1) # 开始战斗 fighting = self.read(picture='fighting.png') pyautogui.click(fighting) time.sleep(2) #是否进入战斗画面,比较图像得到的值 current_screen = pyautogui.screenshot() current_screen.save('current2.png') compare_result1 = float(self.compare(picture='fighting.png', current_png='current2.png')) compare_result2 = float(self.compare(picture='fightingscreen.png', current_png
                
管理员
0
0
0
分享
上一篇: 分享一个冰雪复古辅助多开脚本
下一篇: 八方向行走脚本
评论
历史记录
回顶部
浏览时间 游戏名称 游戏IP 开区网址
注册GM1论坛账号
  • 上传头像
注册

已有账号,

微信扫码登录
重置密码
重置密码

注册

绑定关联手机号
关联手机号