欢迎光临散文网 会员登陆 & 注册

英杰之塔 13层 168360pt python全自动凹分

2023-04-08 00:12 作者:君のいない景色  | 我要投稿

import CV2

import numpy as np

import pyautogui

import keyboard

import time

# 设置屏幕的监视区域

monitor1 = {"top": 807, "left": 470, "width": 65, "height": 45}

monitor2 = {"top": 638, "left": 811, "width": 47, "height": 2}

monitor3 = {"top": 870, "left": 1360, "width": 47, "height": 2}

monitor4 = {"top": 180, "left": 544, "width": 47, "height": 36}


cost1 = CV2.imread('cost1.png', CV2.IMREAD_GRAYSCALE)

cost2 = CV2.imread('cost2.png', CV2.IMREAD_GRAYSCALE)

cost3 = CV2.imread('cost3.png', CV2.IMREAD_GRAYSCALE)

cost4 = CV2.imread('cost4.png', CV2.IMREAD_GRAYSCALE)

cost5 = CV2.imread('cost5.png', CV2.IMREAD_GRAYSCALE)

cost6 = CV2.imread('cost6.png', CV2.IMREAD_GRAYSCALE)

cost7 = CV2.imread('cost7.png', CV2.IMREAD_GRAYSCALE)

cost8 = CV2.imread('cost8.png', CV2.IMREAD_GRAYSCALE)


life = CV2.imread('life.png', CV2.IMREAD_GRAYSCALE)


hpflag = 0

hpflag1 = 0

costflag5 = 0

costflag6 = 0


cost1flag = 0

cost2flag = 0

cost3flag = 0

cost4flag = 0

cost5flag = 0

cost6flag = 0

cost7flag = 0

cost8flag = 0


prev_yellow_pixel_count = 0


def skillactivate():

    pyautogui.mouseDown(x=1479, y=918,duration = 0.2)

    pyautogui.mouseUp()

    pyautogui.mouseDown(x=829, y=628)

    pyautogui.moveTo(1500, 230, duration=0.2)

    pyautogui.mouseUp()


while True:

    # 截取监视区域的屏幕图像

    screen = np.array(pyautogui.screenshot(region=(monitor1['left'], monitor1['top'], monitor1['width'], monitor1['height'])))

    hp = np.array(pyautogui.screenshot(region=(monitor2['left'], monitor2['top'], monitor2['width'], monitor2['height'])))

    skill = np.array(pyautogui.screenshot(region=(monitor3['left'], monitor3['top'], monitor3['width'], monitor3['height'])))

    lifepoint = np.array(pyautogui.screenshot(region=(monitor4['left'], monitor4['top'], monitor4['width'], monitor4['height'])))


    threshold = 0.80

    threshold70 = 0.75

    threshold85 = 0.85

    threshold90 = 0.95


    gray_screen = CV2.cvtColor(screen, CV2.COLOR_BGR2GRAY)

    gray_life = CV2.cvtColor(lifepoint, CV2.COLOR_BGR2GRAY)


    res1 = CV2.matchTemplate(gray_screen, cost1, CV2.TM_CCOEFF_NORMED)

    res2 = CV2.matchTemplate(gray_screen, cost2, CV2.TM_CCOEFF_NORMED)

    res3 = CV2.matchTemplate(gray_screen, cost3, CV2.TM_CCOEFF_NORMED)

    res4 = CV2.matchTemplate(gray_screen, cost4, CV2.TM_CCOEFF_NORMED)

    res5 = CV2.matchTemplate(gray_screen, cost5, CV2.TM_CCOEFF_NORMED)

    res6 = CV2.matchTemplate(gray_screen, cost6, CV2.TM_CCOEFF_NORMED)

    res7 = CV2.matchTemplate(gray_screen, cost7, CV2.TM_CCOEFF_NORMED)

    res8 = CV2.matchTemplate(gray_screen, cost8, CV2.TM_CCOEFF_NORMED)


    res9 = CV2.matchTemplate(gray_life, life, CV2.TM_CCOEFF_NORMED)



    loc1 = np.where(res1 >= threshold)

    loc2 = np.where(res2 >= threshold)

    loc3 = np.where(res3 >= threshold)

    loc4 = np.where(res4 >= threshold)

    loc5 = np.where(res5 >= threshold85)

    loc6 = np.where(res6 >= threshold)

    loc7 = np.where(res7 >= threshold90)

    loc8 = np.where(res8 >= threshold)

   

    loc9 = np.where(res9 >= threshold)



    yellow_pixels = np.where(np.all(hp == [128, 191, 0], axis=-1))

    yellow_pixel_count = len(yellow_pixels[0])

    threshold_red = 150

    red_pixels = np.where((skill[:,:,0] > threshold_red) & (skill[:,:,1] < threshold_red) & (skill[:,:,2] < threshold_red))


    if yellow_pixel_count != 0 and hpflag1 == 0:

        prev_yellow_pixel_count = 90

        hpflag1 = 1


    if yellow_pixel_count == 0 and hpflag1 == 1:

        prev_yellow_pixel_count = 90

        hpflag1 = 0



    if yellow_pixel_count < prev_yellow_pixel_count and hpflag1 == 1:

        # if hpflag == 0:

            pyautogui.mouseDown(x=1300, y=600, duration=0.2)

            pyautogui.mouseUp()

            pyautogui.mouseDown(x=551, y=906)

            pyautogui.moveTo(x=827, y=682, duration=0.2)

            pyautogui.mouseUp()

            pyautogui.mouseDown(x=829, y=628)

            pyautogui.moveTo(x=1500, y=230, duration=0.2)

            pyautogui.mouseUp()

            prev_yellow_pixel_count = yellow_pixel_count


    # 如果检测到模板图像,则模拟鼠标按下

    if len(loc1[0]) > 0 and cost1flag == 0:

        pyautogui.mouseDown(x=668, y=908)

        pyautogui.moveTo(x=827, y=682, duration=0.2)

        pyautogui.mouseUp()

        pyautogui.mouseDown(x=551, y=906)

        pyautogui.moveTo(x=827, y=682, duration=0.2)

        pyautogui.mouseUp()


        pyautogui.mouseDown(x=829, y=628)

        pyautogui.moveTo(1500, 230, duration=0.2)

        pyautogui.mouseUp()

        cost1flag = 1


    if len(loc2[0]) > 0 and cost2flag == 0:

        # time.sleep(1.5)

        skillactivate()

        cost2flag = 1


    if len(loc3[0]) > 0 and cost3flag == 0 and len(red_pixels[0]) > 0:

        # time.sleep(1.5)

        skillactivate()

        cost3flag = 1


    if len(loc4[0]) > 0 and cost4flag == 0 and len(red_pixels[0]) > 0:

        print("cost 142?")

        time.sleep(1.2)

        skillactivate()

        # CV2.imwrite('screen0.png', screen)

        cost4flag = 1


    if len(loc5[0]) > 0:

        costflag5 = 1


    if costflag5 == 1 and cost5flag == 0 and len(red_pixels[0]) > 0 and cost4flag == 1:

    # if cost4flag == 1 and cost5flag == 0 and len(red_pixels[0]) > 0:

        print("cost 180?")

        # time.sleep(1.5)

        skillactivate()

        CV2.imwrite('screen1.png', screen)

        cost5flag = 1


    if len(loc6[0]) > 0:

        costflag6 = 1


    if costflag6 == 1 and cost6flag == 0 and len(red_pixels[0]) > 0 and cost5flag == 1:

        print("cost 227?")

        skillactivate()

        # CV2.imwrite('screen2.png', screen)

        cost6flag = 1


    if len(loc7[0]) > 0 and cost7flag == 0 and len(red_pixels[0]) > 0:

        print("cost 285?")

        time.sleep(1.5)

        skillactivate()

        CV2.imwrite('screen2.png', screen)

        cost7flag = 1


    if len(loc8[0]) > 0 and cost8flag == 0 and len(red_pixels[0]) > 0:

        time.sleep(1.5)

        skillactivate()

        cost8flag = 1


    if len(loc9[0]) > 0:

        pyautogui.mouseDown(x=400, y=200,duration = 0.2)

        pyautogui.mouseUp()

        pyautogui.mouseDown(x=1000, y=500)

        pyautogui.mouseUp()

        hpflag = 0

        hpflag1 = 0

        cost1flag = 0

        cost2flag = 0

        cost3flag = 0

        cost4flag = 0

        cost5flag = 0

        cost6flag = 0

        cost7flag = 0

        cost8flag = 0

        costflag5 = 0

        costflag6 = 0

        prev_yellow_pixel_count = 0


    print(cost1flag, cost2flag, cost3flag, cost4flag, cost5flag, cost6flag, cost7flag, cost8flag)

    # if keyboard.is_pressed('f'):

    #     # 截取屏幕图像并保存到指定路径

    #     CV2.imwrite('screen.png', life)

    time.sleep(0.1)

屏幕大小1920×1080,浏览器缩放125%

几个cost点是12,55,93,142,180,227,285,341


英杰之塔 13层 168360pt python全自动凹分的评论 (共 条)

分享到微博请遵守国家法律