-
Notifications
You must be signed in to change notification settings - Fork 2
/
katas.py
80 lines (60 loc) · 2.05 KB
/
katas.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 math
# F for frames T for time
MODE = 'F'
class Controller:
up = 1
down = 2
left = 4
right = 8
start = 0x10
back = 0x20
left_thumb = 0x40
right_thumb = 0x80
left_shoulder = 0x100
right_shoulder = 0x200
A = 0x1000
B = 0x2000
X = 0x4000
Y = 0x8000
class Scripter:
action_list = []
current_time = 0
def Wait(self, duration):
self.current_time+=duration
def AddRawAction(self, time, duration=1, buttons=0, lt=0, rt=0, lx=0, ly=0, rx=0, ry=0):
if MODE == 'F':
self.action_list.append(f'{time},{duration},{buttons},{lt},{rt},{lx},{ly},{rx},{ry}')
else:
self.action_list.append(f'{time * (1/60)},{duration * (1/60)},{buttons},{lt},{rt},{lx},{ly},{rx},{ry}')
def Button(self, buttons, frame=None, duration=1):
if frame is None:
frame = self.current_time
self.AddRawAction(frame, duration, buttons)
def MoveLeftStick(self, deg, frame=None, duration=1):
x_pos = math.cos(math.radians(deg))*32767
y_pos = math.sin(math.radians(deg))*32767
if frame is None:
frame = self.current_time
self.AddRawAction(frame, duration, lx=x_pos, ly=y_pos)
def MoveRightStick(self, deg, frame=None, duration=1):
x_pos = math.cos(math.radians(deg))*32767
y_pos = math.sin(math.radians(deg))*32767
if frame is None:
frame = self.current_time
self.AddRawAction(frame, duration, rx=x_pos, ry=y_pos)
def Roll(self, duration=1):
self.AddRawAction(self.current_time, duration, rt=0xFF)
def CrouchRoll(self):
self.Button(Controller.down, duration=1)
self.Roll()
def PerfectRollWait(self, amount=1):
for a in range(amount):
self.CrouchRoll()
self.Wait(22)
def WaitLevel(self):
self.Wait(90)
def save(self, file=R'.\..\tas.kzt'):
fw = open(file, 'w')
for st in self.action_list:
fw.write(st+'\n')
fw.close()