From b289e4cbb551a6d2bf61a3e8de2f325837ea4216 Mon Sep 17 00:00:00 2001 From: aeon0 Date: Mon, 8 Nov 2021 08:17:06 +0100 Subject: [PATCH] feat(atk): Config for attack length --- params.ini | 7 ++++-- src/bot.py | 4 ++-- src/char/hammerdin.py | 7 +++--- src/char/sorceress.py | 54 ++++++++++++++++++------------------------- src/config.py | 3 +++ 5 files changed, 36 insertions(+), 39 deletions(-) diff --git a/params.ini b/params.ini index 664a9b1..ca56b02 100644 --- a/params.ini +++ b/params.ini @@ -12,8 +12,8 @@ run_eldritch=1 run_shenk=1 [char] -type=hammerdin -casting_frames=11 +type=sorceress +casting_frames=10 slow_walk=0 num_loot_columns=6 take_health_potion=0.8 @@ -34,6 +34,9 @@ cta_available=0 weapon_switch=x battle_orders=7 battle_command=8 +atk_len_pindle=3 +atk_len_eldritch=3 +atk_len_shenk=4 [sorceress] teleport=1 diff --git a/src/bot.py b/src/bot.py index e43f119..52354c0 100644 --- a/src/bot.py +++ b/src/bot.py @@ -214,8 +214,8 @@ class Bot: bot._char.kill_pindle() wait(1.5, 1.8) bot._picked_up_items = bot._pickit.pick_up_items(bot._char) - # in order to move away for items and such to have a clear tp, move to the end of the hall - if not self.is_last_run(): + # in order to move away for items to have a clear tp, move to the end of the hall + if not bot.is_last_run(): bot._pather.traverse_nodes_fixed("PINDLE_END", bot._char) wait(0.2, 0.3) self.success = True diff --git a/src/char/hammerdin.py b/src/char/hammerdin.py index c852ed4..f541452 100644 --- a/src/char/hammerdin.py +++ b/src/char/hammerdin.py @@ -55,7 +55,7 @@ class Hammerdin(IChar): self._cast_hammers(1) # pindle sometimes knocks back, get back in self._pather.traverse_nodes(Location.PINDLE_SAVE_DIST, Location.PINDLE_END, self, time_out=0.2) - self._cast_hammers(6) + self._cast_hammers(max(1, self._char_config["atk_len_pindle"] - 1)) wait(0.1, 0.15) self._do_redemption() return True @@ -63,7 +63,7 @@ class Hammerdin(IChar): def kill_eldritch(self) -> bool: self._pather.traverse_nodes(Location.ELDRITCH_SAVE_DIST, Location.ELDRITCH_END, self, time_out=0.2) wait(0.1, 0.15) - self._cast_hammers(6) + self._cast_hammers(self._char_config["atk_len_eldritch"]) wait(0.1, 0.15) self._do_redemption() return True @@ -71,9 +71,10 @@ class Hammerdin(IChar): def kill_shenk(self): self._pather.traverse_nodes(Location.SHENK_SAVE_DIST, Location.SHENK_END, self, time_out=0.2) wait(0.1, 0.15) - self._cast_hammers(6) + self._cast_hammers(self._char_config["atk_len_shenk"]) wait(0.1, 0.15) self._do_redemption() + return True if __name__ == "__main__": diff --git a/src/char/sorceress.py b/src/char/sorceress.py index 4564aa3..7da87d2 100644 --- a/src/char/sorceress.py +++ b/src/char/sorceress.py @@ -32,7 +32,7 @@ class Sorceress(IChar): keyboard.send(self._char_config["stand_still"], do_release=False) custom_mouse.move(cast_pos[0], cast_pos[1], duration=(random.random() * 0.05 + 0.15)) keyboard.send(self._skill_hotkeys["skill_left"]) - for i in range(7): + for _ in range(6): x = cast_pos[0] + (random.random() * 2*spray - spray) y = cast_pos[1] + (random.random() * 2*spray - spray) custom_mouse.move(x, y, duration=(random.random() * 0.05 + 0.15)) @@ -54,16 +54,27 @@ class Sorceress(IChar): if pindle_pos_abs is not None: cast_pos_abs = [pindle_pos_abs[0] * 0.9, pindle_pos_abs[1] * 0.9] cast_pos_monitor = self._screen.convert_abs_to_monitor(cast_pos_abs) - self._main_attack(cast_pos_monitor, delay) - self._left_attack(cast_pos_monitor, delay) - self._main_attack(cast_pos_monitor, delay) - self._left_attack(cast_pos_monitor, delay) + for _ in range(int(self._char_config["atk_len_pindle"])): + self._main_attack(cast_pos_monitor, delay) + self._left_attack(cast_pos_monitor, delay) wait(0.1, 0.15) # Move to items self._pather.traverse_nodes(Location.PINDLE_SAVE_DIST, Location.PINDLE_END, self) - wait(0.1, 0.15) - blizzard_cast_pos = self._screen.convert_abs_to_monitor([0, 0]) - self._main_attack(blizzard_cast_pos, delay) + return True + return False + + def kill_eldritch(self) -> bool: + delay = [0.2, 0.3] + pos_abs = self._pather.find_abs_node_pos(123, self._screen.grab()) + if pos_abs is not None: + cast_pos_abs = [pos_abs[0] * 0.9, pos_abs[1] * 0.9] + cast_pos_monitor = self._screen.convert_abs_to_monitor(cast_pos_abs) + for _ in range(int(self._char_config["atk_len_eldritch"])): + self._main_attack(cast_pos_monitor, delay, 90) + self._left_attack(cast_pos_monitor, delay, 90) + wait(0.2, 0.3) + # Move to items + self._pather.traverse_nodes(Location.ELDRITCH_SAVE_DIST, Location.ELDRITCH_END, self, time_out=2.0) return True return False @@ -72,34 +83,13 @@ class Sorceress(IChar): pos_abs = self._pather.find_abs_node_pos(149, self._screen.grab()) cast_pos_abs = [pos_abs[0] * 0.9, pos_abs[1] * 0.9] cast_pos_monitor = self._screen.convert_abs_to_monitor(cast_pos_abs) - # TODO: Not sure if we need so much attacks... maybe add a "number_attack_sequenze" to the param.ini - self._main_attack(cast_pos_monitor, delay, 90) - self._left_attack(cast_pos_monitor, delay, 90) - self._main_attack(cast_pos_monitor, delay, 90) - self._main_attack(cast_pos_monitor, delay, 90) - self._left_attack(cast_pos_monitor, delay, 90) - self._main_attack(cast_pos_monitor, delay, 90) - self._left_attack(cast_pos_monitor, delay, 90) + for _ in range(int(self._char_config["atk_len_shenk"])): + self._main_attack(cast_pos_monitor, delay, 90) + self._left_attack(cast_pos_monitor, delay, 90) wait(0.2, 0.3) # Move to items self._pather.traverse_nodes(Location.SHENK_SAVE_DIST, Location.SHENK_END, self, time_out=2.0) - def kill_eldritch(self) -> bool: - delay = [0.2, 0.3] - pos_abs = self._pather.find_abs_node_pos(123, self._screen.grab()) - if pos_abs is not None: - cast_pos_abs = [pos_abs[0] * 0.9, pos_abs[1] * 0.9] - cast_pos_monitor = self._screen.convert_abs_to_monitor(cast_pos_abs) - self._main_attack(cast_pos_monitor, delay, 90) - self._left_attack(cast_pos_monitor, delay, 90) - self._main_attack(cast_pos_monitor, delay, 90) - self._main_attack(cast_pos_monitor, delay, 90) - self._left_attack(cast_pos_monitor, delay, 90) - wait(0.2, 0.3) - # Move to items - self._pather.traverse_nodes(Location.ELDRITCH_SAVE_DIST, Location.ELDRITCH_END, self, time_out=2.0) - return True - return False if __name__ == "__main__": diff --git a/src/config.py b/src/config.py index ab1d44a..537129a 100644 --- a/src/config.py +++ b/src/config.py @@ -56,6 +56,9 @@ class Config: "battle_command": self._select_val("char", "battle_command"), "casting_frames": int(self._select_val("char", "casting_frames")), "slow_walk": bool(int(self._select_val("char", "slow_walk"))), + "atk_len_pindle": int(self._select_val("char", "atk_len_pindle")), + "atk_len_eldritch": int(self._select_val("char", "atk_len_eldritch")), + "atk_len_shenk": int(self._select_val("char", "atk_len_shenk")), } self.sorceress = dict(self._config["sorceress"])