1
+ import datetime
1
2
import json
2
3
import logging
3
4
import math
5
+ import os
6
+ import shutil
4
7
8
+ from jsonmerge import merge
9
+
10
+ import battle .main
11
+ import load_game
5
12
import memory
6
13
import pathing
7
14
import vars
8
15
import xbox
9
- import battle .main
10
- import datetime
11
- import load_game
12
- import shutil
13
- from jsonmerge import merge
14
16
15
17
FFXC = xbox .controller_handle ()
16
18
@@ -70,15 +72,15 @@ def approach_save_sphere():
70
72
target_coords = memory .main .get_actor_coords (target_actor )
71
73
target_details = get_save_sphere_settings (target_actor )
72
74
logger .debug (f"Approaching actor: { target_actor } " )
73
-
75
+
74
76
# Time-out logic
75
77
start_timer = datetime .datetime .now ()
76
78
if target_actor == 999 :
77
- logger .debug (f "Disregard, save sphere could not be found." )
79
+ logger .debug ("Disregard, save sphere could not be found." )
78
80
return False
79
81
else :
80
- logger .debug (f "80 second time-out logic." )
81
- logger .debug (f "The run is NOT SOFT LOCKED" )
82
+ logger .debug ("80 second time-out logic." )
83
+ logger .debug ("The run is NOT SOFT LOCKED" )
82
84
while not (
83
85
memory .main .diag_progress_flag () == target_details [2 ]
84
86
and memory .main .diag_skip_possible ()
@@ -89,7 +91,7 @@ def approach_save_sphere():
89
91
if total_time .total_seconds () > 80 :
90
92
logger .debug ("Save sphere time out - could not reach save sphere." )
91
93
return False
92
-
94
+
93
95
# Touch sphere logic
94
96
if memory .main .user_control ():
95
97
pathing .set_movement ([target_coords [0 ], target_coords [1 ]])
@@ -139,6 +141,7 @@ def approach_save_sphere():
139
141
FFXC .set_neutral ()
140
142
return True
141
143
144
+
142
145
def disengage_save_sphere ():
143
146
while memory .main .save_menu_cursor () == 0 and memory .main .save_menu_cursor_2 () == 0 :
144
147
logger .debug ("Cursor" )
@@ -153,7 +156,7 @@ def touch_and_go():
153
156
disengage_save_sphere ()
154
157
155
158
156
- def touch_and_save (save_num : int = 999 , game_state :str = "tbd" , step_count :int = 999 ):
159
+ def touch_and_save (save_num : int = 999 , game_state : str = "tbd" , step_count : int = 999 ):
157
160
if game_vars .nemesis ():
158
161
save_num += 80
159
162
if save_num >= 200 :
@@ -213,19 +216,19 @@ def touch_and_save(save_num: int = 999, game_state:str="tbd", step_count:int=999
213
216
logger .debug (file_dest )
214
217
215
218
shutil .move (src = file_orig , dst = file_dest )
216
-
219
+
217
220
# Finally, register save in json.
218
- if save_num not in [199 ,999 ]:
221
+ if save_num not in [199 , 999 ]:
219
222
# 199 is used for Arena battles. Reserved.
220
223
# 999 means any unused save. No special save for this.
221
- if game_state == "tbd" or step_count == 999 :
224
+ if game_state == "tbd" or step_count == 999 :
222
225
return
223
-
226
+
224
227
print ("Registering save" )
225
- filepath = os .path .join (' json_ai_files' , ' save_load_details.json' )
228
+ filepath = os .path .join (" json_ai_files" , " save_load_details.json" )
226
229
with open (filepath , "r" ) as fp :
227
230
results = json .load (fp )
228
-
231
+
229
232
# game_state already a string
230
233
step_count_val = str (step_count )
231
234
nem_value = str (game_vars .nemesis ())
@@ -234,7 +237,7 @@ def touch_and_save(save_num: int = 999, game_state:str="tbd", step_count:int=999
234
237
end_game_version_val = str (game_vars .end_game_version ())
235
238
nea_zone = str (game_vars .get_nea_zone ())
236
239
nem_ap_val = str (game_vars .nem_checkpoint_ap ())
237
-
240
+
238
241
new_val = {
239
242
game_state : {
240
243
step_count_val : {
@@ -244,7 +247,7 @@ def touch_and_save(save_num: int = 999, game_state:str="tbd", step_count:int=999
244
247
"end_game_version_val" : end_game_version_val ,
245
248
"nea_zone" : nea_zone ,
246
249
"nem_ap_val" : nem_ap_val ,
247
- "special_movement" : "none"
250
+ "special_movement" : "none" ,
248
251
}
249
252
}
250
253
}
@@ -253,8 +256,9 @@ def touch_and_save(save_num: int = 999, game_state:str="tbd", step_count:int=999
253
256
with open (filepath , "w" ) as fp :
254
257
json .dump (results , fp , indent = 4 )
255
258
259
+
256
260
def get_save_sphere_settings (actor_index : int ):
257
- filepath = os .path .join (' json_ai_files' , ' save_sphere_details.json' )
261
+ filepath = os .path .join (" json_ai_files" , " save_sphere_details.json" )
258
262
with open (filepath , "r" ) as fp :
259
263
results = json .load (fp )
260
264
@@ -275,7 +279,7 @@ def get_save_sphere_settings(actor_index: int):
275
279
276
280
277
281
def record_save_sphere (x_val : int , y_val : int , diag_prog : int , actor : int ):
278
- filepath = os .path .join (' json_ai_files' , ' save_sphere_details.json' )
282
+ filepath = os .path .join (" json_ai_files" , " save_sphere_details.json" )
279
283
logger .debug (f"Recording save sphere to { filepath } " )
280
284
with open (filepath , "r" ) as fp :
281
285
records = json .load (fp )
0 commit comments