forked from coderwilson/FFX_TAS_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFFX_Battle.py
More file actions
4799 lines (4490 loc) · 171 KB
/
FFX_Battle.py
File metadata and controls
4799 lines (4490 loc) · 171 KB
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import FFX_Xbox
import FFX_Screen
import time
import FFX_Logs
import FFX_memory
FFXC = FFX_Xbox.FFXC
def defend():
FFXC.set_value('BtnY', 1)
time.sleep(0.035)
FFXC.set_value('BtnY', 0)
time.sleep(0.035)
FFXC.set_value('BtnY', 1)
time.sleep(0.035)
FFXC.set_value('BtnY', 0)
time.sleep(0.035)
print("Defend command")
FFX_Xbox.menuA()
FFX_Xbox.menuA()
time.sleep(0.6)
def tidusFlee():
print("Tidus Flee (or similar command pattern)")
if FFX_memory.otherBattleMenu():
while FFX_memory.otherBattleMenu():
FFX_Xbox.menuA()
while FFX_memory.battleMenuCursor() != 20:
if FFX_Screen.turnTidus() == False:
break
if FFX_memory.battleMenuCursor() == 255:
time.sleep(0.01)
elif FFX_memory.battleMenuCursor() == 1:
FFX_Xbox.menuUp()
elif FFX_memory.battleMenuCursor() > 20:
FFX_Xbox.menuUp()
else:
FFX_Xbox.menuDown()
FFX_Xbox.SkipDialog(1.5)
def useSkill(position):
print("Using skill in position: ", position)
while FFX_memory.battleMenuCursor() != 19:
print(FFX_memory.battleMenuCursor())
if FFX_memory.battleMenuCursor() == 255:
time.sleep(0.01)
elif FFX_memory.battleMenuCursor() == 1:
FFX_Xbox.menuUp()
time.sleep(0.1)
elif FFX_memory.battleMenuCursor() > 19:
FFX_Xbox.menuUp()
time.sleep(0.1)
else:
FFX_Xbox.menuDown()
if position == 0:
FFX_Xbox.SkipDialog(1.5)
else:
FFX_Xbox.menuB()
time.sleep(0.035)
while FFX_memory.battleCursor2() != position:
if position % 2 == 0 and FFX_memory.battleCursor2() % 2 == 1:
FFX_Xbox.menuLeft()
elif position % 2 == 1 and FFX_memory.battleCursor2() % 2 == 0:
FFX_Xbox.menuRight()
elif position > FFX_memory.battleCursor2():
FFX_Xbox.menuDown()
else:
FFX_Xbox.menuUp()
FFX_Xbox.SkipDialog(1)
def tidusOD():
print("Tidus overdrive activating")
while not FFX_memory.otherBattleMenu():
FFX_Xbox.menuLeft()
FFX_Xbox.SkipDialog(2)
while not FFX_Screen.PixelTestTol(1239, 436, (191, 186, 208), 10):
doNothing = True
time.sleep(0.43) # First try every time?
FFX_Xbox.menuB()
time.sleep(0.25)
FFX_Xbox.menuB()
time.sleep(0.3)
FFX_Xbox.menuB()
time.sleep(0.35)
FFX_Xbox.menuB()
def tidusODSeymour():
print("Tidus overdrive activating")
FFX_Screen.awaitTurn()
while FFX_memory.battleScreen():
FFX_Xbox.menuLeft()
time.sleep(0.8)
FFX_Xbox.menuB()
time.sleep(0.4)
FFX_Xbox.menuB()
time.sleep(0.4)
FFX_Xbox.menuLeft()
FFX_Xbox.menuB() # Activate overdrive
time.sleep(0.4)
while not FFX_Screen.PixelTestTol(1239, 436, (191, 186, 208), 10):
doNothing = True
time.sleep(0.43) # First try every time?
FFX_Xbox.menuB()
time.sleep(0.25)
FFX_Xbox.menuB()
time.sleep(0.3)
FFX_Xbox.menuB()
time.sleep(0.3)
FFX_Xbox.menuB()
time.sleep(0.35)
FFX_Xbox.menuB()
time.sleep(0.35)
FFX_Xbox.menuB()
time.sleep(0.3)
FFX_Xbox.menuB()
time.sleep(0.25)
FFX_Xbox.menuB()
def remedy(healerposition: int, targetposition: int, direction: str):
if FFX_memory.getThrowItemsSlot(15) < 255:
itemnum = 15
itemname = "Remedy"
else:
itemnum = -1
itemname = "noitemfound"
if itemnum >= 0:
FFX_Logs.writeLog("Using %s" % itemname)
print("Using %s" % itemname)
if FFX_Screen.PixelTestTol(277, 726, (223, 223, 223), 5):
FFX_Xbox.menuDown()
else:
while not FFX_Screen.PixelTestTol(276, 769, (218, 218, 218), 5): # Item option isn't showing up
if FFX_Screen.BattleComplete():
return
FFX_Xbox.menuDown()
while not FFX_Screen.PixelTestTol(130, 779, (165, 167, 165),
5): # Item option isn't selected (it's always last)
if FFX_Screen.BattleComplete():
return
FFX_Xbox.menuDown()
FFX_Xbox.menuB() # Item menu open.
time.sleep(0.3)
cursor = 1
itemPos = FFX_memory.getThrowItemsSlot(itemnum)
if itemPos % 2 == 0:
FFX_Xbox.menuRight()
cursor += 1
if cursor == itemPos:
FFX_Xbox.menuB()
else:
while cursor != itemPos:
FFX_Xbox.menuDown()
cursor += 2
FFX_Xbox.menuB()
print("Direction: ", direction)
direction = direction.lower()
if (targetposition - healerposition) % 3 == 1:
if direction == "left":
FFX_Xbox.menuLeft()
elif direction == "right":
FFX_Xbox.menuRight()
elif direction == "up":
FFX_Xbox.menuUp()
elif direction == "down":
FFX_Xbox.menuDown()
elif (targetposition - healerposition) % 3 == 2:
if direction == "left":
FFX_Xbox.menuRight()
elif direction == "right":
FFX_Xbox.menuLeft()
elif direction == "up":
FFX_Xbox.menuDown()
elif direction == "down":
FFX_Xbox.menuUp()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
return 1
else:
print("No restorative items available")
return 0
def revive():
FFX_Logs.writeLog("Using Phoenix Down")
print("Using Phoenix Down")
while FFX_memory.battleMenuCursor() != 1:
FFX_Xbox.menuDown()
FFX_Xbox.menuB() # Item menu open.
itemPos = FFX_memory.getThrowItemsSlot(6) - 1
while FFX_memory.battleCursor2() != itemPos:
print(FFX_memory.battleCursor2()," | ", itemPos)
if FFX_memory.battleCursor2() == 0:
FFX_Xbox.menuDown()
elif itemPos % 2 == 0 and FFX_memory.battleCursor2() % 2 == 1:
FFX_Xbox.menuRight()
elif itemPos % 2 == 1 and FFX_memory.battleCursor2() % 2 == 0:
FFX_Xbox.menuLeft()
elif itemPos > FFX_memory.battleCursor2():
FFX_Xbox.menuDown()
else:
FFX_Xbox.menuUp()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
def reviveAll():
FFX_Logs.writeLog("Using Mega Phoenix Down")
while FFX_memory.battleMenuCursor() != 1:
FFX_Xbox.menuDown()
FFX_Xbox.menuB() # Item menu open.
time.sleep(0.3)
cursor = 1
itemPos = FFX_memory.getThrowItemsSlot(7)
if itemPos % 2 == 0:
FFX_Xbox.menuRight()
cursor += 1
if cursor == itemPos: # P.downs are in slot 2
FFX_Xbox.menuB()
else:
while cursor != itemPos: # If not slot 2, scroll down until we find phoenix downs.
FFX_Xbox.menuDown()
cursor += 2
FFX_Xbox.menuB()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
def FinishWithAttacksOnly():
BattleComplete = 0
countAttacks = 0
countRevives = 0
while not FFX_memory.menuOpen(): #AKA end of battle screen
if FFX_memory.battleScreen():
if FFX_Screen.faintCheck() > 0:
revive()
countRevives += 1
else:
attack('none')
countAttacks += 1
if FFX_Screen.BattleComplete():
print("Victory Screen")
FFXC.set_value("BtnB", 1)
time.sleep(2.4)
FFXC.set_value("BtnB", 0)
BattleComplete = 1
FFX_Logs.writeStats("Attack-only battle. Attacks: " + str(countAttacks))
FFX_Logs.writeStats("Attack-only battle. Revives: " + str(countRevives))
def selfPot():
FFX_Xbox.menuDown()
FFX_Xbox.menuDown()
FFX_Xbox.menuDown()
FFX_Xbox.menuB()
FFX_Xbox.SkipDialog(2)
def Ammes():
FFX_Logs.writeLog("Fight start: Ammes")
BattleComplete = 0
countAttacks = 0
countRevives = 0
tidusODflag = False
while BattleComplete != 1:
if FFX_memory.battleScreen():
if tidusODflag == False and FFX_Screen.turnTidus() and FFX_Screen.checkCharge(1):
tidusOD()
tidusODflag = True
else:
print("Attacking Sinspawn Ammes")
attack('none')
countAttacks += 1
if FFX_memory.userControl():
BattleComplete = 1
print("Ammes battle complete")
FFX_Logs.writeStats("Sinspawn Ammes. Attacks:")
FFX_Logs.writeStats(str(countAttacks))
def Tanker():
FFX_Logs.writeLog("Fight start: Tanker")
BattleComplete = 0
countAttacks = 0
countRevives = 0
tidusCount = 0
auronCount = 0
FFX_Screen.clickToBattle()
while FFX_memory.getStoryProgress() < 19:
if FFX_memory.battleScreen():
if FFX_Screen.turnTidus():
tidusCount += 1
if tidusCount < 4:
FFX_Xbox.weapSwap(0)
time.sleep(0.5)
else:
attack('none')
elif FFX_Screen.turnAuron():
auronCount += 1
if auronCount < 2:
time.sleep(0.5)
FFX_Xbox.menuB()
time.sleep(0.1)
FFX_Xbox.menuDown()
FFX_Xbox.menuLeft()
FFX_Xbox.menuB()
else:
attack('none')
elif FFX_memory.diagSkipPossible():
FFX_Xbox.menuB()
while not FFX_memory.userControl():
#print("Skip cutscene")
FFXC.set_value('BtnX', 1)
FFXC.set_value('BtnB', 1)
time.sleep(0.035)
FFXC.set_value('BtnX', 0)
FFXC.set_value('BtnB', 0)
time.sleep(0.035)
FFX_Logs.writeStats("Tanker. Attacks:")
FFX_Logs.writeStats(str(countAttacks))
def Klikk():
rikkuSteal = 0
while not FFX_memory.menuOpen(): #AKA end of battle screen
if FFX_memory.battleScreen():
BattleHP = FFX_memory.getBattleHP()
if BattleHP[1] == 0 or BattleHP[2] == 0:
revive()
elif FFX_Screen.turnTidus():
if BattleHP[1] < 120:
FFX_Xbox.menuDown()
FFX_Xbox.menuDown()
FFX_Xbox.menuB()
time.sleep(0.4)
FFX_Xbox.menuB()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
else:
attack('none')
elif FFX_Screen.turnRikkuRed():
if rikkuSteal == 0:
print("Attempting to steal from Klikk")
Steal()
rikkuSteal = 1
elif BattleHP[2] < 110:
FFX_Xbox.menuDown()
FFX_Xbox.menuDown()
FFX_Xbox.menuB()
time.sleep(0.4)
FFX_Xbox.menuB()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
else:
attack('none')
else:
FFX_Xbox.menuB()
print("Klikk fight complete")
FFX_memory.clickToControl() # Maybe not skippable dialog, but whatever.
def Tros():
FFX_Logs.writeLog("Fight start: Tros")
FFXC.set_value('AxisLx', 0)
FFXC.set_value('AxisLy', 0)
battleClock = 0
countAttacks = 0
countRevives = 0
countGrenades = 0
countSteals = 0
countDefends = 0
countHeals = 0
FFX_Screen.clickToBattle()
while not FFX_memory.menuOpen(): #AKA end of battle screen
if FFX_memory.diagSkipPossible():
FFX_Xbox.menuB()
elif FFX_memory.otherBattleMenu():
FFX_Xbox.menuA()
elif FFX_memory.battleScreen():
battleClock += 1
print("Battle clock:", battleClock)
trosPos = 2
print("Determining Tros position")
while trosPos == 2: # Two for "not yet determined".
camera = FFX_memory.getCamera()
# First, determine position of Tros
if camera[0] > 2:
trosPos = 0 # Zero for cannot attack.
print("Tros is long-range. Cannot attack.")
elif camera[0] < -2:
trosPos = 0 # Zero for cannot attack.
print("Tros is long-range. Cannot attack.")
else:
trosPos = 1 # One for "Close range, can be attacked.
print("Tros is short-range.")
partyHP = FFX_memory.getBattleHP()
if partyHP[1] == 0 or partyHP[2] == 0: # Someone requires reviving.
print("Tros: Someone fainted.")
revive()
elif FFX_Screen.turnRikkuRed():
if battleClock < 3:
grenadeSlot = FFX_memory.getUseItemsSlot(35)
if FFX_memory.getItemCountSlot(grenadeSlot) < 6:
print("Rikku's first turn. Steal.")
Steal()
time.sleep(0.5)
else:
print("Already have enough grenades. Hopping to it.")
FFX_Xbox.menuDown()
FFX_Xbox.menuB()
time.sleep(0.4)
FFX_Xbox.menuRight()
FFX_Xbox.SkipDialog(2)
else:
FFX_Xbox.menuDown()
FFX_Xbox.menuB()
time.sleep(0.4)
FFX_Xbox.menuRight()
FFX_Xbox.menuB()
time.sleep(0.4)
if FFX_Screen.PixelTestTol(190, 713, (205, 205, 205), 5):
print("Throwing a grenade")
FFX_Xbox.menuB()
FFX_Xbox.menuB()
countGrenades += 1
elif trosPos == 1:
print("Out of grenades. Stealing instead.")
FFX_Xbox.menuA()
time.sleep(0.2)
FFX_Xbox.menuLeft()
FFX_Xbox.menuB()
FFX_Xbox.menuB()
time.sleep(0.2)
countSteals += 1
else:
print("Out of grenades at range. Skipping turn.")
FFX_Xbox.menuA()
time.sleep(0.2)
FFX_Xbox.menuA()
time.sleep(0.2)
defend()
countDefends += 1
elif FFX_Screen.turnTidus():
if battleClock < 3:
print("Tros: Tidus attacking.")
attack('none')
elif trosPos == 0:
print("Tros: Tidus at range. Defend.")
defend()
elif trosPos == 1:
print("Tros: Tidus in range. Attack.")
attack('none')
else:
print("Something went wrong. Deferring this turn.")
battleClock -= 1
FFX_memory.clickToControl()
FFX_Logs.writeStats("Tros Attacks:")
FFX_Logs.writeStats(str(countAttacks))
FFX_Logs.writeStats("Tros Revives:")
FFX_Logs.writeStats(str(countRevives))
FFX_Logs.writeStats("Tros Grenades:")
FFX_Logs.writeStats(str(countGrenades))
FFX_Logs.writeStats("Tros Steals:")
FFX_Logs.writeStats(str(countSteals))
FFX_Logs.writeStats("Tros Turns defending:")
FFX_Logs.writeStats(str(countDefends))
FFX_Logs.writeStats("Tros Turns healing (potions):")
FFX_Logs.writeStats(str(countHeals))
def besaid():
FFXC.set_value('AxisLx', 0)
FFXC.set_value('AxisLy', 0)
battleFormat = FFX_memory.getBattleNum()
print("Besaid battle format number: ", battleFormat)
while not FFX_memory.menuOpen(): #AKA end of battle screen
if FFX_memory.battleScreen():
if FFX_Screen.turnYuna():
buddySwap(1)
elif FFX_Screen.turnLulu():
if battleFormat == 26:
fire('none')
else:
thunder('none')
elif FFX_Screen.turnWakka():
attack('none')
elif FFX_Screen.turnTidus():
if battleFormat == 27:
attack('right')
elif battleFormat == 23:
defend()
else:
attack('right')
FFX_memory.clickToControl()
def SinFin():
FFX_Logs.writeLog("Fight start: Sin's Fin")
FFX_Screen.awaitTurn()
complete = 0
while complete == 0:
print("Determining first turn.")
if FFX_Screen.turnTidus():
print("Tidus taking first turn")
defend()
time.sleep(0.2)
print("Tidus defend")
FFX_Screen.awaitTurn()
buddySwap(2) # Yuna out, Lulu in
thunder("right")
complete = 1
elif FFX_Screen.turnYuna():
print("Yuna taking first turn")
buddySwap(2) # Yuna out, Lulu in
thunder("right")
FFX_Screen.awaitTurn()
defend()
time.sleep(0.2)
print("Tidus defend")
complete = 1
print("First few turns are complete. Now for the rest of the fight.")
# After the first two turns, the rest of the fight is pretty much scripted.
turnCounter = 0
complete = False
while complete == False:
if FFX_memory.battleScreen():
turnCounter += 1
if FFX_Screen.turnKimahri():
time.sleep(1)
cam = FFX_memory.getCamera()
if cam[0] < -2.1:
FFX_Screen.awaitTurn()
lancet('up')
else:
FFX_Screen.awaitTurn()
lancet('right')
elif FFX_Screen.turnLulu():
thunder('up')
elif FFX_Screen.turnTidus():
if turnCounter < 4:
defend()
time.sleep(0.2)
else:
buddySwap(2)
aeonSummon(0)
elif FFX_Screen.turnAeon():
FFX_Xbox.menuLeft()
time.sleep(0.8)
FFX_Xbox.menuB() # Energy Blast
# while not FFX_Screen.PixelTestTol(1366, 340, (101, 101, 101), 3):
# print("Attempting to target boss")
time.sleep(0.1)
FFX_Xbox.menuRight()
FFX_Xbox.menuUp()
# time.sleep(0.05)
time.sleep(0.15)
FFX_Xbox.menuB()
print("Valefor energy blast")
complete = True
time.sleep(10)
print("Sin's Fin fight complete")
FFX_Screen.clickToBattle()
def Echuilles():
FFX_Logs.writeLog("Fight start: Sinspawn Echuilles")
FFX_Screen.awaitTurn()
print("Sinspawn Echuilles fight start")
tidusCounter = 0
while not FFX_memory.menuOpen(): #AKA end of battle screen
if FFX_memory.battleScreen():
if FFX_Screen.faintCheck() > 0:
revive()
elif FFX_Screen.turnTidus():
tidusCounter += 1
if tidusCounter <= 2:
print("Cheer")
tidusFlee() # performs cheer command
elif tidusCounter == 6:
print("Overdrive")
tidusOD()
else:
print("Tidus attack")
attack('none')
elif FFX_Screen.turnWakka():
if tidusCounter == 1 or tidusCounter == 4:
print("Dark Attack")
useSkill(0) #Dark Attack
elif tidusCounter == 5:
print("Heal Tidus for safety")
FFX_Xbox.menuDown()
FFX_Xbox.menuDown()
FFX_Xbox.menuB()
time.sleep(0.3)
FFX_Xbox.menuB()
time.sleep(0.3)
FFX_Xbox.menuUp()
FFX_Xbox.menuB()
else:
print("Wakka attack")
attack('none')
FFXC.set_value('BtnB', 1)
time.sleep(3.5)
FFXC.set_value('BtnB', 0)
FFX_Xbox.skipScene()
def lancetTutorial():
FFX_Logs.writeLog("Fight start: Lancet tutorial fight (Kilika)")
FFX_Screen.clickToBattle()
lancet('none')
turn1 = 0
turn2 = 0
while not FFX_memory.menuOpen(): #AKA end of battle screen
if FFX_memory.battleScreen():
if FFX_Screen.turnTidus():
attack('none')
elif FFX_Screen.turnKimahri():
buddySwap(1)
defend()
elif FFX_Screen.turnLulu():
fire('none')
else:
defend()
FFXC.set_value('BtnB', 1)
time.sleep(2)
FFXC.set_value('BtnB', 0)
def KilikaWoods(valeforCharge):
FFX_Logs.writeLog("Fight start: Kilika general")
BattleComplete = 0
speedSpheres = 0
currentCharge = False
skipCharge = False
turnCounter = 0
bNum = FFX_memory.getBattleNum()
preEmpt = FFX_Screen.PixelTestTol(1378, 271, (50, 52, 50), 5)
FFXC.set_value('Dpad', 0)
FFXC.set_value('AxisLy', 0)
FFXC.set_value('AxisLx', 0)
# if bNum == 31: #Lizard and Elemental, side
# elif bNum == 32: #Lizard and Bee, front
# elif bNum == 33: #Yellow and Bee, front
# elif bNum == 34: #Lizard, Yellow, and Bee, front
# elif bNum == 35: #Single Ragora, reverse
# elif bNum == 36: #Two Ragoras, reverse
# elif bNum == 37: #Ragora and two bees, reverse
# These battles we want nothing to do with.
if bNum == 32 or bNum == 35 or bNum == 36 or bNum == 37:
skipCharge = True
print("Kilika battle")
while not FFX_memory.menuOpen(): #AKA end of battle screen
if valeforCharge == False and skipCharge == False: # Still to charge Valefor
if FFX_memory.battleScreen():
print("--------------------------------")
print("Battle Turn")
print("Battle Number: ", bNum)
print("Valefor charge state: ", valeforCharge)
print("skipCharge state: ", skipCharge)
turnCounter += 1
if turnCounter > 7:
fleeAll()
break
elif FFX_Screen.faintCheck():
revive()
elif FFX_Screen.turnKimahri():
buddySwap(1)
elif FFX_Screen.turnLulu():
buddySwap(2)
elif bNum == 31: # Working just fine.
print("Logic for battle number 31")
currentCharge = True
if FFX_Screen.turnTidus():
attack('none')
elif FFX_Screen.turnYuna():
aeonSummon(0)
FFX_Screen.awaitTurn()
if preEmpt == True:
FFX_Xbox.menuRight()
FFX_Xbox.SkipDialog(2)
FFX_Screen.awaitTurn()
aeonBoost()
FFX_Screen.awaitTurn()
aeonBoost()
FFX_Screen.awaitTurn()
aeonSpell(2)
elif FFX_Screen.turnAeon():
aeonSpellDirection(2, 'right')
else:
defend()
elif bNum == 33: # Working just fine
print("Logic for battle number 33")
currentCharge = True
if FFX_Screen.turnYuna():
time.sleep(0.2)
aeonSummon(0)
FFX_Screen.awaitTurn()
if preEmpt == True:
FFX_Xbox.menuRight()
FFX_Xbox.SkipDialog(2)
FFX_Screen.awaitTurn()
aeonBoost()
FFX_Screen.awaitTurn()
aeonSpellDirection(1, 'left')
elif FFX_Screen.turnAeon():
aeonSpell(2)
else:
defend()
time.sleep(0.2)
elif bNum == 34:
print("Logic for battle number 34")
currentCharge = True
if FFX_Screen.turnTidus():
attack('none')
elif FFX_Screen.turnYuna():
aeonSummon(0)
FFX_Screen.awaitTurn()
if preEmpt == True:
FFX_Xbox.menuRight()
FFX_Xbox.SkipDialog(2)
FFX_Screen.awaitTurn()
aeonBoost()
FFX_Screen.awaitTurn()
aeonSpellDirection(1, 'right')
elif FFX_Screen.turnAeon():
aeonSpell2(2, 'left')
else:
defend()
elif bNum == 37:
print("Logic for battle number 37 - two bees and a plant thingey")
currentCharge = True
if FFX_Screen.turnTidus():
attack('none')
elif FFX_Screen.turnYuna():
aeonSummon(0)
FFX_Screen.awaitTurn()
if preEmpt == True:
FFX_Xbox.menuRight()
FFX_Xbox.SkipDialog(2)
FFX_Screen.awaitTurn()
aeonSpellDirection(1, 'right')
FFX_Screen.awaitTurn()
aeonSpellDirection(1, 'right')
elif FFX_Screen.turnAeon():
aeonSpell(0)
else:
defend()
else:
skipCharge = True
print("Unexpected battle. Not going to charge Valefor.")
else:
if FFX_memory.battleScreen():
print("--------------------------------")
print("Battle Turn")
print("Battle Number: ", bNum)
print("Valefor charge state: ", valeforCharge)
print("skipCharge state: ", skipCharge)
turnCounter += 1
if turnCounter > 7:
fleeAll()
break
elif FFX_Screen.faintCheck():
revive()
elif FFX_Screen.turnKimahri():
buddySwap(1)
elif FFX_Screen.turnLulu() and bNum != 37:
buddySwap(2)
elif bNum == 31:
if FFX_Screen.turnTidus():
if turnCounter < 4:
attack('none')
else:
tidusFlee()
else:
defend()
elif bNum == 32:
if FFX_Screen.turnTidus():
if turnCounter < 4:
attack('none')
else:
tidusFlee()
elif FFX_Screen.turnWakka():
attack('right')
else:
defend()
elif bNum == 33:
if FFX_Screen.turnTidus():
if turnCounter < 4:
defend()
else:
tidusFlee()
elif FFX_Screen.turnWakka():
attack('right')
else:
defend()
elif bNum == 34:
if FFX_Screen.turnTidus():
if turnCounter < 4:
attack('none')
else:
tidusFlee()
elif FFX_Screen.turnWakka():
attack('right')
else:
defend()
elif bNum == 35 or bNum == 36:
if FFX_Screen.turnTidus():
tidusFlee()
else:
defend()
elif bNum == 37:
if FFX_Screen.turnTidus():
buddySwap(2)
thunder('left')
elif FFX_Screen.turnLulu():
buddySwap(2)
tidusFlee()
elif FFX_Screen.turnWakka():
attack('left')
else:
defend()
FFX_memory.clickToControl() # Rewards screen
if currentCharge == True:
valeforCharge = True
hpCheck = FFX_memory.getHP()
if hpCheck[0] < 250 or hpCheck[1] < 250 or hpCheck[4] < 250:
healUp2(3)
else:
print("No need to heal up. Moving onward.")
return valeforCharge
def Geneaux():
FFX_Logs.writeLog("Fight start: Sinspawn Geneaux")
FFX_Screen.awaitTurn()
if FFX_Screen.turnYuna():
buddySwap(1)
defend()
FFX_Screen.awaitTurn()
attack('none')
FFX_Screen.clickToBattle()
buddySwap(1)
else:
attack('none')
FFX_Screen.clickToBattle()
aeonSummon(0) # Summon Valefor
FFX_Screen.awaitTurn()
FFX_Xbox.menuLeft()
time.sleep(0.8)
FFX_Xbox.menuB()
FFX_Xbox.menuB()
FFX_Xbox.menuB() # Lead off with Valefor overdrive
valeforOD = 0
skipCount = 0
while FFX_memory.getMap() != 78: #AKA end of battle screen
pos = FFX_memory.getCoords()
if FFX_memory.battleScreen():
print("Valefor casting Fire")
aeonSpell(0)
elif FFX_memory.diagSkipPossible():
FFX_Xbox.menuB()
elif FFX_memory.menuOpen():
FFXC.set_value('BtnB', 1)
time.sleep(0.035)
FFXC.set_value('BtnB', 0)
time.sleep(0.035)
elif FFX_memory.userControl():
FFXC.set_value('AxisLy', 1)
if pos[1] > ((-1.25 * pos[0]) + 543.17):
FFXC.set_value('AxisLx', -1)
else:
FFXC.set_value('AxisLx', 0)
else:
FFXC.set_value('AxisLx', 0)
FFXC.set_value('AxisLy', 0)
print("Battle Complete")
def LucaWorkers():
FFX_Logs.writeLog("Fight start: Workers in Luca")
BattleComplete = 0
FFX_Screen.clickToBattle()
while not FFX_memory.menuOpen(): #AKA end of battle screen
if FFX_memory.battleScreen():
if FFX_Screen.turnKimahri() or FFX_Screen.turnTidus():
if FFX_Screen.faintCheck() >= 1:
revive()
else:
defend()
if FFX_Screen.turnLulu():
thunder('none')
elif FFX_memory.diagSkipPossible():
FFX_Xbox.menuB() # Clicking to get through the battle faster
FFX_memory.clickToControl()
def LucaWorkers2():
FFX_Logs.writeLog("Fight start: Workers in Luca")
BattleComplete = 0
kimTurn = 0
tidTurn = 0
luluTurn = 0
FFX_Screen.clickToBattle()
while not FFX_memory.menuOpen(): #AKA end of battle screen
if FFX_memory.battleScreen():
if FFX_Screen.turnKimahri():
if FFX_Screen.faintCheck() >= 1:
revive()
else:
kimTurn += 1
if kimTurn == 2:
FFX_Xbox.menuLeft() # Overdrive
time.sleep(0.8)
FFX_Xbox.menuB() # Ronso Rage
time.sleep(0.4)
FFX_Xbox.menuRight()
FFX_Xbox.menuB() # Seed Cannon
time.sleep(0.4)
FFX_Xbox.menuRight()
FFX_Xbox.menuB() # Target the other guy
time.sleep(0.4)
elif kimTurn < 3:
attack('right')
else:
defend()
elif FFX_Screen.turnTidus():
if FFX_Screen.faintCheck() >= 1:
revive()
else:
tidTurn += 1
if tidTurn < 3:
attack('right')
else:
defend()
elif FFX_Screen.turnLulu():
luluTurn += 1
if luluTurn == 2 and kimTurn < 2:
FFX_Xbox.weapSwap(0)
else:
thunder('none')
elif FFX_memory.diagSkipPossible():
FFX_Xbox.menuB() # Clicking to get through the battle faster
FFX_memory.clickToControl()
def Oblitzerator(earlyHaste):
FFX_Logs.writeLog("Fight start: Oblitzerator")
FFX_Screen.clickToBattle()
crane = 0
# if earlyHaste == 1:
# #First turn is always Tidus. Haste Lulu if we've got the levels.
# FFX_Xbox.tidusHaste('left')
while not FFX_memory.menuOpen(): #AKA end of battle screen
if FFX_memory.battleScreen():
if crane < 3:
if FFX_Screen.turnLulu():
crane += 1
thunder('right')
else:
defend()
elif crane == 3:
if FFX_Screen.turnTidus():
crane += 1