-
Notifications
You must be signed in to change notification settings - Fork 0
/
BotW_Edit_v3.py
712 lines (712 loc) · 25.1 KB
/
BotW_Edit_v3.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
# coding=latin
import binfx
import code #.interact()
import math
import os
import pdb #.set_trace()
import pickle
import sys #.stdin.buffer, ~.read() ~.write()
import time #.sleep()
# start of menu
def nav_fmenu(*args):
global curr_fmenu
global skp
while True:
print('You are in', '> '.join(curr_fmenu.rsplit('_')))
print('Options:')
for arg in args:
print(' [',arg[0],'] ',arg[1],sep='')
if curr_fmenu=='fmenu': darg=('quit','Close the menu')
else: darg=('back','Go to previous submenu')
print(' [',darg[0],'] ',darg[1],sep='')
inp=insist_input('Choose an option: ').lower()
for arg in args:
if arg[0].lower().startswith(inp):
skp=False
clearscr()
curr_fmenu=curr_fmenu+'_'+arg[0]
eval(curr_fmenu+'()')
curr_fmenu='_'.join(curr_fmenu.rsplit('_')[:-1])
if not skp: input('Press enter to return to fmenu.')
clearscr()
break
else:
if darg[0].lower().startswith(inp):
skp=True
return
else:
print('Your input was not a valid choice.')
time.sleep(0.7)
clearscr()
def fmenu():
global curr_fmenu
global skp
curr_fmenu='fmenu'
skp=False
nav_fmenu(
('file','Load or save data'),
('edit','Modify the loaded data'),
('temp','Misc functions')
)
def fmenu_file():
nav_fmenu(
('ddir','Use the current .py directory'),
('cdir','Change the directory where to load file'),
('unpi','Load from previous pickle'),
('load','Load from .sav file'),
('pick','Pickle to file'),
('save','Save to .sav file (adds _mod to file name)')
)
def fmenu_file_ddir():
global cdir
cdir=os.path.dirname(os.path.realpath(__file__))+'\\'
print('Using',cdir,'as cwd.')#print('getcwd:', os.getcwd())
def fmenu_file_cdir():
global cdir
cdir=input('Type in the directory to use: ')
print('Using',cdir,'as cwd.')
def fmenu_file_unpi():
global savedata
try: savedata=pickle.load(open(cdir+'game_data.pickle', 'rb'))
except: print('Unpickling failed.')
else: print('Successfully unpickled data!')
def fmenu_file_load():
global savedata
try: savedata=sav_load(cdir+'game_data.sav')
except: print("Loading failed.")
else: print('Successfully loaded .sav file!')
def fmenu_file_pick():
global savedata
try: pickle.dump(savedata, open(cdir+'game_data.pickle','wb'))
except: print('Error while pickling.')
else: print('Successfully pickled!')
def fmenu_file_save():
global savedata
try: sav_dump(cdir+'game_data_mod.sav',savedata)
except: print('Error while saving.')
else: print('Successfully saved game_data_mod.sav file! Please check the file size to be sure.')
def fmenu_edit():
nav_fmenu(
('auto','Quick predefined edits'),
('sear','Display hashes and modify their data')
)
def fmenu_edit_auto():
nav_fmenu(
('fillp','Order the porch and fill all slots for MarcRobledo\'s editor'),
('sfood','Change the first 12 meals with powerful effects')
)
def fmenu_edit_auto_fillp(curr_fdb=False):
""" Using hashes:
8932285f PorchItem (420*64/4B)
59fc096a PorchItem_Value1 (420*4B)
be924882 PorchItem_EquipFlag ¿420*4B? That's a waste of space
"""
print('ToDo: edit', curr_fmenu)
print('ToCheck: unequip flags')
temp_PorchItem=hashgen_PorchItem()
temp_PorchItem_Value1=hashgen_PorchItem_Value1()
for i in savedata:
if '8932285f'==hx(i[0]):
load_PorchItem=fsplit(i[1],64)
if '59fc096a'==hx(i[0]):
load_PorchItem_Value1=fsplit(i[1],4)
if not load_PorchItem or not load_PorchItem_Value1:
print('Error while loading')
return
pos={'w':0,'b':0,'a':0,'s':0,'c':0,'m':0,'f':0,'o':0}
max={'w':20,'b':14,'a':6,'s':20,'c':100,'m':160,'f':60,'o':40}
stt={'w':0,'b':20,'a':34,'s':40,'c':60,'m':160,'f':320,'o':380}
if curr_fdb:
for i in enumerate(temp_PorchItem[stt['m']:stt['f']]): print(i[0],i[1].strip(b'\x00'))
print('Length of temp_PorchItem:',len(temp_PorchItem))
print('Length of load_PorchItem:',len(load_PorchItem))
print('Length of temp_PorchItem_Value1:',len(temp_PorchItem_Value1))
print('Length of load_PorchItem_Value1:',len(load_PorchItem_Value1))
for i in range(420):
citem_PorchItem=load_PorchItem[i]
citem_PorchItem_Value1=load_PorchItem_Value1[i]
index=hashfx_porchpage(citem_PorchItem)
if index=='m':
def is_in(a, l):
for i in enumerate(l):
if a in i[1]:
return i[0]
return -1
tt=is_in(citem_PorchItem.strip(b'\x00'), temp_PorchItem[stt['m']:stt['f']])
if tt!=-1:
if curr_fdb:
print(citem_PorchItem.strip(b'\x00'),'\tis in',tt,'of temp',
'\twith val', citem_PorchItem_Value1)
temp_PorchItem_Value1[stt['m']+tt]=citem_PorchItem_Value1
elif pos[index]<max[index]:
if curr_fdb: print(citem_PorchItem.strip(b'\x00'),'\t*NOT* in temp')
ti=stt[index]+max[index]-pos[index]-1
temp_PorchItem[ti]=citem_PorchItem
temp_PorchItem_Value1[ti]=citem_PorchItem_Value1
pos[index]+=1
elif index!=None:
if pos[index]<max[index]:
ti=stt[index]+pos[index]
temp_PorchItem[ti]=citem_PorchItem
temp_PorchItem_Value1[ti]=citem_PorchItem_Value1
pos[index]+=1
print('New contents:')
for i in range(len(temp_PorchItem)):
print(temp_PorchItem[i].strip(b'\x00'),temp_PorchItem_Value1[i])
for i in savedata:
if '8932285f'==hx(i[0]):
i[1]=b''.join(temp_PorchItem)
if '59fc096a'==hx(i[0]):
i[1]=b''.join(temp_PorchItem_Value1)
if 'be924882'==hx(i[0]):
i[1]=vfill(b'\x00',sze=len(i[1]))
if curr_fdb:
pdb.set_trace()
for i in savedata:
if '8932285f'==hx(i[0]):
print(i[1])
if '59fc096a'==hx(i[0]):
print(i[1])
else: print('Filled Porch!')
def fmenu_edit_auto_sfood():
""" Using hashes: (floats instead of ints?!?)
ch[0] 05a995ff CookEffect0 [look BotW-HashValues.ods]
ch[1] 93999288 CookEffect1 [unknown,none?(0)]
ch[2] cdb860da StaminaRecover [hearts(30hp=0x78),time(100min=0x1770)]
"""
# Unlike _fillp, I try to make this _sfood function
# kinda generic so I can reuse for other purposes
ch=hashfx_sdpos('05a995ff','93999288','cdb860da')
mods=[
hashgen_CookEffect0(),
hashgen_CookEffect1(),
hashgen_StaminaRecover()
]
for i in range(len(ch)):
print('Editing pos',ch[i],'with length',len(savedata[ch[i]][1]))
savedata[ch[i]][1]=mods[i]+savedata[ch[i]][1][len(mods[i]):]
print('Edited pos',ch[i],'with length',len(savedata[ch[i]][1]),'\n')
print('Done, please check lengths are the same than before edition')
def fmenu_edit_sear():
nav_fmenu(
('hex','Directly search for a hash'),
('str','Look for hashes by name')
)
def fmenu_edit_sear_hex():
sea=insist_input('Enter hex search query or [q] to quit: ').lower()
while sea!='q':
fnd=[]
clearscr()
for n in range(1,len(savedata)):
if sea in hx(savedata[n][0]):
fnd.append(n)
if len(fnd)>=1 and len(fnd)<=7:
for i in fnd:
print('Found index n =',i,'with hash',savedata[i][0].hex(),'and data',savedata[i][1])
print('ToDo: edit', curr_fmenu)
print('If launched with "py -i" you can "^c", edit savedata[n][1] and "fmenu()" to get back\nOtherwise, I can launch the interactive interpreter ("^z" to return to program execution)')
if 'y'==input('Input "y" if you wish to launch the interpreter '):
code.interact()
else:
print(len(fnd),'results not displayed.')
sea=insist_input('Enter hex search query or [q] to quit: ').lower()
def fmenu_edit_sear_str():
try: nameref=tsvload('dump')
except: return
while True:
sea=insist_input('Enter str search query or [q] to quit: ').lower()
if sea=='q': return
hashs=[]
for m in nameref:
if sea in m[1].lower():
hashs.append([m[0],m[1]])
l=len(hashs)
if l>7:
print('Too many (',l,') results, try again.')
continue
elif l>1:
print('Results:')
for i in range(l):
print(i,':',hashs[i])
seh=input('Enter index: ')
try: seh=hashs[int(seh)][0]
except: continue
elif l==1:
print('Found a single result:',hashs[0])
seh=hashs[0][0]
else:
print('No results found.')
continue
print('Searching for', seh)
for n in range(len(savedata)):
if seh in hx(savedata[n][0]):
print('Found hash in index n=',n)
print('ToDo: edit', curr_fmenu)
print('If launched with "py -i" you can "^c", edit savedata[n][1] and "fmenu()" to get back\nOtherwise, I can launch the interactive interpreter ("^z" to return to program execution)')
if 'y'==input('Input "y" if you wish to launch the interpreter '):
code.interact()
def fmenu_temp():
print('ToDo: write', curr_fmenu)
def fmenu_None():
print('ToDo: write', curr_fmenu)
# end of menu
def insist_input(msg):
var=input(msg)
while not var:
print('Could not get input, please try again.')
var=input(msg)
return var
def clearscr():
if os.name=='nt': os.system('cls')
else: os.system('clear')
def sav_load(file):
file=open(file, 'rb')
c_data=file.read(4)
pobj=[[b'', c_data]]
print('Loading file...')
c_hash = file.read(4)
c_data = file.read(4)
while c_hash:
if c_hash==pobj[-1][0]: pobj[-1][1] += c_data
else: pobj.append([c_hash, c_data])
c_hash = file.read(4)
c_data = file.read(4)
print('Hashes Read:', len(pobj))
file.close()
return pobj
def sav_dump(file, pobj):
file=open(file, 'wb')
for i in pobj:
for j in fsplit(fjoin(i[1]),4):
file.write(i[0])
file.write(j)
file.close()
def hx(bin):
#print('Hx:', bin)
#print(int.from_bytes(bin, 'big'))
return format(int.from_bytes(bin, 'big'),'08x')
def bn(hex):
sz=len(hex)>>1
return int(hex, 16).to_bytes(sz, 'big')
def hashgen_PorchItem():
obj=[]
elm=[
#Weapons
[vfill(b'Weapon_Sword_001'),10],
[vfill(b'Weapon_Lsword_001'),5],
[vfill(b'Weapon_Spear_001'),5],
#Bows+Arrows
[vfill(b'Weapon_Bow_001'),14],
[vfill(b'NormalArrow'),1],
[vfill(b'FireArrow'),1],
[vfill(b'IceArrow'),1],
[vfill(b'ElectricArrow'),1],
[vfill(b'BombArrow_A'),1],
[vfill(b'AncientArrow'),1],
#Shields
[vfill(b'Weapon_Shield_035'),20],
#Clothes
[vfill(b'Armor_043_Upper'),50],
[vfill(b'Armor_043_Lower'),50],
#Materials
[vfill(b'Item_Fruit_A'),1],
[vfill(b'Item_Fruit_B'),1],
[vfill(b'Item_Fruit_C'),1],
[vfill(b'Item_Fruit_D'),1],
[vfill(b'Item_Fruit_E'),1],
[vfill(b'Item_Fruit_F'),1],
[vfill(b'Item_Fruit_G'),1],
[vfill(b'Item_Fruit_H'),1],
[vfill(b'Item_Fruit_I'),1],
[vfill(b'Item_Fruit_J'),1],
[vfill(b'Item_Fruit_K'),1],
[vfill(b'Item_Fruit_L'),1],
[vfill(b'Item_Mushroom_A'),1],
[vfill(b'Item_Mushroom_B'),1],
[vfill(b'Item_Mushroom_C'),1],
[vfill(b'Item_MushroomGet_D'),1],
[vfill(b'Item_Mushroom_E'),1],
[vfill(b'Item_Mushroom_F'),1],
[vfill(b'Item_Mushroom_H'),1],
[vfill(b'Item_Mushroom_J'),1],
[vfill(b'Item_Mushroom_L'),1],
[vfill(b'Item_Mushroom_M'),1],
[vfill(b'Item_Mushroom_N'),1],
[vfill(b'Item_Mushroom_O'),1],
#v [vfill(b'Item_Mushroom_D'),1],
# [vfill(b'Item_Fruit_E_00'),1],
# [vfill(b'Item_Mushroom_N_00'),1],
# [vfill(b'Item_Mushroom_F_00'),1],
# [vfill(b'Item_MushroomGet_A'),1],
# [vfill(b'Item_MushroomGet_B'),1],
# [vfill(b'Item_MushroomGet_C'),1],
# [vfill(b'Item_MushroomGet_E'),1],
# [vfill(b'Item_MushroomGet_F'),1],
# [vfill(b'Item_MushroomGet_H'),1],
# [vfill(b'Item_MushroomGet_J'),1],
# [vfill(b'Item_MushroomGet_L'),1],
# [vfill(b'Item_MushroomGet_M'),1],
# [vfill(b'Item_MushroomGet_N'),1],
# [vfill(b'Item_MushroomGet_O'),1],
#v [vfill(b'Item_Plant_A'),1],
#v [vfill(b'Item_Plant_B'),1],
#v [vfill(b'Item_Plant_C'),1],
#v [vfill(b'Item_Plant_E'),1],
#v [vfill(b'Item_Plant_F'),1],
#v [vfill(b'Item_Plant_G'),1],
#v [vfill(b'Item_Plant_H'),1],
#v [vfill(b'Item_Plant_I'),1],
#v [vfill(b'Item_Plant_J'),1],
#v [vfill(b'Item_Plant_L'),1],
#v [vfill(b'Item_Plant_M'),1],
#v [vfill(b'Item_Plant_O'),1],
#v [vfill(b'Item_Plant_Q'),1],
[vfill(b'Item_PlantGet_A'),1],
[vfill(b'Item_PlantGet_B'),1],
[vfill(b'Item_PlantGet_C'),1],
[vfill(b'Item_PlantGet_E'),1],
[vfill(b'Item_PlantGet_F'),1],
[vfill(b'Item_PlantGet_G'),1],
[vfill(b'Item_PlantGet_H'),1],
[vfill(b'Item_PlantGet_I'),1],
[vfill(b'Item_PlantGet_J'),1],
[vfill(b'Item_PlantGet_L'),1],
[vfill(b'Item_PlantGet_M'),1],
[vfill(b'Item_PlantGet_O'),1],
[vfill(b'Item_PlantGet_Q'),1],
[vfill(b'Item_Meat_01'),1],
[vfill(b'Item_Meat_02'),1],
[vfill(b'Item_Meat_06'),1],
[vfill(b'Item_Meat_07'),1],
[vfill(b'Item_Meat_11'),1],
[vfill(b'Item_Meat_12'),1],
[vfill(b'Item_FishGet_A'),1],
[vfill(b'Item_FishGet_B'),1],
[vfill(b'Item_FishGet_C'),1],
[vfill(b'Item_FishGet_D'),1],
[vfill(b'Item_FishGet_E'),1],
[vfill(b'Item_FishGet_F'),1],
[vfill(b'Item_FishGet_G'),1],
[vfill(b'Item_FishGet_H'),1],
[vfill(b'Item_FishGet_I'),1],
[vfill(b'Item_FishGet_J'),1],
[vfill(b'Item_FishGet_K'),1],
[vfill(b'Item_FishGet_L'),1],
[vfill(b'Item_FishGet_M'),1],
[vfill(b'Item_FishGet_X'),1],
[vfill(b'Item_FishGet_Z'),1],
[vfill(b'Animal_Insect_A'),1],
[vfill(b'Animal_Insect_B'),1],
[vfill(b'Animal_Insect_C'),1],
[vfill(b'Animal_Insect_E'),1],
[vfill(b'Animal_Insect_F'),1],
[vfill(b'Animal_Insect_G'),1],
[vfill(b'Animal_Insect_H'),1],
[vfill(b'Animal_Insect_I'),1],
[vfill(b'Animal_Insect_M'),1],
[vfill(b'Animal_Insect_N'),1],
[vfill(b'Animal_Insect_P'),1],
[vfill(b'Animal_Insect_Q'),1],
[vfill(b'Animal_Insect_R'),1],
[vfill(b'Animal_Insect_S'),1],
[vfill(b'Animal_Insect_T'),1],
[vfill(b'Animal_Insect_X'),1],
[vfill(b'Animal_Insect_AA'),1],
[vfill(b'Animal_Insect_AB'),1],
[vfill(b'Item_InsectGet_K'),1],
[vfill(b'Item_InsectGet_O'),1],
[vfill(b'Item_InsectGet_Z'),1],
#v [vfill(b'Animal_Insect_O'),1],
#v [vfill(b'Animal_Insect_K'),1],
#v [vfill(b'Animal_Insect_Z'),1],
# [vfill(b'Item_InsectGet_A'),1],
# [vfill(b'Item_InsectGet_B'),1],
# [vfill(b'Item_InsectGet_C'),1],
# [vfill(b'Item_InsectGet_E'),1],
# [vfill(b'Item_InsectGet_F'),1],
# [vfill(b'Item_InsectGet_G'),1],
# [vfill(b'Item_InsectGet_H'),1],
# [vfill(b'Item_InsectGet_I'),1],
# [vfill(b'Item_InsectGet_M'),1],
# [vfill(b'Item_InsectGet_N'),1],
# [vfill(b'Item_InsectGet_P'),1],
# [vfill(b'Item_InsectGet_Q'),1],
# [vfill(b'Item_InsectGet_R'),1],
# [vfill(b'Item_InsectGet_S'),1],
# [vfill(b'Item_InsectGet_T'),1],
# [vfill(b'Item_InsectGet_X'),1],
# [vfill(b'Item_InsectGet_AA'),1],
# [vfill(b'Item_InsectGet_AB'),1],
# [vfill(b'Item_Ore_A_00'),1],
[vfill(b'BeeHome'),1],
[vfill(b'Obj_FireWoodBundle'),1],
[vfill(b'Item_Enemy_00'),1],
[vfill(b'Item_Enemy_01'),1],
[vfill(b'Item_Enemy_02'),1],
[vfill(b'Item_Enemy_03'),1],
[vfill(b'Item_Enemy_04'),1],
[vfill(b'Item_Enemy_05'),1],
[vfill(b'Item_Enemy_06'),1],
[vfill(b'Item_Enemy_07'),1],
[vfill(b'Item_Enemy_08'),1],
[vfill(b'Item_Enemy_12'),1],
[vfill(b'Item_Enemy_13'),1],
[vfill(b'Item_Enemy_14'),1],
[vfill(b'Item_Enemy_15'),1],
[vfill(b'Item_Enemy_16'),1],
[vfill(b'Item_Enemy_17'),1],
[vfill(b'Item_Enemy_18'),1],
[vfill(b'Item_Enemy_19'),1],
[vfill(b'Item_Enemy_20'),1],
[vfill(b'Item_Enemy_21'),1],
[vfill(b'Item_Enemy_24'),1],
[vfill(b'Item_Enemy_25'),1],
[vfill(b'Item_Enemy_26'),1],
[vfill(b'Item_Enemy_27'),1],
[vfill(b'Item_Enemy_28'),1],
[vfill(b'Item_Enemy_29'),1],
[vfill(b'Item_Enemy_30'),1],
[vfill(b'Item_Enemy_31'),1],
[vfill(b'Item_Enemy_32'),1],
[vfill(b'Item_Enemy_33'),1],
[vfill(b'Item_Enemy_34'),1],
[vfill(b'Item_Enemy_38'),1],
[vfill(b'Item_Enemy_39'),1],
[vfill(b'Item_Enemy_40'),1],
[vfill(b'Item_Enemy_41'),1],
[vfill(b'Item_Enemy_42'),1],
[vfill(b'Item_Enemy_43'),1],
[vfill(b'Item_Enemy_44'),1],
[vfill(b'Item_Enemy_45'),1],
[vfill(b'Item_Enemy_46'),1],
[vfill(b'Item_Enemy_47'),1],
[vfill(b'Item_Enemy_48'),1],
[vfill(b'Item_Enemy_49'),1],
[vfill(b'Item_Enemy_50'),1],
[vfill(b'Item_Enemy_51'),1],
[vfill(b'Item_Enemy_52'),1],
[vfill(b'Item_Enemy_53'),1],
[vfill(b'Item_Enemy_54'),1],
[vfill(b'Item_Enemy_55'),1],
[vfill(b'Item_Enemy_56'),1],
[vfill(b'Item_Enemy_57'),1],
[vfill(b'Item_Enemy_Put_57'),1],
[vfill(b'Item_Material_01'),1],
[vfill(b'Item_Material_02'),1],
[vfill(b'Item_Material_03'),1],
[vfill(b'Item_Material_04'),1],
[vfill(b'Item_Material_05'),1],
[vfill(b'Item_Material_06'),1],
[vfill(b'Item_Material_07'),1],
[vfill(b'Item_Material_08'),1],
[vfill(b'Item_Ore_A'),1],
[vfill(b'Item_Ore_B'),1],
[vfill(b'Item_Ore_C'),1],
[vfill(b'Item_Ore_D'),1],
[vfill(b'Item_Ore_E'),1],
[vfill(b'Item_Ore_F'),1],
[vfill(b'Item_Ore_G'),1],
[vfill(b'Item_Ore_H'),1],
[vfill(b'Item_Ore_I'),1],
[vfill(b'Item_Ore_J'),1],
[vfill(b'Obj_FireWoodBundle'),10],
#Food
[vfill(b'Item_Cook_C_17'),40],
[vfill(b'Item_Cook_C_16'),15],
[vfill(b'Item_Boiled_01'),5],
#Misc
[vfill(b'KeySmall'),40]
]
for i in elm:
add=[i[0]]
add*=i[1]
obj+=add
return obj
def hashgen_PorchItem_Value1():
obj=[]
elm=[
#W+BA+S
[b'\x28\x23\x00\x00',60],
#Clothes
[b'\x00\x00\x00\x00',100],
#Materials
[b'\x30\x00\x00\x00',160],
#Food
[b'\x03\x00\x00\x00',60],
#Misc
[b'\x01\x00\x00\x00',40]
]
for i in elm:
add=[i[0]]
add*=i[1]
obj+=add
return obj
def hashgen_CookEffect0():
obj=[]
elm=[
[b'\x00\x00\x00\x00\x00\x00\x70\x42',1],
[b'\x00\x00\x00\x40\x00\x00\xf0\x42',1],
[b'\x00\x00\x80\x40\x00\x00\x40\x40',1],
[b'\x00\x00\xa0\x40\x00\x00\x40\x40',1],
[b'\x00\x00\xc0\x40\x00\x00\x40\x40',1],
[b'\x00\x00\x20\x41\x00\x00\x40\x40',1],
[b'\x00\x00\x30\x41\x00\x00\x40\x40',1],
[b'\x00\x00\x40\x41\x00\x00\x40\x40',1],
[b'\x00\x00\x50\x41\x00\x00\x40\x40',1],
[b'\x00\x00\x60\x41\x00\x40\x9c\x45',1],
[b'\x00\x00\x70\x41\x00\x00\x70\x41',1],
[b'\x00\x00\x80\x41\x00\x00\x40\x40',1]
]
for i in elm:
add=[i[0]]
add*=i[1]
obj+=add
return fjoin(obj)
def hashgen_CookEffect1():
obj=[]
elm=[
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1],
[b'\x00\x00\x00\x00\x00\x00\x00\x00',1]
]
for i in elm:
add=[i[0]]
add*=i[1]
obj+=add
return fjoin(obj)
def hashgen_StaminaRecover():
obj=[]
elm=[
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1],
[b'\x00\x00\xf0\x42\x00\xb8\xbb\x45',1]
]
for i in elm:
add=[i[0]]
add*=i[1]
obj+=add
return fjoin(obj)
def hashfx_porchpage(obj, rid=1):
if obj.startswith(b'Weapon_Sword'): return (0,'w')[rid]
if obj.startswith(b'Weapon_Lsword'): return (0,'w')[rid]
if obj.startswith(b'Weapon_Spear'): return (0,'w')[rid]
if obj.startswith(b'Weapon_Bow'): return (1,'b')[rid]
if b'Arrow' in obj: return (2,'a')[rid]
if obj.startswith(b'Weapon_Shield'): return (3,'s')[rid]
if obj.startswith(b'Armor'): return (4,'c')[rid]
if obj.startswith(b'Item_Fruit'): return (5,'m')[rid]
if obj.startswith(b'Item_Mushroom'): return (5,'m')[rid]
if obj.startswith(b'Item_Plant'): return (5,'m')[rid]
if obj.startswith(b'Item_Meat'): return (5,'m')[rid]
if obj.startswith(b'Item_Fish'): return (5,'m')[rid]
if obj.startswith(b'Animal_Insect'): return (5,'m')[rid]
if obj.startswith(b'Item_Insect'): return (5,'m')[rid]
if obj.startswith(b'Bee'): return (5,'m')[rid]
if b'FireWoodBundle' in obj: return (5,'m')[rid]
if obj.startswith(b'Item_Enemy'): return (5,'m')[rid]
if b'Item_Material_05_00' in obj: return (6,'f')[rid]
if obj.startswith(b'Item_Material'): return (5,'m')[rid]
if obj.startswith(b'Item_Ore'): return (5,'m')[rid]
if obj.startswith(b'Item_Boiled'): return (6,'f')[rid]
if obj.startswith(b'Item_Chilled'): return (6,'f')[rid]
if obj.startswith(b'Item_Roast'): return (6,'f')[rid]
if obj.startswith(b'Item_Cook'): return (6,'f')[rid]
if obj.startswith(b'Obj'): return (7,'o')[rid]
if b'Player' in obj: return (7,'o')[rid]
if obj.startswith(b'Key'): return (7,'o')[rid]
if obj.startswith(b'Game'): return (7,'o')[rid]
if obj.startswith(b'Get_TwnObj_DLC'): return (7,'o')[rid]
return None#(-1,'x')[rid]
def hashfx_sdpos(*lh):
ch=[None]*len(lh)
for i in range(len(savedata)):
for j in enumerate(lh):
if j[1]==hx(savedata[i][0]): ch[j[0]]=i
return ch
def vfill(var, fll=b'\x00', sze=64):
while len(var)<sze: var+=fll
return var
def chunks(lst, n=4):
for i in range(0,len(lst),n): yield lst[i:i+n]
def fsplit(lst, n=4):
ret=[]
for i in chunks(lst,n): ret+=[i]
return ret
def getsl(obj, typ=(list, tuple)):
# I almost wrote the same as https://gist.github.com/aljiwala/c77a01f382f5bbc10d2d2b97a7ed0f0a but didn't wotk what I wrote
if isinstance(obj, typ):
for sub in obj:
for itm in getsl(sub, typ):
yield itm
else: yield obj
def fjoin(obj, typ=(list, tuple)):
ret=b''
for i in getsl(obj, typ): ret+=i
return ret
def tsvload(name):
global cdir
try:
x=open(cdir+name+'.tsv')
l=[]
for line in x:
l.append(line.strip('\n').split('\t'))
x.close()
except:
return None
else:
return l
# unused?
def hash_dtype(t):
if t<7: return [4,1]
elif t<9: return [4,2]
elif t<11: return [4,3]
elif t<13: return [4,4]
elif t<15: return [32,1]
elif t<17: return [64,1]
else: return [256,1]
def hash_defdat(t):
if t==1:
rt=[]
ra=''
for i in range(20):
rt.append(ra)
ra=''
for i in range(20):
rt.append(ra)
return rt
return None
def hashfx_porchpage_test():
for i in list(dict_PorchItemList):
for j in list(dict_PorchItemList[i]):
print(hshfx_porchpage(j.encode('latin')),j)
# program start
fmenu_file_ddir()
time.sleep(0.7)
try: fmenu_file_load()
except:
print('File not loaded, load it manually please.')
input('Press enter to porceed... ')
else:
print('File in cwd loaded!')
time.sleep(1.2)
clearscr()
fmenu()
#end