diff --git a/README.md b/README.md index 507fc10..466a2f5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # -Simple Pixelbot for Diablo 2 Resurrected written in python and opencv. Obviously only use it in offline mode as it is against the TOS of Blizzard to use it online! +Simple Pixelbot for Diablo 2 Resurrected single player written in python and opencv. Botty does not work for online games and is not intended for this usage! [**Download here**](https://github.com/aeon0/botty/releases). Got to have a [**Discord**](https://discord.gg/Jf3J8cuXWg) nowadays I guess :man_shrugging: diff --git a/game.ini b/game.ini index a38dea5..3ed20fa 100644 --- a/game.ini +++ b/game.ini @@ -23,10 +23,8 @@ center_x=960 center_y=540 ; some distance skill_bar_height=100 -; game creation / ending buttons -play_x_online=800 -play_x_offline=960 -play_y=970 +go_x=960 +go_y=970 normal_x=960 normal_y=456 nightmare_x=960 @@ -98,8 +96,7 @@ reached_node_dist=150 ; all rois are in [left, top, width, height] format is_overburdened=17,765,470,90 save_and_exit=750,350,410,260 -play_btn_online=640,920,320,100 -play_btn_offline=800,940,320,100 +go_btn=800,940,320,100 normal_btn=840,420,245,70 nightmare_btn=840,490,245,70 hell_btn=840,550,245,70 @@ -116,6 +113,7 @@ inventory=1290,515,591,247 vendor_stash=44,126,600,600 skill_right=996,1010,62,62 hero_selection_logo=0,0,550,830 +play_btn=640,920,320,100 [path] pindle_save_dist=1382,53, 1685,105, 1440,132 diff --git a/src/ui_manager.py b/src/ui_manager.py index 819d088..e004890 100644 --- a/src/ui_manager.py +++ b/src/ui_manager.py @@ -136,25 +136,26 @@ class UiManager(): while 1: img = self._screen.grab() # search offline btn - found_off, _ = self._template_finder.search("PLAY_BTN", img, roi=self._config.ui_roi["play_btn_offline"], threshold=0.8) - # search online btn with enabled and disabled version - found_on, _ = self._template_finder.search("PLAY_BTN", img, roi=self._config.ui_roi["play_btn_online"], threshold=0.8) + found_btn, _ = self._template_finder.search("PLAY_BTN", img, roi=self._config.ui_roi["go_btn"], threshold=0.8) score_enabled = self._template_finder.last_score - self._template_finder.search("PLAY_BTN_GRAY", img, roi=self._config.ui_roi["play_btn_online"], threshold=0.8) + self._template_finder.search("PLAY_BTN_GRAY", img, roi=self._config.ui_roi["go_btn"], threshold=0.8) score_disabled = self._template_finder.last_score - found_on = found_on and score_enabled > score_disabled - if found_off or found_on: - x_s = self._config.ui_pos["play_x_offline"] if found_off else self._config.ui_pos["play_x_online"] - pos = [x_s, self._config.ui_pos["play_y"]] + found_btn = found_btn and score_enabled > score_disabled + if found_btn: + x_s = self._config.ui_pos["go_x"] + pos = [x_s, self._config.ui_pos["go_y"]] x, y = self._screen.convert_screen_to_monitor(pos) - mode_info = "offline" if found_off else "online" - Logger.debug(f"Found Play Btn ({mode_info}) -> clicking it") - if mode_info == "online": - Logger.warning("You are creating a game in online mode!") + Logger.debug(f"Found Play Btn") mouse.move(x, y, randomize=[50, 9], delay_factor=[1.0, 1.8]) wait(0.1, 0.15) mouse.click(button="left") break + else: + # Might be in online mode? + found_btn, _ = self._template_finder.search("PLAY_BTN", img, roi=self._config.ui_roi["play_btn"], threshold=0.8) + if found_btn: + Logger.error("Botty only works for single player. Please switch to offline mode!") + os._exit(1) time.sleep(3.0) difficulty=self._config.general["difficulty"].lower() @@ -405,10 +406,11 @@ if __name__ == "__main__": import keyboard keyboard.add_hotkey('f12', lambda: Logger.info('Force Exit (f12)') or os._exit(1)) keyboard.wait("f11") + print("Start") from config import Config config = Config() screen = Screen(config.general["monitor"]) template_finder = TemplateFinder(screen) item_finder = ItemFinder() ui_manager = UiManager(screen, template_finder) - ui_manager.stash_all_items(5, item_finder) + ui_manager.start_game()