-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrng_track.py
1557 lines (1392 loc) · 52.3 KB
/
rng_track.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
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 csv
import json
import logging
import os
import logs
import memory.main
import vars
from tracker.ffx_rng_tracker.data.monsters import MONSTERS
logger = logging.getLogger(__name__)
game_vars = vars.vars_handle()
def current_battle_formation() -> []:
battle_num = str(memory.main.get_encounter_id())
f = open("json_ai_files/battle_id_to_formation.json")
all_formations = json.load(f)
f.close()
if not battle_num in all_formations.keys():
return []
else:
return all_formations[battle_num]
def luck_check(fiend_name:str):
library_check = MONSTERS[fiend_name].stats["luck"]
logger.debug("== Dict Check: {library_check}")
logger.debug("== Dict Check: {library_check}")
logger.debug("== Dict Check: {library_check}")
logger.debug("== Dict Check: {library_check}")
if fiend_name in ["arm","cid","circle","crane","dummy","gate_lock","gate_lock_2","gemini"]:
return 0
if fiend_name in ["geneauxs_tentacle","head","kimahri_weapon","mortiphasm","mortiphasm_3"]:
return 0
if fiend_name in ["mortiphasm_4","mortiphasm_5","negator","nemesis","oblitzerator"]:
return 0
if fiend_name.find("possessed") != -1:
return 0
if fiend_name.find("sinscale") != -1:
return 0
if fiend_name in ["pupu","sahagin_4","sahagin_chief"]:
return 0
if fiend_name in ["sinspawn_ammes","tentacle","vouivre_2","yu_yevon"]:
return 10
if fiend_name in ["stratoavis"]:
return 18
if fiend_name in ["anima","lord_ochu","mortibody","mortiphasm_2","neslug","ornitholestes"]:
return 20
if fiend_name in ["seymour_omnis","yunalesca"]:
return 20
if fiend_name in ["kottos"]:
return 25
if fiend_name in ["fenrir"]:
return 30
if fiend_name in ["hornet"]:
return 30
return 15
def force_drop(drop_chance:int = 255):
values = memory.main.rng_array_from_index(index=10, array_len=100)
if drop_chance <= 0:
return
if values[1] & 0x7FFFFFFF % 255 >= drop_chance:
memory.main.advance_rng_index(index=10)
force_drop(drop_chance=drop_chance)
def force_equip(equip_type:int = 0, character:int = 0, aeon_kill:bool=True, party_size:int = 7):
get_item, _ = item_to_be_dropped(
enemy = "yunalesca",
party_size=party_size,
)
logger.debug("==== Equip check ====")
logger.debug(f"Raw: {get_item}")
logger.debug(f"Char kill: {get_item.owner()}")
logger.debug(f"Aeon kill: {get_item.owner_alt()}")
logger.debug(f"Type (0 for weap): {get_item.equipment_type()}")
logger.debug(f"Abilities: {get_item.abilities()}")
logger.debug("=====================")
if (
(aeon_kill and get_item.owner_alt() != character) or
(not aeon_kill and get_item.owner() != character) or
(equip_type != get_item.equipment_type())
):
memory.main.advance_rng_index(index=12)
force_equip(
equip_type=equip_type,
character=character,
aeon_kill=aeon_kill,
party_size=party_size
)
def force_preempt():
values = memory.main.rng_array_from_index(index=1, array_len=100)
if (values[2] & 0x7FFFFFFF) & 255 >= 32:
memory.main.advance_rng_index(index=1)
force_preempt()
def area_formations(area: str):
f = open("tracker/data/formations.json")
all_formations = json.load(f)
f.close()
if area in all_formations["random"].keys():
return all_formations["random"][area]["formations"]
elif area in all_formations["bosses"].keys():
return all_formations["bosses"][area]["formation"]
else:
logger.debug(f"Key not found: {area}")
def coming_battles(
area: str = "kilika_woods", battle_count: int = 10, extra_advances: int = 0
):
formations = area_formations(area=area)
advances = memory.main.rng_01_advances((battle_count * 2) + extra_advances)
if extra_advances != 0:
while extra_advances != 0:
del advances[0]
extra_advances -= 1
battles = []
for i in range(battle_count):
next_value = formations[(advances[(i * 2) + 1] & 0x7FFFFFFF) % len(formations)]
battles.append(next_value)
return battles
def coming_battle_type(extra_advances: int = 0, initiative=False):
advances = memory.main.rng_01_advances(2 + extra_advances)
if extra_advances != 0:
while extra_advances != 0:
del advances[0]
extra_advances -= 1
battle_type = (advances[2] & 0x7FFFFFFF) & 255
if initiative:
battle_type -= 33
if battle_type < 32:
return 1
elif battle_type < 255 - 32:
return 0
else:
return 2
def singles_battles(
area: str = "kilika_woods", battle_count: int = 10, extra_advances: int = 0
):
# logger.debug(f"Area: {area}")
formations = area_formations(area=area)
advances = memory.main.rng_01_advances(battle_count + extra_advances)
if extra_advances != 0:
while extra_advances != 0:
del advances[0]
extra_advances -= 1
battles = []
for i in range(battle_count):
next_value = formations[(advances[i + 1] & 0x7FFFFFFF) % len(formations)]
battles.append(next_value)
# logger.debug(f"Battles: {battles}")
return battles
def drop_chance(enemy: str = "ghost"):
return MONSTERS[enemy].equipment["drop_chance"]
def drop_rare(drop_num:int = 1):
return memory.main.next_steal_rare(drop_num - 1)
def drop_slots(enemy: str = "ghost"):
return MONSTERS[enemy].equipment["slots_range"]
def slot_modifier(enemy: str = "ghost"):
return MONSTERS[enemy].equipment["slots_modifier"]
def drop_ability_count(enemy: str = "ghost"):
return MONSTERS[enemy].equipment["max_ability_rolls_range"]
def ability_modifier(enemy: str = "ghost"):
return MONSTERS[enemy].equipment["max_ability_rolls_modifier"]
def drop_ability_list(enemy: str = "ghost", equip_type: int = 0):
if equip_type == 0:
array = MONSTERS[enemy].equipment["ability_arrays"]["Tidus"]["Weapon"]
else:
array = MONSTERS[enemy].equipment["ability_arrays"]["Tidus"]["Armor"]
ret_val = []
for i in range(len(array)):
try:
ret_val.append(array[i].tas_id)
except Exception:
ret_val.append(255)
return ret_val
def early_battle_count():
with open("csv\\seed_battle_variance.csv", "r", newline="") as csv_file:
reader = csv.DictReader(csv_file)
for row in reader:
if int(row["Seed"]) == memory.main.rng_seed():
return row
def track_drops(enemy: str = "ghost", battles: int = 20, extra_advances: int = 0):
no_advance_array = []
one_advance_array = []
two_advance_array = []
advances = (battles + 1) * 3
rand_array = memory.main.rng_10_array(array_len=advances + extra_advances)
if extra_advances != 0:
while extra_advances != 0:
del rand_array[0]
extra_advances -= 1
for i in range(len(rand_array)):
if i < 3:
pass
elif (rand_array[i] & 0x7FFFFFFF) % 255 < drop_chance(enemy):
if i % 3 == 0:
no_advance_array.append(i / 3)
elif i % 3 == 1:
one_advance_array.append((i - 1) / 3)
else:
two_advance_array.append((i - 2) / 3)
return [no_advance_array, one_advance_array, two_advance_array]
def item_to_be_dropped(
enemy: str = "ghost",
pre_advance_12: int = 0,
pre_advance_13: int = 0,
party_size: int = 7,
):
test_mode = False
slot_mod = slot_modifier(enemy=enemy)
ability_mod = ability_modifier(enemy=enemy)
party_chars = memory.main.get_order_six()
# Focused on NEA manip, we'd need to back fill this later to other fights.
if enemy == "evrae":
party_chars = [0,2,3,4,5,6]
elif enemy == "larva":
party_chars = [1,2]
elif enemy == "evrae_altana":
party_chars = [0,4,6]
elif enemy == "ykt-63":
party_chars = [0,1,2,4,5,6]
elif enemy in ["seymour_natus","defender_x","yenke_ronso","biran_ronso","ghost"]:
party_chars = [0,1,2,3,4,5,6]
else:
# Good old bubble sort
for i in range(len(party_chars)):
for j in range(i, len(party_chars)):
if party_chars[j] < party_chars[i]:
temp = party_chars[j]
party_chars[j] = party_chars[i]
party_chars[i] = temp
'''
if party_size == 2:
party_chars = [0, 4]
elif party_size == 3: # Oblitzerator
party_chars = [0, 3, 5]
elif party_size == 4:
party_chars = [0, 1, 4, 5]
elif party_size == 5:
party_chars = [0, 1, 3, 4, 5]
elif party_size == 6: # rescue_yuna section
party_chars = [0, 2, 3, 4, 5, 6]
elif party_size == 7:
party_chars = [0, 1, 2, 3, 4, 5, 6]
else:
party_chars = [0]
'''
#logger.warning(party_chars)
advance_12 = 8 + pre_advance_12
test_array_12 = memory.main.rng_12_array(advance_12)
del test_array_12[0]
if pre_advance_12 >= 1:
while pre_advance_12 >= 1:
del test_array_12[0]
pre_advance_12 -= 1
# Assume killer is not aeon
user_2 = party_chars[(test_array_12[0] & 0x7FFFFFFF) % len(party_chars)]
party_chars.append(9)
party_chars.append(9)
party_chars.append(9)
# Assume killer is aeon
user_1 = party_chars[(test_array_12[0] & 0x7FFFFFFF) % len(party_chars)]
# Type
equip_type = (test_array_12[1] & 0x7FFFFFFF) % 2
# Slots
base_slots = (slot_mod + ((test_array_12[2] & 0x7FFFFFFF) & 7)) - 4
slots = (base_slots + ((base_slots >> 31) & 7)) >> 2
if slots == 0:
slots = 1
# Abilities
base_mod = (ability_mod + ((test_array_12[3] & 0x7FFFFFFF) & 7)) - 4
ability_count = (base_mod + ((base_mod >> 31) & 7)) >> 3
if slots < ability_count:
ability_count = slots
# Killer - NEA drop only
character = user_2 # Represents any killer except Auron or Kimahri.
if enemy == "biran_ronso" or enemy == "yenke_ronso":
character = 3
elif enemy in ["defender_x", "maze_larva"]:
character = user_1
# rng13 logic here, determine which ability goes where.
ability_list, advances = ability_to_be_dropped(
enemy=enemy,
equip_type=equip_type,
slots=slots,
ability_count=ability_count,
advances=pre_advance_13,
char=character
)
if test_mode:
logger.debug(f"New Abilities: {ability_list}")
logger.debug(f"OWNER CHECK (aeon): {user_1}")
logger.debug(f"OWNER CHECK (killer): {user_2}")
final_item = memory.main.Equipment(equip_num=0)
final_item.create_custom(
e_type=equip_type,
e_owner_1=user_1,
e_owner_2=user_2,
e_slots=slots,
e_abilities=ability_list,
)
#return final_item, int(pre_advance_13 + advances)
return final_item, advances
def ability_to_be_dropped(
enemy: str = "ghost", equip_type: int = 0, slots: int = 1, advances: int = 0,
ability_count:int=1, char:int = 0
):
test_mode = False # Doesn't functionally change, but prints more stuff.
outcomes = drop_ability_list(enemy=enemy, equip_type=equip_type)
filled_slots = [99] * slots
if char in [2,3] and equip_type == 0: # Weapon for Auron or Kimahri
filled_slots.remove(99)
filled_slots.append(0x800B)
ability_count -= 1
found = 0
ptr = 0 # Pointer that indicates how many advances needed for this evaluation
test_array = memory.main.rng_13_array(array_len=50 + advances)
if test_mode:
logger.debug(f"Enemy: {enemy} - Outcomes: {outcomes}")
while 99 in filled_slots and ptr < 50 + advances and found < ability_count:
# Increment to match the first (and subsequent) advance(s)
try:
ptr += 1
if test_mode and enemy=="ghost":
logger.debug(f"ptr: {ptr}")
logger.debug(f"Try: {test_array[ptr + advances]}")
array_pos = ((test_array[ptr + advances] & 0x7FFFFFFF) % 7) + 1
if test_mode:
logger.debug(f"AP: {array_pos}")
logger.debug(f"Res: {outcomes[array_pos]}")
if outcomes[array_pos] in filled_slots:
pass
else:
filled_slots.remove(99)
filled_slots.append(int(outcomes[array_pos]))
found += 1
if test_mode:
logger.debug(filled_slots)
except Exception as e:
logger.exception(e)
if test_mode:
logger.debug(f"Filled Slots: {filled_slots}")
while 99 in filled_slots:
filled_slots.remove(99)
# Format so that we have four slots always.
if len(filled_slots) < 4:
while len(filled_slots) < 4:
filled_slots.append(255)
if test_mode:
logger.debug(f"Filled Slots fin: {filled_slots}")
return [filled_slots, ptr]
def report_dropped_item(
enemy: str,
drop=memory.main.Equipment,
pref_type: int = 99,
pref_ability: int = 255,
need_adv: int = 0,
report=False,
):
report=False # For now, we don't want to see this. Slows down the TAS slightly.
abi_str = str(pref_ability)
pref_type
report = True
if pref_ability != 255 and abi_str not in drop.equip_abilities:
report = False
elif pref_type != 99 and pref_type != drop.equip_type:
logger.debug(pref_type)
logger.debug(drop.equip_type)
report = False
if report:
logs.write_rng_track(
"+Item drop off of:" + str(enemy) + "| advances:" + str(need_adv)
)
logs.write_rng_track(
"+Owner, char-killed (9 = killer):" + str(drop.equip_owner)
)
logs.write_rng_track("+Owner, aeon-killed:" + str(drop.equip_owner_alt))
if drop.equip_type == 0:
logs.write_rng_track("+Type: Weapon")
else:
logs.write_rng_track("+Type: Armor")
logs.write_rng_track("+Open Slots: " + str(drop.slots))
logs.write_rng_track("+Abilities: " + str(drop.equip_abilities))
logs.write_rng_track("===================")
return True
else:
logs.write_rng_track(
"-Undesirable item dropped by: "
+ str(enemy)
+ " | advances:"
+ str(need_adv)
)
logs.write_rng_track("-Owner, char-killed: " + str(drop.equip_owner))
logs.write_rng_track("-Owner, aeon-killed: " + str(drop.equip_owner_alt))
if drop.equip_type == 0:
logs.write_rng_track("-Type: Weapon")
else:
logs.write_rng_track("-Type: Armor")
logs.write_rng_track("-Open Slots: " + str(drop.slots))
logs.write_rng_track("-Abilities: " + str(drop.equip_abilities))
logs.write_rng_track("===================")
return False
def decide_skip_zan_luck() -> bool:
# This function tracks if we need to pick up the luck and
# fortune spheres in Zanarkand. This will track through from Yunalesca to BFA,
# the two fights with ~4% chance to miss.
# False == there will be a miss.
# True == no miss.
extra_xp = 1
bahamut_luck = 17
keeper_crit = memory.main.future_attack_will_crit(
character=7, char_luck=bahamut_luck, enemy_luck=20, attack_index=extra_xp
)
arm1Crit = False
arm2Crit = False
face_crit = False
attack_count = extra_xp
if keeper_crit:
logger.debug("Expecting crit on SK")
attack_count += 1
else:
attack_count += 2
# Now to test the Yunalesca fight. Crits do not matter here, only hit chance.
for i in range(3):
logger.debug(f"Yunalesca attack num {i} | {attack_count}")
if not future_attack_hit(
character=7, enemy="yunalesca", attack_index=attack_count
):
logger.debug(f"Miss on Yunalesca, attack number {i}")
return False
attack_count += 1
if game_vars.nemesis(): # BFA miss does not factor in for Nemesis route.
return True
arm1Crit = memory.main.future_attack_will_crit(
character=7, char_luck=bahamut_luck, enemy_luck=15, attack_index=attack_count
)
if arm1Crit:
logger.debug("Expecting crit on Arm 1")
attack_count += 1
else:
logger.debug("Expecting no crit on Arm 1")
attack_count += 2
arm2Crit = memory.main.future_attack_will_crit(
character=7, char_luck=bahamut_luck, enemy_luck=15, attack_index=attack_count
)
if arm2Crit:
logger.debug("Expecting crit on Arm 2")
attack_count += 1
else:
logger.debug("Expecting no crit on Arm 2")
attack_count += 2
attack_count += 1 # Core is always one attack
face_crit = memory.main.future_attack_will_crit(
character=7, char_luck=bahamut_luck, enemy_luck=15, attack_index=attack_count
)
if face_crit:
logger.debug("Expecting crit on Face/impulse")
else:
face_crit = memory.main.future_attack_will_crit(
character=7,
char_luck=bahamut_luck,
enemy_luck=15,
attack_index=attack_count + 1,
)
if face_crit:
logger.debug("Expecting crit on Face/attack (first)")
if face_crit:
attack_count += 2
elif game_vars.rng_seed_num() == 31:
attack_count += 2
else:
logger.debug("Expecting no crit on Face")
attack_count += 3 # Should be 3, but we're over-damaging.
if not future_attack_hit(
character=7, enemy="seymour_omnis", attack_index=attack_count
):
logger.debug("Miss on Omnis")
return False
else:
logger.debug("No miss on Omnis")
attack_count += 1 # One attack on Seymour
for i in range(3):
logger.debug(f"BFA attack num {i} | {attack_count}")
if not future_attack_hit(character=7, enemy="bfa", attack_index=attack_count):
logger.debug(f"Miss on BFA, attack number {i}")
return False
attack_count += 1
logger.debug("No misses registered. Should be good to skip Luck/Fortune chests.")
return True
def zombie_track(report=False):
advance_01 = 0
advance_10 = 0
advance_12 = [0] * 3
advance_13 = [0] * 3
zombie_results = [99] * 3
party_size = 7
# "sanctuary_keeper"
# Check random encounters for best charge,
# plan for 1 encounter, 1 death if possible to charge.
# "spectral_keeper"
# "yunalesca"
enemy = "sanctuary_keeper"
drop_chances = track_drops(enemy=enemy, battles=1, extra_advances=advance_10)
if len(drop_chances[0]) >= 1:
final_item, advance_13[0] = item_to_be_dropped(
enemy=enemy,
pre_advance_12=advance_12[0],
pre_advance_13=advance_13[0],
party_size=party_size,
)
advance_12[0] += 4
report_dropped_item(
enemy=enemy,
drop=final_item,
pref_type=0,
pref_ability=0x8032,
report=report,
)
if len(drop_chances[1]) >= 1:
final_item, advance_13[1] = item_to_be_dropped(
enemy=enemy,
pre_advance_12=advance_12[1],
pre_advance_13=advance_13[1],
party_size=party_size,
)
advance_12[1] += 4
report_dropped_item(
enemy=enemy,
drop=final_item,
pref_type=0,
need_adv=1,
pref_ability=0x8032,
report=report,
)
if len(drop_chances[2]) >= 1:
final_item, advance_13[2] = item_to_be_dropped(
enemy=enemy,
pre_advance_12=advance_12[2],
pre_advance_13=advance_13[2],
party_size=party_size,
)
advance_12[2] += 4
report_dropped_item(
enemy=enemy,
drop=final_item,
pref_type=0,
need_adv=2,
pref_ability=0x8032,
report=report,
)
advance_10 += 3
advance_01 += 1
import area.zanarkand as zanarkand
zanarkand.decide_nea(bonus_advance=1)
# One death expected to recharge Rikku. No drops expected.
if game_vars.get_nea_zone() in [1, 2]:
advance_10 += 3
advance_01 += 1
enemy = "spectral_keeper"
drop_chances = track_drops(enemy=enemy, battles=1, extra_advances=advance_10)
if len(drop_chances[0]) >= 1:
final_item, advance_13[0] = item_to_be_dropped(
enemy=enemy,
pre_advance_12=advance_12[0],
pre_advance_13=advance_13[0],
party_size=party_size,
)
advance_12[0] += 4
report_dropped_item(
enemy=enemy,
drop=final_item,
pref_type=0,
pref_ability=0x8032,
report=report,
)
if len(drop_chances[1]) >= 1:
final_item, advance_13[1] = item_to_be_dropped(
enemy=enemy,
pre_advance_12=advance_12[1],
pre_advance_13=advance_13[1],
party_size=party_size,
)
advance_12[1] += 4
report_dropped_item(
enemy=enemy,
drop=final_item,
pref_type=0,
need_adv=1,
pref_ability=0x8032,
report=report,
)
if len(drop_chances[2]) >= 1:
final_item, advance_13[2] = item_to_be_dropped(
enemy=enemy,
pre_advance_12=advance_12[2],
pre_advance_13=advance_13[2],
party_size=party_size,
)
advance_12[2] += 4
report_dropped_item(
enemy=enemy,
drop=final_item,
pref_type=0,
need_adv=2,
pref_ability=0x8032,
report=report,
)
advance_10 += 3
advance_01 += 1
enemy = "yunalesca"
drop_chances = track_drops(enemy=enemy, battles=1, extra_advances=advance_10)
if len(drop_chances[0]) >= 1:
final_item, advance_13[0] = item_to_be_dropped(
enemy=enemy,
pre_advance_12=advance_12[0],
pre_advance_13=advance_13[0],
party_size=party_size,
)
advance_12[0] += 4
if report_dropped_item(
enemy=enemy,
drop=final_item,
pref_type=0,
pref_ability=0x8032,
report=report,
):
zombie_results[0] = final_item.equip_owner_alt
if len(drop_chances[1]) >= 1:
final_item, advance_13[1] = item_to_be_dropped(
enemy=enemy,
pre_advance_12=advance_12[1],
pre_advance_13=advance_13[1],
party_size=party_size,
)
advance_12[1] += 4
if report_dropped_item(
enemy=enemy,
drop=final_item,
pref_type=0,
need_adv=1,
pref_ability=0x8032,
report=report,
):
zombie_results[1] = final_item.equip_owner_alt
if len(drop_chances[2]) >= 1:
final_item, advance_13[2] = item_to_be_dropped(
enemy=enemy,
pre_advance_12=advance_12[2],
pre_advance_13=advance_13[2],
party_size=party_size,
)
advance_12[2] += 4
if report_dropped_item(
enemy=enemy,
drop=final_item,
pref_type=0,
need_adv=2,
pref_ability=0x8032,
report=report,
):
zombie_results[2] = final_item.equip_owner_alt
advance_10 += 3
advance_01 += 1
return zombie_results
def nea_track(pre_defender_x:bool = False, report=False):
drop_x = False
bny = False
advances = 0
#logger.warning(memory.main.rng_array_from_index(index=12, array_len=20))
#logger.warning(memory.main.rng_array_from_index(index=13, array_len=20))
if pre_defender_x:
stage = 2
else:
stage = 3
paths, best = purifico_to_nea(
stage=stage,
report=False
)
if best == 99:
return (99,99)
bny = bool(best >= len(paths)/2)
if stage == 2:
drop_x = bool((best % 4) >= 2)
if not drop_x:
advances = 1
if drop_x != game_vars.get_def_x_drop():
game_vars.set_def_x_drop(drop_x)
#logger.manip(f" BnY: {bny}")
#logger.manip(f"BnY_var: {game_vars.get_nea_after_bny()}")
if bny != game_vars.get_nea_after_bny():
game_vars.set_nea_after_bny(bny)
if report:
logger.manip(
f"Defender X: {game_vars.get_def_x_drop()}, Ronso before NEA: {game_vars.get_nea_after_bny()}"
)
#if not drop_x and not bny:
# return (paths[best], memory.main.next_chance_rng_10_calm())
#elif not drop_x and memory.main.next_chance_rng_10() != 0:
# return (paths[best], 0)
#else:
return (advances, memory.main.next_chance_rng_10())
# Note return of 0 means we don't need any extra mobs, other than X or Ronso.
def print_manip_info(pre_x=False):
if pre_x:
purifico_to_nea(stage=2, report=True)
else:
purifico_to_nea(stage=3, report=True)
_, advances = nea_track(pre_defender_x=pre_x, report=True)
logger.manip(f"Setting up for NEA | " + \
f"X: {game_vars.get_def_x_drop()} | " + \
f"B&Y: {game_vars.get_nea_after_bny()}")
logger.manip(f"We need {advances} extra advances for next equipment drop.")
logger.manip(f"(One advance per steal, three per player or enemy death)")
def desert_to_evrae_equip_drop_count() -> []:
drop_count = [1,1,1] # Evrae will always drop one equipment.
test_array = memory.main.rng_10_array()
ptr = 3 # Ignore first two rolls, we don't care about item drops.
# Guado guardian and three bombs
chance = 12
for i in range(3): # Guado
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
for i in range(3): # Bomb
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
for i in range(3): # Bomb
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
for i in range(3): # Bomb
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
# Dual horns and guado guardian
for i in range(3): # Dual Horn
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
for i in range(3): # Dual Horn
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
chance = 60
for i in range(3): # Guado
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
# Chimeras and guado
chance = 12
for i in range(3): # Guado
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
for i in range(3): # Guado
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
chance = 60
for i in range(3): # Guado
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i] += 1
ptr += 3
return drop_count
def enemy_target_predictions(attacks:int=4, chars:int=3):
rolls = memory.main.rng_array_from_index(index=4, array_len=attacks+3)
results = []
for i in range(attacks):
results.append((rolls[i+1] & 0x7FFFFFFF) % chars)
logger.manip(f"Target predictions: {results}")
return results
def evrae_targets() -> []:
rolls = memory.main.rng_array_from_index(index=4, array_len=5)
results = [9,9]
results[0] = (rolls[1] & 0x7FFFFFFF) % 3
if results[0] == 0:
results[1] = (rolls[2] & 0x7FFFFFFF) % 3
else:
results[1] = (rolls[2] & 0x7FFFFFFF) % 2
if results[0] == results[1]: # Can only occur if both == 1
results[1] = 2
return results
def guards_to_calm_equip_drop_count(
guard_battle_num:int,
ptr:int = 3,
pre_Evrae:bool = False,
report_num = 99
) -> []:
if pre_Evrae:
final, ptr13 = item_to_be_dropped(enemy="evrae")
if final.equipment_type() == 0:
weap = "weapon"
else:
weap = "armor"
#logger.warning(f"Evrae drops {weap} for {final.owner()} - [{final.abilities()}]")
#logger.warning(f"RNG13 after Evrae: {memory.main.rng_array_from_index(index=13, array_len=ptr13+20)[ptr13]}")
drop_count = [["evrae"],["evrae"],["evrae"]] # Count for Altana, Natus, and NEA.
ptr += 3
tars = evrae_targets()
if 1 in tars:
ptr += 3
if 2 in tars:
ptr += 3
#logger.warning(f"Evrae advance manips: {ptr}, {tars}")
else:
drop_count = [[],[],[]] # Count for Altana, Natus, and NEA.
test_array = memory.main.rng_10_array()
#for x in range(ptr+10):
# logger.debug(f"{ptr}: {x}: {test_array[x]}")
# Three warrior monks
chance = 12
if guard_battle_num <= 1:
for i in range(3): # Monk
if guard_battle_num == 1:
if (test_array[ptr] & 0x7FFFFFFF) % 255 < chance: # Tidus kills these first
drop_count[i].append("warrior_monk")
if i == report_num:
logger.manip(f"{i}: Battle 1 drops equipment")
else:
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance: # Tidus kills these first
drop_count[i].append("warrior_monk")
if i == report_num:
logger.manip(f"{i}: Battle 1 drops equipment")
ptr += 6 # Accounting for firearm 'death'
for i in range(3): # Monk
if guard_battle_num == 1:
if (test_array[ptr] & 0x7FFFFFFF) % 255 < chance: # Tidus kills these first
drop_count[i].append("warrior_monk_2")
if i == report_num:
logger.manip(f"{i}: Battle 1 drops equipment")
else:
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance: # Tidus kills these first
drop_count[i].append("warrior_monk_2")
if i == report_num:
logger.manip(f"{i}: Battle 1 drops equipment")
ptr += 6 # Accounting for firearm 'death'
for i in range(3): # Monk
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i].append("warrior_monk")
if i == report_num:
logger.manip(f"{i}: Battle 1 drops equipment")
ptr += 6 # Accounting for firearm 'death'
# YKT-63 and two monks. If second battle, assumes Tidus killed the bot.
if guard_battle_num <= 2:
chance = 30
for i in range(3): # YKT-63 dies first.
if guard_battle_num == 2:
if (test_array[ptr] & 0x7FFFFFFF) % 255 < chance:
drop_count[i].append("ykt-63")
if i == report_num:
logger.manip(f"{i}: Battle 2 drops equipment")
else:
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i].append("ykt-63")
if i == report_num:
logger.manip(f"{i}: Battle 2 drops equipment")
ptr += 3
chance = 12
for i in range(3): # Monk
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i].append("warrior_monk")
if i == report_num:
logger.manip(f"{i}: Battle 2 drops equipment")
ptr += 3
for i in range(3): # Monk
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance:
drop_count[i].append("warrior_monk")
if i == report_num:
logger.manip(f"{i}: Battle 2 drops equipment")
ptr += 9 # Accounting for firearm 'deaths'
# Three MORE monks
if guard_battle_num <= 3:
chance = 12
# Figure out later a way to count remaining enemies in this battle.
for i in range(3): # Monk
if guard_battle_num == 3:
if (test_array[ptr] & 0x7FFFFFFF) % 255 < chance: # Tidus kills these first
drop_count[i].append("warrior_monk")
if i == report_num:
logger.manip(f"{i}: Battle 3 drops equipment")
else:
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance: # Tidus kills these first
drop_count[i].append("warrior_monk")
if i == report_num:
logger.manip(f"{i}: Battle 3 drops equipment")
ptr += 6 # Accounting for firearm 'death'
for i in range(3): # Monk
if guard_battle_num == 3:
if (test_array[ptr] & 0x7FFFFFFF) % 255 < chance: # Tidus kills these first
drop_count[i].append("warrior_monk_2")
if i == report_num:
logger.manip(f"{i}: Battle 3 drops equipment")
else:
if (test_array[ptr+i] & 0x7FFFFFFF) % 255 < chance: # Tidus kills these first
drop_count[i].append("warrior_monk_2")
if i == report_num:
logger.manip(f"{i}: Battle 3 drops equipment")
ptr += 6 # Accounting for firearm 'death'