forked from coderwilson/FFX_TAS_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pathing.py
80 lines (67 loc) · 1.72 KB
/
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
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
80
import logging
from math import copysign
import memory.main
import xbox
logger = logging.getLogger(__name__)
FFXC = xbox.controller_handle()
def set_movement(target) -> bool:
player = memory.main.get_coords()
(forward, right) = memory.main.get_movement_vectors()
# 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
# TODO: Doesn't appear to be used, but left for historical purposes
def seymour_natus(): # First checkpoint ever written. :D
x = 15
y = 150
return [x, y]
# TODO: This appears to be unused
def t_plains_dodging(checkpoint):
x = 999
y = 999
if checkpoint == 0:
x = 29
y = 149
if checkpoint == 1:
x = 16
y = -59
if checkpoint == 2:
x = 115
y = -297
if checkpoint == 3:
x = 35
y = -616
if checkpoint == 4:
x = -91
y = -866
if checkpoint == 5:
x = -121
y = -1089
if checkpoint == 6:
x = -120
y = -1300
return [x, y]