forked from Grouflon/3rd_training_lua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3rd_training.lua
5250 lines (4593 loc) · 183 KB
/
3rd_training.lua
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
game_name = "Street Fighter III 3rd Strike (Japan 990512)"
rom_name = emu.romname()
is_4rd_strike = false
if rom_name == "sfiii3nr1" then
-- NOP
elseif rom_name == "sfiii4n" then
game_name = "Street Fighter III 3rd Strike - 4rd Arrange Edition 2013 (990608)"
is_4rd_strike = true
else
print("-----------------------------")
print("WARNING: You are not using a rom supported by this training mode. Some of the features might not be working correctly.")
print("-----------------------------")
rom_name = "sfiii3nr1"
end
print("-----------------------------")
print(" 3rd_training.lua - v0.9")
print(" Training mode for "..game_name..", on Fightcade v2.0.91")
print(" project url: https://github.com/Grouflon/3rd_training_lua")
print("-----------------------------")
print("")
print("Command List:")
print("- Enter training menu by pressing \"Start\" while in game")
print("- Enter/exit recording mode by double tapping \"Coin\"")
print("- In recording mode, press \"Coin\" again to start/stop recording")
print("- In normal mode, press \"Coin\" to start/stop replay")
print("")
-- Kudos to indirect contributors:
-- *esn3s* for his work on 3s frame data : http://baston.esn3s.com/
-- *dammit* for his work on 3s hitbox display script : https://dammit.typepad.com/blog/2011/10/improved-3rd-strike-hitboxes.html
-- *furitiem* for his prior work on 3s C# training program : https://www.youtube.com/watch?v=vE27xe0QM64
-- *crytal_cube99* for his prior work on 3s training & trial scripts : https://ameblo.jp/3fv/
-- Thanks to *speedmccool25* for recording all the 4rd strike frame data
-- FBA-RR Scripting reference:
-- http://tasvideos.org/EmulatorResources/VBA/LuaScriptingFunctions.html
-- https://github.com/TASVideos/mame-rr/wiki/Lua-scripting-functions
-- Resources
-- https://github.com/Jesuszilla/mame-rr-scripts/blob/master/framedata.lua
json = require ("lua_libs/dkjson")
recording_slot_count = 8
-- debug options
developer_mode = false -- Unlock frame data recording options. Touch at your own risk since you may use those options to fuck up some already recorded frame data
assert_enabled = developer_mode or false
debug_wakeup = false
log_enabled = developer_mode or false
log_categories_display =
{
input = { history = true, print = true },
projectiles = { history = false, print = false },
fight = { history = true, print = true },
animation = { history = true, print = true },
parry_training_FORWARD = { history = false, print = false },
blocking = { history = true, print = true },
counter_attack = { history = false, print = false },
}
function t_assert(_condition, _msg)
_msg = _msg or "Assertion failed"
if assert_enabled and not _condition then
error(_msg, 2)
end
end
saved_path = "saved/"
data_path = "data/"..rom_name.."/"
framedata_path = data_path.."framedata/"
saved_recordings_path = "saved/recordings/"
training_settings_file = "training_settings.json"
frame_data_file_ext = "_framedata.json"
-- Images
require "gd"
img_1_dir = gd.createFromPng("images/1_dir.png"):gdStr()
img_2_dir = gd.createFromPng("images/2_dir.png"):gdStr()
img_3_dir = gd.createFromPng("images/3_dir.png"):gdStr()
img_4_dir = gd.createFromPng("images/4_dir.png"):gdStr()
img_5_dir = gd.createFromPng("images/5_dir.png"):gdStr()
img_6_dir = gd.createFromPng("images/6_dir.png"):gdStr()
img_7_dir = gd.createFromPng("images/7_dir.png"):gdStr()
img_8_dir = gd.createFromPng("images/8_dir.png"):gdStr()
img_9_dir = gd.createFromPng("images/9_dir.png"):gdStr()
img_L_button = gd.createFromPng("images/L_button.png"):gdStr()
img_M_button = gd.createFromPng("images/M_button.png"):gdStr()
img_H_button = gd.createFromPng("images/H_button.png"):gdStr()
img_no_button = gd.createFromPng("images/no_button.png"):gdStr()
img_dir = {
img_1_dir,
img_2_dir,
img_3_dir,
img_4_dir,
img_5_dir,
img_6_dir,
img_7_dir,
img_8_dir,
img_9_dir
}
-- json tools
function read_object_from_json_file(_file_path)
local _f = io.open(_file_path, "r")
if _f == nil then
return nil
end
local _object
local _pos, _err
_object, _pos, _err = json.decode(_f:read("*all"))
_f:close()
if (err) then
print(string.format("Failed to read json file \"%s\" : %s", _file_path, _err))
end
return _object
end
function write_object_to_json_file(_object, _file_path)
local _f, _error, _code = io.open(_file_path, "w")
if _f == nil then
print(string.format("Error %d: %s", _code, _error))
return false
end
local _str = json.encode(_object, { indent = true })
_f:write(_str)
_f:close()
return true
end
-- players
function make_input_set(_value)
return {
up = _value,
down = _value,
left = _value,
right = _value,
LP = _value,
MP = _value,
HP = _value,
LK = _value,
MK = _value,
HK = _value,
start = _value,
coin = _value
}
end
function make_player_object(_id, _base, _prefix)
return {
id = _id,
base = _base,
prefix = _prefix,
input = {
pressed = make_input_set(false),
released = make_input_set(false),
down = make_input_set(false),
state_time = make_input_set(0),
},
blocking = {
wait_for_block_string = true,
block_string = false,
},
counter = {
attack_frame = -1,
ref_time = -1,
recording_slot = -1,
},
throw = {},
max_meter_gauge = 0,
max_meter_count = 0,
}
end
function reset_player_objects()
player_objects = {
make_player_object(1, 0x02068C6C, "P1"),
make_player_object(2, 0x02069104, "P2")
}
P1 = player_objects[1]
P2 = player_objects[2]
P1.gauge_addr = 0x020695B5
P1.meter_addr = { 0x020286AB, 0x020695BF } -- 2nd address is the master variable
P1.stun_max_addr = 0x020695F7
P1.stun_timer_addr = P1.stun_max_addr + 0x2
P1.stun_bar_addr = P1.stun_max_addr + 0x6
P1.meter_update_flag = 0x020157C8
P1.score_addr = 0x020113A2
P1.parry_forward_validity_time_addr = 0x02026335
P1.parry_forward_cooldown_time_addr = 0x02025731
P1.parry_down_validity_time_addr = 0x02026337
P1.parry_down_cooldown_time_addr = 0x0202574D
P1.parry_air_validity_time_addr = 0x02026339
P1.parry_air_cooldown_time_addr = 0x02025769
P1.parry_antiair_validity_time_addr = 0x02026347
P1.parry_antiair_cooldown_time_addr = 0x0202582D
P2.gauge_addr = 0x020695E1
P2.meter_addr = { 0x020286DF, 0x020695EB} -- 2nd address is the master variable
P2.stun_max_addr = 0x0206960B
P2.stun_timer_addr = P2.stun_max_addr + 0x2
P2.stun_bar_addr = P2.stun_max_addr + 0x6
P2.meter_update_flag = 0x020157C9
P2.score_addr = 0x020113AE
P2.parry_forward_validity_time_addr = P1.parry_forward_validity_time_addr + 0x406
P2.parry_forward_cooldown_time_addr = P1.parry_forward_cooldown_time_addr + 0x620
P2.parry_down_validity_time_addr = P1.parry_down_validity_time_addr + 0x406
P2.parry_down_cooldown_time_addr = P1.parry_down_cooldown_time_addr + 0x620
P2.parry_air_validity_time_addr = P1.parry_air_validity_time_addr + 0x406
P2.parry_air_cooldown_time_addr = P1.parry_air_cooldown_time_addr + 0x620
P2.parry_antiair_validity_time_addr = P1.parry_antiair_validity_time_addr + 0x406
P2.parry_antiair_cooldown_time_addr = P1.parry_antiair_cooldown_time_addr + 0x620
end
reset_player_objects()
function update_input(_player_obj)
function update_player_input(_input_object, _input_name, _input)
_input_object.pressed[_input_name] = false
_input_object.released[_input_name] = false
if _input_object.down[_input_name] == false and _input then _input_object.pressed[_input_name] = true end
if _input_object.down[_input_name] == true and _input == false then _input_object.released[_input_name] = true end
if _input_object.down[_input_name] == _input then
_input_object.state_time[_input_name] = _input_object.state_time[_input_name] + 1
else
_input_object.state_time[_input_name] = 0
end
_input_object.down[_input_name] = _input
end
local _local_input = joypad.get()
update_player_input(_player_obj.input, "start", _local_input[_player_obj.prefix.." Start"])
update_player_input(_player_obj.input, "coin", _local_input[_player_obj.prefix.." Coin"])
update_player_input(_player_obj.input, "up", _local_input[_player_obj.prefix.." Up"])
update_player_input(_player_obj.input, "down", _local_input[_player_obj.prefix.." Down"])
update_player_input(_player_obj.input, "left", _local_input[_player_obj.prefix.." Left"])
update_player_input(_player_obj.input, "right", _local_input[_player_obj.prefix.." Right"])
update_player_input(_player_obj.input, "LP", _local_input[_player_obj.prefix.." Weak Punch"])
update_player_input(_player_obj.input, "MP", _local_input[_player_obj.prefix.." Medium Punch"])
update_player_input(_player_obj.input, "HP", _local_input[_player_obj.prefix.." Strong Punch"])
update_player_input(_player_obj.input, "LK", _local_input[_player_obj.prefix.." Weak Kick"])
update_player_input(_player_obj.input, "MK", _local_input[_player_obj.prefix.." Medium Kick"])
update_player_input(_player_obj.input, "HK", _local_input[_player_obj.prefix.." Strong Kick"])
end
function check_input_down_autofire(_player_object, _input, _autofire_rate, _autofire_time)
_autofire_rate = _autofire_rate or 4
_autofire_time = _autofire_time or 23
if _player_object.input.pressed[_input] or (_player_object.input.down[_input] and _player_object.input.state_time[_input] > _autofire_time and (_player_object.input.state_time[_input] % _autofire_rate) == 0) then
return true
end
return false
end
function queue_input_sequence(_player_obj, _sequence)
if _sequence == nil or #_sequence == 0 then
return
end
if _player_obj.pending_input_sequence ~= nil then
return
end
local _seq = {}
_seq.sequence = copytable(_sequence)
_seq.current_frame = 1
_player_obj.pending_input_sequence = _seq
end
function process_pending_input_sequence(_player_obj, _input)
if _player_obj.pending_input_sequence == nil then
return
end
if is_menu_open then
return
end
if not is_in_match then
return
end
-- Cancel all input
_input[_player_obj.prefix.." Up"] = false
_input[_player_obj.prefix.." Down"] = false
_input[_player_obj.prefix.." Left"] = false
_input[_player_obj.prefix.." Right"] = false
_input[_player_obj.prefix.." Weak Punch"] = false
_input[_player_obj.prefix.." Medium Punch"] = false
_input[_player_obj.prefix.." Strong Punch"] = false
_input[_player_obj.prefix.." Weak Kick"] = false
_input[_player_obj.prefix.." Medium Kick"] = false
_input[_player_obj.prefix.." Strong Kick"] = false
-- Charge moves memory locations
-- P1
-- 0x020259D8 H/Urien V/Oro V/Chun H/Q V/Remy
-- 0x020259F4 (+1C) V/Urien H/Q H/Remy
-- 0x02025A10 (+38) H/Oro H/Remy
-- 0x02025A2C (+54) V/Urien V/Alex
-- 0x02025A48 (+70) H/Alex
-- P2
-- 0x02025FF8
-- 0x02026014
-- 0x02026030
-- 0x0202604C
-- 0x02026068
local _gauges_base = 0
if _player_obj.id == 1 then
_gauges_base = 0x020259D8
elseif _player_obj.id == 2 then
_gauges_base = 0x02025FF8
end
local _gauges_offsets = { 0x0, 0x1C, 0x38, 0x54, 0x70 }
local _s = ""
local _current_frame_input = _player_obj.pending_input_sequence.sequence[_player_obj.pending_input_sequence.current_frame]
for i = 1, #_current_frame_input do
local _input_name = _player_obj.prefix.." "
if _current_frame_input[i] == "forward" then
if _player_obj.flip_input then _input_name = _input_name.."Right" else _input_name = _input_name.."Left" end
elseif _current_frame_input[i] == "back" then
if _player_obj.flip_input then _input_name = _input_name.."Left" else _input_name = _input_name.."Right" end
elseif _current_frame_input[i] == "up" then
_input_name = _input_name.."Up"
elseif _current_frame_input[i] == "down" then
_input_name = _input_name.."Down"
elseif _current_frame_input[i] == "LP" then
_input_name = _input_name.."Weak Punch"
elseif _current_frame_input[i] == "MP" then
_input_name = _input_name.."Medium Punch"
elseif _current_frame_input[i] == "HP" then
_input_name = _input_name.."Strong Punch"
elseif _current_frame_input[i] == "LK" then
_input_name = _input_name.."Weak Kick"
elseif _current_frame_input[i] == "MK" then
_input_name = _input_name.."Medium Kick"
elseif _current_frame_input[i] == "HK" then
_input_name = _input_name.."Strong Kick"
elseif _current_frame_input[i] == "h_charge" then
if _player_obj.char_str == "urien" then
memory.writeword(_gauges_base + _gauges_offsets[1], 0xFFFF)
elseif _player_obj.char_str == "oro" then
memory.writeword(_gauges_base + _gauges_offsets[3], 0xFFFF)
elseif _player_obj.char_str == "chunli" then
elseif _player_obj.char_str == "q" then
memory.writeword(_gauges_base + _gauges_offsets[1], 0xFFFF)
memory.writeword(_gauges_base + _gauges_offsets[2], 0xFFFF)
elseif _player_obj.char_str == "remy" then
memory.writeword(_gauges_base + _gauges_offsets[2], 0xFFFF)
memory.writeword(_gauges_base + _gauges_offsets[3], 0xFFFF)
elseif _player_obj.char_str == "alex" then
memory.writeword(_gauges_base + _gauges_offsets[5], 0xFFFF)
end
elseif _current_frame_input[i] == "v_charge" then
if _player_obj.char_str == "urien" then
memory.writeword(_gauges_base + _gauges_offsets[2], 0xFFFF)
memory.writeword(_gauges_base + _gauges_offsets[4], 0xFFFF)
elseif _player_obj.char_str == "oro" then
memory.writeword(_gauges_base + _gauges_offsets[1], 0xFFFF)
elseif _player_obj.char_str == "chunli" then
memory.writeword(_gauges_base + _gauges_offsets[1], 0xFFFF)
elseif _player_obj.char_str == "q" then
elseif _player_obj.char_str == "remy" then
memory.writeword(_gauges_base + _gauges_offsets[1], 0xFFFF)
elseif _player_obj.char_str == "alex" then
memory.writeword(_gauges_base + _gauges_offsets[4], 0xFFFF)
end
end
_input[_input_name] = true
_s = _s.._input_name
end
--print(_s)
_player_obj.pending_input_sequence.current_frame = _player_obj.pending_input_sequence.current_frame + 1
if _player_obj.pending_input_sequence.current_frame > #_player_obj.pending_input_sequence.sequence then
_player_obj.pending_input_sequence = nil
end
end
function clear_input_sequence(_player_obj)
_player_obj.pending_input_sequence = nil
end
function make_input_empty(_input)
if _input == nil then
return
end
_input["P1 Up"] = false
_input["P1 Down"] = false
_input["P1 Left"] = false
_input["P1 Right"] = false
_input["P1 Weak Punch"] = false
_input["P1 Medium Punch"] = false
_input["P1 Strong Punch"] = false
_input["P1 Weak Kick"] = false
_input["P1 Medium Kick"] = false
_input["P1 Strong Kick"] = false
_input["P2 Up"] = false
_input["P2 Down"] = false
_input["P2 Left"] = false
_input["P2 Right"] = false
_input["P2 Weak Punch"] = false
_input["P2 Medium Punch"] = false
_input["P2 Strong Punch"] = false
_input["P2 Weak Kick"] = false
_input["P2 Medium Kick"] = false
_input["P2 Strong Kick"] = false
end
-- training settings
pose = {
"normal",
"crouching",
"jumping",
"highjumping",
}
stick_gesture = {
"none",
"forward",
"back",
"down",
"up",
"QCF",
"QCB",
"HCF",
"HCB",
"DPF",
"DPB",
"HCharge",
"VCharge",
"360",
"DQCF",
"720",
"back dash",
"forward dash",
"Shun Goku Satsu", -- Gouki hidden SA1
"Kongou Kokuretsu Zan", -- Gouki hidden SA2
}
if is_4rd_strike then
table.insert(stick_gesture, "Demon Armageddon") -- Gouki SA3
end
button_gesture =
{
"none",
"recording",
"LP",
"MP",
"HP",
"EXP",
"LK",
"MK",
"HK",
"EXK",
"LP+LK",
"MP+MK",
"HP+HK",
}
function make_input_sequence(_stick, _button)
if _button == "recording" then
return nil
end
local _sequence = {}
if _stick == "none" then _sequence = { { } }
elseif _stick == "forward" then _sequence = { { "forward" } }
elseif _stick == "back" then _sequence = { { "back" } }
elseif _stick == "down" then _sequence = { { "down" } }
elseif _stick == "up" then _sequence = { { "up" } }
elseif _stick == "QCF" then _sequence = { { "down" }, {"down", "forward"}, {"forward"} }
elseif _stick == "QCB" then _sequence = { { "down" }, {"down", "back"}, {"back"} }
elseif _stick == "HCF" then _sequence = { { "back" }, {"down", "back"}, {"down"}, {"down", "forward"}, {"forward"} }
elseif _stick == "HCB" then _sequence = { { "forward" }, {"down", "forward"}, {"down"}, {"down", "back"}, {"back"} }
elseif _stick == "DPF" then _sequence = { { "forward" }, {"down"}, {"down", "forward"} }
elseif _stick == "DPB" then _sequence = { { "back" }, {"down"}, {"down", "back"} }
elseif _stick == "HCharge" then _sequence = { { "back", "h_charge" }, {"forward"} }
elseif _stick == "VCharge" then _sequence = { { "down", "v_charge" }, {"up"} }
elseif _stick == "360" then _sequence = { { "forward" }, { "forward", "down" }, {"down"}, { "back", "down" }, { "back" }, { "up" } }
elseif _stick == "DQCF" then _sequence = { { "down" }, {"down", "forward"}, {"forward"}, { "down" }, {"down", "forward"}, {"forward"} }
elseif _stick == "720" then _sequence = { { "forward" }, { "forward", "down" }, {"down"}, { "back", "down" }, { "back" }, { "up" }, { "forward" }, { "forward", "down" }, {"down"}, { "back", "down" }, { "back" } }
-- full moves special cases
elseif _stick == "back dash" then _sequence = { { "back" }, {}, { "back" } }
return _sequence
elseif _stick == "forward dash" then _sequence = { { "forward" }, {}, { "forward" } }
return _sequence
elseif _stick == "Shun Goku Satsu" then _sequence = { { "LP" }, {}, {}, { "LP" }, { "forward" }, {"LK"}, {}, { "HP" } }
return _sequence
elseif _stick == "Kongou Kokuretsu Zan" then _sequence = { { "down" }, {}, { "down" }, {}, { "down", "LP", "MP", "HP" } }
return _sequence
elseif _stick == "Demon Armageddon" then _sequence = { { "up" }, {}, { "up" }, {}, { "up", "LK", "MK" } }
return _sequence
end
if _button == "none" then
elseif _button == "EXP" then
table.insert(_sequence[#_sequence], "MP")
table.insert(_sequence[#_sequence], "HP")
elseif _button == "EXK" then
table.insert(_sequence[#_sequence], "MK")
table.insert(_sequence[#_sequence], "HK")
elseif _button == "LP+LK" then
table.insert(_sequence[#_sequence], "LP")
table.insert(_sequence[#_sequence], "LK")
elseif _button == "MP+MK" then
table.insert(_sequence[#_sequence], "MP")
table.insert(_sequence[#_sequence], "MK")
elseif _button == "HP+HK" then
table.insert(_sequence[#_sequence], "HP")
table.insert(_sequence[#_sequence], "HK")
else
table.insert(_sequence[#_sequence], _button)
end
return _sequence
end
-- History
input_history_size_max = 12
input_history = {
{},
{}
}
function make_input_history_entry(_prefix, _input)
local _up = _input[_prefix.." Up"]
local _down = _input[_prefix.." Down"]
local _left = _input[_prefix.." Left"]
local _right = _input[_prefix.." Right"]
local _direction = 5
if _down then
if _left then _direction = 1
elseif _right then _direction = 3
else _direction = 2 end
elseif _up then
if _left then _direction = 7
elseif _right then _direction = 9
else _direction = 8 end
else
if _left then _direction = 4
elseif _right then _direction = 6
else _direction = 5 end
end
return {
frame = frame_number,
direction = _direction,
buttons = {
_input[_prefix.." Weak Punch"],
_input[_prefix.." Medium Punch"],
_input[_prefix.." Strong Punch"],
_input[_prefix.." Weak Kick"],
_input[_prefix.." Medium Kick"],
_input[_prefix.." Strong Kick"]
}
}
end
function is_input_history_entry_equal(_a, _b)
if (_a.direction ~= _b.direction) then return false end
if (_a.buttons[1] ~= _b.buttons[1]) then return false end
if (_a.buttons[2] ~= _b.buttons[2]) then return false end
if (_a.buttons[3] ~= _b.buttons[3]) then return false end
if (_a.buttons[4] ~= _b.buttons[4]) then return false end
if (_a.buttons[5] ~= _b.buttons[5]) then return false end
if (_a.buttons[6] ~= _b.buttons[6]) then return false end
return true
end
function update_input_history(_history, _prefix, _input)
local _entry = make_input_history_entry(_prefix, _input)
if #_history == 0 then
table.insert(_history, _entry)
else
local _last_entry = _history[#_history]
if _last_entry.frame ~= frame_number and not is_input_history_entry_equal(_entry, _last_entry) then
table.insert(_history, _entry)
end
end
while #_history > input_history_size_max do
table.remove(_history, 1)
end
end
function draw_input_history_entry(_entry, _x, _y)
gui.image(_x, _y, img_dir[_entry.direction])
local _img_LP = img_no_button
local _img_MP = img_no_button
local _img_HP = img_no_button
local _img_LK = img_no_button
local _img_MK = img_no_button
local _img_HK = img_no_button
if _entry.buttons[1] then _img_LP = img_L_button end
if _entry.buttons[2] then _img_MP = img_M_button end
if _entry.buttons[3] then _img_HP = img_H_button end
if _entry.buttons[4] then _img_LK = img_L_button end
if _entry.buttons[5] then _img_MK = img_M_button end
if _entry.buttons[6] then _img_HK = img_H_button end
gui.image(_x + 13, _y, _img_LP)
gui.image(_x + 18, _y, _img_MP)
gui.image(_x + 23, _y, _img_HP)
gui.image(_x + 13, _y + 5, _img_LK)
gui.image(_x + 18, _y + 5, _img_MK)
gui.image(_x + 23, _y + 5, _img_HK)
end
function draw_input_history(_history, _x, _y, _is_left)
local _step_y = 12
local _j = 0
for _i = #_history, 1, -1 do
local _current_y = _y + _j * _step_y
local _entry = _history[_i]
local _entry_offset = 0
if _is_left then _entry_offset = 13 end
draw_input_history_entry(_entry, _x + _entry_offset, _current_y)
local _next_frame = frame_number
if _i < #_history then
_next_frame = _history[_i + 1].frame
end
local _frame_diff = _next_frame - _entry.frame
local _text = "-"
if (_frame_diff < 999) then
_text = string.format("%d", _frame_diff)
end
local _offset = 0
if _is_left then
_offset = 8
if (_frame_diff < 999) then
if (_frame_diff >= 100) then _offset = 0
elseif (_frame_diff >= 10) then _offset = 4 end
end
else
_offset = 33
end
gui.text(_x + _offset, _current_y + 2, _text, 0xd6e3efff, 0x101000ff)
_j = _j + 1
end
end
-- !History
characters =
{
"",
"alex",
"ryu",
"yun",
"dudley",
"necro",
"hugo",
"ibuki",
"elena",
"oro",
"yang",
"ken",
"sean",
"urien",
"gouki",
"gill",
"chunli",
"makoto",
"q",
"twelve",
"remy",
}
if is_4rd_strike then
characters[1] = "gill"
characters[16] = "usean"
end
fast_wakeup_mode =
{
"never",
"always",
"random",
}
blocking_style =
{
"block",
"parry",
"red parry",
}
blocking_mode =
{
"never",
"always",
"first hit",
"random",
}
tech_throws_mode =
{
"never",
"always",
"random",
}
hit_type =
{
"normal",
"low",
"overhead",
}
life_mode =
{
"no refill",
"refill",
"infinite"
}
meter_mode =
{
"no refill",
"refill",
"infinite"
}
stun_mode =
{
"normal",
"no stun",
"delayed reset"
}
standing_state =
{
"knockeddown",
"standing",
"crouched",
"airborne",
}
players = {
"Player 1",
"Player 2",
}
frame_data_movement_type = {
"animation",
"velocity"
}
special_training_mode = {
"none",
"parry"
}
function make_recording_slot()
return {
inputs = {},
delay = 0,
random_deviation = 0,
weight = 1,
}
end
recording_slots = {}
for _i = 1, recording_slot_count do
table.insert(recording_slots, make_recording_slot())
end
recording_slots_names = {}
for _i = 1, #recording_slots do
table.insert(recording_slots_names, "slot ".._i)
end
slot_replay_mode = {
"normal",
"random",
"repeat",
"repeat random",
}
-- menu
text_default_color = 0xF7FFF7FF
text_default_border_color = 0x101008FF
text_selected_color = 0xFF0000FF
text_disabled_color = 0x999999FF
function gauge_menu_item(_name, _object, _property_name, _unit, _fill_color, _gauge_max, _subdivision_count)
local _o = {}
_o.name = _name
_o.object = _object
_o.property_name = _property_name
_o.player_id = _player_id
_o.autofire_rate = 1
_o.unit = _unit or 2
_o.gauge_max = _gauge_max or 0
_o.subdivision_count = _subdivision_count or 1
_o.fill_color = _fill_color or 0x0000FFFF
function _o:draw(_x, _y, _selected)
local _c = text_default_color
local _prefix = ""
local _suffix = ""
if _selected then
_c = text_selected_color
_prefix = "< "
_suffix = " >"
end
gui.text(_x, _y, _prefix..self.name.." : ", _c, text_default_border_color)
local _box_width = self.gauge_max / self.unit
local _box_top = _y + 1
local _box_left = _x + get_text_width("< "..self.name.." : ") - 1
local _box_right = _box_left + _box_width
local _box_bottom = _box_top + 4
gui.box(_box_left, _box_top, _box_right, _box_bottom, text_default_color, text_default_border_color)
local _content_width = self.object[self.property_name] / self.unit
gui.box(_box_left, _box_top, _box_left + _content_width, _box_bottom, self.fill_color, 0x00000000)
for _i = 1, self.subdivision_count - 1 do
local _line_x = _box_left + _i * self.gauge_max / (self.subdivision_count * self.unit)
gui.line(_line_x, _box_top, _line_x, _box_bottom, text_default_border_color)
end
gui.text(_box_right + 2, _y, _suffix, _c, text_default_border_color)
end
function _o:left()
self.object[self.property_name] = math.max(self.object[self.property_name] - self.unit, 0)
end
function _o:right()
self.object[self.property_name] = math.min(self.object[self.property_name] + self.unit, self.gauge_max)
end
function _o:reset()
self.object[self.property_name] = 0
end
function _o:legend()
return "MP: Reset to default"
end
return _o
end
available_characters = {
" ",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"X",
"Y",
"Z",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"-",
"_",
}
function textfield_menu_item(_name, _object, _property_name, _default_value, _max_length)
_default_value = _default_value or ""
_max_length = _max_length or 16
local _o = {}
_o.name = _name
_o.object = _object
_o.property_name = _property_name
_o.default_value = _default_value
_o.max_length = _max_length
_o.edition_index = 0
_o.is_in_edition = false
_o.content = {}
function _o:sync_to_var()
local _str = ""
for i = 1, #self.content do
_str = _str..available_characters[self.content[i]]
end
self.object[self.property_name] = _str
end
function _o:sync_from_var()
self.content = {}
for i = 1, #self.object[self.property_name] do
local _c = self.object[self.property_name]:sub(i,i)
for j = 1, #available_characters do
if available_characters[j] == _c then
table.insert(self.content, j)
break
end
end
end
end
function _o:crop_char_table()
local _last_empty_index = 0
for i = 1, #self.content do
if self.content[i] == 1 then
_last_empty_index = i
else
_last_empty_index = 0
end
end
if _last_empty_index > 0 then
for i = _last_empty_index, #self.content do
table.remove(self.content, _last_empty_index)
end
end
end
function _o:draw(_x, _y, _selected)
local _c = text_default_color
local _prefix = ""
local _suffix = ""
if self.is_in_edition then
_c = 0xFFFF00FF
elseif _selected then
_c = text_selected_color
end
local _value = self.object[self.property_name]
if self.is_in_edition then
local _cycle = 100
if ((frame_number % _cycle) / _cycle) < 0.5 then
gui.text(_x + (#self.name + 3 + #self.content - 1) * 4, _y + 2, "_", _c, text_default_border_color)
end
end
gui.text(_x, _y, _prefix..self.name.." : ".._value.._suffix, _c, text_default_border_color)
end
function _o:left()
if self.is_in_edition then
self:reset()
end
end
function _o:right()
if self.is_in_edition then
self:validate()
end
end
function _o:up()
if self.is_in_edition then
self.content[self.edition_index] = self.content[self.edition_index] + 1
if self.content[self.edition_index] > #available_characters then
self.content[self.edition_index] = 1
end
self:sync_to_var()
return true