-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTF_CharEx.js
1799 lines (1664 loc) · 68.9 KB
/
TF_CharEx.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
//=================================================
// TF_CharEx.js
// Version :1.0.1.0
// For : RPGツクールMZ (RPG Maker MZ)
// ----------------------------------------------
// Copyright : Tobishima-Factory 2020-2024
// Website : http://tonbi.jp
//
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
//=================================================
/*:ja
* @target MZ
* @plugindesc キャラのアニメや移動など強化
* @author とんび@鳶嶋工房(tonbi.jp)
* @url https://github.com/tonbijp/RPGMakerMZ/blob/master/TF_CharEx.js
* @base PluginCommonBase
* @orderAfter PluginCommonBase
*
* @================= parameter ====================
* @param moveUnit @text [アニメの終了]時の配置単位
* @desc 規定値: 通常(1タイル)
* @type select @default 1
* @option 通常(1タイル) @value 1
* @option 半歩(0.5タイル) @value 0.5
* @option なし(アナログ) @value 0
*
* @================== command =====================
* @command route @text 移動ルートの一括設定
* @desc [移動ルートの設定]コマンドの文字列指定版
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg routeCode @text ルート設定文字列
* @desc
* 例: ↑4⤵︎5→3
* 専用コマンド文字の詳細はヘルプを参照。
* @type string @default ↑1↓1←1→1
*
* @arg repeat @text 動作を繰り返す
* @on 繰り返し @off 一回のみ(規定値)
* @type boolean @default false
*
* @arg skippable @text 移動できない場合は飛ばす
* @on 飛ばす(規定値) @off 停止
* @type boolean @default true
*
* @arg isWait @text 完了までウェイト
* @on 待つ(規定値) @off 完了を待たず並列実行
* @type boolean @default true
*
* @================================================
* @command patternAnime @text キャラパターン指定アニメ
* @desc
* 一定順のパターン表示によるアニメ
* 宝箱・扉を開くなどに使う
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg fileName @text 画像ファイル名
* @desc
* .pngを除いた img/characters/ フォルダのファイル名
* (規定値:そのまま)
* @type file @dir img/characters/
*
* @arg characterNumber @text キャラクター番号
* @desc
* [0123]
* [4567] (規定値:-1 そのまま)
* @type number @default -1
* @min -1 @max 7
*
* @arg animePattern @text パターン
* @desc
* パターンの列(規定値:↓現在列)
* @type select @default -1
* @option ↓現在列 @value -1
* @option ↓・・ 左列 @value 0
* @option ・↓・ 中央列 @value 1
* @option ・・↓ 右列 @value 2
* @option ↑現在列 @value -2
* @option ↑・・ 左列 @value 3
* @option ・↑・ 中央列 @value 4
* @option ・・↑ 右列 @value 5
* @option ┬│↓ 左列から順にすべて @value 6
* @option ↑│┴ 右列から順にすべて @value 7
*
* @arg waitFrames @text ウェイト
* @desc
* 1パターンの表示時間(フレーム数)(0:[移動速度]より算出)
* @type number @default 0
* @min 0
*
* @================================================
* @command setCharPattern @text キャラパターンを指定
* @desc
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg fileName @text 画像ファイル名
* @desc
* .pngを除いた img/characters/ フォルダのファイル名
* (規定値:そのまま)
* @type file @dir img/characters/
*
* @arg characterNumber @text キャラクター番号
* @desc
* [0123]
* [4567] (規定値:-1 そのまま)
* @type number @default -1
* @min -1 @max 7
*
* @arg patternNumber @text 歩行パターン
* @desc
* パターンの列(規定値:↓現在列)
* @type select @default -1
* @option ↓現在列 @value -1
* @option ↓・・ 左列 @value 0
* @option ・↓・ 中央列 @value 1
* @option ・・↓ 右列 @value 2
*
* @arg d @text キャラの向き
* @desc (規定値: そのまま)
* @type select @default 0
* @option そのまま @value 0
* @option ↑ @value 8
* @option ← @value 4
* @option → @value 6
* @option ↓ @value 2
*
* @================================================
* @command goXY @text イベントを指定座標に移動
* @desc 障害物は無視する。
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg pointStr @text 移動先位置(タイル数)
* @desc 移動先座標(小数点以下可)
* @type string @default 0,0
*
* @arg isWait @text 完了までウェイト
* @on 待つ(規定値) @off 完了を待たず並列実行
* @type boolean @default true
*
* @================================================
* @command goEv @text イベントを別のイベント位置に移動
* @desc 障害物は無視する。
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg destinationId @text 目標イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg pointStr @text 移動先位置(タイル数)
* @desc 移動先座標(小数点以下可)
* @type string @default 0,0
*
* @arg isWait @text 完了までウェイト
* @on 待つ(規定値) @off 完了を待たず並列実行
* @type boolean @default true
*
* @================================================
* @command locateXY @text イベントを指定座標に配置
* @desc 瞬間移動する。
* 状況で異なる初期位置の設定などに。
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg pointStr @text 移動先位置(タイル数)
* @desc 移動先座標(小数点以下可)
* @type string @default 0,0
*
* @arg patternNumber @text 歩行パターン
* @desc
* パターンの列(規定値:そのまま)
* @type select @default -1
* @option そのまま @value -1
* @option ↓・・ 左列 @value 0
* @option ・↓・ 中央列 @value 1
* @option ・・↓ 右列 @value 2
*
* @arg d @text キャラの向き
* @desc (規定値: そのまま)
* @type select @default 0
* @option そのまま @value 0
* @option ↑ @value 8
* @option ← @value 4
* @option → @value 6
* @option ↓ @value 2
*
* @================================================
* @command locateEv @text イベントを別のイベント位置に配置
* @desc 瞬間移動する。
* 状況で異なる初期位置の設定などに。
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg destinationId @text 目標イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg pointStr @text 相対座標(タイル数)
* @desc 相対座標(小数点以下可)
* @type string @default 0,0
*
* @arg patternNumber @text 歩行パターン
* @desc
* パターンの列(規定値:そのまま)
* @type select @default -1
* @option そのまま @value -1
* @option ↓・・ 左列 @value 0
* @option ・↓・ 中央列 @value 1
* @option ・・↓ 右列 @value 2
*
* @arg d @text キャラの向き
* @desc (規定値: そのまま)
* @type select @default 0
* @option そのまま @value 0
* @option ↑ @value 8
* @option ← @value 4
* @option → @value 6
* @option ↓ @value 2
*
* @================================================
* @command getOn @text 乗り物に乗る
* @desc すでに乗っている、乗り物を設定してない、
* 乗り物が現在のマップにない場合、動作しない。
*
* @arg eventId @text 対象乗り物
* @desc
* 規定値: 大型船(ship)
* @type select @default ship
* @option 小型船(boat) @value boat
* @option 大型船(ship) @value ship
* @option 飛行船(airship) @value airship
*
* @arg isVehiclePos @text 乗った後の位置
* @desc
* @type boolean @default true
* @on 乗り物位置(規定値) @off プレイヤー位置
*
* @================================================
* @command getOff @text 乗り物から降りる
* @desc 乗り物に乗っていない場合は動作しない。
* 通常降りられない場所でも強制的に降りる。
*
* @arg d @text 降りる向き
* @desc (規定値: 前に降りる)
* @type select @default 0
* @option 前に降りる @value 0
* @option ↑ @value 8
* @option ← @value 4
* @option → @value 6
* @option ↓ @value 2
* @option その場 @value 5
*
* @================================================
* @command follow @text 隊列メンバーの追跡設定
* @desc プレイヤーが動いた場合に追跡するか指定。
*
* @arg eventId @text 隊列メンバーID
* @desc 指定隊列メンバー(規定値:all)
* @type select @default all
* @option all @option follower0 @option follower1 @option follower2
*
* @arg isFollow @text 追跡するか
* @desc ONは[向き固定]などの値をプレイヤーからコピーする。
* @on 追跡する(規定値) @off 追跡しない
* @type boolean @default true
*
* @================================================
* @command anime @text アニメの指定
* @desc アニメモード(移動アニメ停止・[すり抜け]ON)になるので、
* [アニメの終了]を実行しておくこと。
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg pointStr @text 移動距離(ピクセル数)
* @desc (小数点以下可)
* @type string @default 0,0
*
* @arg wait @text ウェイト
* @desc
* 待ちフレーム(1/60秒)(規定値:0)
* @type number @default 0
*
* @arg characterNumber @text キャラクター番号
* @desc
* [0123]
* [4567] (規定値:-1 そのまま)
* @type number @default -1
* @min -1 @max 7
*
* @arg patternNumber @text 歩行パターン
* @desc
* パターンの列(規定値:↓現在列)
* @type select @default -1
* @option ↓現在列 @value -1
* @option ↓・・ 左列 @value 0
* @option ・↓・ 中央列 @value 1
* @option ・・↓ 右列 @value 2
*
* @arg d @text キャラの向き
* @desc (規定値: そのまま)
* @type select @default 0
* @option そのまま @value 0
* @option ↑ @value 8
* @option ← @value 4
* @option → @value 6
* @option ↓ @value 2
*
* @================================================
* @command endAnime @text アニメの終了
* @desc [アニメの指定]をするとアニメモード(移動アニメ停止・[すり抜け]ON)になるのでアニメ終了時に実行すること。
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @================================================
* @command setPriorityType @text プライオリティを設定
* @desc イベントにプライオリティを設定。
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg priorityType @text プライオリティ
* @desc (規定値: 通常キャラと同じ)
* @type select @default 1
* @option 通常キャラの上 @value 2
* @option 通常キャラと同じ @value 1
* @option 通常キャラの下 @value 0
*
* @================================================
* @command getPriorityType @text プライオリティを取得
* @desc イベントのプライオリティを変数に取得。
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg variableId @text 変数ID
* @desc
* 値を返す変数(規定値: 1)
* @type variable @default 1
*
* @================================================
* @command setAngle @text イベントを回転
* @desc 指定した角度(360度指定)に従って時計回り(⤵︎)に回転。
*
* @arg eventId @text イベントID
* @desc
* イベントID(数値)かイベントの名前
* @type combo @default this
* @option this @option player @option follower0 @option follower1 @option follower2
* @option boat @option ship @option airship
*
* @arg angle @text 角度(360度指定)
* @desc (規定値: 0)
* @type number @default 0
*
* @============ この長さに合わせるとヘルプではみ出ない =============
* @help
* 主な機能とイベントコマンドにない利点。
* キャラは、イベント・プレイヤー・隊列メンバーのこと。
*
* 1 : キャラの位置・パターンの設定。
* ピクセル単位の位置指定で、キャラの繊細なアニメーションができる。
* 歩行パターン別の指定で、キャラ素材を無駄なく利用できる。
*
* 2 : 頻出するアニメーションの指定。
* ドア・宝箱の開閉など、縦のアニメーションを1コマンドで指定。
* 歩行パターン別に指定可能なので、3列違う素材を置ける。
*
* 3 : キャラの[ルート移動]の簡易コマンドによる指定。
* [上に移動][上に移動][上に移動][上に移動]と指定が必要な場合、
* ↑4 と書けるので回数調整が容易で、全体の見通しが良い。
*
* 4 : 通常のイベントコマンドでは指定できない隊列メンバーを指定可能。
* 基本的にはプレイヤーの設定がコピーされるので、各種設定を
* 反映させたい場合は[隊列メンバーの追跡設定]をOFFにする。
*
* 利用できるプラグインコマンド一覧
* [移動ルートの一括設定]
* [キャラパターン指定アニメ]
* [キャラパターンを指定]
* [イベントを指定座標に移動]
* [イベントを別のイベント位置に移動]
* [イベントを指定座標に配置]
* [イベントを別のイベント位置に配置]
* [隊列メンバーの追跡設定]
* [アニメの指定]
* [アニメの終了]
* [プライオリティの設定]
* ※ 利用方法はプラグインコマンド設定時の説明をご覧ください。
*
* 【[移動ルートの設定]で使うスクリプト】
* ------------------------------
* this.TF_setCharPattern([キャラクター番号], [歩行パターン], [キャラの向き]);
* [キャラパターンを指定]コマンドの[移動ルートの設定]用。
* ------------------------------
* this.TF_goXY( [x], [y] );
* [イベントを指定座標に移動]コマンドの[移動ルートの設定]用。
* ------------------------------
* this.TF_goEv( [目標イベントID], [dx], [dy] );
* [イベントを別のイベント位置に移動]コマンドの[移動ルートの設定]用。
* ------------------------------
* this.TF_setAngle( [θ] );
* [イベントを回転]コマンドの[移動ルートの設定]用。
* =========================
*
* 【プラグインコマンドに指定する引数の詳細】
* ------------------------------
* [イベントID] は、イベントの[名前]でも指定できる。
* ただし数値や 上記 this などと同じ名前、スペースの入った名前の指定不可。
* ------------------------------
* [向き]にはテンキーに対応した数字の他、以下の文字が利用できる。
* 上: up, u, north, n, ↑, 上, 北
* 左: left, l, west, w, ←, 左, 西
* 右: right, r, east, e, →, 右, 東
* 下: down, d, south, s, ↓, 下, 南
* ※大文字小文字の区別をしません。
* ------------------------------
* [キャラパターン]は歩行グラフィックの[歩行パターン]と[向き]を一度に指定。
* 0, 1, 2 <= 下向き(テンキー2)
* 3, 4, 5 <= 左向き(テンキー4)
* 6, 7, 8 <= 右向き(テンキー6)
* 9, 10, 11 <= 上向き(テンキー8)
* ------------------------------
* 移動速度を[ウェイト]に変換する場合以下のような対応となる。
* 1 / 8倍速 … 64フレーム
* 1 / 4倍速 … 32フレーム
* 1 / 2倍速 … 16フレーム
* 通常速 … 8フレーム
* 2倍速 … 4フレーム
* 4倍速 … 2フレーム
* ------------------------------
* [移動指定] コマンド文字+数字を一単位とする文字列。
* かなり量があるので、印刷するなどして手元で確認することを推奨。
* 移動系のコマンドは数字に0を指定すると、
* 方向転換コマンドの[〇〇を向く]と判断される。
* [〇〇に移動] : [方向]に使える文字に加え以下の文字が使える。
* 左上: upleft, ul, northwest, nw, ↖︎, 左上, 北西
* 右上: upright, ur, northeast, ne, ↗︎, 右上, 北東
* 左下: downleft, dl, southwest, sw, ↙︎, 左下, 南西
* 右下: downright, dr, southeast, se, ↘︎, 右下, 南東
* ランダム: random, &, 乱
* プレイヤーに近づく: tward, t, 近
* プレイヤーから遠ざかる: away, y, 遠
* 一歩前進(0は何もしない): front, forward, f, 前
* 一歩後退(0は[180度回転]): back, backward, b, 後
* [ジャンプ…] : jump, j, 跳
* 数字が0の場合は、その場でジャンプ。
* コンマ( , )で区切ってx,yの座標が指定できる(空白不可)
* [ウェイト…] : wait, z, 待
* 数字はフレーム数。z は寝るイメージ( wは 左に移動なので注意)
* [右に90度回転] : turnright, >, ⤵︎
* 数字に0を指定すると[ランダムに方向転換]
* 1の場合即時変更、2以降は[移動速度]に応じたウェイトをして回転。
* [左に90度回転] : turnleft, <, ⤹, ⤴
* 数字に0を指定すると[右か左に90度回転]
* 1の場合即時変更、2以降は[移動速度]に応じたウェイトをして回転。
* [スイッチ] : switch, h, ス
* コンマ( , )で区切って一つ目の数字はスイッチID。
* ふたつ目の数字が0の場合は[スイッチOFF…]、1で[スイッチON…]
* [移動速度の変更…] : agility, a, 速
* 1: 1 / 8倍速, 2: 1 / 4倍速, 3: 1 / 2倍速, 4: 通常速, 5: 2倍速, 6: 4倍速
* [移動頻度の変更…] : freaqency, q, 頻
* 1: 最低, 2: 低, 3: 通常, 4: 高, 5: 最高
* [歩行アニメ] : walk, k, 歩
* 数字が0の場合は[歩行アニメOFF]、1で[歩行アニメON]
* [足踏みアニメ] : step, p, 踏
* 数字が0の場合は[足踏みアニメOFF]、1で[足踏みアニメON]
* [向き固定] : fix, x, 固
* 数字が0の場合は[向き固定OFF]、1で[向き固定ON]
* [すり抜け] : through, g, 抜
* 数字が0の場合は[すり抜けOFF]、1で[すり抜けON]
* [透明化] : invisible, i, 透
* 数字が0の場合は[透明化OFF]、1で[透明化ON]
* [表示] : visible, v, 示
* 数字が0の場合は[表示OFF]、1で[表示ON]
* 透明化のOFFで見えるというのが分かりづらく間違いまくるので追加。
* [不透明度の変更…] : opacity, o, 濁
* 0〜255 の間の数字。
* [合成方法の変更…] : blendmode, m, 合
* 0: 通常, 1: 加算, 2: 乗算, 3: スクリーン
*
* == プラグインコマンド ==
* [キャラパターンを指定] : change, c, 変
* コンマ( , )で区切って [キャラ番号],[歩行パターン],[向き] を数字で指定。
* 標準のコマンド[画像の変更…]は数字だけで指定できないので、
* 現在指定しているキャラ画像内での変更するコマンドを別に追加。
* [画像の変更…]はファイルとキャラの変更はできる。
* でも[歩行パターン][向き]の変更はできないので、むしろ高機能かも。
* [イベントを指定座標に移動]( [イベントを別のイベント位置に移動] ) : go, @, 移
* コンマ( , )で区切って [x],[y] の座標に移動。
* 数字がひとつだけの場合イベントIDとみなし、その位置に移動。
* [プライオリティを設定] : priority, ^, 積
* プライオリティの設定。
* 0: 通常キャラの下, 1: 通常キャラと同じ, 2: 通常キャラの上
* [イベントを回転] : angle, θ, 回
* 指定した角度(360度指定)に従って時計回り(⤵︎)に回転。
* [イベントを左右反転] : angle, θ, 回
* 指定した角度(360度指定)に従って時計回り(⤵︎)に回転。
* [イベントを左右反転] : angle, θ, 回
* 指定した角度(360度指定)に従って時計回り(⤵︎)に回転。
*
* ※ PluginCommonBase 定義によりパラメータや引数に \V[n] を使えます。
*
* 一部、神無月サスケ(Sasuke KANNAZUKI)さんの EventEffects.js のコードを使っています。
*
* 利用規約 : MITライセンス
*/
( () => {
"use strict";
// エラー表示用にプラグイン名を取得
const PLUGIN_NAME = PluginManagerEx.findPluginName( document.currentScript );
const WAIT_ROUTE = "route";
const WAIT_MOVING = "moving";
const WAIT_ANIMATION = "animation";
const WAIT_BALLOON = "balloon";
/*---- パラメータパース関数 ----*/
const PARAM_TRUE = "true";
const PARAM_ON = "on";
const TYPE_BOOLEAN = "boolean";
const TYPE_NUMBER = "number";
const TYPE_STRING = "string";
/**
* 与えられた文字列に変数が指定されていたら、変数の内容に変換して返す。
* @param {String} value 変換元の文字列( \V[n]形式を含む )
* @return {String} 変換後の文字列
*/
function treatValue( value ) {
if( typeof value === TYPE_NUMBER ) return value;
if( value === undefined || value === "" ) return "0";
const result = value.match( /\x1bV\[(.+)\]/i );
if( result === null ) return value;
const id = parseInt( result[ 1 ], 10 );
if( isNaN( id ) ) {
return $gameVariables.valueByName( result[ 1 ] );
} else {
return $gameVariables.value( id );
}
}
/*--- Game_Variables ---*/
/**
* 変数を文字列で指定し、値を返す。
* 標準のvalueは空文字列だと 0 を返す。
* @param {String} name 変数(ID, 名前による指定が可能)
*/
Game_Variables.prototype.valueByName = function( name ) {
const variableId = stringToVariableId( name );
if( typeof this._data[ variableId ] === TYPE_STRING ) {
return this._data[ variableId ];
} else {
return this.value( variableId );
}
};
/**
* 指定された変数のIDを返す。
* @param {String} name 変数(ID, 名前, \V[n]による指定が可能)
*/
function stringToVariableId( name ) {
name = treatValue( name );
let i = $dataSystem.variables.indexOf( name );
if( 0 <= i ) return i;
i = parseInt( name, 10 );
if( isNaN( i ) ) throw Error( `${PLUGIN_NAME}: I can't find the variable '${name}'` );
return i;
}
/**
* 文字列を整数に変換して返す。
* @param {String|Number} value
* @return {Number} 数値に変換した結果
*/
function parseIntStrict( value ) {
if( typeof value === TYPE_NUMBER ) return Math.floor( value );
const result = parseInt( treatValue( value ), 10 );
if( isNaN( result ) ) throw Error( `${PLUGIN_NAME}: [${value}] is not a number.` );
return result;
}
/**
* 文字列を実数に変換して返す。
* @param {String|Number} value
* @return {Number} 数値に変換した結果
*/
function parseFloatStrict( value ) {
if( typeof value === TYPE_NUMBER ) return value;
const result = parseFloat( treatValue( value ) );
if( isNaN( result ) ) throw Error( `${PLUGIN_NAME}: [${value}] is not a number.` );
return result;
}
/**
* 文字列を真偽値に変換して返す。
* @param {String|Boolean} value 変換元文字列
* @returns {Boolean}
*/
function parseBooleanStrict( value ) {
if( typeof value === TYPE_BOOLEAN ) return value;
value = treatValue( value );
const result = value.toLowerCase();
return ( result === PARAM_TRUE || result === PARAM_ON );
}
/**
* character を拡張して隊列メンバーも指定できるようにしたもの。
* @param {Game_Interpreter} interpreter インタプリタ
* @param {Number} id 拡張イベントID
* @returns {Game_CharacterBase}
*/
function getEventById( interpreter, id ) {
if( id <= VEHICLE_OFFSET ) {
return $gameMap._vehicles[ VEHICLE_OFFSET - id ]; // 乗り物(0〜2)
} else if( id <= FOLLOWER_OFFSET ) {
return $gamePlayer.followers().follower( FOLLOWER_OFFSET - id ); // 隊列メンバー(0〜2)
} else {
return interpreter.character( id ); // プレイヤーキャラおよびイベント
}
}
/**
* 指定された文字列に対応するイベントを返す
* @param {Game_Interpreter} interpreter インタプリタ
* @param {String} eventId イベントIDの番号か識別子
* @returns {Game_CharacterBase}
*/
function stringToEvent( interpreter, eventId ) {
return getEventById( interpreter, stringToEventId( eventId ) );
}
/*---- イベントIDの配置オフセット ----*/
const FOLLOWER_OFFSET = -2;
const VEHICLE_OFFSET = -100;
/*---- イベントID変換用文字列 ----*/
const EVENT_THIS = "this";
const EVENT_PLAYER = "player";
const EVENT_FOLLOWER0 = "follower0";
const EVENT_FOLLOWER1 = "follower1";
const EVENT_FOLLOWER2 = "follower2";
const EVENT_FOLLOWER_ALL = "all";
const VEHICLE_BOAT = "boat";
const VEHICLE_SHIP = "ship";
const VEHICLE_AIRSHIP = "airship";
const VEHICLE_WALK = "walk";
/**
* 文字列をイベントIDへ変換
* @param {String} value イベントIDの番号か識別子
* @returns {Number} 拡張イベントID
*/
function stringToEventId( value ) {
value = treatValue( value );
const result = parseInt( value, 10 );
if( !isNaN( result ) ) return result;
const lowValue = value.toLowerCase();
switch( lowValue ) {
case EVENT_THIS: return 0;
case EVENT_PLAYER: return -1;
case EVENT_FOLLOWER0: return FOLLOWER_OFFSET;
case EVENT_FOLLOWER1: return FOLLOWER_OFFSET - 1;
case EVENT_FOLLOWER2: return FOLLOWER_OFFSET - 2;
case VEHICLE_BOAT: return VEHICLE_OFFSET;
case VEHICLE_SHIP: return VEHICLE_OFFSET - 1;
case VEHICLE_AIRSHIP: return VEHICLE_OFFSET - 2;
}
const e = $dataMap.events.find( e => e && e.name === value );
if( e === undefined ) throw Error( `${PLUGIN_NAME}: I can't find the event '${value}'` );
return e.id;
}
const DIRECTION_DOWN_LEFT = [ "downleft", "dl", "southwest", "sw", "↙︎", "左下", "南西" ];
const DIRECTION_DOWN = [ "down", "d", "south", "s", "↓", "下", "南" ];
const DIRECTION_DOWN_RIGHT = [ "downright", "dr", "southeast", "se", "↘︎", "右下", "南東" ];
const DIRECTION_LEFT = [ "left", "l", "west", "w", "←", "左", "西" ];
const DIRECTION_RIGHT = [ "right", "r", "east", "e", "→", "右", "東" ];
const DIRECTION_UP_LEFT = [ "upleft", "ul", "northwest", "nw", "↖︎", "左上", "北西" ];
const DIRECTION_UP = [ "up", "u", "north", "n", "↑", "上", "北" ];
const DIRECTION_UP_RIGHT = [ "upright", "ur", "northeast", "ne", "↗︎", "右上", "北東" ];
/**
* 方向文字列をテンキー方向の数値に変換して返す
* @param {String} value 方向た文字列
* @returns {Number} テンキー方向の数値(変換できなかった場合:undefined)
*/
function stringToDirection( value ) {
if( typeof value === TYPE_NUMBER ) return value;
value = treatValue( value );
const result = parseInt( value, 10 );
if( !isNaN( result ) ) return result;
value = value.toLowerCase();
if( DIRECTION_DOWN_LEFT.includes( value ) ) return 1;
if( DIRECTION_DOWN.includes( value ) ) return 2;
if( DIRECTION_DOWN_RIGHT.includes( value ) ) return 3;
if( DIRECTION_LEFT.includes( value ) ) return 4;
if( DIRECTION_RIGHT.includes( value ) ) return 6;
if( DIRECTION_UP_LEFT.includes( value ) ) return 7;
if( DIRECTION_UP.includes( value ) ) return 8;
if( DIRECTION_UP_RIGHT.includes( value ) ) return 9;
}
// イベントコマンドの番号
const COMMAND_END = 0;
const TRANSFER_PLAYER = 201;
const SET_MOVEMENT_ROUTE = 205;
const CHANGE_PLAYER_FOLLOWERS = 216;
const FADEOUT_SCREEN = 221;
const FADEIN_SCREEN = 222;
const WAIT_FOR = 230;
const PLAY_SE = 250;
const SET_CHAR = "setChar";
const gc = Game_Character;
/**
* パラメータを受け取る
*/
const pluginParams = PluginManagerEx.createParameter( document.currentScript );
const TF_moveUnit = parseFloatStrict( pluginParams.moveUnit );
/*---- プラグインコマンド ----*/
const COM_ROUTE = "route";
const COM_PATTERN_ANIME = "patternAnime";
const COM_SET_CHAR_PATTERN = "setCharPattern";
const COM_GO_XY = "goXY";
const COM_GO_EV = "goEv";
const COM_LOCATE_XY = "locateXY";
const COM_LOCATE_EV = "locateEv";
const COM_GET_ON = "getOn";
const COM_GET_OFF = "getOff";
const COM_FOLLOW = "follow";
const COM_ANIME = "anime";
const COM_END_ANIME = "endAnime";
const COM_SET_PRIORITY_TYPE = "setPriorityType";
const COM_GET_PRIORITY_TYPE = "getPriorityType";
const COM_SET_ANGLE = "setAngle";
/*--- Game_Interpreter ---*/
const _Game_Interpreter_setupChild = Game_Interpreter.prototype.setupChild;
Game_Interpreter.prototype.setupChild = function( list, eventId ) {
list.forEach( e => { if( e.indent === undefined ) e.indent = 0; } );// indent未設定なら0を設定する
_Game_Interpreter_setupChild.apply( this, arguments );
};
/**
* プラグインコマンドの登録
*/
// [移動ルートの一括設定]
PluginManagerEx.registerCommand( document.currentScript, COM_ROUTE, moveRoute );
// [ キャラパターン指定アニメ ]
PluginManagerEx.registerCommand( document.currentScript, COM_PATTERN_ANIME, patternAnime );
// [ キャラパターンを指定 ]
PluginManagerEx.registerCommand( document.currentScript, COM_SET_CHAR_PATTERN, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
setCharPattern( targetEvent, args.fileName, args.characterNumber, args.patternNumber, args.d );
} );
// [ イベントを指定座標に移動 ]
PluginManagerEx.registerCommand( document.currentScript, COM_GO_XY, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
const point = stringToPoint( args.pointStr );
goXY( targetEvent, point.x, point.y, args.isWait );
} );
// [ イベントを別のイベント位置に移動 ]
PluginManagerEx.registerCommand( document.currentScript, COM_GO_EV, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
const destinationEvent = stringToEvent( this, args.destinationId );
const point = stringToPoint( args.pointStr );
goEv( targetEvent, destinationEvent, point.x, point.y, args.isWait );
} );
// [ イベントを指定座標に配置 ]
PluginManagerEx.registerCommand( document.currentScript, COM_LOCATE_XY, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
const point = stringToPoint( args.pointStr );
locateXY( targetEvent, point.x, point.y, args.patternNumber, args.d );
} );
// [ イベントを別のイベント位置に配置 ]
PluginManagerEx.registerCommand( document.currentScript, COM_LOCATE_EV, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
const destinationEvent = stringToEvent( this, args.destinationId );
const point = stringToPoint( args.pointStr );
locateEv( targetEvent, destinationEvent, point.x, point.y, args.patternNumber, args.d );
} );
// [ 乗り物に乗る ]
PluginManagerEx.registerCommand( document.currentScript, COM_GET_ON, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
if( !targetEvent ) throw Error( `${PLUGIN_NAME}: I can't find the '${args.eventId}'` );
if( args.isVehiclePos ) {
// プレイヤーを乗り物の位置に移動
$gamePlayer.reserveTransfer( targetEvent._mapId, targetEvent.x, targetEvent.y );
this.setWaitMode( "transfer" );
} else {
// 乗り物をプレイヤーの位置に移動
targetEvent.setLocation( $gameMap.mapId(), $gamePlayer.x, $gamePlayer.y );
targetEvent.setDirection( $gamePlayer.direction() );
}
$gamePlayer._vehicleType = args.eventId;
$gamePlayer._vehicleGettingOn = true;
} );
// [ 乗り物から降りる ]
PluginManagerEx.registerCommand( document.currentScript, COM_GET_OFF, function( args ) {
$gamePlayer._followers.synchronize( $gamePlayer.x, $gamePlayer.y, $gamePlayer.direction() );
$gamePlayer.vehicle().getOff();
$gamePlayer._vehicleGettingOff = true;
$gamePlayer.setTransparent( false );
$gamePlayer.setMoveSpeed( 4 );
$gamePlayer.setThrough( false );
$gamePlayer.makeEncounterCount();
const d = args.d;
if( d === 5 ) return;
if( d !== 0 ) {
$gamePlayer._direction = d;
}
$gamePlayer.forceMoveForward();
$gamePlayer.gatherFollowers();
} );
// [ 隊列メンバーの追跡設定 ]
PluginManagerEx.registerCommand( document.currentScript, COM_FOLLOW, function( args ) {
if( args.eventId === EVENT_FOLLOWER_ALL ) {
const followers = $gamePlayer.followers();
followers._data.forEach( follower => {
followMode( follower, args.isFollow );
} );
} else {
const targetEvent = stringToEvent( this, args.eventId );
followMode( targetEvent, args.isFollow );
}
} );
// [ アニメの指定 ]
PluginManagerEx.registerCommand( document.currentScript, COM_ANIME, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
const rect = stringToPoint( args.pointStr );
anime( targetEvent, rect.x, rect.y, args.wait, args.characterNumber, args.patternNumber, args.d );
} );
// [ アニメの終了 ]
PluginManagerEx.registerCommand( document.currentScript, COM_END_ANIME, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
animeMode( targetEvent, false );
} );
// [ プライオリティの設定 ]
PluginManagerEx.registerCommand( document.currentScript, COM_SET_PRIORITY_TYPE, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
targetEvent.setPriorityType( args.priorityType );
} );
// [ プライオリティの取得 ]
PluginManagerEx.registerCommand( document.currentScript, COM_GET_PRIORITY_TYPE, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
const priorityType = targetEvent._priorityType;
$gameVariables.setValue( args.variableId, priorityType );
} );
// [ 回転角度の設定 ]
PluginManagerEx.registerCommand( document.currentScript, COM_SET_ANGLE, function( args ) {
const targetEvent = stringToEvent( this, args.eventId );
targetEvent.TF_setAngle( args.angle );
} );
/**
* 隊列メンバーに対する[移動ルートの設定]を可能にする。
* params[ 0 ] : Number イベント番号
* params[ 1 ] : 移動ルート { repeat: 動作を繰り返す, skippable: 移動できない場合は飛ばす, wait: 完了までウェイト, list: 移動コマンドのリスト }
*/
const _Game_Interpreter_command205 = Game_Interpreter.prototype.command205;
Game_Interpreter.prototype.command205 = function( params ) {
if( FOLLOWER_OFFSET < params[ 0 ] ) return _Game_Interpreter_command205.call( this, params );
$gameMap.refreshIfNeeded();
this._characterId = params[ 0 ];
const targetEvent = getEventById( this, params[ 0 ] );
if( !targetEvent ) return true;
targetEvent.forceMoveRoute( params[ 1 ] );
if( params[ 1 ].wait ) this.setWaitMode( WAIT_ROUTE );
return true;
};
/**
* ウェイトモードに移動待ちを追加。
* Game_Follower, Game_Vehicle に対応。
*/
const _Game_Interpreter_updateWaitMode = Game_Interpreter.prototype.updateWaitMode;
Game_Interpreter.prototype.updateWaitMode = function() {
let character;
let waiting;
switch( this._waitMode ) {
case WAIT_MOVING:
character = getEventById( this, this._characterId );
waiting = character.isMoving();
break;
case WAIT_ROUTE:
character = getEventById( this, this._characterId );
waiting = character && character.isMoveRouteForcing();
break;
case WAIT_ANIMATION:
character = getEventById( this, this._characterId );
waiting = character && character.isAnimationPlaying();
break;
case WAIT_BALLOON:
character = getEventById( this, this._characterId );
waiting = character && character.isBalloonPlaying();
break;
}
if( waiting === undefined ) return _Game_Interpreter_updateWaitMode.call( this );
if( waiting === false ) {
this._waitMode = "";
}
return waiting;
};
/**