def queueing(again): global is_in_menu queue_start_time = datetime.now() try: pos = s.locate_center_on_screen('/friends.png', .85) settings.safe_point = pos[0], pos[1] except TypeError: pass m.move_to(settings.safe_point[0], settings.safe_point[1], .1) if again: needed_pic = "/match_found_again.png" else: needed_pic = "/match_found.png" while True: try: x, y, w, h = s.locate_on_screen(needed_pic, .8) print(Fore.LIGHTGREEN_EX + "Found!" + Fore.WHITE, end='') stats.show_current_time() is_in_menu = False stats.time_searching += datetime.now() - queue_start_time break except TypeError: time.sleep(settings.checks_refresh_rate)
def check_rewards(): try: x, y, w, h = s.locate_on_screen('/rewards.png', .65) k.press_button('esc') print(Fore.LIGHTGREEN_EX + "Rewards acquired" + Fore.WHITE) except TypeError: try: x, y, w, h = s.locate_on_screen('/rewards_1.png', .65) k.press_button('esc') print(Fore.LIGHTGREEN_EX + "Rewards acquired" + Fore.WHITE) except TypeError: try: x, y, w, h = s.locate_on_screen('/rewards.png', .6) k.press_button('esc') print(Fore.LIGHTGREEN_EX + "Rewards acquired" + Fore.WHITE) except TypeError: try: x, y, w, h = s.locate_on_screen('/rewards_1.png', .6) k.press_button('esc') print(Fore.LIGHTGREEN_EX + "Rewards acquired" + Fore.WHITE) except TypeError: pass
def check_for(pic, conf, region, message=None, func=None, args=None): try: x, y, w, h = s.locate_on_screen(pic, conf, region) if message is not None: print(Fore.LIGHTGREEN_EX + message + Fore.WHITE) stats.time_in_match += datetime.now() - match_start_time if args is None: func() else: func(*args) except TypeError: pass
def click_on(pic, confidence, message, region, speed=None, amount_of_clicks=None): x, y, w, h = s.locate_on_screen(pic, confidence, region) if amount_of_clicks is None: m.click_on_area(x, y, w, h, speed) else: for i in range(amount_of_clicks): m.click_on_area(x, y, w, h, speed) print(Fore.LIGHTGREEN_EX + message + Fore.WHITE)
def launch(): run_command_line('cmd') print(Fore.YELLOW + "Launching Valorant" + Fore.WHITE) pyautogui.write(settings.valorant_location) time.sleep(settings.system_animations_time) pyautogui.press('enter') exit_command_line() time.sleep(10) check_update() time.sleep(settings.average_valorant_load_time) # so Valorant window will be focused in case any shit happened m.click_on_center(settings.safe_point[0], settings.safe_point[1]) while True: # Valorant launched into an error try: x, y, w, h = screen.locate_on_screen('/val51.png', .75) m.click_on_area(x, y, w, h) time.sleep(settings.average_valorant_closing_time) launch() break except TypeError: pass print(Fore.YELLOW + "Waiting for Valorant to launch..." + Fore.WHITE) # Valorant launched to the match try: x, y, w, h = screen.locate_on_screen('/hundred_hp.png', .75) screen.shot('../resources/temp/control_picture_1.png', x, y, w, h) if pyautogui.pixelMatchesColor(int(x + w - 3), int(y + h / 2), colors.almost_white, tolerance=4): print(Fore.LIGHTGREEN_EX + "\nLaunched successfully into the match" + Fore.WHITE) settings.first_game = False settings.was_relaunched_after_error = True settings.valorant_is_opened = True stats.time_handling_errors += datetime.now( ) - ingame_error.error_handling_start_time if menu.is_in_menu: # menu -> relaunch -> match gameplay.is_in_match = True gameplay.simulate(False) menu.press_play_again() time.sleep(1) menu.check_rewards() else: # match -> relaunch -> match gameplay.simulate(False) break except TypeError: pass # Valorant launched to the main menu try: x, y, w, h = screen.locate_on_screen('/game_launched.png', .7) screen.shot('../resources/temp/control_picture_1.png', x, y, w, h) if colors.compare_colors(colors.list_for_game_launch, '../resources/temp/control_picture_1.png', tolerance=3): print(Fore.LIGHTGREEN_EX + "\nLaunched successfully into the menu\n" + Fore.WHITE) settings.first_game = True settings.valorant_is_opened = True stats.time_handling_errors += datetime.now( ) - ingame_error.error_handling_start_time if menu.is_in_menu: # menu -> relaunch -> menu menu.press_play() time.sleep(.3) menu.select_game_mode() menu.close_lobby() menu.start_search() else: # match -> relaunch -> menu menu.start_game() break except TypeError: pass time.sleep(settings.checks_refresh_rate + 1.5)