【实战项目记录1】编写一个传奇3法师自动练级的python脚本

我基于pyautogui、tkinter以及几个标准库,结合面向对象的编程思路,从传奇3游戏的自动功能需求出发,研究了一个完整的法师练级打怪赚钱的小工具,给大家参考一下编程思路和一些实现想法。

闲来无事,在2022年上半年疫情封在家里,玩了一段时间的传奇3私服,估计这年头玩的没几个人了。

玩着玩着觉得练级枯燥了,打怪打钻都很枯燥,于是琢磨着想自动打怪,打好了还得自动捡装备,自动飞地图,装备满了还想自动去卖,卖完了再自动返回。于是就开始用python开始折腾了。

最后忘了迭代了多少个版本,终于可以稳定使用满足需求了,也发给了一起玩的几个哥们,省了他们的外挂月费。

疫情解封后就不玩游戏了,界面比较简单,代码写在下面,纯粹个人兴趣爱好。

  

#!/usr/bin/env python

# -*- coding:utf-8 -*-

# @Time      :2022-4-11 23:03

# @Author    :Mengxh

# @File      :mir3-07-3.py    更新绝情LV1挂机脚本,自动红包和福利店,UI版

from tkinter import *

import os
import pyautogui
import time
import datetime

import mir3_init
import mir3_is_enemy
import mir3_is_item
import mir3_pickup


def attack():
    while True:
        print('开始攻击f2法术')
        k = 1
        pyautogui.press('f2', interval=0.5)
        pyautogui.press('f2', interval=0.5)
        im_1 = pyautogui.locateOnScreen('./pics/menupng/kouxue.png', region=region_main,
                                        confidence=0.9)
        im_2 = pyautogui.locateOnScreen('./pics/menupng/kouxue.png', region=region_main,
                                        confidence=0.9)
        if im_1 or im_2:
            # print('打了有怪')
            pass
        else:
            # print('打了无怪')
            break


def hongbao():
    # pyautogui.click(role_x, role_y)
    # time.sleep(1)
    if window.poll:
        t = pyautogui.locateOnScreen('./pics/menupng/hongbao2.png', region=region_main, confidence=0.8)
        if t is not None:
            pos = pyautogui.center(t)
            pyautogui.doubleClick(pos.x, pos.y)
            time.sleep(0.5)
            s = pyautogui.locateOnScreen('./pics/menupng/num_7.png', region=region_main, confidence=0.8)
            if s is not None:
                pos1 = pyautogui.center(s)
                pyautogui.click(pos1.x, pos1.y)
                time.sleep(2.5)
                window.after(1000, hongbao)
    else:
        print("结束红包")
        window.poll = True
    print('hongbao:', window.poll)


def fulishop():
    pyautogui.click(role_x, role_y)
    time.sleep(1)
    if window.poll:
        # 点老头
        t = pyautogui.locateOnScreen('./pics/menupng/fucai1.png', region=region_main, confidence=0.8)
        if t is not None:
            pos = pyautogui.center(t)
            pyautogui.moveTo(pos.x, pos.y - 10)
            pyautogui.click()
            time.sleep(3)
        # 点页面上的格子
        t = pyautogui.locateOnScreen('./pics/menupng/fucai2.png', region=region_main, confidence=0.8)
        if t is not None:
            pos = pyautogui.center(t)
            pyautogui.click(pos.x, pos.y)
            time.sleep(1)
        else:
            # 点上一页
            print('当前页开完,点击上一页')
            t = pyautogui.locateOnScreen('./pics/menupng/fucai3.png', region=region_main, confidence=0.8)
            print(t)
            if t is not None:
                pos = pyautogui.center(t)
                print(pos)
                pyautogui.click(pos.x, pos.y)
            time.sleep(2)
            # 点页面上的格子
            t = pyautogui.locateOnScreen('./pics/menupng/fucai2.png', region=region_main, confidence=0.8)
            if t is not None:
                pos = pyautogui.center(t)
                pyautogui.click(pos.x, pos.y)
                time.sleep(1)
                window.after(1000, fulishop)

            else:
                print('钻石福利买完')
    else:
        print('点击停止')
        window.poll = True


def zuanshi():
    print('操作D菜单回收钻石')
    # pyautogui.click(role_x, role_y)
    # time.sleep(1)
    pyautogui.press('d')
    t = pyautogui.locateOnScreen('./pics/menupng/jinbi1.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)
    t = pyautogui.locateOnScreen('./pics/menupng/jinbi2.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)
    t = pyautogui.locateOnScreen('./pics/menupng/jinbi3.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)
    t = pyautogui.locateOnScreen('./pics/menupng/zuanshihuishou1.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)
    t = pyautogui.locateOnScreen('./pics/menupng/zuanshihuishou2.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)


def buymed(n):
    print('随身买药')
    # pyautogui.click(role_x, role_y)
    time.sleep(1)
    pyautogui.press('w')
    t = pyautogui.locateOnScreen('./pics/menupng/med.png', region=region_main, confidence=0.8)
    if t is not None:
        print('包裹还有药,不买')
        pyautogui.press('w')
        pass
    else:
        print('开始买药')
        pyautogui.press('d')
        t = pyautogui.locateOnScreen('./pics/menupng/suishen1.png', region=region_main, confidence=0.8)
        if t is not None:
            pos = pyautogui.center(t)
            pyautogui.click(pos.x, pos.y)

        t = pyautogui.locateOnScreen('./pics/menupng/suishen2.png', region=region_main, confidence=0.8)
        if t is not None:
            pos = pyautogui.center(t)
            pyautogui.click(pos.x, pos.y)
            pyautogui.typewrite(str(n))
            pyautogui.press('enter')

        t = pyautogui.locateOnScreen('./pics/menupng/suishen3.png', region=region_main, confidence=0.8)
        if t is not None:
            pos = pyautogui.center(t)
            pyautogui.click(pos.x, pos.y)


def repair():
    print('装备特修')
    # pyautogui.click(role_x, role_y)
    time.sleep(1)
    pyautogui.press('d')
    t = pyautogui.locateOnScreen('./pics/menupng/texiu1.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)

    t = pyautogui.locateOnScreen('./pics/menupng/texiu2.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)


def goto_lv1():
    # 点击神石
    t = pyautogui.locateOnScreen('./pics/locatepng/00shenshi.png', region=region_main, confidence=0.8)
    pos = pyautogui.center(t)
    pyautogui.moveTo(pos.x, pos.y - 10)
    # 点击神石
    pyautogui.click()
    t = pyautogui.locateOnScreen('./pics/locatepng/xueyuanlv1.png', region=region_main, confidence=0.8)
    pos = pyautogui.center(t)
    pyautogui.click(pos)
    time.sleep(1)
    t = pyautogui.locateOnScreen('./pics/locatepng/mapzoom.png', region=region_main, confidence=0.6)
    if t is None:
        pyautogui.press('v')
        t = pyautogui.locateOnScreen('./pics/locatepng/mapzoom.png', region=region_main, confidence=0.6)
    pos = pyautogui.center(t)
    pyautogui.click(pos)
    t = pyautogui.locateOnScreen('./pics/locatepng/jqgate.png', region=region_main, confidence=0.6)
    pos = pyautogui.center(t)
    print(pos)
    pyautogui.moveTo(pos.x - 2, pos.y + 4)
    pyautogui.doubleClick()

    while True:
        t = pyautogui.locateOnScreen('./pics/locatepng/jqdoor.png', region=region_main, confidence=0.6)
        if t is not None:
            break

    t = pyautogui.locateOnScreen('./pics/locatepng/mapzoom.png', region=region_main, confidence=0.6)
    if t is None:
        pyautogui.press('v')
        t = pyautogui.locateOnScreen('./pics/locatepng/mapzoom.png', region=region_main, confidence=0.6)
    pos = pyautogui.center(t)
    pyautogui.click(pos)

    while True:
        # print('靠近大门')
        t = pyautogui.locateOnScreen('./pics/locatepng/jqdoor.png', region=region_main, confidence=0.6)
        if t is not None:
            # print('判断大门坐标')
            pos = pyautogui.center(t)
            # 判断物品坐标与人物的相对方向,定义行走方向
            if pos.x < role_x - 13:
                x = l
            elif pos.x > role_x + 13:
                x = r
            else:
                x = role_x
            if pos.y <= role_y - 5:
                y = u
            elif pos.y >= role_y + 5:
                y = d
            else:
                y = role_y
            pyautogui.click(x=x, y=y, button='LEFT')
        else:
            pyautogui.click(x=x, y=y, button='LEFT')
            break
    time.sleep(1)
    pyautogui.press('v')


def auto_lv1():

    global i
    global p
    if window.poll:
        time.sleep(2)
        k = 0
        while mir3_is_enemy.is_enemy():
            # 发现有怪继续攻击
            while True:
                k = 1
                pyautogui.press('f2', interval=0.5)
                pyautogui.press('f2', interval=0.5)
                im_1 = pyautogui.locateOnScreen('./pics/menupng/kouxue.png', region=region_main,
                                                confidence=0.9)
                im_2 = pyautogui.locateOnScreen('./pics/menupng/kouxue.png', region=region_main,
                                                confidence=0.9)
                if im_1 or im_2:
                    # print('打了有怪')
                    pass
                else:
                    # print('打了无怪')
                    break

            if k == 1:
                # 2. 判断捡东西
                print('进入捡东西')
                # 获取东西坐标
                pos_list = mir3_is_item.multi_thread()
                if pos_list:
                    # 循环走到坐标点
                    for pos in pos_list:
                        mir3_pickup.pickup(pos)
                        p += 1
                        print('捡第%d个' % p)
                        if p > 25:
                            zuanshi()
                            p = 0

        # 定期修理装备
        if i % 300 == 0:
            repair()

            # 随身买药
        if i % 800 == 0:
            buymed(100)

        print('捡东西完成,瞬移')
        pyautogui.press('f5')

        print('i=', i, 'time = ', time.ctime())
        i += 1

        window.after(1000, auto_lv1)


def auto_jqboss():
    global i
    global p
    global jqboss_state
    global j
    if window.poll:
        if jqboss_state == 'active':
            print('i=', i, 'time = ', time.ctime())
            # 判断有怪
            print('判断是否有怪')
            if mir3_is_enemy.is_enemy():
                pyautogui.click(role_x, role_y)
                attack()
            # 获取东西坐标
            print('获取东西坐标列表')
            pos_list = mir3_is_item.multi_thread()

            if pos_list:
                if len(pos_list) > 10:
                    zuanshi()
                # 循环走到坐标点
                for pos in pos_list:
                    mir3_pickup.pickup(pos)
                    time.sleep(0.5)
                    p += 1
                    print('捡第%d个' % p)
                    if p % 8 == 0:
                        zuanshi()
                        if mir3_is_enemy.is_enemy():
                            attack()
                        break
            else:
                t1 = pyautogui.locateOnScreen(f'./pics/locatepng/jqcenter2.png', region=mir3_init.region_jq, confidence=0.6)
                if t1 is not None:
                    pos = pyautogui.center(t1)
                    if abs(pos.x - mir3_init.jq_pos[0]) > 2 or abs(pos.y - mir3_init.jq_pos[1]) > 2:
                        print('未在中心点区域,执行行走')
                        while True:
                            t1 = pyautogui.locateOnScreen(f'./pics/locatepng/jqcenter2.png', region=mir3_init.region_jq,
                                                          confidence=0.6)
                            if t1 is not None:
                                pos = pyautogui.center(t1)
                                print('pos:', pos)
                                if abs(pos.x - mir3_init.jq_pos[0]) > 2 or abs(pos.y - mir3_init.jq_pos[1]) > 2:
                                    print('执行移动')
                                    if pos.x < mir3_init.jq_pos[0]:
                                        x = l
                                    elif pos.x > mir3_init.jq_pos[0]:
                                        x = r
                                    else:
                                        x = role_x
                                    if pos.y < mir3_init.jq_pos[1] - 2:
                                        y = u
                                    elif pos.y > mir3_init.jq_pos[1] + 2:
                                        y = d
                                    else:
                                        y = role_y
                                    pyautogui.click(x=x, y=y)
                                    if mir3_is_enemy.is_enemy():
                                        print('向中心区域移动遇敌')
                                        attack()
                                        print('移动中遇敌攻击,中断移动')
                                        break
                                else:
                                    print('移到中心区域,等待')
                                    jqboss_state = 'wait'
                                    zuanshi()
                                    repair()
                                    buymed(500)
                                    break

                    else:
                        print('已在中心点区域,等待')
                        jqboss_state = 'wait'

            # 定期修理装备
            if i % 100 == 0:
                repair()

                # 随身买药
            if i % 300 == 0:
                buymed(200)

            i += 1

        if jqboss_state == 'wait':
            if mir3_is_enemy.is_enemy():
                print('遇敌攻击切换状态')
                attack()
                jqboss_state = 'active'
                j = 1
            else:
                print('\r等待刷怪',j,end='',flush=True)
                j+=1
                pass


        window.after(1000, auto_jqboss)


def buygjbs():
    print('购买攻击宝石')
    # m = int(input("输入要购买攻击宝石的次数,每次30个:"))
    m = int(pyautogui.prompt("输入要购买攻击宝石的次数,每次30个:"))
    pyautogui.click(role_x, role_y)
    time.sleep(1)
    pyautogui.press('d')
    t = pyautogui.locateOnScreen('./pics/menupng/suishen_zuanshi.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)

    t = pyautogui.locateOnScreen('./pics/menupng/zuanshi_teshu.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)

    t = pyautogui.locateOnScreen('./pics/menupng/teshu_qita.png', region=region_main, confidence=0.8)
    if t is not None:
        pos = pyautogui.center(t)
        pyautogui.click(pos.x, pos.y)

    for i in range(m):
        t = pyautogui.locateOnScreen('./pics/menupng/gongjibaoshi.png', region=region_main, confidence=0.8)
        if t is not None:
            pos = pyautogui.center(t)
            pyautogui.click(pos.x, pos.y)
            pyautogui.typewrite('30')
            pyautogui.press('enter')
            print(i + 1)


def pickup_only():
    global p
    if window.poll:
        pos_list = mir3_is_item.multi_thread()
        if pos_list:
            # 循环走到坐标点
            for pos in pos_list:
                mir3_pickup.pickup(pos)
                p += 1
                print('捡第%d个' % p)
                if p % 5 == 0:
                    break
                if p > 23:
                    zuanshi()
                    p = 0
                    break

        window.after(1000, pickup_only)


def backto_daoguan():
    pyautogui.click(role_x, role_y)
    time.sleep(1)
    pyautogui.press('1')
    t = pyautogui.locateOnScreen('./pics/locatepng/home_daoguan.png', region=region_main, confidence=0.8)
    pos = pyautogui.center(t)
    pyautogui.click(pos)
    time.sleep(1)
    pyautogui.click(ld, button=RIGHT)
    pyautogui.click(ld, button=RIGHT)
    pyautogui.click(ld, button=RIGHT)


def ten_boss():
    global p
    backto_daoguan()
    p = 0
    for n in range(8):
        # 判断boss是否被杀
        time.sleep(2)
        pyautogui.press('d')
        t = pyautogui.locateOnScreen('./pics/locatepng/bossquery.png', region=region_main, confidence=0.8)
        pos = pyautogui.center(t)
        pyautogui.click(pos)
        time.sleep(2)
        t = pyautogui.locateOnScreen(bosskilllist[n], region=region_main, confidence=0.8)
        if t is not None:
            print(f'第{n + 1}个boss已消灭')
            t1 = pyautogui.locateOnScreen('./pics/menupng/suishen3.png', region=region_main, confidence=0.8)
            pos = pyautogui.center(t1)
            pyautogui.click(pos)
            continue

        # 点击神石
        t = pyautogui.locateOnScreen('./pics/locatepng/00shenshi.png', region=region_main, confidence=0.8)
        pos = pyautogui.center(t)
        pyautogui.moveTo(pos.x, pos.y - 10)
        pyautogui.click()
        # 点击BOSS名字
        t = pyautogui.locateOnScreen(bossmaplist[n], region=region_main, confidence=0.8)
        pos = pyautogui.center(t)
        pyautogui.click(pos)

        # 进入BOSS房移动
        print('进入boss房移动')
        time.sleep(1)
        if n == 0:  # 沃玛教主
            print('进入沃玛教主房')
            while True:
                attack()
                pyautogui.click(rd, button='RIGHT')
                pyautogui.click(rd, button='RIGHT')
                pyautogui.click(rd, button='RIGHT')
                t = pyautogui.locateOnScreen('./pics/locatepng/tenbosspic/01.png', region=region_main, confidence=0.8)
                if t is not None:
                    print('结束移动')
                    break
        if n == 1:  # 触龙神
            attack()
            print('进入生死关')
            for i in range(6):
                pyautogui.click(r, role_y, button='RIGHT')
                attack()
            time.sleep(5)
        if n == 2:  # 野猪
            print('进入猪洞')
            while True:
                pyautogui.mouseDown(ru, button='RIGHT')
                time.sleep(2)
                pyautogui.click(ru, button='RIGHT')
                attack()
                t = pyautogui.locateOnScreen('./pics/locatepng/tenbosspic/03.png', region=region_main, confidence=0.8)
                t1 = pyautogui.locateOnScreen('./pics/locatepng/tenbosspic/03a.png', region=region_main, confidence=0.8)
                if t is not None:
                    pos = pyautogui.center(t)
                    if pos.x >= role_x:
                        pass
                    else:
                        print('结束移动')
                        pyautogui.click(button='RIGHT')
                        break
                if t1 is not None:
                    break
            time.sleep(1)
            pyautogui.click(rd, button='RIGHT')
            pyautogui.click(rd, button='RIGHT')
            pyautogui.click(rd, button='RIGHT')

        if n == 3:  # 赤月恶魔
            print('进入赤月恶魔')
            attack()
            pyautogui.click(ru, button='RIGHT')
            pyautogui.click(ru, button='RIGHT')
            pyautogui.click(ru, button='RIGHT')
            attack()
            pyautogui.click(r, role_y, button='RIGHT')
            pyautogui.click(r, role_y, button='RIGHT')

        if n == 4:  # 骷髅教主
            print('进入骷髅教主')
            attack()
            pyautogui.click(ld, button='RIGHT')
            pyautogui.click(ld, button='RIGHT')
            pyautogui.click(ld, button='RIGHT')

        if n == 5:  # 祖玛教主
            print('进入祖玛教主')
            attack()
            pyautogui.click(r, role_y, button='RIGHT')
            pyautogui.click(r, role_y, button='RIGHT')
            pyautogui.click(r, role_y, button='RIGHT')
            attack()
            pyautogui.click(rd, button='RIGHT')
            pyautogui.click(rd, button='RIGHT')
            attack()
            pyautogui.click(ru, button='RIGHT')
            pyautogui.click(ru, button='RIGHT')
            attack()
            time.sleep(3)

        if n == 6:  # 牛魔王
            print('进入牛魔王')
            while True:
                pyautogui.mouseDown(ld, button='RIGHT')
                time.sleep(1)
                pyautogui.click(ld, button='RIGHT')
                t = pyautogui.locateOnScreen('./pics/locatepng/tenbosspic/06a.png', region=region_main, confidence=0.8)
                if t is not None:
                    break
                attack()
                t1 = pyautogui.locateOnScreen('./pics/locatepng/tenbosspic/06b.png', region=region_main, confidence=0.8)
                if t1 is not None:
                    break

        if n == 7:  # 震天魔神
            print('进入震天魔神')
            for i in range(4):
                attack()
                pyautogui.click(lu, button='RIGHT')
                pyautogui.click(lu, button='RIGHT')

        # 开始攻击
        # 捡东西
        print('攻击后进入捡东西')
        # 获取东西坐标
        while True:
            attack()
            time.sleep(1)
            attack()
            pos_list = mir3_is_item.multi_thread()
            if pos_list:
                # 循环走到坐标点
                for pos in pos_list:
                    mir3_pickup.pickup(pos)
                    time.sleep(1)
                    p += 1
                    print('捡第%d个' % p)
                    if p > 10:
                        zuanshi()
                        p = 0
            else:
                break
        # 离开
        backto_daoguan()


def auto_lv1boss():
    global a
    global b

    global i
    global p

    if window.poll:
        time.sleep(2)
        k = 0
        while mir3_is_enemy.is_enemy():
            # 发现有怪继续攻击
            while True:
                k = 1
                pyautogui.press('f2', interval=0.5)
                pyautogui.press('f2', interval=0.5)
                im_1 = pyautogui.locateOnScreen('./pics/menupng/kouxue.png', region=region_main,
                                                confidence=0.9)
                im_2 = pyautogui.locateOnScreen('./pics/menupng/kouxue.png', region=region_main,
                                                confidence=0.9)
                if im_1 or im_2:
                    # print('打了有怪')
                    pass
                else:
                    # print('打了无怪')
                    break

            if k == 1:
                # 2. 判断捡东西
                print('进入捡东西')
                # 获取东西坐标
                pos_list = mir3_is_item.multi_thread()
                if pos_list:
                    # 循环走到坐标点
                    for pos in pos_list:
                        mir3_pickup.pickup(pos)
                        p += 1
                        print('捡第%d个' % p)
                        if p > 30:
                            zuanshi()
                            p = 0


        # 定期修理装备
        if i % 300 == 0:
            repair()

            # 随身买药
        if i % 800 == 0:
            buymed(100)

        print('捡东西完成,瞬移')
        pyautogui.press('f5')

        print('i=', i, 'time = ', time.ctime())
        i += 1

        if time.localtime()[3] == a:
            zuanshi()
            repair()
            ten_boss()
            goto_lv1()
            a = 25
        if time.localtime()[3] == b:
            zuanshi()
            repair()
            ten_boss()
            goto_lv1()
            b = 25

        window.after(1000, auto_lv1boss)


def neice_tool():
    input('打开内测管理者,点击[其他物品]')
    choice = int(input('选择要领取的东西:1.高级改造卡,2.高级神石,3.天地之锤,4.魔晶石:'))
    m = int(int(input("输入要的个数:"))/2)
    time.sleep(1)
    # pyautogui.click(role_x, role_y)
    if choice == 1:
        item = 'gaogai.png'
    elif choice == 2:
        item = 'gaoshen.png'
    elif choice == 3:
        item = 'tiandi.png'
    elif choice == 4:
        item = 'mojing.png'
    else:
        pyautogui.alert(f'输入错误!')
        item = ''
    if item:
        for i in range(m):
            t = pyautogui.locateOnScreen(f'./pics/menupng/{item}', region=region_main, confidence=0.8)
            if t is not None:
                pos = pyautogui.center(t)
                pyautogui.click(pos.x, pos.y)
                pyautogui.typewrite('2')
                pyautogui.press('enter')
                print(m-i)
        pyautogui.alert(f'{m*2}个{item}兑换成功!')


def upgrade_weapon():
    for i in range(41):
        t = pyautogui.locateOnScreen(f'./pics/menupng/chaomax.png', region=region_main, confidence=0.8)
        if t is not None:
            pos = pyautogui.center(t)
            pyautogui.click(pos.x, pos.y)
            pyautogui.click(pos.x, pos.y)
            t = pyautogui.locateOnScreen(f'./pics/menupng/chaomax_re.png', region=region_main, confidence=0.8)
            if t is not None:
                pos = pyautogui.center(t)
                pyautogui.click(pos.x, pos.y)


def stop():
    global tt
    print('time = ', datetime.timedelta(seconds=(time.time() - tt)))
    window.poll = False
    b10.config(state=DISABLED)
    print('stop:', window.poll)


def reset_poll():
    window.poll = True
    global a
    global b
    global i
    global p
    global tt
    global j
    global jqboss_state
    tt = time.time()
    i = 1
    p = 0
    a = 4
    b = 7
    j = 1
    jqboss_state = 'active'
    print('reset poll True')
    b10.config(state=ACTIVE)


def shutdown():
    n = int(pyautogui.prompt('输入多少时间(分钟)后关机'))
    n = n * 60
    os.system('shutdown -s -t %d' %n)
    pyautogui.alert(f'将于{n}秒自动关机')


if __name__ == '__main__':
    print('窗口初始化')

    region_main = mir3_init.region_main  # 游戏主画面范围
    # 定义逐点行走方向和鼠标左右键
    l = mir3_init.l  # x = 100左
    r = mir3_init.r  # x = 900右
    u = mir3_init.u  # y = 150上
    d = mir3_init.d  # y = 550下
    role_x = mir3_init.role_x  # 人物中心点x坐标
    role_y = mir3_init.role_y  # 人物中心点y坐标
    lu = (l, u)  # 左上
    ld = (l, d)  # 左下
    ru = (r, u)  # 右上
    rd = (r, d)  # 右下
    move_list_u = [lu, ru]
    move_list_d = [ld, rd]
    move_list = move_list_d + move_list_u

    # 装备图库载入列表
    itemlist = []
    for root, dirs, files in os.walk("./pics/pickup", topdown=False):
        for name in files:
            itemlist.append(os.path.join(root, name))

    bosskilllist = []
    for i in range(1, 9):
        bosskilllist.append(f'./pics/locatepng/bossiskill/0{i}.png')

    bossmaplist = []
    for i in range(1, 9):
        bossmaplist.append(f'./pics/locatepng/tenbosspic/00{i}.png')

    pyautogui.FAILSAFE = True
    pyautogui.PAUSE = 1
    window = Tk()
    window.title('传奇3小工具——made by mxh')
    window.geometry('490x90+1200+700')
    window.resizable(0,0)


    # 定义按钮
    b1 = Button(
        window,
        text='打开红包',
        width=10,
        height=1,
        command=hongbao
    )
    b1.grid(row=0, column=0)

    b2 = Button(
        window,
        text='钻石福利',
        width=10,
        height=1,
        command=fulishop
    )
    b2.grid(row=0, column=1)

    b3 = Button(
        window,
        text='买攻击宝石',
        width=10,
        height=1,
        command=buygjbs
    )
    b3.grid(row=0, column=2)

    b4 = Button(
        window,
        text='lv1挂机',
        width=10,
        height=1,
        command=auto_lv1
    )
    b4.grid(row=1, column=0)

    b5 = Button(
        window,
        text='jqboss挂机',
        width=10,
        height=1,
        command=auto_jqboss
    )
    b5.grid(row=1, column=1)

    b6 = Button(
        window,
        text='挂机+10boss',
        width=10,
        height=1,
        command=auto_lv1boss
    )
    b6.grid(row=1, column=2)

    b7 = Button(
        window,
        text='10个boss',
        width=10,
        height=1,
        command=ten_boss
    )
    b7.grid(row=2, column=0)

    b8 = Button(
        window,
        text='前往雪原1',
        width=10,
        height=1,
        command=goto_lv1
    )
    b8.grid(row=2, column=1)

    # b8 = Button(
    #     window,
    #     text='超MAX武器',
    #     width=10,
    #     height=1,
    #     command=upgrade_weapon
    # )
    # b8.grid(row=2, column=1)

    b9 = Button(
        window,
        text='自动关机',
        width=10,
        height=1,
        command=shutdown
    )
    b9.grid(row=2, column=3)

    # b9 = Button(
    #     window,
    #     text='返回道馆',
    #     width=10,
    #     height=1,
    #     command=backto_daoguan
    # )
    # b9.grid(row=2, column=2)

    # b9 = Button(
    #     window,
    #     text='内测兑换',
    #     width=10,
    #     height=1,
    #     command=neice_tool
    # )
    # b9.grid(row=2, column=2)

    b10 = Button(
        window,
        text='停止脚本',
        width=10,
        height=1,
        command=stop,
    )
    b10.grid(row=0, column=3)

    b11 = Button(
        window,
        text='RESET',
        width=10,
        height=1,
        command=reset_poll
    )
    b11.grid(row=1, column=3)

    b12 = Button(
        window,
        text='捡装备',
        width=10,
        height=1,
        command=pickup_only
    )
    b12.grid(row=2, column=2)

    reset_poll()


    window.mainloop()

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值