Reworked trapsin a bit to include casting/attack delays between skills. Also added mindblast and added to pindle run.

This commit is contained in:
Randi
2024-06-26 19:59:50 -04:00
parent 8df42bbcb1
commit 30d407e978
2 changed files with 147 additions and 44 deletions
+128 -28
View File
@@ -1,4 +1,5 @@
import keyboard
from ui import skills
from utils.custom_mouse import mouse
from char import IChar
from pather import Pather
@@ -6,6 +7,7 @@ from logger import Logger
from screen import convert_abs_to_monitor, convert_screen_to_abs, grab
from config import Config
from utils.misc import wait, rotate_vec, unit_vector
import time
import random
from pather import Location, Pather
import numpy as np
@@ -25,16 +27,11 @@ class Trapsin(IChar):
wait(0.1, 0.13)
mouse.click(button="right")
wait(self._cast_duration)
if self._skill_hotkeys["shadow_warrior"]:
keyboard.send(self._skill_hotkeys["shadow_warrior"])
wait(0.1, 0.13)
mouse.click(button="right")
wait(self._cast_duration)
def pre_move(self, wait_tp: bool = False):
super().pre_move(wait_tp=wait_tp)
if self._skill_hotkeys["burst_of_speed"]:
keyboard.send(self._skill_hotkeys["burst_of_speed"])
wait(0.1, 0.13)
mouse.click(button="right")
wait(self._cast_duration)
self._cast_burst_of_speed()
def _left_attack(self, cast_pos_abs: tuple[float, float], spray: int = 10):
keyboard.send(Config().char["stand_still"], do_release=False)
@@ -50,7 +47,6 @@ class Trapsin(IChar):
mouse.release(button="left")
keyboard.send(Config().char["stand_still"], do_press=False)
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)
@@ -66,35 +62,139 @@ class Trapsin(IChar):
atk(4)
keyboard.send(self._skill_hotkeys["death_sentry"])
atk(1)
def _cast_shadow_warrior(self, cast_pos_abs: tuple[float, float], spray: float = 10):
if self._skill_hotkeys["shadow_warrior"]:
keyboard.send(self._skill_hotkeys["shadow_warrior"])
x = cast_pos_abs[0] + (random.random() * 2 * spray - spray)
y = cast_pos_abs[1] + (random.random() * 2 * spray - spray)
cast_pos_monitor = convert_abs_to_monitor((x, y))
mouse.move(*cast_pos_monitor)
mouse.press(button="right")
wait(0.06, 0.08)
mouse.release(button="right")
wait(self._cast_duration-0.06)
def _cast_mind_blast(self, cast_pos_abs: tuple[float, float], spray: float = 10):
if self._skill_hotkeys["mind_blast"]:
keyboard.send(self._skill_hotkeys["mind_blast"])
x = cast_pos_abs[0] + (random.random() * 2 * spray - spray)
y = cast_pos_abs[1] + (random.random() * 2 * spray - spray)
cast_pos_monitor = convert_abs_to_monitor((x, y))
mouse.move(*cast_pos_monitor)
mouse.press(button="right")
wait(0.06, 0.08)
mouse.release(button="right")
wait(self._cast_duration-0.06)
def _cast_burst_of_speed(self):
if self._skill_hotkeys["burst_of_speed"]:
keyboard.send(self._skill_hotkeys["burst_of_speed"])
mouse.press(button="right")
wait(0.06, 0.08)
mouse.release(button="right")
wait(self._cast_duration-0.06)
def _cast_fire_blast(self, cast_pos_abs: tuple[float, float], spray: float = 10, duration: float = 0.3):
keyboard.send(Config().char["stand_still"], do_release=False)
#Get mouse in initial target logcation
x = cast_pos_abs[0] + (random.random() * 2 * spray - spray)
y = cast_pos_abs[1] + (random.random() * 2 * spray - spray)
cast_pos_monitor = convert_abs_to_monitor((x, y))
mouse.move(*cast_pos_monitor)
#We just hold down left mouse button to ensure we get full attack speed.
mouse.press(button="left")
now = start = time.time()
while (now - start) < duration:
x = cast_pos_abs[0] + (random.random() * 2 * spray - spray)
y = cast_pos_abs[1] + (random.random() * 2 * spray - spray)
cast_pos_monitor = convert_abs_to_monitor((x, y))
mouse.move(*cast_pos_monitor)
wait(0.06, 0.08)
now = time.time()
mouse.release(button="left")
keyboard.send(Config().char["stand_still"], do_press=False)
wait(self._attack_duration-0.06)
def _cast_lightning_sentry(self, cast_pos_abs: tuple[float, float], spray: float = 10):
if not self._skill_hotkeys["lightning_sentry"]:
Logger.error("Lightning sentry hotkey not assigned. Required for trapsin!")
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)
cast_pos_monitor = convert_abs_to_monitor((x, y))
mouse.move(*cast_pos_monitor)
mouse.press(button="right")
wait(0.06, 0.08)
mouse.release(button="right")
wait(self._attack_duration-0.06)
def _cast_death_sentry(self, cast_pos_abs: tuple[float, float], spray: float = 10):
if not self._skill_hotkeys["death_sentry"]:
Logger.error("Death sentry hotkey not assigned. Required for trapsin!")
keyboard.send(self._skill_hotkeys["death_sentry"])
x = cast_pos_abs[0] + (random.random() * 2 * spray - spray)
y = cast_pos_abs[1] + (random.random() * 2 * spray - spray)
cast_pos_monitor = convert_abs_to_monitor((x, y))
mouse.move(*cast_pos_monitor)
mouse.press(button="right")
wait(0.06, 0.08)
mouse.release(button="right")
wait(self._attack_duration-0.06)
def kill_pindle(self) -> bool:
atk_len = max(1, int(Config().char["atk_len_pindle"] / 2))
pindle_pos_abs = convert_screen_to_abs(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)
cast_pos_abs = [pindle_pos_abs[0] * 1.2, pindle_pos_abs[1] * 1.2]
trap_cast_pos_abs = [pindle_pos_abs[0] * 0.45, pindle_pos_abs[1] * 0.40]
start = time.time()
self._cast_mind_blast(cast_pos_abs=cast_pos_abs)
cast_pos_abs = [pindle_pos_abs[0] * 0.8, pindle_pos_abs[1] * 0.8]
self._cast_shadow_warrior(cast_pos_abs=cast_pos_abs)
for _ in range(4):
self._cast_lightning_sentry(cast_pos_abs=trap_cast_pos_abs, spray=5.0)
self._cast_death_sentry(cast_pos_abs=trap_cast_pos_abs, spray=5.0)
trap_cast_pos_abs = [pindle_pos_abs[0] * 0.50, pindle_pos_abs[1] * 0.50]
time_remaining = Config().char["atk_len_pindle"] - (time.time() - start)
self._cast_fire_blast(cast_pos_abs=cast_pos_abs, duration=time_remaining)
if self.capabilities.can_teleport_natively:
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
#Walk just close enough to pindle's position to see items. That way we leave sooner if there is nothing to grab
x_m, y_m = convert_abs_to_monitor([pindle_pos_abs[0] * 0.65, pindle_pos_abs[1] * 0.65])
self.move((x_m, y_m), force_move=True)
return False
def kill_eldritch(self) -> bool:
atk_len = max(1, int(Config().char["atk_len_eldritch"] / 2))
eld_pos_abs = convert_screen_to_abs(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)
eldritch_pos_abs = convert_screen_to_abs(Config().path["eldritch_end"][0])
cast_pos_abs = [eldritch_pos_abs[0] * 1.5, eldritch_pos_abs[1] * 1.5]
trap_cast_pos_abs = [eldritch_pos_abs[0] * 0.70, eldritch_pos_abs[1] * 0.70]
start = time.time()
self._cast_shadow_warrior(cast_pos_abs=cast_pos_abs)
for _ in range(4):
self._cast_lightning_sentry(cast_pos_abs=trap_cast_pos_abs)
self._cast_death_sentry(cast_pos_abs=trap_cast_pos_abs)
time_remaining = Config().char["atk_len_eldritch"] - (time.time() - start)
self._cast_fire_blast(cast_pos_abs=cast_pos_abs, duration=time_remaining)
if self.capabilities.can_teleport_natively:
self._pather.traverse_nodes_fixed("eldritch_end", self)
else:
self._pather.traverse_nodes((Location.A5_ELDRITCH_SAFE_DIST, Location.A5_ELDRITCH_END), self, timeout=0.6, force_tp=True)
x_m, y_m = convert_abs_to_monitor([eldritch_pos_abs[0] * 1.0, eldritch_pos_abs[1] * 1.0])
self.move((x_m, y_m), force_move=True)
return True
def kill_shenk(self) -> bool: