forked from coderwilson/FFX_TAS_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blitz_pathing.py
42 lines (34 loc) · 1011 Bytes
/
blitz_pathing.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
from math import copysign
import memory.main
import xbox
FFXC = xbox.controller_handle()
def set_movement(target) -> bool:
player = memory.main.get_coords()
(forward, right) = ((1, 0), (0, -1))
# Calculate forward and right directions relative to camera space
pX = player[0]
pY = player[1]
eX = target[0]
eY = target[1]
fX = forward[0]
fY = forward[1]
rX = right[0]
rY = right[1]
Ly = fX * (eX - pX) + rX * (eY - pY)
Lx = fY * (eX - pX) + rY * (eY - pY)
sums_up = abs(Lx) + abs(Ly)
if sums_up == 0:
sums_up = 0.01
Lx /= sums_up
Ly /= sums_up
if abs(Lx) > abs(Ly):
Ly = copysign(Ly / Lx if Lx else 0, Ly)
Lx = copysign(1, Lx)
elif abs(Ly) > abs(Lx):
Lx = copysign(Lx / Ly if Ly else 0, Lx)
Ly = copysign(1, Ly)
FFXC.set_movement(Lx, Ly)
if abs(player[1] - target[1]) < 3 and abs(player[0] - target[0]) < 3:
return True # Checkpoint reached
else:
return False