Trapsin updates (#325)

This commit is contained in:
aeon0
2021-12-24 12:24:10 +01:00
committed by GitHub
parent db7c011ded
commit bb523b34fe
2 changed files with 65 additions and 56 deletions
+1
View File
@@ -116,6 +116,7 @@ redemption=
; ==========================
; ==== Builds: Assassin ====
; ==========================
; Currently no Trav implementaiton!
[trapsin]
teleport=f1
skill_left=f8
+64 -56
View File
@@ -6,10 +6,11 @@ from ui import UiManager
from pather import Pather
from logger import Logger
from screen import Screen
from utils.misc import wait
from utils.misc import wait, rotate_vec, unit_vector
import random
from typing import Tuple
from pather import Location, Pather
import numpy as np
class Trapsin(IChar):
@@ -37,25 +38,25 @@ class Trapsin(IChar):
mouse.click(button="right")
wait(self._cast_duration)
def _left_attack(self, cast_pos_abs: Tuple[float, float], delay: float, spray: int = 10):
def _left_attack(self, cast_pos_abs: Tuple[float, float], spray: int = 10):
keyboard.send(self._char_config["stand_still"], do_release=False)
if self._skill_hotkeys["skill_left"]:
keyboard.send(self._skill_hotkeys["skill_left"])
for _ in range(6):
for _ in range(4):
x = cast_pos_abs[0] + (random.random() * 2*spray - spray)
y = cast_pos_abs[1] + (random.random() * 2*spray - spray)
cast_pos_monitor = self._screen.convert_abs_to_monitor((x, y))
mouse.move(*cast_pos_monitor)
mouse.press(button="left")
wait(delay[0], delay[1])
wait(0.2, 0.3)
mouse.release(button="left")
keyboard.send(self._char_config["stand_still"], do_press=False)
def _right_attack(self, cast_pos_abs: Tuple[float, float], delay: float, spray: float = 10):
def _right_attack(self, cast_pos_abs: Tuple[float, float], spray: float = 10):
keyboard.send(self._skill_hotkeys["lightning_sentry"])
x = cast_pos_abs[0] + (random.random() * 2*spray - spray)
y = cast_pos_abs[1] + (random.random() * 2*spray - spray)
x = cast_pos_abs[0] + (random.random() * 2 * spray - spray)
y = cast_pos_abs[1] + (random.random() * 2 * spray - spray)
cast_pos_monitor = self._screen.convert_abs_to_monitor((x, y))
mouse.move(*cast_pos_monitor)
def atk(num: int):
@@ -69,63 +70,70 @@ class Trapsin(IChar):
atk(1)
def kill_pindle(self) -> bool:
delay = [0.2, 0.3]
atk_len = max(1, int(self._char_config["atk_len_pindle"] / 2))
pindle_pos_abs = self._screen.convert_screen_to_abs(self._config.path["pindle_end"][0])
cast_pos_abs = [pindle_pos_abs[0] * 0.9, pindle_pos_abs[1] * 0.9]
for _ in range(atk_len):
self._right_attack(cast_pos_abs, 11)
self._left_attack(cast_pos_abs, 11)
# Move to items
wait(self._cast_duration, self._cast_duration + 0.2)
if self.can_teleport():
pindle_pos_abs = self._screen.convert_screen_to_abs(self._config.path["pindle_end"][0])
self._pather.traverse_nodes_fixed("pindle_end", self)
else:
pindle_pos_abs = self._pather.find_abs_node_pos(104, self._screen.grab())
if pindle_pos_abs is not None:
cast_pos_abs = [pindle_pos_abs[0] * 0.9, pindle_pos_abs[1] * 0.9]
for _ in range(int(self._char_config["atk_len_pindle"])):
self._right_attack(cast_pos_abs, delay, 11)
self._left_attack(cast_pos_abs, delay, 11)
wait(self._cast_duration, self._cast_duration + 0.2)
# Move to items
if self.can_teleport():
self._pather.traverse_nodes_fixed("pindle_end", self)
else:
self._pather.traverse_nodes((Location.A5_PINDLE_SAFE_DIST, Location.A5_PINDLE_END), self, force_tp=True)
return True
return False
self._pather.traverse_nodes((Location.A5_PINDLE_SAFE_DIST, Location.A5_PINDLE_END), self, force_tp=True)
return True
def kill_eldritch(self) -> bool:
delay = [0.2, 0.3]
pos_abs = self._pather.find_abs_node_pos(1, self._screen.grab())
if pos_abs is not None:
eld_pos_abs = [pos_abs[0] * 0.9, pos_abs[1] * 0.9]
atk_len = max(1, int(self._char_config["atk_len_eldritch"] / 2))
eld_pos_abs = self._screen.convert_screen_to_abs(self._config.path["eldritch_end"][0])
cast_pos_abs = [eld_pos_abs[0] * 0.9, eld_pos_abs[1] * 0.9]
for _ in range(atk_len):
self._right_attack(cast_pos_abs, 90)
self._left_attack(cast_pos_abs, 90)
# Move to items
wait(self._cast_duration, self._cast_duration + 0.2)
if self.can_teleport():
self._pather.traverse_nodes_fixed("eldritch_end", self)
else:
eld_pos_abs = self._screen.convert_screen_to_abs(self._config.path["eldritch_end"][0])
if eld_pos_abs is not None:
cast_pos_abs = [eld_pos_abs[0] * 0.9, eld_pos_abs[1] * 0.9]
for _ in range(int(self._char_config["atk_len_eldritch"])):
self._right_attack(cast_pos_abs, delay, 90)
self._left_attack(cast_pos_abs, delay, 90)
wait(self._cast_duration, self._cast_duration + 0.2)
# Move to items
if self.can_teleport():
self._pather.traverse_nodes_fixed("eldritch_end", self)
else:
self._pather.traverse_nodes((Location.A5_ELDRITCH_SAFE_DIST, Location.A5_ELDRITCH_END), self, time_out=0.6, force_tp=True)
return True
return False
self._pather.traverse_nodes((Location.A5_ELDRITCH_SAFE_DIST, Location.A5_ELDRITCH_END), self, time_out=0.6, force_tp=True)
return True
def kill_shenk(self) -> bool:
delay = [0.2, 0.3]
pos_abs = self._pather.find_abs_node_pos(149, self._screen.grab())
if pos_abs is not None:
shenk_pos_abs = [pos_abs[0] * 0.9, pos_abs[1] * 0.9]
else:
atk_len = max(1, int(self._char_config["atk_len_shenk"] / 2))
shenk_pos_abs = self._pather.find_abs_node_pos(149, self._screen.grab())
if shenk_pos_abs is None:
shenk_pos_abs = self._screen.convert_screen_to_abs(self._config.path["shenk_end"][0])
if shenk_pos_abs is not None:
cast_pos_abs = [shenk_pos_abs[0] * 0.9, shenk_pos_abs[1] * 0.9]
for _ in range(int(self._char_config["atk_len_shenk"])):
self._right_attack(cast_pos_abs, delay, 90)
self._left_attack(cast_pos_abs, delay, 90)
wait(self._cast_duration, self._cast_duration + 0.2)
# Move to items
self._pather.traverse_nodes((Location.A5_SHENK_SAFE_DIST, Location.A5_SHENK_END), self, time_out=1.4, force_tp=True)
return True
return False
cast_pos_abs = [shenk_pos_abs[0] * 0.9, shenk_pos_abs[1] * 0.9]
for _ in range(atk_len):
self._right_attack(cast_pos_abs, 90)
self._left_attack(cast_pos_abs, 90)
# Move to items
wait(self._cast_duration, self._cast_duration + 0.2)
self._pather.traverse_nodes((Location.A5_SHENK_SAFE_DIST, Location.A5_SHENK_END), self, time_out=1.4, force_tp=True)
return True
def kill_nihlatak(self, end_nodes: list[int]) -> bool:
# Find nilhlatak position
atk_len = max(1, int(self._char_config["atk_len_nihlatak"] / 2))
for i in range(atk_len):
nihlatak_pos_abs = self._pather.find_abs_node_pos(end_nodes[-1], self._screen.grab())
if nihlatak_pos_abs is None:
return False
cast_pos_abs = np.array([nihlatak_pos_abs[0] * 0.9, nihlatak_pos_abs[1] * 0.9])
self._left_attack(cast_pos_abs, 90)
self._right_attack(cast_pos_abs, 90)
# Do some tele "dancing" after each sequence
if i < atk_len - 1:
rot_deg = random.randint(-10, 10) if i % 2 == 0 else random.randint(170, 190)
tele_pos_abs = unit_vector(rotate_vec(cast_pos_abs, rot_deg)) * 100
pos_m = self._screen.convert_abs_to_monitor(tele_pos_abs)
self.pre_move()
self.move(pos_m)
# Move to items
wait(self._cast_duration, self._cast_duration + 0.2)
self._pather.traverse_nodes(end_nodes, self, time_out=0.8)
return True
if __name__ == "__main__":