diff --git a/CaveBot/AutoAttack.py b/CaveBot/AutoAttack.py index 5ef1bc8..3e312aa 100644 --- a/CaveBot/AutoAttack.py +++ b/CaveBot/AutoAttack.py @@ -16,7 +16,7 @@ class AutoAttack: - def __init__(self, auto_loot: AutoLoot, player: Player, walk_event: Event, combat_event: Event, creatures: list[ScriptEnemy]): + def __init__(self, auto_loot: AutoLoot, player: Player, walk_event: Event, combat_event: Event, creatures: list[ScriptEnemy], force_ring: bool): initial_frame = WindowCapturer.start() self.battle_list = BattleList.create(initial_frame) self.auto_loot = auto_loot @@ -25,6 +25,7 @@ def __init__(self, auto_loot: AutoLoot, player: Player, walk_event: Event, comba self.combat_event = combat_event self.creatures = creatures self.runner_enemy = False + self.force_ring = force_ring def attack(self) -> None: while True: @@ -40,6 +41,9 @@ def attack(self) -> None: battle_list_attack_position = enemies_in_battle_list[0].position for enemy in enemies_in_battle_list: + if self.force_ring: + self.player.use_stealth_ring() + self.runner_enemy = enemy.runner self.__activate_chase_opponent(enemy) @@ -110,3 +114,21 @@ def __activate_chase_opponent(self, enemy: Enemy) -> None: if not self.__is_chasing_opponent_activated(frame) and enemy.runner: self.player.chase_opponent() + + def __is_stealth_ring_on(self, frame: np.array) -> bool: + (start_x, end_x, start_y, end_y) = Scanner.ring_position(frame) + + frame_roi = frame[start_y:end_y, start_x:end_x] + + hsv_image = cv2.cvtColor(frame_roi, cv2.COLOR_BGR2HSV) + + # Define the RGB value of the color red that are counter of the ring + color_to_find = (191, 0, 0) + + # Check if the color is similar to the target color + color_found = np.all(hsv_image == color_to_find, axis=-1).any() + + print(color_found) + + # Determine if the image contains blue color + return color_found diff --git a/CaveBot/AutoWalk.py b/CaveBot/AutoWalk.py index f738d6a..e0f9a43 100644 --- a/CaveBot/AutoWalk.py +++ b/CaveBot/AutoWalk.py @@ -16,7 +16,7 @@ class AutoWalk: __waypoints: LinkedList = LinkedList() __previous_waypoint = None - FLOOR_LEVEL = 8 + FLOOR_LEVEL = 7 FLOORS_LEVELS: set[int] = set() @@ -62,7 +62,7 @@ def start(self) -> None: command: MoveCommand = walk_instructions.current.data - time.sleep(0.2) + # time.sleep(0.2) self.player.move(command) diff --git a/CaveBot/CaveBot.py b/CaveBot/CaveBot.py index ce13cd5..b3465ad 100644 --- a/CaveBot/CaveBot.py +++ b/CaveBot/CaveBot.py @@ -21,15 +21,23 @@ def start(self): combat_event = Event() # Thread(daemon=True, target=player.watch_mana).start() - cave_bot_script = Script.load('Wiki/Script/Thais/thais_wasp.json') + # cave_bot_script = Script.load('Wiki/Script/Thais/thais_wasp.json') # cave_bot_script = Script.load('Wiki/Script/Venore/swamp_troll_cave.json') # cave_bot_script = Script.load('Wiki/Script/Venore/swampling_cave_floor_10.json') + cave_bot_script = Script.load('Wiki/Script/Venore/orc_fortress_outskirt.json') auto_loot = AutoLoot(player, Screen.GAME_WINDOW) auto_walk = AutoWalk(cave_bot_script, player, walking_event) - auto_attack = AutoAttack(auto_loot, player, walking_event, combat_event, cave_bot_script.creatures) + auto_attack = AutoAttack( + auto_loot, + player, + walking_event, + combat_event, + cave_bot_script.creatures, + cave_bot_script.force_ring + ) attack_thread = Thread(daemon=True, target=auto_attack.attack) diff --git a/CaveBot/Player.py b/CaveBot/Player.py index 343f50b..20248ce 100644 --- a/CaveBot/Player.py +++ b/CaveBot/Player.py @@ -69,3 +69,6 @@ def position(self, frame: np.array) -> Position: def move(self, command: MoveCommand) -> None: Keyboard.press(command.key) + + def use_stealth_ring(self) -> None: + Keyboard.press('t') diff --git a/CaveBot/Script.py b/CaveBot/Script.py index 74d7d6e..b876087 100644 --- a/CaveBot/Script.py +++ b/CaveBot/Script.py @@ -9,6 +9,7 @@ class Script: waypoints: LinkedList = LinkedList() creatures: list[ScriptEnemy] = list() + force_ring: bool = False __previous_waypoint = None @@ -24,6 +25,9 @@ def __init__(self, script_json_data): self.FLOORS_LEVELS.add(Script.__extract_z_level_from_waypoint(waypoint[0])) self.waypoints.append(waypoint) + if 'ring' in script_json_data: + self.force_ring = True + @staticmethod def load(name: str) -> 'Script': with open(name, Script.__READ_MODE) as file: diff --git a/ScreenAnalizerPackage/Scanner.py b/ScreenAnalizerPackage/Scanner.py index 8e794be..0b21f07 100644 --- a/ScreenAnalizerPackage/Scanner.py +++ b/ScreenAnalizerPackage/Scanner.py @@ -8,7 +8,21 @@ class Scanner: + @staticmethod + def ring_position(frame: np.array) -> tuple[int, int, int, int]: + grey_scale_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + + soul_anchor = Cv2File.load_image('Wiki/Ui/GameWindow/soul.png') + + match = cv2.matchTemplate(grey_scale_frame, soul_anchor, cv2.TM_CCOEFF_NORMED) + + [_, _, _, max_coordinates] = cv2.minMaxLoc(match) + + (x, y) = max_coordinates + + height, width = soul_anchor.shape + return x, x + width, y - 39, y + height @staticmethod def combat_stance_position(frame: np.array) -> tuple[int, int, int, int]: grey_scale_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) diff --git a/Wiki/Script/Venore/orc_fortress_outskirt.json b/Wiki/Script/Venore/orc_fortress_outskirt.json new file mode 100644 index 0000000..3d06c92 --- /dev/null +++ b/Wiki/Script/Venore/orc_fortress_outskirt.json @@ -0,0 +1,66 @@ +{ + "walk": [ + ["32828,31767,7"], + ["32834,31764,7"], + ["32834,31757,7"], + ["32834,31747,7"], + ["32834,31740,7"], + ["32825,31740,7"], + ["32822,31731,7"], + ["32825,31722,7"], + ["32833,31720,7"], + ["32840,31725,7"], + ["32840,31738,7"], + ["32840,31755,7"], + ["32840,31765,7"], + ["32846,31765,7"], + ["32860,31769,7"], + ["32870,31779,7"], + ["32870,31768,7"], + ["32880,31760,7"], + ["32884,31749,7"], + ["32888,31739,7"], + ["32890,31729,7"], + ["32894,31721,7"], + ["32890,31729,7"], + ["32888,31739,7"], + ["32884,31749,7"], + ["32880,31760,7"], + ["32870,31768,7"], + ["32852,31768,7"], + ["32830,31768,7"] + ], + "creatures": [ + { + "name": "orc_warrior", + "runner": true, + "loot": false + }, + { + "name": "orc", + "runner": true, + "loot": false + }, + { + "name": "orc_shaman", + "runner": true, + "loot": true + }, + { + "name": "orc_berserker", + "runner": true, + "loot": false + }, + { + "name": "orc_spearman", + "runner": true, + "loot": false + }, + { + "name": "orc_leader", + "runner": true, + "loot": false + } + ], + "ring": true +} \ No newline at end of file diff --git a/Wiki/Ui/Battle/Mobs/Orc/orc.png b/Wiki/Ui/Battle/Mobs/Orc/orc.png new file mode 100644 index 0000000..71ade04 Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/Orc/orc.png differ diff --git a/Wiki/Ui/Battle/Mobs/Orc/orc_label.png b/Wiki/Ui/Battle/Mobs/Orc/orc_label.png new file mode 100644 index 0000000..a6af674 Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/Orc/orc_label.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcBerserker/orc_berserker.png b/Wiki/Ui/Battle/Mobs/OrcBerserker/orc_berserker.png new file mode 100644 index 0000000..a624b5a Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcBerserker/orc_berserker.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcBerserker/orc_berserker_label.png b/Wiki/Ui/Battle/Mobs/OrcBerserker/orc_berserker_label.png new file mode 100644 index 0000000..5a95db5 Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcBerserker/orc_berserker_label.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcLeader/orc_leader.png b/Wiki/Ui/Battle/Mobs/OrcLeader/orc_leader.png new file mode 100644 index 0000000..3f32d5a Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcLeader/orc_leader.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcLeader/orc_leader_label.png b/Wiki/Ui/Battle/Mobs/OrcLeader/orc_leader_label.png new file mode 100644 index 0000000..d726fa8 Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcLeader/orc_leader_label.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcShaman/orc_shaman.png b/Wiki/Ui/Battle/Mobs/OrcShaman/orc_shaman.png new file mode 100644 index 0000000..7f775e0 Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcShaman/orc_shaman.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcShaman/orc_shaman_label.png b/Wiki/Ui/Battle/Mobs/OrcShaman/orc_shaman_label.png new file mode 100644 index 0000000..cc64284 Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcShaman/orc_shaman_label.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcSpearman/orc_spearman.png b/Wiki/Ui/Battle/Mobs/OrcSpearman/orc_spearman.png new file mode 100644 index 0000000..d44038d Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcSpearman/orc_spearman.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcSpearman/orc_spearman_label.png b/Wiki/Ui/Battle/Mobs/OrcSpearman/orc_spearman_label.png new file mode 100644 index 0000000..daecf23 Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcSpearman/orc_spearman_label.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcWarrior/orc_warrior.png b/Wiki/Ui/Battle/Mobs/OrcWarrior/orc_warrior.png new file mode 100644 index 0000000..cf8697b Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcWarrior/orc_warrior.png differ diff --git a/Wiki/Ui/Battle/Mobs/OrcWarrior/orc_warrior_label.png b/Wiki/Ui/Battle/Mobs/OrcWarrior/orc_warrior_label.png new file mode 100644 index 0000000..b7f66c7 Binary files /dev/null and b/Wiki/Ui/Battle/Mobs/OrcWarrior/orc_warrior_label.png differ diff --git a/Wiki/Ui/GameWindow/soul.png b/Wiki/Ui/GameWindow/soul.png new file mode 100644 index 0000000..d1fbaf6 Binary files /dev/null and b/Wiki/Ui/GameWindow/soul.png differ