-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMovelistParser.py
More file actions
2919 lines (2391 loc) · 132 KB
/
MovelistParser.py
File metadata and controls
2919 lines (2391 loc) · 132 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
'''
see HowTheMovelistBytesWork.md for a full description of how the movelist is parsed
'''
import struct
import AddressMap
import MovelistEnums as mve
from MovelistEnums import *
import GameplayEnums
import copy
import math
import json
import os
def b4i (bytes, index : int):
return struct.unpack('I', bytes[index: index + 4])[0]
def bs4i (bytes, index : int):
return struct.unpack('I', bytes[index: index + 4])[0]
def b2i (bytes, index : int , big_endian = False):
if not big_endian:
return struct.unpack('H', bytes[index: index + 2])[0]
else:
return struct.unpack('>H', bytes[index: index + 2])[0]
def bs2i (bytes, index : int , big_endian = False):
if not big_endian:
return struct.unpack('h', bytes[index: index + 2])[0]
else:
return struct.unpack('>h', bytes[index: index + 2])[0]
def b1i (bytes, index : int):
return struct.unpack('B', bytes[index: index + 1])[0]
def bs1i (bytes, index : int):
return struct.unpack('b', bytes[index: index + 1])[0]
def b4f (bytes, index : int):
return struct.unpack('f', bytes[index: index + 4])[0]
def encode_move_id(decoded_move_id, movelist):
move_id = decoded_move_id
if move_id >= movelist.block_T_start: # this is kinda an escape value for stances??? and neutral???
move_id -= movelist.block_T_start
move_id += 0x3000
elif move_id >= movelist.block_S_start:
move_id -= movelist.block_S_start
move_id += 0x2000
elif move_id >= movelist.block_R_start:
move_id -= movelist.block_R_start
move_id += 0x1000
return move_id
def decode_move_id(encoded_move_id, movelist):
move_id = encoded_move_id
if move_id >= 0x3000: # this is kinda an escape value for stances??? and neutral???
move_id -= 0x3000
move_id += movelist.block_T_start
elif move_id >= 0x2000:
move_id -= 0x2000
move_id += movelist.block_S_start
elif move_id >= 0x1000:
move_id -= 0x1000
move_id += movelist.block_R_start
return move_id
def string_to_class(string, custom_types=None):
conversion_table = {
"BoolFlag": BoolFlag,
"Button": Button,
"PaddedButton": PaddedButton,
"EffectPart": EffectPart,
"EffectTarget": EffectTarget,
"TraceKind": TraceKind,
"TracePart": TracePart,
'InputType': InputType,
"ComboConditions": ComboConditions,
"ReturnState": ReturnState,
"SpecialState": BattleState,
"AssetType": AssetType,
"CharacterIndex": CharacterIndex,
"Hand": Hand,
"MeterType": MeterType,
"MeterAmount": MeterAmount,
"MeterCalcBase": MeterCalcBase,
"VoiceCategory": VoiceCategory,
"RandomVoiceCategory": RandomVoiceCategory,
"FacialExpression": FacialExpression,
"AirStunType": AirStunType,
"LH_Situation": LH_Situation,
"LH_Condition": LH_Condition,
"GI_Type": GI_Type,
"AttackLevel": AttackLevel,
"StunOverride": StunOverride,
"ViewTarget": ViewTarget,
"OpponentState": OpponentState,
"CharacterValue": CharacterValue,
"CharacterGender": CharacterGender,
"CharacterID": CharacterID
}
for t in custom_types:
if t["name"] == string:
return string
for s in conversion_table.keys():
if s == string:
return conversion_table[s]
def find_script_info(movelist, state, char_data, custom_data, data, script_type, second_arg = -1, args_list = None, params = None):
found = False
state_info = None
argp = []
param_out = []
if movelist.character_id != '000' and movelist.custom == True:
for index_id in char_data:
if "state" not in index_id:
index_id["state"] = "0x0000"
if "return_value" not in index_id:
index_id["return_value"] = False
if "script_type" not in index_id:
index_id["script_type"] = "0x01"
if "name" not in index_id:
index_id["name"] = "NO NAME"
if isinstance(index_id["state"],list):
for i, idx in enumerate(index_id["state"]):
if index_id['state'][i] == str(f"0x{state:04x}") and index_id["script_type"] == script_type:
state_info = index_id
found = True
break
else:
if index_id['state'] == str(f"0x{state:04x}") and index_id["script_type"] == script_type:
state_info = index_id
found = True
break
if found == False:
for index_id in custom_data:
if "state" not in index_id:
index_id["state"] = "0x0000"
if "return_value" not in index_id:
index_id["return_value"] = False
if "script_type" not in index_id:
index_id["script_type"] = "0x01"
if "name" not in index_id:
index_id["name"] = "NO NAME"
if isinstance(index_id["state"],list):
for i, idx in enumerate(index_id["state"]):
if index_id['state'][i] == str(f"0x{state:04x}") and index_id["script_type"] == script_type:
state_info = index_id
found = True
break
else:
if index_id['state'] == str(f"0x{state:04x}") and index_id["script_type"] == script_type:
state_info = index_id
found = True
break
if found == False:
for index_id in data:
if "state" not in index_id:
index_id["state"] = "0x0000"
if "return_value" not in index_id:
index_id["return_value"] = False
if "script_type" not in index_id:
index_id["script_type"] = "0x01"
if "name" not in index_id:
index_id["name"] = "NO NAME"
if isinstance(index_id["state"],list):
for i, idx in enumerate(index_id["state"]):
if index_id['state'][i] == str(f"0x{state:04x}") and index_id["script_type"] == script_type:
state_info = index_id
found = True
break
else:
if index_id['state'] == str(f"0x{state:04x}") and index_id["script_type"] == script_type:
state_info = index_id
found = True
break
if found:
argp = []
if "args" not in state_info:
state_info["args"] = []
for i, a in enumerate(state_info["args"]):
if "index" not in a:
a["index"] = i
if "prefix" not in a:
a["prefix"] = ""
if "name" not in a:
a["name"] = "" if a["index"] == -1 else f'{a["index"]}'
if a["name"] != "":
a["name"] = f'{a["name"]}:' if a["name"][-1] != ":" else a["name"]
if "value_type" not in a:
a["value_type"] = None
if "format_method" not in a:
a["format_method"] = "format_value"
if "data" not in a:
a["data"] = {}
offset = 1
if state_info["args"][0]["index"] == -1:
offset = 0
if second_arg == -1:
param_out.append(str(a["name"]).split(":")[0])
continue
if i >= second_arg - offset:
break
if a["format_method"] == "format_value" and args_list != None:
if isinstance(a["index"],list):
try:
val = f'{format_value(args_list[a["index"][0]], string_to_class(a["value_type"], movelist.custom_types), movelist=movelist,params=params, **a["data"])} to {format_value(args_list[a["index"][1]], string_to_class(a["value_type"], movelist.custom_types), movelist=movelist,params=params, **a["data"])}'
except:
val = f'{format_value(args_list[a["index"][0]], string_to_class(a["value_type"], movelist.custom_types), movelist=movelist,params=params, **a["data"])} to {format_value(args_list[a["index"][0]], string_to_class(a["value_type"], movelist.custom_types), movelist=movelist,params=params, **a["data"])}'
else:
val = format_value(args_list[a["index"]], string_to_class(a["value_type"], movelist.custom_types), movelist=movelist,params=params, **a["data"])
argp.append(f'{a["prefix"]}[{a["name"]}{val}]')
elif a["format_method"] == "name_from_enum":
val = name_from_enum(string_to_class(a["value_type"], movelist.custom_types), state, **a["data"])
argp.append(f'[{a["name"]}{val}]')
if second_arg == -1:
return param_out
return found, state_info, argp
def format_value(bytes, cls=None, auto = False, decode = False, movelist = None, params = [], negative = False, end = False, prefix = "", suffix = "", offset = 0, replace_char = " ", format = False, slice= False, slice_index = 0, FP16 = False, percent = False, percent_base = 100, multiplier = 0, divisor = 0, divide_first = False):
value = bs2i(bytes,1,big_endian=True) if negative else b2i(bytes,1,big_endian=True)
value_f = bs2i(bytes,1,big_endian=True)
value_f_b = bs1i(bytes,2)
type = int(bytes[0])
result = 0
# custom_type_dir = './Data/Types/'
custom_types = movelist.custom_types
if type == 0x89: #constant
if cls != None:
found = False
for t in custom_types:
if t["name"] == cls:
for k in t["values"]:
if isinstance(k["input_value"],list):
for v in k["input_value"]:
if v == value:
result = f'{prefix}<b>{k["output_value"]}<b>{suffix}'
found = True
break
else:
if k["input_value"] == value:
result = f'{prefix}<b>{k["output_value"]}<b>{suffix}'
found = True
break
if found == False:
result = f'{prefix}<b>{name_from_enum(cls, value, replace_char, format, slice, slice_index)}<b>{suffix}'
else:
if value == 0 and auto:
result = f'<b>Auto<b>'
elif percent:
result = f'<b>{math.floor(value / percent_base * 100)}%<b>'
elif FP16:
result = ((value_f & 0x7c00) << 13) + 0x38000000 | (value_f & 0x3ff) << 13 | value_f & 0x80000000
if multiplier:
result = f"<b>{round(struct.unpack('f', struct.pack('I', result & 0xFFFFFFFF))[0] * multiplier,6)}{suffix}<b>"
if divisor:
result = f"<b>{round(struct.unpack('f', struct.pack('I', result & 0xFFFFFFFF))[0] / divisor, 6)}{suffix}<b>"
result = f"<b>{round(struct.unpack('f', struct.pack('I', result & 0xFFFFFFFF))[0],3)}{suffix}<b>"
else:
if divide_first == 0:
if multiplier:
value = value * multiplier
if divisor:
value = value / divisor
if divide_first == 1:
if divisor:
value = value / divisor
if multiplier:
value = value * multiplier
result = f'{prefix}<b>{decode_move_id(value,movelist)}<b>{suffix}' if decode else f'{prefix}<b>{value + offset}<b>{suffix}'
return result if result != None else "<b>last return<b>"
elif type == 0x8b: #encoded / shortcut
sockets = [x for x in range(-32745, -32736)]
if cls != None:
found = False
for t in custom_types:
if t["name"] == cls:
for k in t["values"]:
if isinstance(k["input_value"],list):
for v in k["input_value"]:
if v == value:
result = f'{prefix}<b>{k["output_value"]}<b>{suffix}'
found = True
break
else:
if k["input_value"] == value:
result = f'{prefix}<b>{k["output_value"]}<b>{suffix}'
found = True
break
if found == False:
result = f'<b>{name_from_enum(cls, value, replace_char, format, slice, slice_index)}<b>'
elif value == 0xffff:
result = 'NONE'
elif value == 0x7fff:
if end:
result = f'∞'
else:
result = f'∞'
elif value & 0x7600 == 0x7600:
result_label = f'<b>exit frame - {abs(value_f_b)}<b>' if value_f_b <= -1 else f'<b>exit frame + {abs(value_f_b)}<b>'
result = result_label if value_f_b != 0 else '<b>exit frame<b>'
elif value & 0x7500 == 0x7500:
result_label = f'<b>exit frame - {abs(value_f_b)}<b>' if value_f_b <= -1 else f'<b>exit frame + {abs(value_f_b)}<b>'
result = result_label if value_f_b != 0 else '<b>exit frame<b>'
elif value & 0x7c00 == 0x7c00:
result_label = f'<b>(current frame +1) - {abs(value_f_b)}<b>' if value_f_b <= -1 else f'<b>(current frame + 1) + {abs(value_f_b)}<b>'
result = result_label if value_f_b != 0 else '<b>current frame + 1<b>'
elif value & 0x7400 == 0x7400:
result_label = f'<b>entry frame - {abs(value_f_b)}<b>' if value_f_b <= -1 else f'<b>entry frame + {abs(value_f_b)}<b>'
result = result_label if value_f_b != 0 else '<b>entry frame<b>'
elif value & 0x7a00 == 0x7a00:
result_label = f'<b>remaining frames - {abs(value_f_b)}<b>' if value_f_b <= -1 else f'<b>remaining frames + {abs(value_f_b)}<b>'
result = result_label if value_f_b != 0 else '<b>remaining frames<b>'
elif value & 0x7800 == 0x7800 and value != 0x7a00:
result_label = f'<b>current frame - {abs(value_f_b)}<b>' if value_f_b <= -1 else f'<b>current frame + {abs(value_f_b)}<b>'
result = result_label if value_f_b != 0 else '<b>current frame<b>'
else:
if value in sockets:
for i, socket in enumerate(sockets):
if value == socket:
result = f"<b>Weapon Socket {i+1}<b>"
break
elif value == 0 and auto:
result = f'<b>Auto<b>'
elif percent:
result = f'<b>{math.floor(value / percent_base * 100)}%<b>'
elif FP16:
result = ((value & 0x7c00) << 13) + 0x38000000 | (value & 0x3ff) << 13 | value & 0x80000000
if multiplier:
result = f"<b>{round(struct.unpack('f', struct.pack('I', result & 0xFFFFFFFF))[0] * multiplier,6)}{suffix}<b>"
if divisor:
result = f"<b>{round(struct.unpack('f', struct.pack('I', result & 0xFFFFFFFF))[0] / divisor, 6)}{suffix}<b>"
result = f"<b>{round(struct.unpack('f', struct.pack('I', result & 0xFFFFFFFF))[0],3)}{suffix}<b>"
else:
if divide_first == 0:
if multiplier:
value = value * multiplier
if divisor:
value = value / divisor
if divide_first == 1:
if divisor:
value = value / divisor
if multiplier:
value = value * multiplier
result = f'{prefix}<b>{decode_move_id(value,movelist)}<b>{suffix}' if decode else f'{prefix}<b>{value + offset}<b>{suffix}'
return result if result != None else "<b>last return<b>"
elif type == 0x8a or type == 0x19 or type == 0x1a or type == 0x1b or type == 0x1c or type == 0x1d or type == 0x1e or type == 0x12 or type == 0x13 or type == 0x92 or type == 0x93 or type == 0x99: #variable / input param
if value & 0xf0 == 0xf0:
index = value ^ 0xf0
if params != [] and index < len(params):
result = f'<b>{params[index]}<b>'
else:
result = f'<b>input param {(value ^ 0xf0) + 1}<b>'
elif value & 0x0100 == 0x0100:
result = f'<b>local variable {(value ^ 0x0100)}<b>'
else:
result = f'<b>variable {value}<b>'
return result if result != None else "<b>last return<b>"
def format_return_value(bytes, index, offset1 = 6, offset2 = 4, movelist = None, params = []):
variable_operators = [0x12, 0x13, 0x19, 0x1a, 0x1c, 0x8a, 0x92, 0x93, 0x99]
math_operators = [0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x94, 0x95, 0x97, 0x98]
compare_operators = [0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4]
if bytes[index - offset1] == 0xa5 or bytes[index - offset2] == 0x25:
return"<b>last return value<b>"
elif bytes[index-offset2] in math_operators and bytes[index-offset1] not in variable_operators:
return"<b>math result<b>"
elif bytes[index-offset2] in compare_operators:
return"<b>compare result<b>"
else:
return format_value(bytes[index - 6:index - 3],movelist=movelist, params=params, negative=True)
class FrameData:
def __init__(self, id, com, t, startup, block_stun, hit_launch, hit_stun, counter_launch, counter_stun, damage, attack_type, active_frames, recovery, delta, extra_info):
self.id = id
self.com = com
self.whiff = t
self.imp = startup
self.bstun = block_stun
self.hlaunch = hit_launch
self.hstun = hit_stun
self.claunch = counter_launch
self.cstun = counter_stun
self.dam = damage
self.attack_type = attack_type
self.active = active_frames
self.rec = recovery
self.delta = delta
self.notes = extra_info
def __repr__(self):
id = self.id
cl = self.claunch
c = self.cstun
hl = self.hlaunch
h = self.hstun
b = self.bstun
rec = self.rec
com = self.com
s = self.imp
at = self.attack_type
d = self.dam
act = self.active
t = self.whiff
tf = self.notes
if cl == hl and c == h:
cl = ''
c = ''
else:
c = FrameData.StringifyAdvantage(rec - c)
gap = 0
if self.delta != 0:
gap = self.imp + self.delta - 1
#str = "{:^3}|{:^7}|{:^4}|{:^2}|{:^7}|{:^7}|{:^7}|{:^4}|{:^4}|{:^1}|{:^4}|{}".format(id, '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12')
str = "{:^3}|{:^7}|{:^4}|{:^2}|{:^5}|{:^7}|{:^7}|{:^2}|{:^4}|{:^1}|{:^3}|{:^3}|{:^3}|{}".format(
id,
com[-7:],
s,
at,
'{}'.format(FrameData.StringifyAdvantage(rec - b)),
'{} {}'.format(hl, FrameData.StringifyAdvantage(rec - h)),
'{} {}'.format(cl, c),
d,
'[gd]',#'{:^4}',
act,
t,
rec - 1,
gap,
' '.join(tf),
)
return str
def StringifyAdvantage(f : int):
flipped = f * -1
if flipped >= 0:
return '+{}'.format(flipped)
else:
return '{}'.format(flipped)
class Move:
LENGTH = 0x48
def __init__(self, bytes, movelist, move_id):
self.movelist = movelist
self.move_id = move_id
self.bytes = bytes
self.modified_bytes = None
self.animation = b4i(bytes, 0x00)
self.unknown_04 = b4i(bytes, 0x04)
self.motion_multiplier = b4f(bytes, 0x08)
self.speed_multiplier = b4f(bytes, 0x0C)
self.unknown_10 = b4i(bytes, 0x10)
self.unknown_multiplier = b4i(bytes, 0x30)
self.total_frames = b2i(bytes, 0x34)
self.cancel_address = b4i(bytes, 0x38)
self.attack_indexes = []
count = 0
while count < 6:
attack_index = b2i(bytes, 0x3C + 2 * count)
if attack_index == 0xFFFF:
break
else:
self.attack_indexes.append(attack_index)
count += 1
def get_modified_bytes(self):
if self.modified_bytes == None:
return self.bytes
else:
return self.modified_bytes
def set_cancel(self, cancel):
self.cancel:Cancel = cancel
def set_attacks(self, attacks):
self.attacks:Attack|Throw = attacks
def get_weight_to_move_id(self, move_id):
link = self.cancel.get_link_to_move_id(move_id)
if link == None:
return None, None
else:
is_block_stun_applied = False
cancel_weight = link.weight
if len(self.attacks) > 0:
startup = self.attacks[0].startup
else:
startup = 0
if link.leave_on > startup:
cancel_weight -= startup
is_block_stun_applied = True
return cancel_weight, is_block_stun_applied
def get_no_hitbox_startup(self):
startup = self.cancel.get_fastest_exit(self.total_frames)
return startup
def get_frame_data(self, delta = 0):
data = []
# for attack in self.attacks:
# if isinstance(attack, Throw):
# break
# else:
for i, a in enumerate(self.attacks):
cf = self.cancel.get_cancelable_frames()
tf = self.cancel.get_technical_frames()
tf.append(f'[HITBOX {i + 1}]')
t = self.total_frames - cf
com = self.movelist.get_command_by_move_id(self.move_id)
if isinstance(a, Throw):
startup = self.movelist.last_attack.startup
recovery = 0
block_stun = 0 #self.movelist.last_attack.block_stun
hit_stun = 0 #self.movelist.last_attack.hit_stun
counter_stun = 0 #self.movelist.last_attack.counter_stun
cl = self.movelist.last_attack.counter_launch
#c = recovery - counter_stun
attack_type = self.movelist.last_attack.hit_level
try:
attack_type = GameplayEnums.HitLevel(attack_type).name
except Exception as e:
pass
active_frames = self.movelist.last_attack.active - startup + 1
data.append(FrameData(self.move_id, com, -1, startup + 1, 0, self.movelist.last_attack.hit_launch, 0, cl, 0, a.damage, attack_type, -1, recovery, delta, tf))
else:
if a.physics_grounded[0] > 0:
tf.append('GRND')
startup = a.startup
recovery = t - startup
block_stun = a.block_stun
hit_stun = a.hit_stun
counter_stun = a.counter_stun
cl = a.counter_launch
#c = recovery - counter_stun
attack_type = a.hit_level
try:
attack_type = GameplayEnums.HitLevel(attack_type).name
except Exception as e:
pass
active_frames = a.active - startup + 1
self.movelist.last_attack = a
#if not attack_type.startswith('throw'):
data.append(FrameData(self.move_id, com, t, startup + 1, block_stun, a.hit_launch, a.hit_stun, cl, counter_stun, a.damage, attack_type, active_frames, recovery, delta, tf))
return data
def get_gui_guide(self):
guide = [
(0x00, 0x02, b2i, "animation id"),
(0x02, 0x04, bs2i,"animation start frame"),
(0x04, 0x06, b2i, "animation max frame override"),
(0x06, 0x08, b2i, "???"),
(0x08, 0x0c, b4f, "weapon(?) motion(?) multiplier"),
(0x0c, 0x10, b4f, "animation speed multiplier (no change in total frames)"),
(0x10, 0x12, bs2i, "transition/blending animation"),
(0x12, 0x14, b2i, "blending animation start frame"),
(0x14, 0x16, b2i, "blending animation max frame override"),
(0x16, 0x18, b2i, "???"),
(0x18, 0x1c, b4f, "?float?transition?"),
(0x1c, 0x20, b4f, "?float?transition?"),
(0x20, 0x24, b4i, "???"),
(0x24, 0x28, b4i, "???"),
(0x28, 0x2C, b4i, "???"),
(0x2C, 0x30, b4i, "???"),
(0x30, 0x34, b4f, "move speed multiplier (multiplies total frames)"),
(0x34, 0x36, b2i, "total animation frames"),
(0x36, 0x38, b2i, "???"),
(0x38, 0x3C, lambda x, y: '{:04x}'.format(b4i(x, y)), "address of script information"),
(0x3C, 0x3E, lambda x, y: b2i(x, y) if b2i(x,y) != 0xFFFF else 'None', "hitbox 1 index"),
(0x3E, 0x40, lambda x, y: b2i(x, y) if b2i(x,y) != 0xFFFF else 'None', "hitbox 2 index"),
(0x40, 0x42, lambda x, y: b2i(x, y) if b2i(x,y) != 0xFFFF else 'None', "hitbox 3 index"),
(0x42, 0x44, lambda x, y: b2i(x, y) if b2i(x,y) != 0xFFFF else 'None', "hitbox 4 index"),
(0x44, 0x46, lambda x, y: b2i(x, y) if b2i(x,y) != 0xFFFF else 'None', "hitbox 5 index"),
(0x46, 0x48, lambda x, y: b2i(x, y) if b2i(x,y) != 0xFFFF else 'None', "hitbox 6 index"),
]
return self.bytes, guide
class Attack:
LENGTH = 0x70
def __init__(self, bytes):
self.bytes = bytes
self.modified_bytes = None
self.hitbox = b2i(self.bytes, 0) #hitbox limb?? 40 40 = right leg? 80 80 = left leg ??
self.mystery_02 = b2i(self.bytes, 2) #Counter({128: 125, 0: 43, 17: 21, 2560: 18, 1: 14, 6144: 11, 2048: 10, 512: 10, 2: 9, 6784: 8, 51: 8, 4096: 6, 162: 4, 4608: 4, 34: 4, 513: 4, 640: 3, 641: 3, 3: 2, 129: 2, 3072: 1, 2099: 1})
#physics is stored as 6 bytes; or 3 2 byte pairs(?) [magnitude, left/right vector, up/down/back/forward vector]
#somewhat unclear how the number maps to a direction
self.physics_hit_normal = (b2i(self.bytes, 0x08), b2i(self.bytes, 0x0a), b2i(self.bytes, 0x0c))
self.physics_hit_launch = (b2i(self.bytes, 0x0e), b2i(self.bytes, 0x10), b2i(self.bytes, 0x12))
self.physics_counter_normal = (b2i(self.bytes, 0x14), b2i(self.bytes, 0x16), b2i(self.bytes, 0x18))
self.physics_counter_launch = (b2i(self.bytes, 0x1a), b2i(self.bytes, 0x1c), b2i(self.bytes, 0x1e))
self.physics_airborne = (b2i(self.bytes, 0x20), b2i(self.bytes, 0x22), b2i(self.bytes, 0x24))
self.physics_block = (b2i(self.bytes, 0x26), b2i(self.bytes, 0x28), b2i(self.bytes, 0x2a))
self.physics_grounded = (b2i(self.bytes, 0x2c), b2i(self.bytes, 0x2e), b2i(self.bytes, 0x30))
self.hit_level = b1i(self.bytes, 0x32)
#0x33?
self.strange_guard = b2i(self.bytes, 0x34) #this number is 0, 1, 2, 4, 8, or 16 (for tira). Changing it can change if it can cause guard crushes as well as influence the guard damage
self.startup = b2i(self.bytes, 0x36)
self.active = b2i(self.bytes, 0x38) #usually 1 or 2 higher than startup, possible when active frames end?
self.damage = b2i(self.bytes, 0x3A)
self.block_stun = b2i(self.bytes, 0x44)
self.hit_stun = b2i(self.bytes, 0x46)
self.counter_stun = b2i(self.bytes, 0x48)
self.b2 = b2i(self.bytes, 0x4A) #for all but maybe 5 moves (for Tira), these values are the exact same as the stun value,
self.h2 = b2i(self.bytes, 0x4C)
self.c2 = b2i(self.bytes, 0x4E)
self.hit_effect = b2i(self.bytes, 0x50) #this may be two sepearate 1 byte enums
self.hit_launch = GameplayEnums.HitEffectToLaunchType(self.hit_effect)
self.counter_effect = b2i(self.bytes, 0x52)
self.counter_launch = GameplayEnums.HitEffectToLaunchType(self.counter_effect)
self.mystery_54 = b1i(self.bytes, 0x54) #Counter({0: 172, 17: 74, 5: 23, 12: 8, 18: 8, 11: 7, 29: 6, 8: 3, 32: 2, 33: 2, 24: 2, 35: 1, 9: 1, 41: 1, 30: 1})
self.mystery_55 = b1i(self.bytes, 0x55) #Always 4
self.block_effect = b1i(self.bytes, 0x56) #CE forces crouching #Counter({214: 57, 184: 32, 218: 25, 202: 22, 200: 14, 179: 13, 206: 12, 167: 12, 169: 11, 170: 10, 173: 10, 226: 8, 185: 7, 233: 6, 174: 6, 181: 6, 248: 5, 188: 5, 208: 4, 209: 4, 223: 4, 232: 4, 203: 3, 222: 3, 228: 3, 183: 3, 251: 3, 194: 2, 195: 2, 201: 2, 216: 2, 220: 2, 221: 2, 224: 2, 207: 1, 225: 1, 239: 1, 186: 1, 189: 1})
self.mystery_57 = b1i(self.bytes, 0x57) #Always 3
self.mystery_58 = b1i(self.bytes, 0x58) #almost always the same as 0x56, 20 or so differences, just frame guard effect perhaps???
self.mystery_5A = b2i(self.bytes, 0x5A) #changes guard damage, 0 is 0, 0x0002 makes guard damage 512 # Counter({65533: 225, 0: 31, 2: 14, 40: 12, 20: 5, 6: 4, 80: 4, 8: 4, 10: 3, 120: 3, 50: 2, 9: 1, 15: 1, 25: 1, 9999: 1})
self.mystery_5C = b2i(self.bytes, 0x5C) #Counter({0: 257, 32: 32, 40: 12, 1: 8, 33: 1, 41: 1})
self.strange_guard2 = b2i(self.bytes, 0x5E) #Another, possibly primary, guard crush determiner, but not the sole one?
self.mystery_60 = b2i(self.bytes, 0x60) #always the same as 0x5e, possibly another just guard??? see 0x58
self.mystery_62 = b2i(self.bytes, 0x62) #????
self.mystery_64 = b2i(self.bytes, 0x64) # ????
self.mystery_66 = b2i(self.bytes, 0x66) # ????
self.ffff_1 = b4i(self.bytes, 0x68) # ????
self.ffff_2 = b4i(self.bytes, 0x6C) # ????
def get_modified_bytes(self):
if self.modified_bytes == None:
return self.bytes
else:
return self.modified_bytes
def get_gui_guide(self):
guide = [
(0x00, 0x02, b2i, "???"),
(0x02, 0x04, b2i, "hitbox width/hitbox... height(?)"),
(0x04, 0x08, b2i, "???"),
(0x08, 0x0e, b2i, "physics on hit (pushback) [magnitude ; left|right ; up|down|forward|back]"),
(0x0e, 0x14, b2i, "physics on hit (launch distance)"),
(0x14, 0x1a, b2i, "physics on counter (pushback?)"),
(0x1a, 0x20, b2i, "physics on counter (launch?)"),
(0x20, 0x26, b2i, "physics on airborne"),
(0x26, 0x2c, b2i, "physics on block"),
(0x2c, 0x32, b2i, "physics on grounded"),
(0x32, 0x33, b1i, "hit level (high/low/unblockable/etc.)"),
(0x33, 0x34, b1i, "???"),
(0x34, 0x36, b2i, "hit spark type (contributes to guard damage)"),
(0x36, 0x38, b2i, "begin active frames (startup)"),
(0x38, 0x3A, b2i, "end active frames"),
(0x3A, 0x3C, b2i, "damage"),
(0x3C, 0x3E, b2i, "chip damage"),
(0x3E, 0x40, b2i, "chip damage related?"),
(0x40, 0x42, lambda x, y: f'{bs2i(x, y)}%', "combo scaling"),
(0x42, 0x44, lambda x, y: f'{bs2i(x, y)}%', "guard break scaling"),
(0x44, 0x46, b2i, "frames of block stun"),
(0x46, 0x48, b2i, "frames of hit stun"),
(0x48, 0x4a, b2i, "frames of counterhit stun"),
(0x4a, 0x4c, b2i, "repeat of block stun"),
(0x4c, 0x4e, b2i, "repeat of hit stun"),
(0x4e, 0x50, b2i, "repeat of counterhit stun"),
(0x50, 0x52, b2i, "hit effect (type of launch/crouching recovery/etc.)"),
(0x52, 0x54, b2i, "counter hit effect"),
(0x54, 0x56, b2i, "grounded hit effect"),
(0x56, 0x58, b2i, "standing block hit effect"),
(0x58, 0x5a, b2i, "crouching block hit effect"),
(0x5a, 0x5c, lambda x, y: f'{math.floor(bs2i(x, y)*100/240)}%' if bs2i(x,y) >= 0 else 'disabled' , "guard damage override (otherwise uses hit spark size and type calc)"),
(0x5c, 0x5e, b2i, f"combo condition flag(s) [0x01 = counterhit, 0x08 = won't chain, 0x20 = jails on block]"),
(0x5e, 0x60, b2i, "ATK type and strength (Ex: 0x06 = medium horizontal attack, 0x1a = strong vertical attack, 0x31 = weak kick/throw)"),
(0x60, 0x62, b2i, "same as above"),
(0x62, 0x64, b2i, "hit spark size (contributes to guard damage)"),
(0x64, 0x66, b2i, "???"),
(0x66, 0x68, b2i, "???"),
(0x68, 0x6c, lambda x, y: f'[{name_from_enum(AssetType, b2i(x,y))}][{bs2i(x,y+2)}]' if bs2i(x,y+2) > -1 else 'None', "VFX addition on block - [VFX type][VFX ID]"),
(0x6c, 0x70, lambda x, y: f'[{name_from_enum(AssetType,b2i(x,y))}][{bs2i(x,y+2)}]' if bs2i(x,y+2) > -1 else 'None', "VFX addition on hit - [VFX type][VFX ID]"),
]
return self.bytes, guide
class Throw:
LENGTH = 0x06
def __init__(self, bytes):
self.bytes = bytes
self.modified_bytes = None
self.damage = b2i(self.bytes, 0) #throw damage
self.mystery_4 = b2i(self.bytes, 2) #unknown, usually -3
self.scaling = b2i(self.bytes, 4) #throw damage scaling
def get_modified_bytes(self):
if self.modified_bytes == None:
return self.bytes
else:
return self.modified_bytes
def get_gui_guide(self):
guide = [
(0x00, 0x02, b2i, "throw damage"),
(0x02, 0x04, bs2i, "???"),
(0x04, 0x06,lambda x, y: f'{bs2i(x, y)}%', "damage scaling"),
]
return self.bytes, guide
class AttackResizer:
LENGTH = 0x30
def __init__(self, bytes):
self.bytes = bytes
self.modified_bytes = None
self.move_id = b2i(self.bytes, 0) #throw damage
self.hitbox_id = b2i(self.bytes, 4) #throw damage scaling
self.mystery_4 = b2i(self.bytes, 4) #unknown, usually 0x00
def get_modified_bytes(self):
if self.modified_bytes == None:
return self.bytes
else:
return self.modified_bytes
def get_gui_guide(self):
guide = [
(0x00, 0x02, b2i, "move id"),
(0x02, 0x04, bs2i, "damage scaling"),
(0x04, 0x06, b2i, "???"),
]
return self.bytes, guide
class Cancel:
def __init__(self, movelist, bytes, address, move_id, verbose = False):
self.movelist = movelist
self.address = address
self.bytes = bytes
self.modified_bytes = None
self.goto_blocks = []
if len(self.bytes) >= 3:
self.type = int(self.bytes[2])
else:
self.type = -1
self.move_id = move_id
self.links = Movelist.links_from_bytes(self, self.movelist,verbose)
def get_modified_bytes(self):
if self.modified_bytes == None:
return self.bytes
else:
return self.modified_bytes
def condense_all_shortcuts(self):
extra_links = []
for link in self.links:
if link.is_shortcut:
extra_links.append((link, self.movelist.move_ids_to_cancels[link.move_id].links))
#TODO: replace 8a arguments with passed in arguments from original link?
for shortcut_link, link_list in extra_links:
for link in link_list:
copy_link = copy.copy(link)
copy_link.leave_on = shortcut_link.leave_on
copy_link.enter_in = shortcut_link.enter_in
self.links.append(copy_link)
#if self.move_id == 424:
#print(link)
def update_goto_instructions(self, new_bytes, old_bytes):
diff = len(new_bytes) - len(old_bytes)
i = 0
first_index = -1
while i < len(new_bytes) and i < len(old_bytes):
if new_bytes[i] != old_bytes[i]:
first_index = i
break
i += 1
if first_index == -1 or diff == 0:
return new_bytes
else:
updated_bytes = b''
z = 0
new_diff = diff
while z < len(new_bytes):
inst = new_bytes[z]
try:
inst = CC(inst)
except:
pass
if not inst in Movelist.THREE_BYTE_INSTRUCTIONS:
updated_bytes += new_bytes[z:z+1]
z += 1
else:
if not inst in [CC.PEN_28, CC.PEN_29, CC.PEN_2A]:
updated_bytes += new_bytes[z:z+3]
z += 3
else:
updated_bytes += new_bytes[z:z+1]
goto = bs2i(new_bytes, z + 1, big_endian=True)
if first_index >= len(old_bytes) - 1:
new_diff = 0
if goto > first_index:
if z + 1 >= first_index and z + 1 <= first_index + diff:
if goto > len(new_bytes) - 1:
goto = len(new_bytes) - 1
new_diff = 0
elif goto + diff >= len(new_bytes) - 1:
goto = len(new_bytes) - 1
new_diff = 0
else:
new_diff = diff
if goto <= 0:
goto = 0
new_diff = 0
goto += new_diff if goto + new_diff <= len(new_bytes) - 1 else 0
updated_bytes += goto.to_bytes(2, byteorder='big')
z += 3
return updated_bytes
def get_link_to_move_id(self, move_id):
for link in self.links:
if link.move_id == move_id:
return link
return None
def get_fastest_exit(self, total_frames):
exit = total_frames - self.get_cancelable_frames()
for link in self.links:
if link.is_to_attack_or_stance(self.movelist):
if link.leave_on < exit:
exit = link.leave_on
return exit
def has_at_least_one_button_press(self):
for link in self.links:
if link.is_button_press():
return True
return False
def get_last_call_address_index(bytes): #hypothesis: this is the GOTO address for when the move reaches it's totoal frames (maybe?) usually the last 0-3 lines
try:
split = bytes.split(b'\x8b\x00\x09\xa5\x01\x01\x96\x28')[1]
final_address_index = b2i(split, 0, big_endian=True)
return final_address_index
except:
return len(bytes) - 1
def get_cancelable_frames(self): #the number of frames 'early' the move can be canceled
try:
byte_sets = [b'\x8b\x30\x20', b'\x8b\x30\x21']