def find_hp():
    '''finds the location (pixels) of the health bar'''
    image = 'assets/life.png'
    img = cv2.imread(image, 0)
    img_w, img_h = img.shape[::-1]
    x_end, y_end = pyautogui.size()
    x_start = (x_end / 5) * 4
    screen_shot = imgS.region_grabber((x_start, 0, x_end, y_end))
    coords_relative = imgS.imagesearcharea(image,
                                           x_start,
                                           0,
                                           x_end,
                                           y_end,
                                           im=screen_shot)
    if coords_relative[0] is not -1:
        coords = [
            coords_relative[0] + x_start + img_w, coords_relative[1] + 5
        ]  #add back offset
        hp_start = utilities.find_pixel_color(COLOR_DICT['hp'], COLOR_DICT['hp_full'], 0,\
            coords[0], coords[1], x_end, y_end)
        if hp_start[0] is not -1:
            append_dict(START_COORDS_DICT, 'hp', hp_start)
            hp_end = utilities.find_pixel_color(COLOR_DICT['hp_end_bar'], COLOR_DICT['hp_full'], 0,\
                hp_start[0], hp_start[1], x_end, y_end)
            if hp_end[0] is not -1:
                append_dict(END_COORDS_DICT, 'hp', hp_end)
def has_targets(battlelist_coords):
    '''checks battlelist for monsters'''
    no_monster = "assets/battlelist/empty.png"
    monster = imgS.imagesearcharea(no_monster, battlelist_coords[0][0], battlelist_coords[0][1], \
            battlelist_coords[1][0], battlelist_coords[1][1], precision=0.8)
    if monster[1] is -1 or monster[1] > 40:
        return True
    return False
Example #3
0
def has_cd(img, x, y, im=None):
    img = 'assets/cds/{}.png'.format(img)
    no_cd = imgS.imagesearcharea(img, x, y, x + 50, y + 50, 0.7, im)
    if no_cd[0] is not -1:
        #it has no cd, return false
        return False
    else:
        return True
Example #4
0
def find_battlelist():
    battlelist_start = imgS.imagesearch('assets/battlelist/battlelist.png')
    if battlelist_start[0] is not -1:
        x2, y2 = pyautogui.size()
        battlelist_end = imgS.imagesearcharea(
            'assets/battlelist/minimize_close.png', battlelist_start[0],
            battlelist_start[1], x2, y2)
        if battlelist_end[0] is not -1:
            battlelist_end = (battlelist_end[0] + battlelist_start[0], y2
                              )  #relative to absolute
            return [battlelist_start, battlelist_end]
    return [-1, -1]
Example #5
0
def chase_on(title):
    '''turns chasing on'''
    image = "assets/chase_target.png"
    x, y = pyautogui.size()
    x_start = x / 10 * 9
    follow_mode = imgS.imagesearcharea(image, x_start, 0, x, y)
    print("on: ", follow_mode)
    if follow_mode[0] is not -1:
        print("chase is on")
        sendInput.send_click(follow_mode[0] + x_start, follow_mode[1] - 13,
                             title)
        time.sleep(0.5)
Example #6
0
def chase_off(title):
    '''turns chasing off'''
    image = "assets/stop_chase.png"
    x, y = pyautogui.size()
    x_start = x / 10 * 9
    follow_mode = imgS.imagesearcharea(image, x_start, 0, x, y)
    print("off: ", follow_mode)
    if follow_mode[0] is not -1:
        sendInput.send_click(follow_mode[0] + x_start, follow_mode[1] - 13,
                             title)
        print("chase is off")
        time.sleep(0.5)
Example #7
0
def wpt_reached(wpt_img, minimap_pos):
    '''check if we reached wpt'''
    middle = 50
    middle_start = (minimap_pos[0] + middle, minimap_pos[1] + middle)
    middle_end = (minimap_pos[2] - middle, minimap_pos[3] - middle)
    wpt = imgS.imagesearcharea("assets/map/" + wpt_img["mark"] + ".png",
                               middle_start[0], middle_start[1], middle_end[0],
                               middle_end[1], 0.7)
    if wpt[0] is not -1:
        return True
    print("havent reached wpt: ", wpt_img)
    return False
def find_status_bar():
    '''finds the status bar below equipment'''
    image = 'assets/statusbar/left_corner.png'
    img = cv2.imread(image, 0)
    img_w, img_h = img.shape[::-1]
    x2, y2 = pyautogui.size()
    x1 = int((x2 / 5) * 4)
    para_coords = imgS.imagesearcharea(image, x1, 0, x2, y2)
    if para_coords[0] is not -1:
        append_dict(STATUS_BAR_DICT, 'start',
                    [para_coords[0] + x1, para_coords[1] + int(img_h / 2)])
        append_dict(
            STATUS_BAR_DICT, 'end',
            [para_coords[0] + x1 + 100, para_coords[1] + int(img_h / 2) + 1])
def find_player_name(
        img_path, coords
):  #coords is array with tuples [(x_start, y_start), (x_end, y_end)]
    if os.path.isfile(img_path):
        # print(img_path, coords[0][0], coords[0][1], coords[1][0], coords[1][1])
        x, y = imgS.imagesearcharea(img_path, coords[0][0], coords[0][1],
                                    coords[1][0], coords[1][1])
        if x is not -1:
            return [(coords[0][0] + x, coords[0][1] + y),
                    (coords[1][0], coords[1][1])]
        else:
            return None
    else:
        print('There is no file "{0}" in assets/battlelist/friends/'.format(
            img_path))
        return [(-1, -1)]
Example #10
0
def go_wpt(wpt_img, minimap_pos, battlelist_coords, gui):
    '''click and move to wpt'''
    wpt = imgS.imagesearcharea("assets/map/" + wpt_img["mark"] + ".png",
                               minimap_pos[0], minimap_pos[1], minimap_pos[2],
                               minimap_pos[3], 0.7)
    if wpt[0] is not -1:
        target = targeting.has_targets(battlelist_coords)
        while target:
            print("killing something, sleeping")
            time.sleep(0.5)
            target = targeting.has_targets(battlelist_coords)
            if not target:
                # all targets dead, trigger looting
                looting.loot(gui)
        click_wpt(wpt_img, wpt, minimap_pos, gui.title)
        pressed = gui.checkButton_hk_bools['cavebot'].get()
        if not wpt_reached(wpt_img, minimap_pos) and pressed:
            go_wpt(wpt_img, minimap_pos, battlelist_coords, gui)
        else:
            if wpt_img["type"] != "stand":
                action_wpt(wpt_img, gui, minimap_pos, battlelist_coords)
    else:
        print("wpt not found: ", wpt_img)
def find_mp():
    '''finds the location (pixels) of the mana bar'''
    image = 'assets/mana.png'
    img = cv2.imread(image, 0)
    img_w, img_h = img.shape[::-1]
    x2, y2 = pyautogui.size()
    x1 = (x2 / 5) * 4
    im = imgS.region_grabber((x1, 0, x2, y2))
    coords_relative = imgS.imagesearcharea(image, x1, 0, x2, y2, im=im)
    if coords_relative[0] is not -1:
        coords = [coords_relative[0] + x1 + img_w,
                  coords_relative[1] + 5]  #add back offset
        mp_start = utilities.find_pixel_color(COLOR_DICT['mp'],
                                              COLOR_DICT['mp_full'], 0,
                                              coords[0], coords[1], x2,
                                              coords[1] + 1)
        if mp_start[0] is not -1:
            append_dict(START_COORDS_DICT, 'mp', mp_start)
            mp_end = utilities.find_pixel_color(COLOR_DICT['mp_end_bar'],
                                                COLOR_DICT['mp_full'], 0,
                                                mp_start[0], mp_start[1], x2,
                                                mp_start[1] + 1)
            if mp_end[0] is not -1:
                append_dict(END_COORDS_DICT, 'mp', mp_end)