Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.
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
6 changes: 6 additions & 0 deletions config/params.ini
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ atk_len_diablo_infector=4.0
atk_len_diablo_vizier=2.0
atk_len_diablo=3.0
cs_mob_detect=1
;for diablo only, requires NAJs PUZZLER on offhand switch
teleport_weapon_swap=0
; DIABLO END
;#########################

; cs_town_visits is currently broken, ignore for now
cs_town_visits=0
kill_cs_trash=0
Expand All @@ -105,6 +110,7 @@ belt_hp_columns=1
belt_mp_columns=1
belt_rejuv_columns=2


; Potion/chicken settings
take_health_potion=0.8
take_mana_potion=0.5
Expand Down
35 changes: 35 additions & 0 deletions src/char/i_char.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,41 @@ def _pre_buff_cta(self):
Logger.warning("Failed to switch weapon, try again")
wait(0.5)

def switch_to_tele_offhand(self): #for teleport on switch
# Save current skill img
skill_before = cut_roi(grab(), Config().ui_roi["skill_right"])
# Try to switch weapons and select bo until we find the skill on the right skill slot
start = time.time()
switch_sucess = False
while time.time() - start < 4:
keyboard.send(Config().char["weapon_switch"])
wait(0.3, 0.35)
self._select_skill(skill = "teleport", mouse_click_type="right", delay=(0.1, 0.2))
if skills.is_right_skill_selected(["teleport"]):
switch_sucess = True
break

if not switch_sucess:
Logger.warning("You dont have Teleport bound, or you do not have NAJs Puzzler on offhand. Switching off teleport_weapon_swap")
Config().char["teleport_weapon_swap"] = 0
else:
# We switched succesfully, we can now teleport as long as we have charges!
return skill_before

# Make sure the switch back to the original weapon is good
def switch_from_tele_offhand(self, skill_before):
start = time.time()
while time.time() - start < 4:
keyboard.send(Config().char["weapon_switch"])
wait(0.3, 0.35)
skill_after = cut_roi(grab(), Config().ui_roi["skill_right"])
_, max_val, _, _ = cv2.minMaxLoc(cv2.matchTemplate(skill_after, skill_before, cv2.TM_CCOEFF_NORMED))
if max_val > 0.9:
break
else:
Logger.warning("Failed to switch weapon, try again")
wait(0.5)


def vec_to_monitor(self, target):
circle_pos_screen = self._pather._adjust_abs_range_to_screen(target)
Expand Down
2 changes: 2 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ def load_data(self):
"gamble_items": False if not self._select_val("char", "gamble_items") else self._select_val("char", "gamble_items").replace(" ","").split(","),
"sell_junk": bool(int(self._select_val("char", "sell_junk"))),
"enable_no_pickup": bool(int(self._select_val("char", "enable_no_pickup"))),
"teleport_weapon_swap": bool(int(self._select_val("char", "teleport_weapon_swap"))),#for diablo
"safer_routines": bool(int(self._select_val("char", "safer_routines"))),

}
# Sorc base config
sorc_base_cfg = dict(self.configs["config"]["parser"]["sorceress"])
Expand Down
2 changes: 1 addition & 1 deletion src/pather.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def _convert_rel_to_abs(rel_loc: tuple[float, float], pos_abs: tuple[float, floa
return (rel_loc[0] + pos_abs[0], rel_loc[1] + pos_abs[1])

def traverse_nodes_fixed(self, key: str | list[tuple[float, float]], char: IChar) -> bool:
if not char.capabilities.can_teleport_natively:
if not char.capabilities.can_teleport_natively or char.capabilities.can_teleport_with_charges:
error_msg = "Teleport is required for static pathing"
Logger.error(error_msg)
raise ValueError(error_msg)
Expand Down
13 changes: 10 additions & 3 deletions src/run/diablo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ def approach(self, start_loc: Location) -> bool | Location:
Logger.info("Run Diablo")
Logger.debug("settings for trash =" + str(Config().char["kill_cs_trash"]))
Logger.debug("settings for mob_detection =" + str(Config().char["cs_mob_detect"]))
if not self._char.capabilities.can_teleport_natively:

if self._char.capabilities.can_teleport_with_charges:
Logger.info ("Dia with Tele charges on Alpha version!")
elif not self._char.capabilities.can_teleport_natively:
raise ValueError("Diablo requires teleport")
if not self._town_manager.open_wp(start_loc):
return False
wait(0.4)
waypoint.use_wp("River of Flame")
return Location.A4_DIABLO_WP


# BUY POTS & STASH WHEN AT PENTAGRAM
def _cs_town_visit(self, location:str) -> bool:
# Do we want to go back to town and restock potions etc?
Expand Down Expand Up @@ -456,13 +458,18 @@ def battle(self, do_pre_buff: bool) -> bool | tuple[Location, bool]:

#Clear Trash in CS

if Config().char["teleport_weapon_swap"]: self._char.switch_to_tele_offhand() #switch to teleport

if Config().char["kill_cs_trash"]:
if not self._river_of_flames_trash(): return False
else:
if not self._river_of_flames(): return False

#Arrive at and clear Pentagram
if not self._cs_pentagram(): return False

if Config().char["teleport_weapon_swap"]: self._char.switch_from_tele_offhand() #switch to back to main
#rest of the run is w/o tele staff - must be changed to walking nodes :D

#OLD APPROACH HAS 80% SUCCESS RATE
if Config().char["kill_cs_trash"]: self._trash_seals()
Expand Down