-
Notifications
You must be signed in to change notification settings - Fork 1
/
KRD_Sugoroku_Alpha.js
1030 lines (976 loc) · 33.3 KB
/
KRD_Sugoroku_Alpha.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
// KRD_Sugoroku_Alpha.js
//
// Copyright (c) 2019 KRD_DATA (くろうど)
// This is under the MIT License.
// https://opensource.org/licenses/mit-license.php
/*:
* @plugindesc Sugoroku Plugin version Alpha. 2019/12/02 Update.
* @author KRD_DATA (くろうど)
*
* @requiredAssets img/pictures/dice_1
* @requiredAssets img/pictures/dice_2
* @requiredAssets img/pictures/dice_3
* @requiredAssets img/pictures/dice_4
* @requiredAssets img/pictures/dice_5
* @requiredAssets img/pictures/dice_6
*
* @param Common_Sugoroku
* @desc Set a common event number to use for Sugoroku Move.
* @default 1
* @type common_event
*
* @param Common_Goal
* @desc Set a common event number to use for Goal Event.
* @default 2
* @type common_event
*
* @param Common_RivalMove
* @desc Set a common event number to use for Rival Move.
* @default 3
* @type common_event
*
* @param Common_CollisionByRival
* @desc Set a common event number to use for Collision by Rival.
* @default 4
* @type common_event
*
* @param Common_CollisionByActor
* @desc Set a common event number to use for Collision by Actor.
* @default 5
* @type common_event
*
* @param Common_CollisionByReverse
* @desc Set a common event number to use for Collision by Reverse.
* @default 6
* @type common_event
*
* @param Common_RegionBase
* @desc Set a common event number's base to use for Region ID.
* @default 10
* @type common_event
*
* @param Switch_SugorokuMode
* @desc Set a switch number to use for Sugoroku Mode.
* @default 1
* @type switch
*
* @param Switch_DiceRoll
* @desc Set a switch number to use for Dice Roll.
* @default 2
* @type switch
*
* @param Switch_Collision
* @desc Set a switch number to use for Collision to Rival.
* @default 3
* @type switch
*
* @param Switch_CanMoveRival
* @desc Set a switch number to use for Rival Movable.
* @default 4
* @type switch
*
* @param Variable_Dice
* @desc Set a variables number to use for Number of Dice.
* @default 1
* @type variable
*
* @param Variable_RollType
* @desc Set a variables number to use for Dice Roll Type.
* @default 2
* @type variable
*
* @param Variable_Result
* @desc Set a variables number to use for Result from Dice Roll.
* @default 3
* @type variable
*
* @param Variable_NextDirection
* @desc Set a variables number to use for not Terrain Tag.
* @default 4
* @type variable
*
* @param Variable_EventX
* @desc Set a variables number to use for Rival's X Position.
* @default 5
* @type variable
*
* @param Variable_EventY
* @desc Set a variables number to use for Rival's Y Position.
* @default 6
* @type variable
*
* @param Variable_RivalStatus
* @desc Set a variables number to use for Rival's Status.
* @default 7
* @type variable
*
* @param Event_Rival
* @desc Set a Map Event ID to use for Rival.
* @default 1
* @type number
* @min 0
*
* @param DiceX
* @desc Set Dice Position X.
* @default 408
* @type number
* @min 0
*
* @param NextDicePosition
* @desc Set Next Dice Position X.
* @default 120
* @type number
* @min 0
*
* @param HalfNextDicePosition
* @desc Set Half Next Dice Position X.
* @default 60
* @type number
* @min 0
*
* @param DiceY
* @desc Set Dice Position Y.
* @default 312
* @type number
* @min 0
*
* @param MoveSpeed
* @desc Set Move Speed for Sugoroku Move.
* @default 6
* @type number
* @min 0
*
* @param DefaultSpeed
* @desc Set Default Speed.
* @default 4
* @type number
* @min 0
*
* @help
* This is the Sugoroku Plugin version Alpha.
*
* [Use Image]
* Please set dice images into pictures folder.
* For example the name is dice_1.
* For example the size is 100px.
* Use picture id 1 to 15.
*
* img/pictures/dice_1
* img/pictures/dice_2
* img/pictures/dice_3
* img/pictures/dice_4
* img/pictures/dice_5
* img/pictures/dice_6
*
* [Setting]
* Set Terrain Tag for direction to move.
* Terrain Tag : Direction
* 1 : Down
* 2 : Left
* 3 : Right
* 4 : Up
*
* Set Region ID to use Stop Event.
* Stop event is common event.
* Common Event ID + Common_RegionBase = Stop Event's Common Event ID
*
* [Usage Sugoroku Start]
* Player can't move on Sugoroku Mode Switch is ON.
*
* If the player wants to move, execute a common event.
* The common event is Common_Sugoroku.
*
* For that reason, The common event is written to Dice Roll and Player Move.
*
* [Usege Dice Roll]
* 1. Set the Roll Type Variable.
* Value : Roll Type
* 1 : Add dice rolls (nD6)
* 2 : DiceA * 10 + DiceB (D66)
* 3 : Count 3 or more
* 4 : Count 4 or more
*
* 2. Set the Number of Dice Variable to use Number of Dice.
* 3. Set the Dice Roll Switch to ON to roll some dice.
* 4. Set the Dice Roll Switch to OFF to stop roll.
*
* [Usage Player Move]
* Set player's move steps by plugin command KRD_setPlayerStep.
*
* Then, player auto move by terrain tag.
* And move stop.
* And execute common event by region id.
*
* When terrain tag is zero that is goal.
* Execute common event Common_Goal.
*
* [Usage Rival]
* Player can sugoroku with a rival.
*
* When using a rival, set event ID for Event_Rival.
*
* For rival move, use KRD_startRival.
* And use plugin command KRD_setRivalStep.
* Then, rival auto move.
*
* When Switch_Collision is ON,
* when player collision to rival, execute event.
*
* [Step]
* Sugoroku step is Variable_Result's value.
*
* When step is minus, player move reverse.
* But, player reverse can't turn.
*
* [Plugin Command]
* - KRD_setPlayerStep
* Set step value for player move.
* Parameter is variables number.
*
* - KRD_setPlayerStepValue
* Set step value for player move.
* Parameter is step value.
*
* - KRD_setRivalStep
* Set step value for rival move.
* Parameter is variables number.
*
* - KRD_eraseDice
* Erase dice pictures on screen.
* Parameter is nothing.
*
* - KRD_initSugoroku
* Start sugoroku in the map.
* Parameter is nothing.
*
* - KRD_initRival
* Initialize rival position.
* Parameter is nothing.
*
* - KRD_idleRival
* Rival is idling.
* Parameter is nothing.
*
* - KRD_startRival
* Starting the rival move.
* Parameter is nothing.
*
* - KRD_stopRival
* Finish the rival move.
* Parameter is nothing.
*
* - KRD_setCanMoveRival
* The rival movable is set for the Switch_CanMoveRival.
* Parameter is nothing.
*
*/
/*:ja
* @plugindesc すごろくプラグイン。アルファ版。2019/12/02 更新。
* @author KRD_DATA (くろうど)
*
* @requiredAssets img/pictures/dice_1
* @requiredAssets img/pictures/dice_2
* @requiredAssets img/pictures/dice_3
* @requiredAssets img/pictures/dice_4
* @requiredAssets img/pictures/dice_5
* @requiredAssets img/pictures/dice_6
*
* @param Common_Sugoroku
* @desc プレイヤーの移動に使うコモンイベント番号を設定してください。
* @default 1
* @type common_event
*
* @param Common_Goal
* @desc ゴールに止まった時に使うコモンイベント番号を設定してください。
* @default 2
* @type common_event
*
* @param Common_RivalMove
* @desc ライバルの移動に使うコモンイベント番号を設定してください。
* @default 3
* @type common_event
*
* @param Common_CollisionByRival
* @desc ライバルがプレイヤーに衝突した時に使うコモンイベント番号を設定してください。
* @default 4
* @type common_event
*
* @param Common_CollisionByActor
* @desc アクターがライバルに衝突した時に使うコモンイベント番号を設定してください。
* @default 5
* @type common_event
*
* @param Common_CollisionByReverse
* @desc アクターが戻る移動してライバルに衝突した時に使うコモンイベント番号を設定してください。
* @default 6
* @type common_event
*
* @param Common_RegionBase
* @desc マスに止まった時に使うコモンイベント番号の基礎値を設定してください。
* @default 10
* @type common_event
*
* @param Switch_SugorokuMode
* @desc すごろくモードに使うスイッチ番号を設定してください。
* @default 1
* @type switch
*
* @param Switch_DiceRoll
* @desc サイコロを振る時に使うスイッチ番号を設定してください。
* @default 2
* @type switch
*
* @param Switch_Collision
* @desc ライバルとの衝突処理を使うかどうかのスイッチ番号を設定してください。
* @default 3
* @type switch
*
* @param Switch_CanMoveRival
* @desc ライバルの移動可能状態に使うスイッチ番号を設定してください。
* @default 4
* @type switch
*
* @param Variable_Dice
* @desc サイコロを振る個数を入れる変数の番号を設定してください。
* @default 1
* @type variable
*
* @param Variable_RollType
* @desc サイコロの判定方法に使う変数の番号を設定してください。
* @default 2
* @type variable
*
* @param Variable_Result
* @desc サイコロの判定結果を入れる変数の番号を設定してください。
* @default 3
* @type variable
*
* @param Variable_NextDirection
* @desc 地形タグを無視して次の方向を決める時に使う変数の番号を設定してください。
* @default 4
* @type variable
*
* @param Variable_EventX
* @desc ライバルの位置(x座標)を入れる変数の番号を設定してください。
* @default 5
* @type variable
*
* @param Variable_EventY
* @desc ライバルの位置(y座標)を入れる変数の番号を設定してください。
* @default 6
* @type variable
*
* @param Variable_RivalStatus
* @desc ライバルの状態を入れる変数の番号を設定してください。
* @default 7
* @type variable
*
* @param Event_Rival
* @desc ライバルに使用するマップイベントIDを設定してください。
* @default 1
* @type number
* @min 0
*
* @param DiceX
* @desc 1つ目のサイコロ画像を表示する位置(x座標)を設定してください。
* @default 408
* @type number
* @min 0
*
* @param NextDicePosition
* @desc サイコロ画像を表示する位置に加算していく値を設定してください。
* @default 120
* @type number
* @min 0
*
* @param HalfNextDicePosition
* @desc サイコロ画像を表示する位置に加算していく値(の半分)を設定してください。
* @default 60
* @type number
* @min 0
*
* @param DiceY
* @desc 1つ目のサイコロ画像を表示する位置(y座標)を設定してください。
* @default 312
* @type number
* @min 0
*
* @param MoveSpeed
* @desc すごろくの移動時に使う移動速度を設定してください(1~6)。
* @default 6
* @type number
* @min 0
*
* @param DefaultSpeed
* @desc すごろく以外で使う移動速度を設定してください(1~6)。
* @default 4
* @type number
* @min 0
*
* @help
* これはすごろくプラグイン(アルファ版)です。
*
* 【使用する画像】
* サイコロ画像を pictures フォルダに入れてください。
* ファイル名は dice_1 から dice_6 としてください。
* サイコロ画像の画像サイズは一辺が 100 ピクセルの正方形を想定しています。
* サイコロ処理で、ピクチャID 1~15 を使います。
*
* img/pictures/dice_1
* img/pictures/dice_2
* img/pictures/dice_3
* img/pictures/dice_4
* img/pictures/dice_5
* img/pictures/dice_6
*
* 【設定】
* 移動に使用するタイルセットに地形タグを設定してください。
*
* 地形タグ : 移動する方向
* 1 : 下 ↓
* 2 : 左 ←
* 3 : 右 →
* 4 : 上 ↑
*
* 止まった時に発生するコモンイベントの番号と
* 対応するリージョンIDをマップに設定してください。
* 「リージョンID + Common_RegionBase の値
* = 止まった時に発生するコモンイベントの番号」となります。
*
* 【すごろくの開始について】
* すごろくモードスイッチが ON の時、プレイヤーは移動が出来なくなります。
*
* この状態で、プレイヤーが移動しようとした時、
* Common_Sugoroku のコモンイベントが実行されます。
* ですので、このコモンイベントの中に、
* 以下の「サイコロ処理」および「プレイヤーの移動処理」を
* 記述してください。
*
* 【サイコロ処理の使い方】
* 1. 「サイコロの判定方法に使う変数(Variable_RollType)」に
* 値を設定してください。
*
* 設定する値 : 判定方法
* 1 : 出目を加算(nD6)
* 2 : サイコロを2個振り片方を10の位とする(D66)
* 3 : 出目(3以上)の個数をカウント
* 4 : 出目(4以上)の個数をカウント
*
* 2. 「サイコロを振る個数を入れる変数(Variable_Dice)」に
* サイコロの個数を設定してください。
* 3. 「サイコロを振る時に使うスイッチ(Switch_DiceRoll)」を
* ON にしてください。
* サイコロを振っている状態になります。
* 4. プレイヤーの入力などにより、
* 「サイコロを振る時に使うスイッチ(Switch_DiceRoll)」を
* OFF にしてください。
*
* (イベント例)
* ◆スイッチの操作:#0002 Rolling Dice = ON
* ◆ループ
* ◆選択肢の表示:サイコロを止める (ウィンドウ, 中, #1, -)
* :サイコロを止めるのとき
* ◆スイッチの操作:#0002 Rolling Dice = OFF
* ◆ループの中断
* ◆
* :分岐終了
* :以上繰り返し
*
* 【プレイヤーの移動処理】
* プラグインコマンド「KRD_setPlayerStep」を使用して、
* プレイヤーが移動する歩数(マスの数)を設定してください。
*
* そうすると、マスに設定された地形タグに従って自動的に移動します。
* そして、止まったマスのリージョンIDを元に算出されたコモンイベントを実行します。
*
* 地形タグを設定していないマス、つまり地形タグが 0 のマスは、移動が強制停止し、
* ゴールイベント(Common_Goal で設定したコモンイベント)が実行されます。
*
* 【ライバルの使い方】
* 一緒にすごろくをするキャラクターを1体用意する事が出来ます。
* これをこのプラグインではライバルと呼びます。
*
* ライバルを使用する場合、
* まず、Event_Rival にマップイベントIDを設定します。
* この値は全マップ共通で使うので 1 を使う事を想定しています。
*
* ライバルを移動させるには
* まず、 KRD_startRival を使います。
*
* そして、プラグインコマンド「KRD_setRivalStep」を使用して、
* ライバルが移動する歩数(マスの数)を設定してください。
* そうすると、ライバルが自動的に移動します。
* ライバルはマスに止まってもイベントが発生しません。
*
* ライバルとの衝突イベントを発生させる場合、
* Switch_Collision で設定したスイッチを ON にしてください。
*
* 【歩数について】
* 歩数は Variable_Result で設定した変数を使用する想定ですが、
* 必ずしもサイコロを振る必要はなく、値の設定方法は自由です。
*
* 歩数がマイナスの場合、マスの向きと反対方向に移動します。
* つまり、戻る移動をするわけですが、曲がる事は出来ません。
*
* 戻す先が決まっているなら、移動ルートの設定でジャンプするなどしてください。
*
* 【プラグインコマンドの使い方】
* 以下はプラグインコマンドのコマンド名です。
* プラグインコマンドは「コマンド名 パラメータ」という構成で記述します。
* コマンド名とパラメータの間は半角スペースです。
*
* - KRD_setPlayerStep
* プレイヤーが移動する歩数を設定します。
* パラメータは、歩数が入っている変数の番号です。
*
* - KRD_setPlayerStepValue
* プレイヤーが移動する歩数を設定します。
* パラメータは、歩数の値そのものです。
*
* - KRD_setRivalStep
* ライバルが移動する歩数を設定します。
* パラメータは、歩数が入っている変数の番号です。
*
* - KRD_eraseDice
* 表示されているサイコロ画像を消します。
* パラメータはありません。
*
* - KRD_initSugoroku
* そのマップでのすごろく処理を開始します。
* パラメータはありません。
*
* - KRD_initRival
* ライバルの位置を初期化します。
* パラメータはありません。
*
* - KRD_idleRival
* ライバルを一時移動停止します。
* パラメータはありません。
*
* - KRD_startRival
* ライバルが移動可能な状態にします。
* パラメータはありません。
*
* - KRD_stopRival
* ライバルの移動を終了します。
* パラメータはありません。
*
* - KRD_setCanMoveRival
* ライバルが移動可能な状態なのかチェックしてスイッチをON/OFFします。
* Switch_CanMoveRival で設定したスイッチが使用されます。
* パラメータはありません。
*
*/
(function() {
'use strict';
const parameters = PluginManager.parameters('KRD_Sugoroku_Alpha');
// Common Event ID
const cmnSugoroku = Number(parameters['Common_Sugoroku']);
const cmnGoal = Number(parameters['Common_Goal']);
const cmnRivalMove = Number(parameters['Common_RivalMove']);
const cmnCollisionByRival = Number(parameters['Common_CollisionByRival']);
const cmnCollisionByActor = Number(parameters['Common_CollisionByActor']);
const cmnCollisionByReverse = Number(parameters['Common_CollisionByReverse']);
const cmnPlus = Number(parameters['Common_RegionBase']);
// Switch ID
const swSugoroku = Number(parameters['Switch_SugorokuMode']);
const swRolling = Number(parameters['Switch_DiceRoll']);
const swCollision = Number(parameters['Switch_Collision']);
const swRival = Number(parameters['Switch_CanMoveRival']);
// Variable ID
const varDice = Number(parameters['Variable_Dice']);
const varType = Number(parameters['Variable_RollType']);
const varResult = Number(parameters['Variable_Result']);
const varDirection = Number(parameters['Variable_NextDirection']);
const varEventX = Number(parameters['Variable_EventX']);
const varEventY = Number(parameters['Variable_EventY']);
const varRival = Number(parameters['Variable_RivalStatus']);
// Event ID
const evRival = Number(parameters['Event_Rival']);
// Dice Image
const dx = Number(parameters['DiceX']);
const dNext = Number(parameters['NextDicePosition']);
const dHalf = Number(parameters['HalfNextDicePosition']);
const dy = Number(parameters['DiceY']);
// Move Speed
const moveSpeed = Number(parameters['MoveSpeed']);
const defaultSpeed = Number(parameters['DefaultSpeed']);
//================================================
// Plugin Command
const KRD_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
KRD_Game_Interpreter_pluginCommand.call(this, command, args);
switch (command) {
case 'KRD_setPlayerStep':
var v = !!Number(args) ? Number(args) : 0;
$gamePlayer.setStep($gameVariables.value(v));
break;
case 'KRD_setPlayerStepValue':
var step = !!Number(args) ? Number(args) : 0;
$gamePlayer.setStep(step);
break;
case 'KRD_setRivalStep':
var v = !!Number(args) ? Number(args) : 0;
$gameMap._events[evRival].setStep($gameVariables.value(v));
break;
case 'KRD_eraseDice':
$gameScreen.eraseDice();
break;
case 'KRD_initSugoroku':
$gamePlayer.initSugoroku();
break;
case 'KRD_initRival':
$gameMap._events[evRival].initRival();
break;
case 'KRD_idleRival':
$gameMap._events[evRival].idleRival();
break;
case 'KRD_startRival':
$gameMap._events[evRival].startRival();
break;
case 'KRD_stopRival':
$gameMap._events[evRival].stopRival();
break;
case 'KRD_setCanMoveRival':
var movable = $gameMap._events[evRival].canMoveRival();
$gameSwitches.setValue(swRival, movable);
break;
}
};
//================================================
// Move for Sugoroku
const KRD_Game_Player_executeMove = Game_Player.prototype.executeMove;
Game_Player.prototype.executeMove = function(direction) {
if ($gameSwitches.value(swSugoroku)) {
$gameTemp.reserveCommonEvent(cmnSugoroku);
} else {
KRD_Game_Player_executeMove.call(this, direction);
}
};
const KRD_Game_Player_triggerButtonAction = Game_Player.prototype.triggerButtonAction;
Game_Player.prototype.triggerButtonAction = function() {
if ($gameSwitches.value(swSugoroku)) {
if (Input.isTriggered('ok')) {
$gameTemp.reserveCommonEvent(cmnSugoroku);
return true;
}
return false;
} else {
KRD_Game_Player_triggerButtonAction.call(this);
}
};
//================================================
// Sugoroku Initialize
Game_Player.prototype.initSugoroku = function(){
if (evRival > 0) {
$gameMap._events[evRival].loadRival();
}
};
//================================================
// Sugoroku Step
Game_Player.prototype.setStep = function(step = null){
this._step = step;
};
Game_Player.prototype.sugorokuStep = function(){
const x = $gamePlayer.x;
const y = $gamePlayer.y;
let direction = $gameMap.terrainTag(x, y);
const next = $gameVariables.value(varDirection);
if (next > 0 && next <= 4) {
direction = next;
$gameVariables.setValue(varDirection, 0);
}
switch (direction) {
case 1: // Down
this.setDirection(2);
break;
case 2: // Left
this.setDirection(4);
break;
case 3: // Right
this.setDirection(6);
break;
case 4: // Up
this.setDirection(8);
break;
default: // Don't Move
return;
}
this.forceMoveForward();
if (evRival > 0) {
$gameMap._events[evRival].collisionEvent(cmnCollisionByActor);
}
};
Game_Player.prototype.sugorokuReverse = function(){
const x = $gamePlayer.x;
const y = $gamePlayer.y;
const tag = $gameMap.terrainTag(x, y);
switch (tag) {
case 1: // Down -> Up
this.setDirection(8);
break;
case 2: // Left -> Right
this.setDirection(6);
break;
case 3: // Right -> Left
this.setDirection(4);
break;
case 4: // Up -> Down
this.setDirection(2);
break;
default: // Don't Move
return;
}
this.forceMoveForward();
if (evRival > 0) {
$gameMap._events[evRival].collisionEvent(cmnCollisionByReverse);
}
};
const KRD_Game_Player_updateStop = Game_Player.prototype.updateStop;
Game_Player.prototype.updateStop = function() {
KRD_Game_Player_updateStop.call(this);
if (this._step != null) {
if (this._step > 0) {
this._step -= 1;
this.setMoveSpeed(moveSpeed);
this.sugorokuStep();
} else if (this._step < 0) {
this._step += 1;
this.setMoveSpeed(moveSpeed);
this.sugorokuReverse();
} else {
this.checkRegion();
this.setMoveSpeed(defaultSpeed);
this._step = null;
}
}
};
const KRD_Game_Player_canMove = Game_Player.prototype.canMove;
Game_Player.prototype.canMove = function() {
if (this._step != null) {
return false;
} else {
return KRD_Game_Player_canMove.call(this);
}
};
//================================================
// Sugoroku Stop Event
Game_Player.prototype.checkRegion = function(){
const x = $gamePlayer.x;
const y = $gamePlayer.y;
const region = $gameMap.regionId(x, y);
if (region > 0) {
$gameTemp.reserveCommonEvent(region + cmnPlus);
} else {
$gameTemp.reserveCommonEvent(cmnGoal);
}
};
//================================================
// Dice Roll
const maxDice = 15;
Game_Screen.prototype.rollDice = function(count = 0, max = 1){
const name = ['dice_1', 'dice_2', 'dice_3', 'dice_4', 'dice_5', 'dice_6'];
const d4 = dNext + dHalf;
const d5 = dNext + dNext;
const baseX = [
/* 1*/ [dx]
/* 2*/ , [dx - dHalf, dx + dHalf]
/* 3*/ , [dx - dNext, dx, dx + dNext]
/* 4*/ , [dx - dNext, dx, dx + dNext, dx]
/* 5*/ , [dx - dNext, dx, dx + dNext, dx - dHalf, dx + dHalf]
/* 6*/ , [dx - dNext, dx, dx + dNext, dx - dNext, dx, dx + dNext]
/* 7*/ , [dx - dNext, dx, dx + dNext, dx - dNext, dx, dx + dNext, dx]
/* 8*/ , [dx - dNext, dx, dx + dNext, dx - dNext, dx, dx + dNext, dx - dHalf, dx + dHalf]
/* 9*/ , [dx - dNext, dx, dx + dNext, dx - dNext, dx, dx + dNext, dx - dNext, dx, dx + dNext]
/*10*/ , [dx - d4, dx - dHalf, dx + dHalf, dx + d4, dx - d4, dx - dHalf, dx + dHalf, dx + d4, dx - dHalf, dx + dHalf]
/*11*/ , [dx - d4, dx - dHalf, dx + dHalf, dx + d4, dx - d4, dx - dHalf, dx + dHalf, dx + d4, dx - dNext, dx, dx + dNext]
/*12*/ , [dx - d4, dx - dHalf, dx + dHalf, dx + d4, dx - d4, dx - dHalf, dx + dHalf, dx + d4, dx - d4, dx - dHalf, dx + dHalf, dx + d4]
/*13*/ , [dx - d5, dx - dNext, dx, dx + dNext, dx + d5, dx - d5, dx - dNext, dx, dx + dNext, dx + d5, dx - dNext, dx, dx + dNext]
/*14*/ , [dx - d5, dx - dNext, dx, dx + dNext, dx + d5, dx - d5, dx - dNext, dx, dx + dNext, dx + d5, dx - d4, dx - dHalf, dx + dHalf, dx + d4]
/*15*/ , [dx - d5, dx - dNext, dx, dx + dNext, dx + d5, dx - d5, dx - dNext, dx, dx + dNext, dx + d5, dx - d5, dx - dNext, dx, dx + dNext, dx + d5]
];
const xx = baseX[max - 1][count];
const y3 = dy + Math.floor(count / 3) * dNext;
const y4 = dy + Math.floor(count / 4) * dNext;
const y5 = dy + Math.floor(count / 5) * dNext;
const dice = Math.randomInt(6) + 1;
if (max <= 9) {
// showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode);
this.showPicture(count + 1, name[dice - 1], 1, xx, y3, 100, 100, 255, 0);
} else if (max <= 12) {
// showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode);
this.showPicture(count + 1, name[dice - 1], 1, xx, y4, 100, 100, 255, 0);
} else if (max <= 15) {
// showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode);
this.showPicture(count + 1, name[dice - 1], 1, xx, y5, 100, 100, 255, 0);
}
return dice;
};
Game_Screen.prototype.rollAllDice = function() {
$gameVariables.setValue(varResult, 0);
const max = Math.min($gameVariables.value(varDice), maxDice);
for (let i = 0; i < max; i++) {
$gameVariables.setValue(varResult, this.rollDice(i, max) + $gameVariables.value(varResult));
}
};
Game_Screen.prototype.rollD66 = function() {
$gameVariables.setValue(varDice, 2);
$gameVariables.setValue(varResult, this.rollDice(0, 2) * 10);
$gameVariables.setValue(varResult, this.rollDice(1, 2) + $gameVariables.value(varResult));
};
Game_Screen.prototype.rollUpper = function(border = 3) {
$gameVariables.setValue(varResult, 0);
const max = Math.min($gameVariables.value(varDice), maxDice);
for (let i = 0; i < max; i++) {
$gameVariables.setValue(varResult,
this.rollDice(i, max) >= border ? $gameVariables.value(varResult) + 1 : $gameVariables.value(varResult));
}
};
Game_Screen.prototype.selectRollType = function() {
if ($gameSwitches.value(swRolling)) {
switch ($gameVariables.value(varType)) {
case 1:
this.rollAllDice();
break;
case 2:
this.rollD66();
break;
case 3:
this.rollUpper();
break;
case 4:
this.rollUpper(4);
break;
default:
this.rollAllDice();
break;
}
}
};
const KRD_Game_Screen_updatePictures = Game_Screen.prototype.updatePictures;
Game_Screen.prototype.updatePictures = function() {
this.selectRollType();
KRD_Game_Screen_updatePictures.call(this);
};
Game_Screen.prototype.eraseDice = function() {
const max = Math.min($gameVariables.value(varDice), maxDice);
for (let i = 1; i <= max; i++) {
const realPictureId = this.realPictureId(i);
this._pictures[realPictureId] = null;
}
};
//================================================
// Rival Move
Game_Event.prototype.setStep = function(step = null){
this._step = step;
};
Game_Event.prototype.sugorokuStep = function(){
const x = this.x;
const y = this.y;
const tag = $gameMap.terrainTag(x, y);
switch (tag) {
case 1: // Down
this.setDirection(2);
break;
case 2: // Left
this.setDirection(4);
break;
case 3: // Right
this.setDirection(6);
break;
case 4: // Up
this.setDirection(8);
break;
default: // Don't Move
return;
}
this.moveForward();
this.collisionEvent(cmnCollisionByRival);
};
const KRD_Game_Event_updateStop = Game_Event.prototype.updateStop;
Game_Event.prototype.updateStop = function() {
KRD_Game_Event_updateStop.call(this);
if (this._step != null) {
if (this._step > 0) {
this._step -= 1;
this.setThrough(true);
this.setMoveSpeed(moveSpeed);
this.sugorokuStep();
} else {
switch ($gameVariables.value(varRival)){
case 100:
this.saveRival();
break;
case 200:
this.saveRival();
break;
case 300:
this.saveRival();
break;
}
this.setMoveSpeed(defaultSpeed);
this.setThrough(false);
this._step = null;
}
}
};
//================================================
// Rival Position
Game_Event.prototype.initRival = function(){
$gameVariables.setValue(varEventX, 0);
$gameVariables.setValue(varEventY, 0);
};
Game_Event.prototype.loadRival = function(){
const x = $gameVariables.value(varEventX);
const y = $gameVariables.value(varEventY);
if (x != 0 && y != 0) {
this.locate(x, y);
}
};
Game_Event.prototype.idleRival = function(){
const rivalStatus = $gameVariables.value(varRival);
$gameVariables.setValue(varRival, rivalStatus < 300 ? 100 : rivalStatus);
};
Game_Event.prototype.startRival = function(){
const rivalStatus = $gameVariables.value(varRival);
$gameVariables.setValue(varRival, rivalStatus < 300 ? 200 : rivalStatus);
};
Game_Event.prototype.stopRival = function(){
const rivalStatus = $gameVariables.value(varRival);
$gameVariables.setValue(varRival, rivalStatus < 300 ? 300 : rivalStatus);
};
Game_Event.prototype.saveRival = function(){
$gameVariables.setValue(varEventX, this.x);
$gameVariables.setValue(varEventY, this.y);
};
Game_Event.prototype.canMoveRival = function(){
const x = this.x;
const y = this.y;
const tag = $gameMap.terrainTag(x, y);
if (tag === 0) {