-
Notifications
You must be signed in to change notification settings - Fork 0
/
orbwalker.py
79 lines (71 loc) · 3.71 KB
/
orbwalker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import time
import mouse
import keyboard
from world import find_game_time
LETHAL_TEMPO = 'ASSETS/Perks/Styles/Precision/LethalTempo/LethalTempo.lua'
HAIL_OF_BLADES = 'ASSETS/Perks/Styles/Domination/HailOfBlades/HailOfBladesBuff.lua'
LETHAL_TEMPO_STACKS_UNCAPPED_RANGED = 30.
LETHAL_TEMPO_STACKS_UNCAPPED_MELEE = 90.
class OrbWalker:
def __init__(self, mem):
self.mem = mem
game_time = find_game_time(self.mem)
self.can_attack_time = game_time
self.can_move_time = game_time
@staticmethod
def get_attack_time(champion, attack_speed_base, attack_speed_ratio, attack_speed_cap):
total_attack_speed = min(attack_speed_cap, (champion.attack_speed_multiplier - 1) * attack_speed_ratio + attack_speed_base)
return 1. / total_attack_speed
@staticmethod
def get_windup_time(champion, attack_speed_base, attack_speed_ratio, windup_percent, windup_modifier, attack_speed_cap):
# More information at https://leagueoflegends.fandom.com/wiki/Basic_attack#Attack_speed
attack_time = OrbWalker.get_attack_time(champion, attack_speed_base, attack_speed_ratio, attack_speed_cap)
base_windup_time = (1 / attack_speed_base) * windup_percent
windup_time = base_windup_time + ((attack_time * windup_percent) - base_windup_time) * (1+windup_modifier)
return min(windup_time, attack_time)
@staticmethod
def get_attack_speed_cap(stats, champion, game_time):
uncapped = False
lethal_tempo_buffs = [buff for buff in champion.buffs[LETHAL_TEMPO] if buff.end_time > game_time]
assert len(lethal_tempo_buffs) <= 1
if lethal_tempo_buffs:
lethal_tempo, = lethal_tempo_buffs
if stats.is_melee(champion.name):
uncapped |= lethal_tempo.count >= LETHAL_TEMPO_STACKS_UNCAPPED_MELEE
else:
uncapped |= lethal_tempo.count >= LETHAL_TEMPO_STACKS_UNCAPPED_RANGED
uncapped |= any([buff.end_time > game_time for buff in champion.buffs[HAIL_OF_BLADES]])
if uncapped:
return 90.
return 2.5
def walk(self, stats, champion, x, y, game_time):
mouse.press(mouse.MIDDLE)
attack_speed_cap = OrbWalker.get_attack_speed_cap(stats, champion, game_time)
if x is not None and y is not None and self.can_attack_time < game_time:
stored_x, stored_y = mouse.get_position()
mouse.move(int(x), int(y))
mouse.right_click()
time.sleep(0.01)
game_time = find_game_time(self.mem)
attack_speed_base, attack_speed_ratio = stats.get_attack_speed(champion.name)
windup_percent, windup_modifier = stats.get_windup(champion.name)
self.can_attack_time = game_time + OrbWalker.get_attack_time(champion, attack_speed_base, attack_speed_ratio, attack_speed_cap)
self.can_move_time = game_time + OrbWalker.get_windup_time(champion, attack_speed_base, attack_speed_ratio, windup_percent, windup_modifier, attack_speed_cap)
mouse.move(stored_x, stored_y)
elif self.can_move_time < game_time:
mouse.right_click()
MOVE_CLICK_DELAY = 0.05
self.can_move_time = game_time + MOVE_CLICK_DELAY
mouse.release(mouse.MIDDLE)
def cast(self, x, y, spell):
mouse.press(mouse.MIDDLE)
if x is not None and y is not None:
stored_x, stored_y = mouse.get_position()
mouse.move(int(x), int(y))
keyboard.press_and_release('w')
time.sleep(0.01)
game_time = find_game_time(self.mem)
self.can_attack_time = game_time + 0.25
self.can_move_time = game_time + 0.25
mouse.move(stored_x, stored_y)
mouse.release(mouse.MIDDLE)