diff --git a/src/bot.py b/src/bot.py index da7a12c..ac10293 100644 --- a/src/bot.py +++ b/src/bot.py @@ -68,9 +68,9 @@ class Bot: elif self._config.char["type"] == "necro": self._char: IChar = Necro(self._config.necro, self._config.char, self._screen, self._template_finder, self._ui_manager, self._pather) elif self._config.char["type"] == "basic": - self._char: IChar = Basic(self._config.basic, self._config.char, self._screen, self._template_finder, self._ui_manager, self._pather) + self._char: IChar = Basic(self._config.basic, self._config.char, self._screen, self._template_finder, self._ui_manager, self._pather) elif self._config.char["type"] == "basic_ranged": - self._char: IChar = Basic_Ranged(self._config.basic, self._config.char, self._screen, self._template_finder, self._ui_manager, self._pather) + self._char: IChar = Basic_Ranged(self._config.basic_ranged, self._config.char, self._screen, self._template_finder, self._ui_manager, self._pather) else: Logger.error(f'{self._config.char["type"]} is not supported! Closing down bot.') os._exit(1) diff --git a/src/config.py b/src/config.py index 1c8b95c..2c888ae 100644 --- a/src/config.py +++ b/src/config.py @@ -157,16 +157,16 @@ class Config: self.barbarian = self._config["barbarian"] if "barbarian" in self._custom: self.barbarian.update(self._custom["barbarian"]) - + # Basic config self.basic = self._config["basic"] if "basic" in self._custom: - self.basic.update(self._custom["basic"]) + self.basic.update(self._custom["basic"]) # Basic Ranged config - self.basic = self._config["basic_ranged"] + self.basic_ranged = self._config["basic_ranged"] if "basic_ranged" in self._custom: - self.basic_ranged.update(self._custom["basic_ranged"]) + self.basic_ranged.update(self._custom["basic_ranged"]) # Necro config self.necro = self._config["necro"] diff --git a/src/main.py b/src/main.py index 66ff439..d3e0d21 100644 --- a/src/main.py +++ b/src/main.py @@ -13,10 +13,11 @@ from utils.auto_settings import adjust_settings, backup_settings, restore_settin from config import Config from logger import Logger -config = Config(print_warnings=True) -game_controller = GameController(config) -debugger_controller = GraphicDebuggerController(config) +# Will be initialized in the __main__() function +config = None +game_controller = None +debugger_controller = None def start_or_pause_bot(): global game_controller @@ -56,7 +57,8 @@ def main(): print(f"ERROR: Unkown logg_lvl {config.general['logg_lvl']}. Must be one of [info, debug]") # Create folder for debug screenshots if they dont exist yet - os.system("mkdir stats") + if not os.path.exists("stats"): + os.system("mkdir stats") if not os.path.exists("info_screenshots") and config.general["info_screenshots"]: os.system("mkdir info_screenshots") if not os.path.exists("loot_screenshots") and (config.general["loot_screenshots"] or config.general["message_api_type"] == "discord"): @@ -87,6 +89,9 @@ def main(): if __name__ == "__main__": # To avoid cmd just closing down, except any errors and add a input() to the end try: + config = Config(print_warnings=True) + game_controller = GameController(config) + debugger_controller = GraphicDebuggerController(config) main() except: traceback.print_exc() diff --git a/src/utils/custom_mouse.py b/src/utils/custom_mouse.py index 01eb2c5..30035b3 100644 --- a/src/utils/custom_mouse.py +++ b/src/utils/custom_mouse.py @@ -1,5 +1,5 @@ # Mostly copied from: https://github.com/patrikoss/pyclick -from os import stat +import os import mouse as _mouse from mouse import _winmouse import pytweening @@ -7,6 +7,7 @@ import numpy as np import random import math import time +import traceback from config import Config from typing import Union, Tuple @@ -184,7 +185,13 @@ class HumanCurve(): class mouse: # TODO: Not nice, this will execute every single time someone imports custom_mouse... - _config = Config() + try: + _config = Config() + except Exception as e: + traceback.print_exc() + print("Press Enter to exit ...") + input() + os._exit(-1) @staticmethod def sleep(duration, get_now=time.perf_counter):