-
Notifications
You must be signed in to change notification settings - Fork 11
/
character.js
1577 lines (1488 loc) · 37.9 KB
/
character.js
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
/** a LF2 character
*/
define(['LF/livingobject','LF/global','F.core/combodec','F.core/util','LF/util'],
function(livingobject, Global, Fcombodec, Futil, util)
{
var GC=Global.gameplay;
var states=
{
'generic':function(event,K)
{ var $=this;
switch (event) {
case 'frame':
$.opoint();
break;
case 'TU':
if( $.state_update('post_interaction'))
; //do nothing
else
$.post_interaction();
var ps=$.ps;
if( ps.y===0 && ps.vy>0) //fell onto ground
{
var result = $.state_update('fell_onto_ground');
if( result)
$.trans.frame(result, 15);
else
{
//console.log(ps.vx, util.lookup_abs(GC.friction.fell,ps.vx));
ps.vy=0; //set to zero
$.mech.linear_friction(
util.lookup_abs(GC.friction.fell,ps.vx),
util.lookup_abs(GC.friction.fell,ps.vz)
);
}
}
else if( ps.y+ps.vy>=0 && ps.vy>0) //predict falling onto the ground
{
var result = $.state_update('fall_onto_ground');
if( result)
$.trans.frame(result, 15);
else
{
if( $.frame.N===212) //jumping
$.trans.frame(215, 15); //crouch
else
$.trans.frame(219, 15); //crouch2
}
}
//health reduce
if( $.frame.D.mp)
{
if( $.data.frame[$.frame.PN].next===$.frame.N)
{ //if this frame is transited by next of previous frame
if( $.frame.D.mp<0)
{
$.health.mp += $.frame.D.mp;
if( $.health.mp<0)
{
$.health.mp = 0;
$.trans.frame($.frame.D.hit_d);
}
}
}
else
{
var dmp = $.frame.D.mp%1000,
dhp = Math.floor($.frame.D.mp/1000)*10;
$.health.mp -= dmp;
$.health.hp -= dhp;
}
}
//health recover
//http://lf2.wikia.com/wiki/Health_and_mana
if( $.match.time.t%12===0)
if( $.health.hp < $.health.hp_bound)
{
$.health.hp++;
}
if( $.match.time.t%3===0)
if( $.health.mp < $.health.mp_full)
{
$.health.mp+= 1+Math.floor((500-($.health.hp<500?$.health.hp:500))/100);
}
//recovery
if( $.health.fall>0) $.health.fall += GC.recover.fall;
if( $.health.bdefend>0) $.health.bdefend += GC.recover.bdefend;
//combo buffer
$.combo_buffer.timeout--;
if( $.combo_buffer.timeout===0)
{
switch ($.combo_buffer.combo)
{
case 'def': case 'jump': case 'att': case 'run':
$.combo_buffer.combo = null;
break;
//other combo is not cleared
}
}
break;
case 'transit':
//dynamics: position, friction, gravity
$.mech.dynamics(); //any further change in position will not be updated on screen until next TU
$.wpoint(); //my holding weapon following my change
break;
case 'combo':
switch(K)
{
case 'left': case 'right':
case 'run':
break;
default:
//here is where D>A, D>J... etc handled
var tag = Global.combo_tag[K];
if( tag && $.frame.D[tag])
{
if( !$.id_update('generic_combo',K,tag))
{
$.trans.frame($.frame.D[tag], 11);
return 1;
}
}
}
break;
case 'post_combo': //after state specific processing
$.pre_interaction();
break;
case 'state_exit':
switch ($.combo_buffer.combo)
{
case 'att': case 'run':
//cannot transfer across states
$.combo_buffer.combo = null;
break;
}
break;
}},
//state specific processing to different events
'0':function(event,K) //standing
{ var $=this;
switch (event) {
case 'frame':
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
$.trans.frame(12);
break;
case 'combo':
switch(K)
{
case 'left': case 'right': case 'up': case 'down':
case 'jump': case null:
var dx = $.con.state.left !== $.con.state.right,
dz = $.con.state.up !== $.con.state.down;
if( dx || dz)
{
//apply movement
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
{
if( dx) $.ps.vx=$.dirh()*($.data.bmp.heavy_walking_speed);
$.ps.vz=$.dirv()*($.data.bmp.heavy_walking_speedz);
}
else
{
if( K!=='jump') //walk
$.trans.frame(5); //TODO: select randomly from 5,6,7,8
if( dx) $.ps.vx=$.dirh()*($.data.bmp.walking_speed);
$.ps.vz=$.dirv()*($.data.bmp.walking_speedz);
}
}
break;
}
switch(K)
{
case 'run':
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
$.trans.frame(16, 10);
else
$.trans.frame(9, 10);
return 1;
case 'def':
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
return 1;
$.trans.frame(110, 10);
return 1;
case 'jump':
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
{
if( !$.proper('heavy_weapon_jump'))
return 1;
else
{
$.trans.frame($.proper('heavy_weapon_jump'), 10);
return 1;
}
}
$.trans.frame(210, 10);
return 1;
case 'att':
if( $.hold.obj)
{
var dx = $.con.state.left !== $.con.state.right;
if( $.hold.obj.type==='heavyweapon')
{
$.trans.frame(50, 10); //throw heavy weapon
return 1;
}
else if( $.proper($.hold.obj.id,'just_throw'))
{
$.trans.frame(45, 10); //throw light weapon
return 1;
}
else if ( dx && $.proper($.hold.obj.id,'stand_throw'))
{
$.trans.frame(45, 10); //throw weapon
return 1;
}
else if( $.proper($.hold.obj.id,'attackable')) //light weapon attack
{
$.trans.frame($.match.random()<0.5? 20:25, 10);
return 1;
}
}
//
var vol=$.mech.volume(Futil.make_array($.data.frame[72].itr)[0]); //super punch, frame 72
var hit= $.scene.query(vol, $, {tag:'itr:6', not_team:$.team});
for( var t in hit)
{ //if someone is in my hitting scoope who has itr kind:6
var hit_itr=(hit[t].vol_itr(6))[0].data;
if( $.itr_rest_test( hit[t].uid, hit_itr))
{
$.trans.frame(70, 10); //I 'll use super punch!
$.itr_rest_update( hit[t].uid, hit_itr);
return 1;
}
}
//
$.trans.frame($.match.random()<0.5? 60:65, 10);
return 1;
}
break;
}},
'1':function(event,K) //walking
{ var $=this;
var dx=0,dz=0;
if($.con.state.left) dx-=1;
if($.con.state.right) dx+=1;
if($.con.state.up) dz-=1;
if($.con.state.down) dz+=1;
switch (event) {
case 'frame':
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
{
if( dx || dz)
$.frame_ani_oscillate(12,15);
else
$.trans.set_next($.frame.N);
}
else
{
$.frame_ani_oscillate(5,8);
}
$.trans.set_wait($.data.bmp.walking_frame_rate-1);
break;
case 'TU':
//apply movement
var xfactor = 1-($.dirv()?1:0)*(2/7); //reduce x speed if moving diagonally
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
{
if( dx) $.ps.vx=xfactor*$.dirh()*($.data.bmp.heavy_walking_speed);
$.ps.vz=$.dirv()*($.data.bmp.heavy_walking_speedz);
}
else
{
if( dx) $.ps.vx=xfactor*$.dirh()*($.data.bmp.walking_speed);
$.ps.vz=$.dirv()*($.data.bmp.walking_speedz);
if( !dx && !dz && !$.statemem.transed)
{
$.statemem.transed=true;
$.trans.set_next(999); //go back to standing
$.trans.set_wait(1,1,2);
}
}
break;
case 'state_entry':
$.trans.set_wait(0);
break;
case 'combo':
if( dx!==0 && dx!==$.dirh())
$.switch_dir($.ps.dir==='right'?'left':'right'); //toogle dir
if( !dx && !dz && !$.statemem.released)
{
$.statemem.released=true;
$.mech.unit_friction();
}
//walking same as standing, except null combo
if( K) return $.states['0'].call($,event,K);
break;
}},
'2':function(event,K) //running, heavy_obj_run
{ var $=this;
switch (event) {
case 'frame':
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
$.frame_ani_oscillate(16,18);
else
$.frame_ani_oscillate(9,11);
$.trans.set_wait($.data.bmp.running_frame_rate);
//no break here
case 'TU':
//to maintain the velocity against friction
var xfactor = 1-($.dirv()?1:0)*(1/7); //reduce x speed if moving diagonally
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
{
$.ps.vx= xfactor * $.dirh() * $.data.bmp.heavy_running_speed;
$.ps.vz= $.dirv() * $.data.bmp.heavy_running_speedz;
}
else
{
$.ps.vx= xfactor * $.dirh() * $.data.bmp.running_speed;
$.ps.vz= $.dirv() * $.data.bmp.running_speedz;
}
break;
case 'combo':
switch(K)
{
case 'left': case 'right':
if(K!=$.ps.dir)
{
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
$.trans.frame(19, 10);
else
$.trans.frame(218, 10);
return 1;
}
break;
case 'def':
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
return 1;
$.trans.frame(102, 10);
return 1;
case 'jump':
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
{
if( !$.proper('heavy_weapon_dash'))
return 1;
else
{
$.trans.frame($.proper('heavy_weapon_dash'), 10);
return 1;
}
}
$.trans.frame(213, 10);
return 1;
case 'att':
if( $.hold.obj)
{
if( $.hold.obj.type==='heavyweapon')
{
$.trans.frame(50, 10); //throw heavy weapon
return 1;
}
else
{
var dx = $.con.state.left !== $.con.state.right;
if( dx && $.proper($.hold.obj.id,'run_throw'))
{
$.trans.frame(45, 10); //throw light weapon
return 1;
}
else if( $.proper($.hold.obj.id,'attackable'))
{
$.trans.frame(35, 10); //light weapon attack
return 1;
}
}
}
$.trans.frame(85, 10);
return 1;
}
break;
}},
'3':function(event,K) //punch, jump_attack, run_attack, ...
{ var $=this;
switch (event) {
case 'frame':
if( $.frame.D.next===999 && $.ps.y<0)
$.trans.set_next(212); //back to jump
$.id_update('state3_frame');
break;
case 'hit_stop':
return $.id_update('state3_hit_stop');
case 'frame_force':
return $.id_update('state3_frame_force');
}},
'4':function(event,K) //jump
{ var $=this;
switch (event) {
case 'frame':
$.statemem.frameTU=true;
if( $.frame.PN===80 || $.frame.PN===81) //after jump attack
$.statemem.attlock=2;
break;
case 'TU':
if( $.statemem.frameTU)
{ $.statemem.frameTU=false;
if( $.frame.N===212 && $.frame.PN===211)
{ //start jumping
var dx=0;
if($.con.state.left) dx-=1;
if($.con.state.right) dx+=1;
$.ps.vx= dx * ($.data.bmp.jump_distance-1);
$.ps.vz= $.dirv() * ($.data.bmp.jump_distancez-1);
$.ps.vy= $.data.bmp.jump_height; //upward force
}
}
if( $.statemem.attlock)
$.statemem.attlock--;
break;
case 'combo':
if( (K==='att' || $.con.state.att) && !$.statemem.attlock)
{
// a transition to jump_attack can only happen after entering frame 212
if( $.frame.N===212)
{
if( $.hold.obj)
{
var dx = $.con.state.left !== $.con.state.right;
if( dx && $.proper($.hold.obj.id,'jump_throw'))
$.trans.frame(52, 10); //sky light weapon throw
else if( $.proper($.hold.obj.id,'attackable'))
$.trans.frame(30, 10); //light weapon attack
}
else
$.trans.frame(80, 10); //jump attack
if( K==='att')
return 1; //key consumed
}
}
break;
}},
'5':function(event,K) //dash
{ var $=this;
switch (event) {
case 'state_entry':
$.ps.vx= $.dirh() * ($.data.bmp.dash_distance-1) * ($.frame.N===213?1:-1);
$.ps.vz= $.dirv() * ($.data.bmp.dash_distancez-1);
$.ps.vy= $.data.bmp.dash_height;
break;
case 'combo':
if( K==='att' || $.con.state.att)
{
if( $.proper('dash_backattack') || //back attack
$.dirh()===($.ps.vx>0?1:-1)) //if not turning back
{
if( $.hold.obj && $.proper($.hold.obj.id,'attackable')) //light weapon attack
$.trans.frame(40, 10);
else
$.trans.frame(90, 10);
$.allow_switch_dir=false;
if( K==='att')
return 1;
}
}
if( K==='left' || K==='right')
{
if( K!=$.ps.dir)
{
if( $.dirh()==($.ps.vx>0?1:-1))
{ //turn back
if( $.frame.N===213) $.trans.frame(214, 0);
if( $.frame.N===216) $.trans.frame(217, 0);
$.switch_dir(K);
}
else
{ //turn to front
if( $.frame.N===214) $.trans.frame(213, 0);
if( $.frame.N===217) $.trans.frame(216, 0);
$.switch_dir(K);
}
return 1;
}
}
break;
}},
'6':function(event,K) //rowing
{ var $=this;
switch (event) {
case 'TU':
if( $.frame.N===100 || $.frame.N===108)
{
$.ps.vy = 0;
}
break;
case 'frame':
if( $.frame.N===100 || $.frame.N===108)
{
$.trans.set_wait(1);
}
break;
case 'fall_onto_ground':
if( $.frame.N===101 || $.frame.N===109)
return 215;
break;
}},
'7':function(event,K) //defending
{ var $=this;
switch (event) {
case 'frame':
if( $.frame.N===111)
$.trans.inc_wait(4);
break;
}},
'8':function(event,K) //broken defend
{ var $=this;
switch (event) {
case 'frame_force':
case 'TU_force':
//nasty fix: to compensate that frame_force is applied with respecting to facing direction
if( $.frame.D.dvx)
{
if( ($.ps.vx>0?1:-1) !== $.dirh())
{
var avx = $.ps.vx>0?$.ps.vx:-$.ps.vx;
var dirx = 2*($.ps.vx>0?1:-1);
if( $.ps.y<0 || avx < $.frame.D.dvx)
$.ps.vx = dirx * $.frame.D.dvx;
if( $.frame.D.dvx<0)
$.ps.vx = $.ps.vx - dirx;
}
}
break;
}},
'9':function(event,K) //catching, throw lying man
{ var $=this;
switch (event) {
case 'state_entry':
$.statemem.stateTU=true;
$.statemem.counter=43;
$.statemem.attacks=0;
break;
case 'state_exit':
$.catching=null;
$.ps.zz=0;
break;
case 'frame':
switch ($.frame.N)
{
case 123: //a successful attack
$.statemem.attacks++;
$.statemem.counter+=3;
$.trans.inc_wait(1);
break;
case 233: case 234:
$.trans.inc_wait(-1);
break;
}
if( $.frame.N===234)
return;
$.catching.caught_b(
$.mech.make_point($.frame.D.cpoint),
$.frame.D.cpoint,
$.ps.dir
);
break;
case 'TU':
if( $.caught_cpointkind()===1 &&
$.catching.caught_cpointkind()===2 )
{ //really catching you
if( $.statemem.stateTU)
{ $.statemem.stateTU=false;
/**the immediate `TU` after `state`. the reason for this is a synchronization issue,
i.e. it must be waited until both catcher and catchee transited to the second frame
and it is not known at the point of `frame` event, due to different scheduling.
*/
//injury
if( $.frame.D.cpoint.injury)
{
$.catching.hit( $.frame.D.cpoint, $, {x:$.ps.x,y:$.ps.y,z:$.ps.z}, null);
$.trans.inc_wait(1, 10, 99); //lock until frame transition
}
//cover
var cover = GC.default.cpoint.cover;
if( $.frame.D.cpoint.cover!==undefined) cover=$.frame.D.cpoint.cover;
if( cover===0 || cover===10 )
$.ps.zz=1;
else
$.ps.zz=-1;
if( $.frame.D.cpoint.dircontrol===1)
{
if($.con.state.left) $.switch_dir('left');
if($.con.state.right) $.switch_dir('right');
}
}
}
break; //TU
case 'post_combo':
$.statemem.counter--;
if( $.statemem.counter<=0)
if( !($.frame.N===122 && $.statemem.attacks===4)) //let it finish the 5th punch
if( $.frame.N===121 || $.frame.N===122)
{
$.catching.caught_release();
$.trans.frame(999,15);
}
break;
case 'combo':
switch(K)
{
case 'att':
if( $.frame.N===121)
{
var dx = $.con.state.left !== $.con.state.right;
var dy = $.con.state.up !== $.con.state.down;
if( (dx || dy) && $.frame.D.cpoint.taction)
{
var tac = $.frame.D.cpoint.taction;
if( tac<0)
{ //turn myself around
$.switch_dir($.ps.dir==='right'?'left':'right'); //toogle dir
$.trans.frame(-tac, 10);
}
else
{
$.trans.frame(tac, 10);
}
var nextframe=$.data.frame[$.trans.next()];
$.catching.caught_throw( nextframe.cpoint, $.dirv());
$.statemem.counter+=10;
}
else if($.frame.D.cpoint.aaction)
$.trans.frame($.frame.D.cpoint.aaction, 10);
else
$.trans.frame(122, 10);
}
return 1; //always return true so that `att` is not re-fired next frame
case 'jump':
if( $.frame.N===121)
if($.frame.D.cpoint.jaction)
{
$.trans.frame($.frame.D.cpoint.jaction, 10);
return 1;
}
break;
}
break;
}},
'10':function(event,K) //being caught
{ var $=this;
switch (event) {
case 'state_exit':
$.catching=null;
$.caught_b_holdpoint=null;
$.caught_b_cpoint=null;
$.caught_b_adir=null;
$.caught_throwz=null;
break;
case 'frame':
$.statemem.frameTU=true;
$.trans.set_wait(99, 10, 99); //lock until frame transition
break;
case 'TU':
if( $.frame.N===135) //to be lifted against gravity
{
$.ps.vy=0;
}
if( $.caught_cpointkind()===2 &&
$.catching && $.catching.caught_cpointkind()===1 )
{ //really being caught
if( $.statemem.frameTU)
{ $.statemem.frameTU=false; //the immediate `TU` after `frame`
var holdpoint=$.caught_b_holdpoint;
var cpoint=$.caught_b_cpoint;
var adir=$.caught_b_adir;
if( cpoint.vaction)
$.trans.frame(cpoint.vaction, 20);
if( cpoint.throwvz !== GC.unspecified)
{ //I am being thrown!
var dvx=cpoint.throwvx, dvy=cpoint.throwvy, dvz=cpoint.throwvz;
if( dvx !==0) $.ps.vx = (adir==='right'?1:-1)* dvx;
if( dvy !==0) $.ps.vy = dvy;
if( dvz !==0) $.ps.vz = dvz * $.caught_throwz;
//impulse
$.mech.set_pos(
$.ps.x + $.ps.vx*2.5,
$.ps.y + $.ps.vy*2,
$.ps.z + $.ps.vz );
}
else
{
if( cpoint.dircontrol===undefined)
{
if( cpoint.cover && cpoint.cover>=10)
$.switch_dir(adir); //follow dir of catcher
else //default cpoint cover
$.switch_dir(adir==='left'?'right':'left'); //face the catcher
$.mech.coincideXZ(holdpoint,$.mech.make_point($.frame.D.cpoint));
}
else
{
$.mech.coincideXY(holdpoint,$.mech.make_point($.frame.D.cpoint));
}
}
}
}
else
{
if( $.catching)
$.trans.frame(212, 10);
}
break;
}},
'11':function(event,K) //injured
{ var $=this;
switch (event) {
case 'state_entry':
$.trans.inc_wait(0, 20); //set lock only
break;
case 'frame':
switch($.frame.N)
{
case 221: case 223: case 225:
$.trans.set_next(999);
break;
case 220: case 222: case 224: case 226:
//$.trans.inc_wait(0, 20, 99); //lock until frame transition
break;
}
break;
}},
'12':function(event,K) //falling
{ var $=this;
switch (event) {
case 'frame':
if( $.effect.dvy <= 0)
switch ($.frame.N)
{
case 180:
$.trans.set_next(181);
$.trans.set_wait(util.lookup_abs(GC.fall.wait180,$.effect.dvy));
break;
case 181:
//console.log('y:'+$.ps.y+', vy:'+$.ps.vy+', vx:'+$.ps.vx);
$.trans.set_next(182);
var vy = $.ps.vy>0?$.ps.vy:-$.ps.vy;
if( 0<=vy && vy<=4)
$.trans.set_wait(2);
else if( 4<vy && vy<7)
$.trans.set_wait(3);
else if( 7<=vy)
$.trans.set_wait(4);
break;
case 182:
$.trans.set_next(183);
break;
//
case 186:
$.trans.set_next(187);
break;
case 187:
$.trans.set_next(188);
break;
case 188:
$.trans.set_next(189);
break;
}
else
switch ($.frame.N)
{
case 180:
$.trans.set_next(185);
$.trans.set_wait(1);
break;
case 186:
$.trans.set_next(191);
break;
}
break;
case 'fell_onto_ground':
case 'fall_onto_ground':
if( $.caught_throwinjury>0)
{
$.injury(-$.caught_throwinjury);
$.caught_throwinjury = null;
}
var ps=$.ps;
//console.log('speed:'+$.mech.speed()+', vx:'+ps.vx+', vy:'+ps.vy);
if( $.mech.speed() > GC.character.bounceup.limit.xy ||
ps.vy > GC.character.bounceup.limit.y)
{
$.mech.linear_friction(
util.lookup_abs(GC.character.bounceup.absorb,ps.vx),
util.lookup_abs(GC.character.bounceup.absorb,ps.vz)
);
ps.vy = -GC.character.bounceup.y;
if( 180 <= $.frame.N && $.frame.N <= 185)
return 185;
if( 186 <= $.frame.N && $.frame.N <= 191)
return 191;
}
else
{
if( 180 <= $.frame.N && $.frame.N <= 185)
return 230; //next frame
if( 186 <= $.frame.N && $.frame.N <= 191)
return 231;
}
break;
case 'combo':
if( $.frame.N===182 ||
$.frame.N===188)
{
if( K==='jump')
{
if( $.frame.N===182)
$.trans.frame(100);
else
$.trans.frame(108);
$.ps.vx = 5; //magic number
if( $.ps.vz) $.ps.vz = 2;
return 1;
}
}
return 1; //always return true so that `jump` is not re-fired next frame
}},
'14':function(event,K) //lying
{ var $=this;
switch (event) {
case 'state_entry':
$.health.fall=0;
$.health.bdefend=0;
break;
case 'state_exit':
$.effect.timein=0;
$.effect.timeout=30;
$.effect.blink=true;
$.effect.super=true;
break;
}},
'15':function(event,K) //stop_running, crouch, crouch2, dash_attack, light_weapon_thw, heavy_weapon_thw, heavy_stop_run, sky_lgt_wp_thw
{ var $=this;
switch (event) {
case 'frame':
switch( $.frame.N)
{
case 19: //heavy_stop_run
if( $.hold.obj && $.hold.obj.type==='heavyweapon')
$.trans.set_next(12);
break;
case 215:
$.trans.inc_wait(-1);
break;
case 219: //crouch
if( !$.id_update('state15_crouch'))
switch( $.frame.PN) //previous frame number
{
case 105: //after rowing
$.mech.unit_friction();
break;
case 216: //after dash
case 90: case 91: case 92: //dash attack
$.trans.inc_wait(-1);
break;
}
break;
case 54: //sky_lgt_wp_thw
if( $.frame.D.next===999 && $.ps.y<0)
$.trans.set_next(212); //back to jump
break;
}
break;
case 'combo':
if( $.frame.N===215) //only after jumping
{
if( K==='def')
{
$.trans.frame(102, 10);
return 1;
}
if( K==='jump')
{
var dx=0;
if($.con.state.left) dx-=1;
if($.con.state.right) dx+=1;
if( dx)
{
$.trans.frame(213, 10);
$.switch_dir(dx===1?'right':'left');
}
else if( $.ps.vx===0)
{
$.trans.inc_wait(2, 10, 99); //lock until frame transition
$.trans.set_next(210, 10);
}
else if( ($.ps.vx>0?1:-1)===$.dirh())
{
$.trans.frame(213, 10);
}
else
{
$.trans.frame(214, 10);
}
return 1;
}
}
break;
}},
'16':function(event,K) //injured 2 (dance of pain)
{ var $=this;
switch (event) {
}},
'301':function(event,K) //deep specific
{ var $=this;
switch (event) {
case 'frame_force':
if( $.frame.N!==290)
return 1; //disable pre update of force
break;
case 'TU':
$.ps.vz=$.dirv()*($.data.bmp.walking_speedz);
break;
case 'hit_stop':
$.effect_stuck(1,2); //not stuck immediately but next frame (timein=1)
$.trans.inc_wait(1);
return 1;
}},
'x':function(event,K)
{ var $=this;
switch (event) {
}}
};
var idupdates = //nasty fix (es)
{
'default':function()
{
},
'1': function(event,K,tag) //deep
{
var $=this;