forked from triacontane/RPGMakerMV
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathChronus.js
1760 lines (1585 loc) · 72.6 KB
/
Chronus.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
//=============================================================================
// Chronus.js
// ----------------------------------------------------------------------------
// (C) 2015 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.16.2 2019/11/17 1.15.0の修正以後、場所移動したときのタイルセット情報の取得が、移動前のものになっていた問題を修正
// 1.16.1 2019/11/10 1.16.1で追加したアラーム機能で、アラームに設定した時間を超過して判定された場合、次回のインターバルが超過した時間からカウントされてしまう問題を修正
// 1.16.0 2019/11/09 1.15.0で追加したアラーム機能にインターバル機能を追加
// 1.15.0 2019/10/23 特定のゲーム内時刻になるとスイッチ操作されるアラーム機能を追加
// タイルセット変更した場合に、新しいタイルセットの色調や天候有無の設定が反映されない問題を修正
// 1.14.1 2019/10/17 ヘルプの記載漏れを修正
// 1.14.0 2019/09/01 時間帯名称をカレンダーに表示する機能を追加
// 1.13.1 2019/06/09 ニューゲーム時もしくはプロジェクト保存後のロード時に場所移動の時間が経過してしまう問題を修正
// 1.13.0 2019/04/20 カレンダーを初期状態で非表示にできるパラメータを追加
// 1.12.0 2018/12/27 カレンダー表示に行間を設定できる機能を追加
// 1.11.1 2018/10/14 実時間表示に切り替えてから内部時間に反映されるまでにラグがある問題の修正
// 1.11.0 2018/10/14 カレンダーの枠を非表示にできる機能を追加
// 1.10.3 2018/10/08 プラグインコマンドで天候変化を無効にした場合でも、内部で制御している天候による色調の調整が反映されてしまう問題を修正
// 1.10.2 2018/04/11 時間表示方法(実時間、ゲーム時間)を切り替えた直後に、時間変数の値が更新されない問題を修正
// 1.10.1 2018/03/07 場所移動の際、移動先マップの色調有効フラグが異なっていた場合に、色調がリフレッシュされない問題を修正
// 1.10.0 2018/02/24 日付フォーマットに基づいて計算した時間を変数に自動設定する機能を追加
// 1.9.4 2018/02/19 カレンダーの初期表示をtrueに変更しました。
// 1.9.3 2017/11/18 マップロード時に色調を時間に合わせて瞬間変更していた仕様を撤廃
// 1.9.2 2017/11/02 イベント実行中に時間を変更した場合にアナログ時計の表示が変更されない問題を修正
// 1.9.1 2017/11/02 時間経過の初期状態を「停止」から「開始」に変更
// 1.9.0 2017/10/05 アナログ時計の画像を変更できる機能を追加
// カレンダーウィンドウのフォントサイズと不透明度を変更できる機能を追加
// 1.8.3 2017/07/18 タイマーの機能のプラグインコマンドに関する説明が一部間違っていた問題を修正
// 1.8.2 2017/07/05 時間変動間隔を変更したときにアナログ時計が正しく表示されない問題を修正
// 1.8.1 2017/06/29 1.8.0で追加した累計時間の初期化機能で、現在時間まで初期化されてしまう問題を修正
// 1.8.0 2017/06/28 累計経過日数を格納するパラメータと、累計時間および日数を初期化できるプラグインコマンドを追加
// パラメータの型指定に対応
// 1.7.0 2017/06/01 実時間およびゲーム内時間と連動するタイマー機能を追加
// 時間が変動する間隔を自由に指定できる機能を追加
// 1.6.0 2017/04/23 降雪マップをマップ単位でタイルセット単位で設定する機能を追加、降水確率を調整できる機能を追加
// 1.5.0 2017/01/23 カレンダーに月名を表記する書式「MON」を追加
// 1.4.0 2017/01/07 ゲーム開始からの累計時間(分単位)を指定したゲーム変数に格納する機能を追加
// 1.3.3 2017/01/02 色調変更を禁止しているときにイベントで色調変更した場合、すぐにリセットされてしまう問題を修正
// 1.3.2 2016/07/24 1.3.1でロード時にエラーになる問題の修正
// 1.3.1 2016/07/23 イベント処理中の時間経過有無をイベントごとに設定できるよう変更
// 一部コードのリファクタリング
// 1.3.0 2016/07/21 イベント処理中も時間が経過する設定を追加
// 1.2.7 2016/07/10 自然時間加算が0の場合に色調や天候の変化が正しく行われない問題を修正
// 1.2.6 2016/05/30 曜日に「Y」を含む文字列を指定できないバグを修正
// 1.2.5 2016/04/29 createUpperLayerによる競合対策
// 1.2.4 2016/03/13 アナログ時計を指定しないで起動した場合にエラーになる現象の修正
// 1.2.3 2016/03/10 時間帯と時間帯ごとの色調をカスタマイズできるようにユーザ書き換え領域を作成
// 1.2.2 2016/03/04 本体バージョン1.1.0の未使用素材の削除機能への対応
// 1.2.1 2016/02/25 実時間表示設定でロードするとエラーが発生する現象の修正
// 1.2.0 2016/02/14 アナログ時計の表示機能を追加
// 現実の時間を反映させる機能の追加
// 1.1.3 2016/01/21 競合対策(YEP_MessageCore.js)
// 1.1.2 2016/01/10 カレンダーウィンドウの表示位置をカスタマイズできる機能を追加
// 1.1.1 2015/12/29 日の値に「1」を設定した場合に日付の表示がおかしくなる不具合を修正
// 一部コードのリファクタリング
// 1.1.0 2015/12/01 天候と時間帯をゲーム変数に格納できるよう機能追加
// 1.0.0 2015/11/27 初版
// ----------------------------------------------------------------------------
// [Blog] : https://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub] : https://github.com/triacontane/
//=============================================================================
/*:
* @plugindesc ゲーム内時間の導入プラグイン
* @author トリアコンタン
*
* @param 月ごとの日数配列
* @desc 各月の日数の配列です。カンマ区切りで指定してください。個数は自由です。
* @default 31,28,31,30,31,30,31,31,30,31,30,31
*
* @param 月名配列
* @desc 月の名称配列です。カンマ区切りで指定してください。個数は自由です。
* @default Jan.,Feb.,Mar.,Apr.,May.,Jun.,Jul.,Aug.,Sep.,Oct.,Nov.,Dec.
*
* @param 曜日配列
* @desc 曜日の名称配列です。カンマ区切りで指定してください。個数は自由です。
* @default (日),(月),(火),(水),(木),(金),(土)
*
* @param 自然時間加算
* @type number
* @desc 1秒(自然時間加算間隔で指定した間隔)ごとに加算されるゲーム時間(分単位)の値です。イベント処理中は無効です。
* @default 5
*
* @param 自然時間加算間隔
* @type number
* @desc ゲーム時間の自然加算が行われる間隔(フレーム数)です。1F=1/60秒
* @default 60
*
* @param 場所移動時間加算
* @type number
* @desc 1回の場所移動で加算されるゲーム時間(分単位)の値です。
* @default 30
*
* @param 戦闘時間加算(固定)
* @type number
* @desc 1回の戦闘で加算されるゲーム時間(分単位)の値です。
* @default 30
*
* @param 戦闘時間加算(ターン)
* @type number
* @desc 1回の戦闘で消費したターン数ごとに加算されるゲーム時間(分単位)の値です。
* @default 5
*
* @param 年のゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「年」の値が自動設定されます。
* @default 0
*
* @param 月のゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「月」の値が自動設定されます。
* @default 0
*
* @param 日のゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「日」の値が自動設定されます。
* @default 0
*
* @param 曜日IDのゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「曜日」のIDが自動設定されます。
* @default 0
*
* @param 曜日名のゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「曜日」の名称が自動設定されます。
* ゲーム変数に文字列が入るので注意してください。
* @default 0
*
* @param 時のゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「時」の値が自動設定されます。
* @default 0
*
* @param 分のゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「分」の値が自動設定されます。
* @default 0
*
* @param 累計時間のゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「累計時間」(分単位)の値が自動設定されます。
* @default 0
*
* @param 累計日数のゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「累計日数」の値が自動設定されます。
* @default 0
*
* @param 時間帯IDのゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「時間帯」のIDが自動設定されます。
* 0:深夜 1:早朝 2:朝 3:昼 4:夕方 5:夜
* @default 0
*
* @param 天候IDのゲーム変数
* @type variable
* @desc 指定した番号のゲーム変数に「天候」のIDが自動設定されます。
* 0:なし 1:雨 2:嵐 3:雪
* @default 0
*
* @param フォーマット時間の変数
* @type variable
* @desc 「フォーマット時間の計算式」に基づいて計算した結果が自動設定されます。
* @default 0
*
* @param フォーマット時間の計算式
* @desc 日時フォーマットを使った計算式の内容です。
* YYYY:年 MON:月名 MM:月 DD:日 など(詳細はヘルプ参照)
* @default HH24 * 60 + MI
*
* @param 日時フォーマット1
* @desc マップ上の日付ウィンドウ1行目に表示される文字列です。
* YYYY:年 MON:月名 MM:月 DD:日 など(詳細はヘルプ参照)
* @default YYYY年 MM月 DD日 DY
*
* @param 日時フォーマット2
* @desc マップ上の日付ウィンドウ2行目に表示される文字列です。
* YYYY:年 MON:月名 MM:月 DD:日 など(詳細はヘルプ参照)
* @default AMHH時 MI分
*
* @param 日時フォーマット行間
* @type number
* @desc カレンダー表示の行間です。
* @default 0
*
* @param カレンダー表示X座標
* @type number
* @desc カレンダーの表示 X 座標です。
* @default 0
*
* @param カレンダー表示Y座標
* @type number
* @desc カレンダーの表示 Y 座標です。
* @default 0
*
* @param カレンダーフォントサイズ
* @type number
* @desc カレンダーのフォントサイズです。0を指定するとデフォルトとなります。
* @default 0
*
* @param カレンダー不透明度
* @type number
* @desc カレンダーの背景の不透明度(0-255)です。
* @default 192
*
* @param カレンダー枠の非表示
* @type boolean
* @desc カレンダーのウィンドウ枠を非表示にします。
* @default false
*
* @param カレンダーの非表示
* @type boolean
* @desc カレンダーを非表示します。プラグインコマンドから表示できます。
* @default false
*
* @param カレンダー余白
* @type number
* @desc カレンダーの余白(8-)です。
* @default 8
*
* @param 文字盤画像ファイル
* @desc アナログ時計を表示する場合の文字盤画像ファイル名(拡張子は不要)です。
* 画像は「img/pictures/」以下に保存してください。
* @default
* @require 1
* @dir img/pictures/
* @type file
*
* @param 長針画像ファイル
* @desc アナログ時計を表示する場合の長針画像ファイル名(拡張子は不要)です。
* 画像は「img/pictures/」以下に保存してください。
* @default
* @require 1
* @dir img/pictures/
* @type file
*
* @param 短針画像ファイル
* @desc アナログ時計を表示する場合の長針画像ファイル名(拡張子は不要)です。
* 画像は「img/pictures/」以下に保存してください。
* @default
* @require 1
* @dir img/pictures/
* @type file
*
* @param 時計X座標
* @type number
* @desc アナログ時計の表示X座標です。画像の中心座標を指定してください。
* @default 84
*
* @param 時計Y座標
* @type number
* @desc アナログ時計の表示Y座標です。画像の中心座標を指定してください。
* @default 156
*
* @param イベント中時間経過
* @desc イベント実行中も時間経過するようになります。(ON/OFF)
* @default false
* @type boolean
*
* @help ゲーム内で時刻と天候の概念を表現できるプラグインです。
* 自動、マップ移動、戦闘で時間が経過し、時間と共に天候と色調が変化します。
* これらの時間は調節可能で、またイベント中は時間の進行が停止します。
*
* さらに、現実の時間をゲーム中に反映させる機能もあります。
* 設定を有効にすると現実の時間がゲーム内とリンクします。
*
* 日付や曜日も記録し、曜日の数や名称を自由に設定できます。
* 現在日付はフォーマットに従って、画面左上に表示されます。
*
* 日付フォーマットには以下を利用できます。
* YYYY:年 MON:月名 MM:月 DD:日 HH24:時(24) HH:時(12)
* AM:午前 or 午後 MI:分 DY:曜日 TZ 時間帯名称
*
* また、規格に沿った画像を用意すればアナログ時計も表示できます。
* 表示位置は各画像の表示可否は調整できます。
*
* 画像の規格は以下の通りです。
* ・文字盤 : 任意のサイズの正方形画像
* ・長針 : 文字盤と同じサイズの画像で、上(0)を指している針の画像
* ・短針 : 文字盤と同じサイズの画像で、上(0)を指している針の画像
*
* ツクマテにて規格に合った時計画像をリクエストしました。
* 使用する場合は、以下のURLより利用規約を別途確認の上、ご使用ください。
* http://tm.lucky-duet.com/viewtopic.php?f=47&t=555&p=1615#p1615
*
* プラグインコマンド詳細
* イベントコマンド「プラグインコマンド」から実行。
* 指定する値には制御文字\V[n]を使用できます。
* (引数の間は半角スペースで区切る)
*
* C_ADD_TIME [分] : 指定した値(分単位)だけ時間が経過します。
* C_ADD_DAY [日] : 指定した値(日単位)だけ日数が経過します。
* C_SET_TIME [時] [分] : 指定した時間に変更します。
* C_SET_DAY [年] [月] [日] : 指定した日付に変更します。
* C_STOP : 時間の進行を停止します。
* C_START : 時間の進行を開始します。
* C_SHOW : カレンダーを表示します。
* C_HIDE : カレンダーを非表示にします。
* C_DISABLE_TINT : 時間帯による色調の変更を禁止します。
* C_ENABLE_TINT : 時間帯による色調の変更を許可します。
* C_DISABLE_WEATHER : 時間経過による天候の変化を禁止します。
* C_ENABLE_WEATHER : 時間経過による天候の変化を許可します。
* C_SET_SNOW_LAND : 悪天候時に雪が降るようになります。
* C_RESET_SNOW_LAND : 悪天候時に雨もしくは嵐が降るようになります。
* C_SET_SPEED [分] : 実時間1秒あたりの時間の経過速度を設定します。
* C_SHOW_CLOCK : アナログ時計を表示します。
* C_HIDE_CLOCK : アナログ時計を非表示にします。
* C_SET_TIME_REAL : 時間の取得方法を実時間に変更します。
* C_SET_TIME_VIRTUAL : 時間の取得方法をゲーム内時間に変更します。
* C_SET_RAINY_PERCENT [確率] : 降水確率(0-100)を設定します。
* C_INIT_TOTAL_TIME : 累計時間、累計日数を初期化します。
*
* ・アナログ時計画像変更コマンド
* アナログ時計の画像ファイル名(img/pictures)を変更できます。
* ただし、実際に画像が変更されるのはマップを移動した後になります。
* C_SET_CLOCK_BASE [ファイル名] : 文字盤画像のファイル名を変更します。
* C_SET_HOUR_HAND [ファイル名] : 短針画像のファイル名を変更します。
* C_SET_MINUTE_HAND [ファイル名] : 長針画像のファイル名を変更します。
*
* ・タイマー操作系コマンド
* コマンド実行から指定した時間[分]が経過後にスイッチやセルフスイッチを
* ONにできるコマンドです。
* 実時間連動機能と併せて使用することもできます。
* スイッチの場合はIDを、セルフスイッチの場合は種類(A,B,C,D)を指定します。
*
* C_SET_SWITCH_TIMER [分] [スイッチID] [ループ]
* 指定例(ゲーム内時間で30分経過後する度にスイッチ[10]をONにする)
* C_SET_SWITCH_TIMER 30 10 ON
*
* C_SET_SELF_SWITCH_TIMER [分] [セルフスイッチ種類] [ループ]
* 指定例(ゲーム内時間で3時間過後にセルフスイッチ[B](※)をONにする)
* C_SET_SELF_SWITCH_TIMER 180 B OFF
* ※対象イベントはプラグインコマンドを実行したイベントです。
*
* 途中で解除や一時停止する可能性がある場合は[タイマー名]を指定するコマンドを
* 実行してください。解除などの際にタイマー名を指定する必要があるためです。
*
* C_SET_SWITCH_NAMED_TIMER [タイマー名] [分] [スイッチID] [ループ]
* 指定例(ゲーム内時間で30分経過後する度にスイッチ[10]をONにする)
* C_SET_SWITCH_NAMED_TIMER timer 30 10 ON
*
* C_SET_SELF_SWITCH_NAMED_TIMER [タイマー名] [分] [セルフスイッチ種類] [ループ]
* 指定例(ゲーム内時間で3時間過後にセルフスイッチ[B](※)をONにする)
* C_SET_SELF_SWITCH_NAMED_TIMER timer 180 B OFF
* ※対象イベントはプラグインコマンドを実行したイベントです。
*
* 解除、停止、再開のコマンドは以下の通りです。
* C_CLEAR_TIMER timer # タイマー名「timer」を解除します。
* C_STOP_TIMER timer # タイマー名「timer」を一時停止します。
* C_START_TIMER timer # タイマー名「timer」を再開します。
*
* 時間ではなく時刻指定でスイッチ操作できるアラーム機能です。
* [年月時分]は、「YYYYMMDDHHMM」形式で指定してください。
* 解除はタイマー用のコマンドを使います。
* C_SET_SWITCH_ALARM [年月時分] [スイッチID] [インターバル]
* C_SET_SELF_SWITCH_ALARM [年月時分] [セルフスイッチ種類] [インターバル]
* C_SET_SWITCH_NAMED_ALARM [アラーム名] [年月時分] [スイッチID] [インターバル]
* C_SET_SELF_SWITCH_NAMED_ALARM [アラーム名] [年月時分] [セルフスイッチ種類] [インターバル]
*
* 指定例(ゲーム内時間で2019/10/22 15:00を過ぎるとセルフスイッチ[B]をONにする)
* C_SET_SELF_SWITCH_ALARM 201910221500 B
*
* インターバルを指定した場合、スイッチがONになった後も指定した期間が経過すると
* 再度、スイッチがONになるようになります。単位は分ですが計算式が使えます。
*
* 指定例(ゲーム内時間で2019/10/22 15:00を過ぎるとセルフスイッチ[B]をONにする。
* その後、1日経過ごとに再度セルフスイッチ[B]をONにする)
* C_SET_SELF_SWITCH_ALARM 201910221500 B 24*60
*
* メモ欄詳細
* タイトルセットおよびマップのメモ欄に以下を入力すると、
* 一時的に天候と色調変化を自動で無効化できます。
* 屋内マップやイベントシーンなどで一時的に無効化したい場合に利用できます。
* 設定はマップのメモ欄が優先されます。
*
* <C_Tint:OFF> # 色調の変更を一時的に無効化します。
* <C_色調:OFF> # 同上
* <C_Weather:OFF> # 天候を一時的に無効化します。
* <C_天候:OFF> # 同上
* <C_Snow:ON> # 天候を雪に設定します。
* <C_雪:ON> # 同上
*
* イベント実行中にも時間経過するかどうかをイベントごとに設定できます。
* この設定はパラメータの設定よりも優先されます。
* イベントのメモ欄に以下を入力してください。
* <C_時間経過:ON> # イベント実行中に時間経過します。(ON/OFF)
* <C_NoStop:ON> # 同上
*
* 高度な設定
* ソースコード中の「ユーザ書き換え領域」を参照すると以下を変更できます。
* 時間帯の情報(朝が何時から何時まで等)
* 時間帯ごとの色調(ただし、悪天候の場合は補正が掛かります)
*
* 利用規約:
* 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
* についても制限はありません。
* このプラグインはもうあなたのものです。
*/
/**
* ゲーム内時間を扱うゲームオブジェクトです。
* @constructor
*/
function Game_Chronus() {
this.initialize.apply(this, arguments);
}
/**
* ゲーム内タイマーを扱うゲームオブジェクトです。
* @constructor
*/
function Game_ChronusTimer() {
this.initialize.apply(this, arguments);
}
/**
* 時計画像を扱うスプライトです。
* @constructor
*/
function Sprite_Chronicle_Clock() {
this.initialize.apply(this, arguments);
}
/**
* ゲーム内時間を描画するウィンドウです。
* @constructor
*/
function Window_Chronus() {
this.initialize.apply(this, arguments);
}
(function() {
'use strict';
//=============================================================================
// ユーザ書き換え領域 - 開始 -
//=============================================================================
var settings = {
/* timeZone:時間帯 */
timeZone: [
/* name:時間帯名称 start:開始時刻 end:終了時刻 timeId:時間帯ID */
{name: '深夜', start: 0, end: 4, timeId: 0},
{name: '早朝', start: 5, end: 6, timeId: 1},
{name: '朝', start: 7, end: 11, timeId: 2},
{name: '昼', start: 12, end: 16, timeId: 3},
{name: '夕方', start: 17, end: 18, timeId: 4},
{name: '夜', start: 19, end: 21, timeId: 5},
{name: '深夜', start: 22, end: 24, timeId: 0}
],
/* timeTone:時間帯ごとの色調 */
timeTone: [
/* timeId:時間帯ID value:色調[赤(-255...255),緑(-255...255),青(-255...255),グレー(0...255)] */
{timeId: 0, value: [-102, -102, -68, 102]},
{timeId: 1, value: [-68, -68, 0, 0]},
{timeId: 2, value: [0, 0, 0, 0]},
{timeId: 3, value: [34, 34, 34, 0]},
{timeId: 4, value: [68, -34, -34, 0]},
{timeId: 5, value: [-68, -68, 0, 68]}
]
};
//=============================================================================
// ユーザ書き換え領域 - 終了 -
//=============================================================================
var pluginName = 'Chronus';
var metaTagPrefix = 'C_';
var getParamString = function(paramNames) {
var value = getParamOther(paramNames);
return value === null ? '' : value;
};
var getParamNumber = function(paramNames, min, max) {
var value = getParamOther(paramNames);
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return (parseInt(value, 10) || 0).clamp(min, max);
};
var getParamOther = function(paramNames) {
if (!Array.isArray(paramNames)) paramNames = [paramNames];
for (var i = 0; i < paramNames.length; i++) {
var name = PluginManager.parameters(pluginName)[paramNames[i]];
if (name) return name;
}
return null;
};
var getParamBoolean = function(paramNames) {
var value = (getParamOther(paramNames) || '').toUpperCase();
return value === 'ON' || value === 'TRUE';
};
var isParamExist = function(paramNames) {
return getParamOther(paramNames) !== null;
};
var getParamArrayString = function(paramNames) {
var values = getParamString(paramNames).split(',');
for (var i = 0; i < values.length; i++) values[i] = values[i].trim();
return values;
};
var getParamArrayNumber = function(paramNames, min, max) {
var values = getParamArrayString(paramNames);
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
for (var i = 0; i < values.length; i++) values[i] = (parseInt(values[i], 10) || 0).clamp(min, max);
return values;
};
var getCommandName = function(command) {
return (command || '').toUpperCase();
};
var getArgNumber = function(arg, min, max) {
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return parseIntStrict(convertEscapeCharacters(arg)).clamp(min, max);
};
var parseIntStrict = function(value, errorMessage) {
var result = parseInt(value, 10);
if (isNaN(result)) throw Error('指定した値[' + value + ']が数値ではありません。' + errorMessage);
return result;
};
var convertEscapeCharacters = function(text) {
if (text == null) text = '';
var window = SceneManager._scene._windowLayer.children[0];
return window ? window.convertEscapeCharacters(text) : text;
};
var getArgBoolean = function(arg) {
return (arg || '').toUpperCase() === 'ON' || (arg || '').toUpperCase() === 'TRUE';
};
var getMetaValue = function(object, name) {
var metaTagName = metaTagPrefix + (name ? name : '');
return object.meta.hasOwnProperty(metaTagName) ? object.meta[metaTagName] : undefined;
};
var getMetaValues = function(object, names) {
if (!Array.isArray(names)) return getMetaValue(object, names);
for (var i = 0, n = names.length; i < n; i++) {
var value = getMetaValue(object, names[i]);
if (value !== undefined) return value;
}
return undefined;
};
var _DataManager_extractSaveContents = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
_DataManager_extractSaveContents.apply(this, arguments);
$gameSystem.onLoad();
};
//=============================================================================
// パラメータの取得と整形
//=============================================================================
var paramAutoAddInterval = getParamNumber('自然時間加算間隔', 1) || 60;
var paramCalendarFontSize = getParamNumber('カレンダーフォントサイズ', 0);
var paramCalendarOpacity = getParamNumber('カレンダー不透明度', 0);
var paramCalendarPadding = getParamNumber('カレンダー余白', 8);
var paramClockBaseFile = getParamString('文字盤画像ファイル');
var paramMinutesHandFile = getParamString('長針画像ファイル');
var paramHourHandFile = getParamString('短針画像ファイル');
var paramCalendarFrameHidden = getParamBoolean('カレンダー枠の非表示');
var paramCalendarLineSpacing = getParamNumber('日時フォーマット行間', 0);
var paramCalendarHidden = getParamBoolean('カレンダーの非表示');
//=============================================================================
// Game_Interpreter
// プラグインコマンド[C_ADD_TIME]などを追加定義します。
//=============================================================================
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.apply(this, arguments);
var commandPrefix = new RegExp('^' + metaTagPrefix);
if (!command.match(commandPrefix)) return;
this.pluginCommandChronus(command.replace(commandPrefix, ''), args);
};
Game_Interpreter.prototype.pluginCommandChronus = function(command, args) {
switch (getCommandName(command)) {
case 'ADD_TIME' :
$gameSystem.chronus().addTime(getArgNumber(args[0], 0, 99999));
break;
case 'ADD_DAY' :
$gameSystem.chronus().addDay(getArgNumber(args[0], 0, 99999));
break;
case 'SET_TIME' :
var hour = getArgNumber(args[0], 0, 23);
var minute = getArgNumber(args[1], 0, 59);
$gameSystem.chronus().setTime(hour, minute);
break;
case 'SET_DAY' :
var year = getArgNumber(args[0], 1, 5000);
var month = getArgNumber(args[1], 1, $gameSystem.chronus().getMonthOfYear());
var day = getArgNumber(args[2], 1, $gameSystem.chronus().getDaysOfMonth(month));
$gameSystem.chronus().setDay(year, month, day);
break;
case 'STOP' :
$gameSystem.chronus().stop();
break;
case 'START' :
$gameSystem.chronus().start();
break;
case 'SHOW' :
$gameSystem.chronus().showCalendar();
break;
case 'HIDE' :
$gameSystem.chronus().hideCalendar();
break;
case 'DISABLE_TINT':
$gameSystem.chronus().disableTint();
break;
case 'ENABLE_TINT':
$gameSystem.chronus().enableTint();
break;
case 'DISABLE_WEATHER':
$gameSystem.chronus().disableWeather();
break;
case 'ENABLE_WEATHER':
$gameSystem.chronus().enableWeather();
break;
case 'SET_SNOW_LAND':
$gameSystem.chronus().setSnowLand();
break;
case 'RESET_SNOW_LAND':
$gameSystem.chronus().resetSnowLand();
break;
case 'SET_SPEED':
$gameSystem.chronus().setTimeAutoAdd(getArgNumber(args[0], 0, 99));
break;
case 'SHOW_CLOCK':
$gameSystem.chronus().showClock();
break;
case 'HIDE_CLOCK':
$gameSystem.chronus().hideClock();
break;
case 'SET_TIME_REAL':
$gameSystem.chronus().setTimeReal();
break;
case 'SET_TIME_VIRTUAL':
$gameSystem.chronus().setTimeVirtual();
break;
case 'SET_RAINY_PERCENT':
$gameSystem.chronus().setRainyPercent(getArgNumber(args[0], 0, 100));
break;
case 'SET_SWITCH_TIMER':
this.setSwitchTimer(args, false);
break;
case 'SET_SWITCH_NAMED_TIMER':
this.setSwitchTimer(args, true);
break;
case 'SET_SELF_SWITCH_TIMER':
this.setSwitchTimer(args, false, true);
break;
case 'SET_SELF_SWITCH_NAMED_TIMER':
this.setSwitchTimer(args, true, true);
break;
case 'SET_SWITCH_ALARM':
this.setSwitchAlarm(args, false);
break;
case 'SET_SWITCH_NAMED_ALARM':
this.setSwitchAlarm(args, true);
break;
case 'SET_SELF_SWITCH_ALARM':
this.setSwitchAlarm(args, false, true);
break;
case 'SET_SELF_SWITCH_NAMED_ALARM':
this.setSwitchAlarm(args, true, true);
break;
case 'STOP_TIMER':
$gameSystem.chronus().stopTimer(convertEscapeCharacters(args[0]));
break;
case 'START_TIMER':
$gameSystem.chronus().startTimer(convertEscapeCharacters(args[0]));
break;
case 'CLEAR_TIMER':
$gameSystem.chronus().clearTimer(convertEscapeCharacters(args[0]));
break;
case 'INIT_TOTAL_TIME':
$gameSystem.chronus().initTotalTime();
break;
case 'SET_CLOCK_BASE':
$gameSystem.chronus().setClockBaseFile(convertEscapeCharacters(args[0]));
break;
case 'SET_MINUTE_HAND':
$gameSystem.chronus().setMinuteHandFile(convertEscapeCharacters(args[0]));
break;
case 'SET_HOUR_HAND':
$gameSystem.chronus().setHourHandFile(convertEscapeCharacters(args[0]));
break;
}
};
Game_Interpreter.prototype.setSwitchTimer = function(args, named, selfSwitch) {
var timerName = named ? convertEscapeCharacters(args.shift()) : null;
var timeout = getArgNumber(args.shift(), 0);
var switchKey = this.getSwitchKey(args.shift(), selfSwitch);
var loop = getArgBoolean(args.shift());
$gameSystem.chronus().makeTimer(timerName, timeout, switchKey, loop);
};
Game_Interpreter.prototype.setSwitchAlarm = function(args, named, selfSwitch) {
var timerName = named ? convertEscapeCharacters(args.shift()) : null;
var timeout = getArgNumber(args.shift(), 0);
var switchKey = this.getSwitchKey(args.shift(), selfSwitch);
var interval = args.shift();
if (interval) {
interval = eval(convertEscapeCharacters(interval));
}
$gameSystem.chronus().makeAlarm(timerName, timeout, switchKey, interval);
};
Game_Interpreter.prototype.getSwitchKey = function(arg, selfSwitch) {
return selfSwitch ? [$gameMap.mapId(), this.eventId(), convertEscapeCharacters(arg).toUpperCase()] : getArgNumber(arg);
};
var _Game_Interpreter_command236 = Game_Interpreter.prototype.command236;
Game_Interpreter.prototype.command236 = function() {
var result = _Game_Interpreter_command236.call(this);
if (!$gameParty.inBattle()) {
var chronus = $gameSystem.chronus();
chronus.setWeatherType(Game_Chronus.weatherTypes.indexOf(this._params[0]));
chronus.setWeatherPower(this._params[1]);
chronus.refreshTint(true);
chronus.forceSetBatWeatherLevel(this._params[0], this._params[1]);
}
return result;
};
var _Game_Interpreter_command282 = Game_Interpreter.prototype.command282;
Game_Interpreter.prototype.command282 = function() {
var result = _Game_Interpreter_command282.apply(this, arguments);
if (!$gameParty.inBattle()) {
var chronus = $gameSystem.chronus();
chronus.refreshTint(true);
chronus.refreshWeather(true);
}
return result;
};
//=============================================================================
// Game_System
// ゲーム内時間を扱うクラス「Game_Chronus」を追加定義します。
//=============================================================================
var _Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
_Game_System_initialize.call(this);
this._chronus = new Game_Chronus();
};
Game_System.prototype.chronus = function() {
return this._chronus;
};
Game_System.prototype.onBattleEnd = function() {
this.chronus().onBattleEnd();
};
var _Game_System_onLoad = Game_System.prototype.onLoad;
Game_System.prototype.onLoad = function() {
if (_Game_System_onLoad) _Game_System_onLoad.apply(this, arguments);
if (!this.chronus()) this._chronus = new Game_Chronus();
this._chronus.onLoad();
};
//=============================================================================
// Game_Map
// マップ及びタイルセットから、色調変化無効フラグを取得します。
//=============================================================================
Game_Map.prototype.isDisableTint = function() {
return !this.isChronicleMetaInfo(['Tint', '色調'], true);
};
Game_Map.prototype.isDisableWeather = function() {
return !this.isChronicleMetaInfo(['Weather', '天候'], true);
};
Game_Map.prototype.isSnowLand = function() {
return this.isChronicleMetaInfo(['Snow', '雪'], false);
};
Game_Map.prototype.isChronicleMetaInfo = function(tagNames, defaultValue) {
if (DataManager.isBattleTest() || DataManager.isEventTest()) return false;
var metaValue1 = getMetaValues($dataMap, tagNames);
if (metaValue1 !== undefined) {
return getArgBoolean(metaValue1);
}
var tileset = $gamePlayer.isTransferring() ? $dataTilesets[$dataMap.tilesetId] : this.tileset();
var metaValue2 = getMetaValues(tileset, tagNames);
if (metaValue2 !== undefined) {
return getArgBoolean(metaValue2);
}
return defaultValue;
};
Game_Map.prototype.isTimeStopEventRunning = function() {
if (this.isEventRunning()) {
if (!this._isTimeStopEventRunning) this._isTimeStopEventRunning = this.getTimeStopEventRunning();
} else {
this._isTimeStopEventRunning = false;
}
return this._isTimeStopEventRunning;
};
Game_Map.prototype.getTimeStopEventRunning = function() {
var event = this.event(this._interpreter.eventId());
if (!event) return false;
var stop = getMetaValues(event.event(), ['時間経過', 'NoStop']);
if (stop) {
return !getArgBoolean(stop);
} else {
return !getParamBoolean('イベント中時間経過');
}
};
//=============================================================================
// Game_Player
// 場所移動時の時間経過を追加定義します。
//=============================================================================
var _Game_Player_performTransfer = Game_Player.prototype.performTransfer;
Game_Player.prototype.performTransfer = function() {
var realTransfer = this._newMapId !== $gameMap.mapId() && $gameMap.mapId() > 0;
$gameSystem.chronus().transfer(realTransfer);
_Game_Player_performTransfer.call(this);
};
//=============================================================================
// Scene_Map
// Game_Chronusの更新を追加定義します。
//=============================================================================
var _Scene_Map_onMapLoaded = Scene_Map.prototype.onMapLoaded;
Scene_Map.prototype.onMapLoaded = function() {
$gameSystem.chronus().onMapLoaded();
_Scene_Map_onMapLoaded.apply(this, arguments);
};
var _Scene_Map_updateMain = Scene_Map.prototype.updateMain;
Scene_Map.prototype.updateMain = function() {
_Scene_Map_updateMain.apply(this, arguments);
$gameSystem.chronus().update();
};
var _Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
Scene_Map.prototype.createAllWindows = function() {
this.createChronusWindow();
_Scene_Map_createAllWindows.apply(this, arguments);
};
Scene_Map.prototype.createChronusWindow = function() {
this._chronusWindow = new Window_Chronus();
this.addWindow(this._chronusWindow);
};
//=============================================================================
// BattleManager
// 戦闘終了時のゲーム内時間経過処理を追加定義します。
//=============================================================================
var _BattleManager_endBattle = BattleManager.endBattle;
BattleManager.endBattle = function(result) {
$gameSystem.onBattleEnd();
_BattleManager_endBattle.call(this, result);
};
//=============================================================================
// Window_Chronus
// ゲーム内時間情報を描画するウィンドウです。
//=============================================================================
Window_Chronus.prototype = Object.create(Window_Base.prototype);
Window_Chronus.prototype.constructor = Window_Chronus;
var _Window_Chronus_initialize = Window_Chronus.prototype.initialize;
Window_Chronus.prototype.initialize = function() {
_Window_Chronus_initialize.call(this, 0, 0, this.getDefaultWidth(), this.getDefaultHeight());
this.createContents();
this.x = getParamNumber('カレンダー表示X座標');
this.y = getParamNumber('カレンダー表示Y座標');
if (paramCalendarFrameHidden) {
this.opacity = 0;
}
this.refresh();
};
Window_Chronus.prototype.getDefaultWidth = function() {
var bitmap = new Bitmap();
bitmap.fontSize = this.standardFontSize();
var width1 = bitmap.measureTextWidth(this.getDateFormat(1));
var width2 = bitmap.measureTextWidth(this.getDateFormat(2));
return Math.max(width1, width2) + this.standardPadding() * 2;
};
Window_Chronus.prototype.getDefaultHeight = function() {
return this.standardFontSize() * (this.getDateFormat(2) ? 2 : 1) + this.standardPadding() * 2 + paramCalendarLineSpacing;
};
Window_Chronus.prototype.standardPadding = function() {
return paramCalendarPadding;
};
Window_Chronus.prototype.standardBackOpacity = function() {
return paramCalendarOpacity;
};
Window_Chronus.prototype.lineHeight = function() {
return this.standardFontSize();
};
var _Window_Chronus_standardFontSize = Window_Chronus.prototype.standardFontSize;
Window_Chronus.prototype.standardFontSize = function() {
return paramCalendarFontSize || _Window_Chronus_standardFontSize.apply(this, arguments);
};
Window_Chronus.prototype.refresh = function() {
this.contents.clear();
var width = this.contents.width;
var height = this.lineHeight();
this.contents.drawText(this.getDateFormat(1), 0, 0, width, height, 'left');
this.contents.drawText(this.getDateFormat(2), 0, height + paramCalendarLineSpacing, width, height, 'left');
};
Window_Chronus.prototype.update = function() {
if (this.chronus().isShowingCalendar()) {
this.show();
if (this.chronus().isNeedRefresh()) this.refresh();
} else {
this.hide();
}
};
Window_Chronus.prototype.chronus = function() {
return $gameSystem.chronus();
};
Window_Chronus.prototype.getDateFormat = function(lineNumber) {
return this.chronus().getDateFormat(lineNumber);
};
//=============================================================================
// Sprite_Chronicle_Clock
// アナログ時計表示スプライトクラスです。
//=============================================================================
Sprite_Chronicle_Clock.prototype = Object.create(Sprite.prototype);
Sprite_Chronicle_Clock.prototype.constructor = Sprite_Chronicle_Clock;
var _Sprite_Chronicle_Clock_initialize = Sprite_Chronicle_Clock.prototype.initialize;
Sprite_Chronicle_Clock.prototype.initialize = function() {
_Sprite_Chronicle_Clock_initialize.apply(this, arguments);
this.x = getParamNumber('時計X座標');
this.y = getParamNumber('時計Y座標');
this.anchor.x = 0.5;
this.anchor.y = 0.5;
this.bitmap = ImageManager.loadPicture(this.chronus().getClockBaseFile());
this.createHourHandSprite();
this.createMinuteHandSprite();
};
Sprite_Chronicle_Clock.prototype.createHourHandSprite = function() {
var handName = this.chronus().getHourHandFile();
var handSprite = new Sprite();
handSprite.anchor.x = 0.5;
handSprite.anchor.y = 0.5;
handSprite.bitmap = handName ? ImageManager.loadPicture(handName) : ImageManager.loadEmptyBitmap();
handSprite.visible = !!handName;
this.hourHandSprite = handSprite;
this.addChild(this.hourHandSprite);
};
Sprite_Chronicle_Clock.prototype.createMinuteHandSprite = function() {
var handName = this.chronus().getMinuteHandFile();
var handSprite = new Sprite();
handSprite.anchor.x = 0.5;
handSprite.anchor.y = 0.5;
handSprite.bitmap = handName ? ImageManager.loadPicture(handName) : ImageManager.loadEmptyBitmap();
handSprite.visible = !!handName;
this.minuteHandSprite = handSprite;
this.addChild(this.minuteHandSprite);
};
Sprite_Chronicle_Clock.prototype.update = function() {
this.visible = this.chronus().isShowingClock();
if (this.visible) {
this.updateHourHand();
this.updateMinuteHand();
}
};
Sprite_Chronicle_Clock.prototype.updateHourHand = function() {
if (!this.hourHandSprite.visible) return;
this.hourHandSprite.rotation = this.chronus().getRotationHourHand();
};
Sprite_Chronicle_Clock.prototype.updateMinuteHand = function() {
if (!this.minuteHandSprite.visible) return;