Esempio n. 1
0
def findWine():
    ######### find wine only in tabel!!! to make ti work better##########
    ps, psx, psy = RS.getPlayingScreen()

    lower = np.array([0,4,117])
    upper = np.array([16,22,182])

    mask = cv2.inRange(ps, lower, upper)

    # removes left side of stall
    w, h = mask.shape
    cv2.rectangle(mask,(0,0),(w,h),(0,0,0),-1)

    _, contours, _  = cv2.findContours(mask.copy(), 1, 2)
    # find biggest area
    biggest_area = 0
    for cnt in contours:
        if cv2.contourArea(cnt) > biggest_area:
            biggest_area = cv2.contourArea(cnt)

    # click on bnding rectangle of biggest area
    for cnt in contours:
        if cv2.contourArea(cnt) == biggest_area and biggest_area > 100:
            x,y,w,h = cv2.boundingRect(cnt)
            #cv2.rectangle(mask, (x,y), (x+w, y+h), (255,255,255), -1)
            x = x + psx
            y = y + psy

            Mouse.moveClick(x,y,1)
            return
Esempio n. 2
0
def find_ham_guard():
    import random
    try:
        ps, psx, psy = RS.getPlayingScreen()

        lower_pink = np.array([154, 0, 0])
        upper_pink = np.array([160, 255, 255])

        mask = cv2.inRange(ps, lower_pink, upper_pink)

        _, contours, _ = cv2.findContours(mask.copy(), 1, 2)

        for cnt in contours:
            if cv2.contourArea(cnt) <= 1:
                continue
            #print("Area: {}".format(cv2.contourArea(cnt)))
            M = cv2.moments(cnt)
            cx = int(M['m10'] / M['m00'])
            cy = int(M['m01'] / M['m00'])

            cx += psx
            cy += psy

            cx += random.randint(-20, 20)
            cy += random.randint(-20, 20)

            # Find bouding box coords

            Mouse.moveClick(cx, cy, 3)
            break

        RS.findOptionClick(cx, cy, 'pickpocket')
    except Exception as e:
        print(e)
Esempio n. 3
0
def find_ham_guard():
    import random
    try:
        ps, psx, psy = RS.getPlayingScreen()

        lower_pink = np.array([154,0,0])
        upper_pink = np.array([160,255,255])

        mask = cv2.inRange(ps, lower_pink, upper_pink)


        _, contours, _ = cv2.findContours(mask.copy(), 1,2)

        for cnt in contours:
            if cv2.contourArea(cnt) <= 1:
                continue
            #print("Area: {}".format(cv2.contourArea(cnt)))
            M = cv2.moments(cnt)
            cx = int(M['m10']/M['m00'])
            cy = int(M['m01']/M['m00'])

            cx += psx
            cy += psy

            cx += random.randint(-20,20)
            cy += random.randint(-20,20)

            # Find bouding box coords

            Mouse.moveClick(cx,cy, 3)
            break

        RS.findOptionClick(cx,cy, 'pickpocket')
    except Exception as e:
        print(e)
Esempio n. 4
0
def find_mine():
    global mine_this
    mines = {
        'tin1': ([0, 13, 104], [3, 73, 148]),
        'tin': ([0, 19, 121], [1, 30, 136]),
        'cooper': ([14, 135, 88], [15, 140, 169]),
        'iron': ([7, 138, 50], [10, 146, 85]),
        'gems': ([150, 223, 61], [151, 235, 169])
    }

    play_window, psx, psy = RS.getPlayingScreen()

    #mask = cv2.inRange(play_window, np.array(mines['tin'][0]), np.array(mines['tin'][1]))
    #mask = cv2.inRange(play_window, np.array(mines['cooper'][0]), np.array(mines['cooper'][1]))
    mask = cv2.inRange(play_window, np.array(mines[mine_this][0]),
                       np.array(mines[mine_this][1]))

    kernel = np.ones((20, 20), np.uint8)
    closing = cv2.morphologyEx(mask.copy(), cv2.MORPH_CLOSE, kernel)

    _, contours, _ = cv2.findContours(closing.copy(), 1, 2)
    # adds white rectangle around the mines
    for con in contours:
        x, y, w, h = cv2.boundingRect(con)
        cv2.rectangle(closing, (x, y), (x + w, y + h), (255, 255, 255), -1)
    #cv2.imshow('closing', closing)
    #cv2.waitKey(0)

    # finds mine mounts
    _, contours, _ = cv2.findContours(closing.copy(), 1, 2)
    mine_areas = {}
    for con in contours:
        #print("\n###############################")
        #print(cv2.contourArea(con))
        if cv2.contourArea(con) > 500:
            #print(cv2.contourArea(con))
            M = cv2.moments(con)
            cx = int(M['m10'] / M['m00'])
            cy = int(M['m01'] / M['m00'])
            # adds areas to dictionary to call next
            mine_areas[cv2.contourArea(con)] = (cx, cy)

    try:
        # gets random mine from mine areas
        random_mine = random.choice(mine_areas.keys())
    except Exception as e:
        #print(e)
        random_mine = mine_areas[mine_areas.keys()[0]]
    #print(random_mine)
    mine_center_x, mine_center_y = mine_areas[random_mine]
    # combine coords with playscreen to make relative
    mine_center_x += psx
    mine_center_y += psy

    # adds randomness to coords
    mine_center_x += random.randint(-11, 11)
    mine_center_y += random.randint(-11, 11)

    Mouse.moveClick(mine_center_x, mine_center_y, 1)
Esempio n. 5
0
def find_mine():
    global mine_this
    mines = {
        'tin1':([0,13,104],[3,73,148]),
        'tin':([0,19,121],[1,30,136]),
        'cooper':([14,135,88],[15,140,169]),
        'iron':([7,138,50],[10,146,85]),
        'gems':([150,223,61],[151,235,169])
    }

    play_window,psx,psy = RS.getPlayingScreen()

    #mask = cv2.inRange(play_window, np.array(mines['tin'][0]), np.array(mines['tin'][1]))
    #mask = cv2.inRange(play_window, np.array(mines['cooper'][0]), np.array(mines['cooper'][1]))
    mask = cv2.inRange(play_window, np.array(mines[mine_this][0]), np.array(mines[mine_this][1]))

    kernel = np.ones((20,20), np.uint8)
    closing  =  cv2.morphologyEx(mask.copy(), cv2.MORPH_CLOSE, kernel)

    _,contours,_ = cv2.findContours(closing.copy(), 1, 2)
    # adds white rectangle around the mines
    for con in contours:
        x,y,w,h = cv2.boundingRect(con)
        cv2.rectangle(closing,(x,y),(x+w,y+h),(255,255,255),-1)
    #cv2.imshow('closing', closing)
    #cv2.waitKey(0)

    # finds mine mounts
    _,contours,_ = cv2.findContours(closing.copy(), 1, 2)
    mine_areas = {}
    for con in contours:
        #print("\n###############################")
        #print(cv2.contourArea(con))
        if cv2.contourArea(con) > 500:
            #print(cv2.contourArea(con))
            M = cv2.moments(con)
            cx = int(M['m10']/M['m00'])
            cy = int(M['m01']/M['m00'])
            # adds areas to dictionary to call next
            mine_areas[cv2.contourArea(con)] = (cx,cy)

    try:
        # gets random mine from mine areas
        random_mine = random.choice(mine_areas.keys())
    except Exception as e:
        #print(e)
        random_mine = mine_areas[mine_areas.keys()[0]]
    #print(random_mine)
    mine_center_x, mine_center_y = mine_areas[random_mine]
    # combine coords with playscreen to make relative
    mine_center_x += psx 
    mine_center_y += psy

    # adds randomness to coords
    mine_center_x += random.randint(-11,11)
    mine_center_y += random.randint(-11,11)

    Mouse.moveClick(mine_center_x, mine_center_y,1)
Esempio n. 6
0
def find_motherload_mine():
    """Returns mine's location x, and y coords"""
    play_img, psx, psy = RS.getPlayingScreen()

    mines = {
        0: (np.array([0, 0, 153]), np.array([8, 25, 209])),
        1: (np.array([0, 0, 72]), np.array([2, 25, 144]))
    }

    for mine_key in mines.keys():
        #print("Mine: {}".format(mine_key))
        lower = mines[mine_key][0]
        upper = mines[mine_key][1]

        mask = cv2.inRange(play_img, lower, upper)

        kernel = np.ones((10, 10), np.uint8)

        closing = cv2.morphologyEx(mask.copy(), cv2.MORPH_CLOSE, kernel)

        #cv2.imshow('mask', mask)
        #cv2.imshow('closing', closing)
        #cv2.waitKey(0)

        _, contours, _ = cv2.findContours(mask.copy(), cv2.RETR_TREE,
                                          cv2.CHAIN_APPROX_SIMPLE)
        if contours[0].any():
            pass
        else:
            print('didnt find contours')
            break

        for con in contours[::-1]:
            M = cv2.moments(con)
            if cv2.contourArea(con) > 20:
                # Shows the mask

                #centroid from img moments
                cx = int(M['m10'] / M['m00'])
                cy = int(M['m01'] / M['m00'])

                #combine psx,psy coords with centroid coords from above
                cx += psx
                cy += psy

                #print("Area:",cv2.contourArea(con))
                #print(con[0][0][0],con[0][0][1])
                Mouse.moveClick(cx, cy, 1)
                return cx, cy
            else:
                continue
Esempio n. 7
0
def find_yellow_birds():
    ps, psx, psy = RS.getPlayingScreen()

    lower_pink = np.array([28, 197, 168])
    upper_pink = np.array([29, 234, 239])

    mask = cv2.inRange(ps, lower_pink, upper_pink)

    #cv2.imshow('img', mask)
    #cv2.waitKey(0)

    _, contours, _ = cv2.findContours(mask, 1, 2)

    # returns true if birds found
    for cnt in contours:
        if cv2.contourArea(cnt) > 0:
            return 1
Esempio n. 8
0
def find_yellow_birds():
    ps, psx, psy = RS.getPlayingScreen()

    lower_pink = np.array([28,197,168])
    upper_pink = np.array([29,234,239])

    mask = cv2.inRange(ps, lower_pink, upper_pink)

    #cv2.imshow('img', mask)
    #cv2.waitKey(0)

    _, contours, _ = cv2.findContours(mask, 1,2)

    # returns true if birds found 
    for cnt in contours:
        if cv2.contourArea(cnt) > 0:
            return 1