forked from coderwilson/FFX_TAS_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
airship_pathing.py
269 lines (249 loc) · 10.4 KB
/
airship_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
import logging
import math
import battle.main
import memory.main
import pathing
import vars
import xbox
from paths import Airship
logger = logging.getLogger(__name__)
game_vars = vars.vars_handle()
FFXC = xbox.controller_handle()
def air_ship_path(version):
memory.main.click_to_control()
distiller_purchase = False
complete = False
checkpoint = 0
while not complete:
if memory.main.user_control():
# Map changes
if checkpoint == 2:
memory.main.click_to_event_temple(3)
checkpoint += 1
elif (
version == 1
and not distiller_purchase
and checkpoint == 5
and (memory.main.get_speed() < 9 or memory.main.get_power() < 23)
):
# Tyton to update this with the actual purchase.
while memory.main.diag_progress_flag() != 44:
if memory.main.user_control():
pathing.set_movement([-6, 6])
xbox.tap_b()
else:
FFXC.set_neutral()
if memory.main.battle_active():
battle.main.flee_all()
elif memory.main.menu_open():
xbox.tap_b()
FFXC.set_neutral()
memory.main.click_to_diag_progress(48)
while memory.main.airship_shop_dialogue_row() != 1:
xbox.tap_down()
while not memory.main.item_shop_menu() == 7:
xbox.tap_b() # Click through until items menu comes up
while not memory.main.item_shop_menu() == 10:
xbox.tap_b() # Select buy command
if memory.main.get_power() < 23:
while memory.main.equip_buy_row() != 7:
if memory.main.equip_buy_row() < 7:
xbox.tap_down()
else:
xbox.tap_up()
while not memory.main.item_shop_menu() == 16:
xbox.tap_b()
while memory.main.purchasing_amount_items() != min(
math.ceil((23 - memory.main.get_power()) / 2), 3
):
if memory.main.purchasing_amount_items() < min(
math.ceil((23 - memory.main.get_power()) / 2), 3
):
xbox.tap_right()
else:
xbox.tap_left()
while not memory.main.item_shop_menu() == 10:
xbox.tap_b()
if memory.main.get_speed() < 9:
while memory.main.equip_buy_row() != 9:
if memory.main.equip_buy_row() < 9:
xbox.tap_down()
else:
xbox.tap_up()
while not memory.main.item_shop_menu() == 16:
xbox.tap_b()
while memory.main.purchasing_amount_items() != min(
math.ceil((9 - memory.main.get_speed()) / 2), 2
):
if memory.main.purchasing_amount_items() < min(
math.ceil((9 - memory.main.get_speed()) / 2), 2
):
xbox.tap_right()
else:
xbox.tap_left()
while not memory.main.item_shop_menu() == 10:
xbox.tap_b()
memory.main.close_menu()
memory.main.click_to_control_3()
distiller_purchase = True
elif checkpoint < 6 and memory.main.get_map() == 351: # Screen with Isaaru
checkpoint = 6
elif (
checkpoint < 9 and memory.main.get_map() == 211
): # Gallery screen (includes lift screens)
checkpoint = 9
# Optional save sphere can be touched here.
# Should not be necessary, we should be touching save sphere in Home
elif checkpoint == 14 and version == 2:
logger.info("Talking to Yuna/Kimahri in the gallery")
checkpoint = 23
logger.debug(f"Checkpoint update: {checkpoint}")
elif checkpoint == 16:
memory.main.click_to_event_temple(0)
checkpoint += 1
elif checkpoint == 18:
FFXC.set_neutral()
xbox.skip_dialog(1)
memory.main.await_control()
checkpoint += 1
elif checkpoint == 24:
memory.main.click_to_event_temple(7)
checkpoint += 1
# Return trip map changes
elif checkpoint in [32, 34]: # Formerly included 13
memory.main.click_to_event_temple(0)
checkpoint += 1
elif checkpoint == 37:
memory.main.click_to_event_temple(1)
checkpoint += 1
elif checkpoint == 40:
memory.main.click_to_event_temple(7)
checkpoint += 1
elif checkpoint in [43, 44] and not game_vars.csr():
checkpoint = 45
elif checkpoint == 44: # Talk to Cid
while memory.main.user_control():
pathing.set_movement([-250, 339])
xbox.tap_b()
FFXC.set_neutral()
complete = True
elif checkpoint == 46: # Talk to Cid
while memory.main.user_control():
pathing.set_movement([-230, 366])
xbox.tap_b()
FFXC.set_neutral()
complete = True
# Complete states
elif checkpoint == 19 and version == 1:
logger.info("Pre-Evrae pathing")
FFXC.set_movement(0, 1)
memory.main.wait_frames(30 * 3)
FFXC.set_neutral()
complete = True
elif checkpoint == 19 and version == 3:
logger.info("Sin's Arms")
FFXC.set_movement(0, 1)
memory.main.wait_frames(30 * 3)
FFXC.set_neutral()
while not memory.main.battle_active():
if memory.main.diag_skip_possible():
xbox.tap_b()
elif memory.main.cutscene_skip_possible():
xbox.skip_scene()
complete = True
elif checkpoint == 19 and version == 4:
logger.info("Straight to the deck, talking to Yuna.")
FFXC.set_movement(0, 1)
memory.main.wait_frames(30 * 3)
FFXC.set_neutral()
memory.main.await_control()
pathing.set_movement([-2, -15])
memory.main.wait_frames(30 * 0.5)
while memory.main.user_control():
pathing.set_movement([-2, -15])
xbox.tap_b()
FFXC.set_neutral()
while not memory.main.user_control():
if memory.main.diag_skip_possible():
xbox.tap_b()
elif memory.main.cutscene_skip_possible():
xbox.skip_scene()
complete = True
elif checkpoint == 19 and version == 5:
logger.info("Again to the deck, three skips.")
FFXC.set_movement(0, 1)
memory.main.wait_frames(30 * 3)
FFXC.set_neutral()
while not memory.main.battle_active():
if memory.main.diag_skip_possible():
xbox.tap_b()
elif memory.main.cutscene_skip_possible():
xbox.skip_scene()
complete = True
elif checkpoint == 19 and version == 6:
logger.info("Sin's Face")
FFXC.set_movement(0, 1)
memory.main.wait_frames(30 * 3)
FFXC.set_neutral()
complete = True
# General Pathing
elif pathing.set_movement(Airship.execute(checkpoint)):
checkpoint += 1
logger.debug(f"Checkpoint reached: {checkpoint}")
else:
FFXC.set_neutral()
if memory.main.battle_active():
battle.main.flee_all()
elif memory.main.menu_open() or memory.main.diag_skip_possible():
logger.debug("Mark")
xbox.tap_b()
logger.info("End of section, Airship pathing")
def air_ship_return():
logger.info("Conversation with Yuna/Kimahri.")
memory.main.click_to_control()
pos = memory.main.get_coords()
logger.info("Ready to run back to the cockpit.")
while pos[1] > -90: # Leaving Yuna/Kimahri, heading back down.
FFXC.set_value("axis_ly", -1)
FFXC.set_value("axis_lx", 0)
pos = memory.main.get_coords()
logger.debug("Turn East")
while pos[0] < -1:
FFXC.set_value("axis_lx", 1)
FFXC.set_value("axis_ly", 0)
pos = memory.main.get_coords()
logger.debug("Turn North")
while memory.main.user_control():
FFXC.set_value("axis_lx", 0)
FFXC.set_value("axis_ly", 1)
pos = memory.main.get_coords()
FFXC.set_value("axis_ly", 0)
FFXC.set_value("axis_lx", 0)
memory.main.await_control()
while memory.main.user_control():
FFXC.set_value("axis_lx", 0)
FFXC.set_value("axis_ly", 1)
FFXC.set_value("axis_ly", 0)
FFXC.set_value("axis_lx", 0)
memory.main.await_control()
while memory.main.user_control():
pos = memory.main.get_coords()
memory.main.wait_frames(30 * 0.05)
FFXC.set_value("axis_ly", 1)
if pos[0] < -1:
FFXC.set_value("axis_lx", 1)
else:
FFXC.set_value("axis_lx", 0)
FFXC.set_value("axis_ly", 0)
FFXC.set_value("axis_lx", 0)
memory.main.await_control()
FFXC.set_value("axis_ly", 1)
memory.main.wait_frames(30 * 1.2)
FFXC.set_value("axis_ly", 0)
FFXC.set_value("axis_lx", -1)
memory.main.wait_frames(30 * 0.5)
while memory.main.user_control():
FFXC.set_value("axis_ly", 1)
FFXC.set_value("axis_lx", -1)
FFXC.set_value("axis_ly", 0)
FFXC.set_value("axis_lx", 0)