Skip to content

Instantly share code, notes, and snippets.

@Grayfox96
Last active June 17, 2021 17:36
Show Gist options
  • Save Grayfox96/6a78cf96a029c6bcdff2a5d4f8f4ba69 to your computer and use it in GitHub Desktop.
Save Grayfox96/6a78cf96a029c6bcdff2a5d4f8f4ba69 to your computer and use it in GitHub Desktop.
import csv
def get_condition(raw_rng):
condition_rng = raw_rng & 255
condition = 2
if condition_rng < (255 - 32):
condition = 1 if condition_rng < 32 else 0
if condition == 0:
output = ""
elif condition == 1:
output = "Preemptive"
elif condition == 2:
output = "Ambush"
return output
damage_rolls = {}
damage_rolls['auron'] = {}
damage_rolls['tidus'] = {}
damage_rolls['possible_rolls'] = {}
damage_rolls['possible_rolls']['tidus'] = (125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141)
damage_rolls['possible_rolls']['auron'] = (260, 261, 262, 263, 264, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 293, 294)
damage_rolls['auron'][1] = int(input('Auron 1:'))
damage_rolls['tidus'][1] = int(input('Tidus 1:'))
damage_rolls['auron'][2] = int(input('Auron 2:'))
damage_rolls['tidus'][2] = int(input('Tidus 2:'))
damage_rolls['auron'][3] = int(input('Auron 3:'))
damage_rolls['tidus'][3] = int(input('Tidus 3:'))
for key, roll in damage_rolls['auron'].items():
if roll not in damage_rolls['possible_rolls']['auron']:
if roll / 2 not in damage_rolls['possible_rolls']['auron']:
print(f'Invalid damage roll: {roll}')
else:
damage_rolls['auron'][key] = roll // 2
for key, roll in damage_rolls['tidus'].items():
if roll not in damage_rolls['possible_rolls']['tidus']:
if roll / 2 not in damage_rolls['possible_rolls']['tidus']:
print(f'Invalid damage roll: {roll}')
else:
damage_rolls['tidus'][key] = roll // 2
seed_found = False
with open('ffxhd-raw-encounter-values.csv') as rng_file:
csv_reader = csv.reader(rng_file, delimiter=',')
line_count = 0
for line in csv_reader:
if line_count == 0:
pass
else:
if all([damage_rolls['auron'][1] == int(line[0]), damage_rolls['auron'][2] == int(line[2]), damage_rolls['auron'][3] == int(line[4]),
damage_rolls['tidus'][1] == int(line[1]), damage_rolls['tidus'][2] == int(line[3]), damage_rolls['tidus'][3] == int(line[5])]):
print('Seed found!')
print(f'Seed number is {line_count}')
current_seed = line
seed_found = True
break
line_count += 1
if seed_found == False:
print("Seed not found!")
current_rng_roll = 0
while seed_found:
raw_rng_roll = int(line[current_rng_roll + 6])
f_e_condition = get_condition(raw_rng_roll)
next_raw_rng_roll = int(line[current_rng_roll + 6 + 1])
r_e_condition = get_condition(next_raw_rng_roll)
input(f'Seed roll {(current_rng_roll + 1):3}: | Forced: {f_e_condition:10} | Random: {r_e_condition:10}')
current_rng_roll += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment