diff --git a/assets/templates/eldritch/eldritch_7.png b/assets/templates/eldritch/eldritch_7.png new file mode 100644 index 0000000..8e69662 Binary files /dev/null and b/assets/templates/eldritch/eldritch_7.png differ diff --git a/assets/templates/eldritch/eldritch_8.png b/assets/templates/eldritch/eldritch_8.png new file mode 100644 index 0000000..21fff44 Binary files /dev/null and b/assets/templates/eldritch/eldritch_8.png differ diff --git a/assets/templates/eldritch/eldritch_9.png b/assets/templates/eldritch/eldritch_9.png new file mode 100644 index 0000000..34a4faf Binary files /dev/null and b/assets/templates/eldritch/eldritch_9.png differ diff --git a/src/bot.py b/src/bot.py index 3711a03..2bf3d2c 100644 --- a/src/bot.py +++ b/src/bot.py @@ -4,6 +4,7 @@ import keyboard import time import os import random +import cv2 from typing import Union from utils.misc import wait @@ -253,6 +254,8 @@ class Bot: self.trigger_or_stop("end_game") def on_end_game(self, failed: bool = False): + if self._config.general["info_screenshots"]: + cv2.imwrite("./info_screenshots/info_failed_game_" + time.strftime("%Y%m%d_%H%M%S") + ".png", self._screen.grab()) self._curr_loc = False self._pre_buffed = False self._ui_manager.save_and_exit() diff --git a/src/char/barbarian.py b/src/char/barbarian.py index 7ec8695..50a018c 100644 --- a/src/char/barbarian.py +++ b/src/char/barbarian.py @@ -9,6 +9,7 @@ from screen import Screen from utils.misc import wait, cut_roi, is_in_roi import time from pather import Pather, Location +import cv2 class Barbarian(IChar): @@ -193,7 +194,7 @@ if __name__ == "__main__": keyboard.add_hotkey('f12', lambda: Logger.info('Force Exit (f12)') or os._exit(1)) keyboard.wait("f11") from config import Config - from ui_manager import UiManager + from ui.ui_manager import UiManager config = Config() screen = Screen(config.general["monitor"]) t_finder = TemplateFinder(screen) diff --git a/src/char/hammerdin.py b/src/char/hammerdin.py index 60073f1..a6736e8 100644 --- a/src/char/hammerdin.py +++ b/src/char/hammerdin.py @@ -104,6 +104,9 @@ class Hammerdin(IChar): return True def kill_council(self) -> bool: + if not self._do_pre_move: + keyboard.send(self._skill_hotkeys["concentration"]) + wait(0.05, 0.15) # Check out the node screenshot in assets/templates/trav/nodes to see where each node is at atk_len = self._char_config["atk_len_trav"] # Go inside and hammer a bit diff --git a/src/char/i_char.py b/src/char/i_char.py index df9a067..bb8cee5 100644 --- a/src/char/i_char.py +++ b/src/char/i_char.py @@ -161,12 +161,12 @@ class IChar: # Make sure that we are back at the previous skill skill_after = cut_roi(self._screen.grab(), self._config.ui_roi["skill_right"]) _, max_val, _, _ = cv2.minMaxLoc(cv2.matchTemplate(skill_after, skill_before, cv2.TM_CCOEFF_NORMED)) - if max_val < 0.96: + if max_val < 0.9: Logger.warning("Failed to switch weapon, try again") wait(1.2) skill_after = cut_roi(self._screen.grab(), self._config.ui_roi["skill_right"]) _, max_val, _, _ = cv2.minMaxLoc(cv2.matchTemplate(skill_after, skill_before, cv2.TM_CCOEFF_NORMED)) - if max_val < 0.96: + if max_val < 0.9: keyboard.send(self._char_config["weapon_switch"]) wait(0.4) else: diff --git a/src/pather.py b/src/pather.py index cc50909..5eaf5a6 100644 --- a/src/pather.py +++ b/src/pather.py @@ -91,9 +91,9 @@ class Pather: 104: {'PINDLE_4': (717, -117), 'PINDLE_3': (843, -244), 'PINDLE_5': (-187, 237), 'PINDLE_6': (-467, 89)}, # Eldritch 120: {'ELDRITCH_0': (293, 24), 'ELDRITCH_1': (-307, 76), 'ELDRITCH_5': (27, -164), 'ELDRITCH_6': (400, -50)}, - 121: {'ELDRITCH_6': (360, -244), 'ELDRITCH_1': (-329, -103), 'ELDRITCH_2': (411, 171), 'ELDRITCH_3': (-91, 198)}, - 122: {'ELDRITCH_2': (353, -145), 'ELDRITCH_3': (-149, -119)}, - 123: {'ELDRITCH_3': (-99, -252), 'ELDRITCH_2': (403, -279), 'ELDRITCH_4': (-62, -109)}, + 121: {'ELDRITCH_6': (360, -244), 'ELDRITCH_1': (-329, -103), 'ELDRITCH_2': (411, 171), 'ELDRITCH_3': (-91, 198), 'ELDRITCH_7': (409, 180), 'ELDRITCH_8': (465, 345)}, + 122: {'ELDRITCH_2': (353, -145), 'ELDRITCH_3': (-149, -119), 'ELDRITCH_9': (-253, -118), 'ELDRITCH_7': (352, -134), 'ELDRITCH_8': (404, 29)}, + 123: {'ELDRITCH_3': (-99, -252), 'ELDRITCH_2': (403, -279), 'ELDRITCH_4': (-62, -109), 'ELDRITCH_9': (-204, -254), 'ELDRITCH_8': (400, -267), 'ELDRITCH_8': (454, -104)}, # Shenk 141: {'SHENK_0': (-129, 44), 'SHENK_1': (464, 107), 'SHENK_2': (-167, -34), 'SHENK_17': (-520, 528), 'SHENK_15': (77, 293), 'SHENK_18': (518, 512)}, 142: {'SHENK_1': (584, 376), 'SHENK_4': (-443, -103), 'SHENK_2': (-52, 235), 'SHENK_3': (357, -129)}, @@ -423,7 +423,7 @@ if __name__ == "__main__": t_finder = TemplateFinder(screen) pather = Pather(screen, t_finder) - # display_all_nodes(pather, "NIL2D") + display_all_nodes(pather, "ELD") # # changing node pos and generating new code # code = "" @@ -435,8 +435,8 @@ if __name__ == "__main__": # code += (f'"{k}": {pather._nodes[node_idx][k]}, ') # print(code) - ui_manager = UiManager(screen, t_finder) - char = Hammerdin(config.hammerdin, config.char, screen, t_finder, ui_manager, pather) - pather.traverse_nodes_fixed("trav_safe_dist", char) - print("-----") + # ui_manager = UiManager(screen, t_finder) + # char = Hammerdin(config.hammerdin, config.char, screen, t_finder, ui_manager, pather) + # pather.traverse_nodes_fixed("trav_safe_dist", char) + # print("-----") # pather.traverse_nodes([226, 228, 229], char) diff --git a/src/run/trav.py b/src/run/trav.py index 6561c37..e7b5e90 100644 --- a/src/run/trav.py +++ b/src/run/trav.py @@ -56,7 +56,6 @@ class Trav: if not self._pather.traverse_nodes([229], self._char, time_out=2.5): self._pather.traverse_nodes([228, 229], self._char, time_out=2.5) picked_up_items |= self._pickit.pick_up_items(self._char, is_at_trav=True) - # if we picked up items lets make sure we go back to the center to not hide the tp - if picked_up_items: - self._pather.traverse_nodes([230], self._char, time_out=2.5) + # Make sure we go back to the center to not hide the tp + self._pather.traverse_nodes([230], self._char, time_out=2.5) return (Location.A3_TRAV_CENTER_STAIRS, picked_up_items) diff --git a/src/utils/auto_settings.py b/src/utils/auto_settings.py index f9fb905..3970f13 100644 --- a/src/utils/auto_settings.py +++ b/src/utils/auto_settings.py @@ -2,9 +2,11 @@ import json import os from config import Config from mss import mss +from utils.misc import close_down_d2 def adjust_settings(): + close_down_d2() # You might not belive it, but there are cases where users press f9 and just dont read any console output and think everything is done # so for now, removing this warning as it seems there has never been anybody actually backing up the original settings anyway... # print("Warning: This will overwrite some of your graphics and gameplay settings. D2R must not be running during this action! Continue with Enter...") @@ -43,7 +45,7 @@ def adjust_settings(): # write back to settings.json with open(d2_saved_games + "\\Settings.json", 'w') as outfile: json.dump(curr_settings, outfile) - print("Changed settings succesfully. You can now start D2R and botty.") + print("Adapted settings succesfully. You can now restart D2r and botty.") if __name__ == "__main__": diff --git a/src/utils/misc.py b/src/utils/misc.py index c3d5132..34f6022 100644 --- a/src/utils/misc.py +++ b/src/utils/misc.py @@ -7,8 +7,12 @@ import cv2 from typing import List, Tuple import os from math import cos, sin, dist +import subprocess +def close_down_d2(): + subprocess.call(["taskkill","/F","/IM","D2R.exe"], stderr=subprocess.DEVNULL) + def wait(min_seconds, max_seconds = None): if max_seconds is None: max_seconds = min_seconds