Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion CaveBot/AutoAttack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions CaveBot/AutoWalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AutoWalk:
__waypoints: LinkedList = LinkedList()
__previous_waypoint = None

FLOOR_LEVEL = 8
FLOOR_LEVEL = 7

FLOORS_LEVELS: set[int] = set()

Expand Down Expand Up @@ -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)

Expand Down
12 changes: 10 additions & 2 deletions CaveBot/CaveBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions CaveBot/Player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
4 changes: 4 additions & 0 deletions CaveBot/Script.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Script:

waypoints: LinkedList = LinkedList()
creatures: list[ScriptEnemy] = list()
force_ring: bool = False

__previous_waypoint = None

Expand All @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions ScreenAnalizerPackage/Scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
66 changes: 66 additions & 0 deletions Wiki/Script/Venore/orc_fortress_outskirt.json
Original file line number Diff line number Diff line change
@@ -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
}
Binary file added Wiki/Ui/Battle/Mobs/Orc/orc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki/Ui/Battle/Mobs/Orc/orc_label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki/Ui/Battle/Mobs/OrcLeader/orc_leader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki/Ui/Battle/Mobs/OrcLeader/orc_leader_label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki/Ui/Battle/Mobs/OrcShaman/orc_shaman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki/Ui/Battle/Mobs/OrcShaman/orc_shaman_label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki/Ui/Battle/Mobs/OrcSpearman/orc_spearman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki/Ui/Battle/Mobs/OrcWarrior/orc_warrior.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki/Ui/Battle/Mobs/OrcWarrior/orc_warrior_label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wiki/Ui/GameWindow/soul.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.