-
Notifications
You must be signed in to change notification settings - Fork 0
/
NRP_BattleTargetCursor.js
1690 lines (1511 loc) · 52.6 KB
/
NRP_BattleTargetCursor.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
//=============================================================================
// NRP_BattleTargetCursor.js
//=============================================================================
/*:
* @target MV MZ
* @plugindesc v1.042 Display the cursor when selecting a target in battle.
* @author Takeshi Sunagawa (http://newrpg.seesaa.net/)
* @url http://newrpg.seesaa.net/article/482370647.html
*
* @help The cursor is displayed during battle
* and when the target is selected.
* Various adjustments can be made accordingly.
*
* By default, it is designed for side view.
* It can also be used in front view by adjusting the settings.
*
* There are no advanced functions such as referring
* to the positional relationship of the target
* when the directional key is pressed
* to determine the cursor's transition destination.
* Pressing a key simply moves the cursor
* to the target of the previous or next ID.
*
* ■Usage
* Just introducing it will change the behavior.
* The cursor image is not set by default,
* so only the target name is displayed.
*
* A sample cursor is available on the introduction page.
* Please refer to it for reference.
*
* After that, you can adjust the plugin parameters as you wish.
*
* Note that most of the actor's parameters can be left blank.
* In that case, the parameters of the enemy side
* will be automatically referenced.
* ※The cursor image and X-coordinate adjustments
* will be flipped left and right.
*
* [Terms]
* There are no restrictions.
* Modification, redistribution freedom, commercial availability,
* and rights indication are also optional.
* The author is not responsible,
* but will deal with defects to the extent possible.
*
* @param <EnemySide>
*
* @param HideEnemyNameList
* @parent <EnemySide>
* @type boolean
* @default true
* @desc Hides the default enemy name list.
*
* @param SwitchEnemyUpDown
* @parent <EnemySide>
* @type boolean
* @default true
* @desc Enables to switch the selection of enemies up&down. Only available when HideEnemyNameList is on.
*
* @param SwitchEnemyLeftRight
* @parent <EnemySide>
* @type select
* @option Invalid @value
* @option Left to Next @value left
* @option Right to Next @value right
* @default left
* @desc Enables to switch the selection of enemies left&right. Only available when HideEnemyNameList is on.
*
* @param EnemyTargetCursor
* @parent <EnemySide>
* @type file
* @dir img/pictures
* @desc Specify the cursor image when targeting an enemy.
* The image should be placed in the picture folder.
*
* @param EnemyCursorPosition
* @parent <EnemySide>
* @type select
* @option Foot @value foot
* @option Center @value center
* @option Head @value head
* @default center
* @desc The reference point for the enemy cursor image.
* The name window will also be based on this.
*
* @param EnemyCursorAdjustX
* @parent <EnemySide>
* @type number
* @min -999 @max 999
* @default 60
* @desc Adjusts the X coordinate of the cursor image when targeting an enemy.
*
* @param EnemyCursorAdjustY
* @parent <EnemySide>
* @type number
* @min -999 @max 999
* @default 0
* @desc Adjusts the Y coordinate of the cursor image when targeting an enemy.
*
* @param ShowTargetEnemyName
* @parent <EnemySide>
* @type boolean
* @default true
* @desc Displays the name of the currently selected enemy.
*
* @param EnemyNameWindowHeight
* @parent <EnemySide>
* @type number
* @default 72
* @desc The height of the enemy name window.
* Default value is 72.
*
* @param EnemyNameWindowOpacity
* @parent <EnemySide>
* @type number
* @default 255
* @desc The opacity of the enemy name window (0~255).
*
* @param EnemyNameWindowAdjustX
* @parent <EnemySide>
* @type number
* @min -999 @max 999
* @default 0
* @desc Adjusts the X coordinate of the enemy name window.
*
* @param EnemyNameWindowAdjustY
* @parent <EnemySide>
* @type number
* @min -999 @max 999
* @default 60
* @desc Adjusts the Y coordinate of the enemy name window.
*
* @param EnemyNameFontSize
* @parent <EnemySide>
* @type number
* @desc The font size of the enemy name.
* If blank, the system setting is used.
*
* @param EnemyNameTextAdjustY
* @parent <EnemySide>
* @type number
* @min -999 @max 999
* @default 0
* @desc Adjusts the Y coordinate of the text displayed in the enemy name window.
*
* @param <ActorSide>
*
* @param SwitchActorUpDown
* @parent <ActorSide>
* @type boolean
* @default true
* @desc Enables to switch the selection of actors up&down.
*
* @param SwitchActorLeftRight
* @parent <ActorSide>
* @type boolean
* @default true
* @desc Enables to switch the selection of actors left&right.
* This is the standard behavior of RPG Maker MZ.
*
* @param ActorTargetCursor
* @parent <ActorSide>
* @type file
* @dir img/pictures
* @desc Specify the cursor image when targeting an actor.
* If blank, it will flip the enemy's one left or right.
*
* @param ActorCursorPosition
* @parent <ActorSide>
* @type select
* @option Foot @value foot
* @option Center @value center
* @option Head @value head
* @desc The reference point for the actor cursor image.
* If blank, use the same value as the enemy.
*
* @param ActorCursorAdjustX
* @parent <ActorSide>
* @type number
* @min -999 @max 999
* @desc Adjusts the X coordinate of the cursor when targeting an actor.
* If blank, use the enemy's value flipped left or right.
*
* @param ActorCursorAdjustY
* @parent <ActorSide>
* @type number
* @min -999 @max 999
* @desc Adjusts the Y coordinate of the cursor when targeting an actor.
* If blank, use the same value as the enemy.
*
* @param ShowTargetActorName
* @parent <ActorSide>
* @type boolean
* @desc Displays the name of the currently selected actor.
* If blank, use the same value as the enemy.
*
* @param ActorNameWindowHeight
* @parent <ActorSide>
* @type number
* @desc The height of the actor name window.
* If blank, use the same value as the enemy.
*
* @param ActorNameWindowOpacity
* @parent <ActorSide>
* @type number
* @desc The opacity of the actor name window (0~255).
* If blank, use the same value as the enemy.
*
* @param ActorNameWindowAdjustX
* @parent <ActorSide>
* @type number
* @min -999 @max 999
* @desc Adjusts the X coordinate of the enemy name window.
* If blank, use the enemy's value flipped left or right.
*
* @param ActorNameWindowAdjustY
* @parent <ActorSide>
* @type number
* @min -999 @max 999
* @desc Adjusts the Y coordinate of the enemy name window.
* If blank, use the same value as the enemy.
*
* @param ActorNameFontSize
* @parent <ActorSide>
* @type number
* @desc The font size of the actor name.
* If blank, use the same value as the enemy.
*
* @param ActorNameTextAdjustY
* @parent <ActorSide>
* @type number
* @min -999 @max 999
* @desc Adjusts the Y coordinate of the text in the enemy name window. If blank, use the same value as the enemy.
*
* @param <Common>
*
* @param LeftLimitX
* @parent <Common>
* @type string
* @default 0
* @desc The X coordinate that is the left limit of the cursor display. Default: left edge of the screen (0).
*
* @param RightLimitX
* @parent <Common>
* @type string
* @default Graphics.width
* @desc The X coordinate that is the right limit of the cursor display. Default: right end of the screen (Graphics.width).
*
* @param UpLimitY
* @parent <Common>
* @type string
* @default 0
* @desc The Y coordinate that is the upper limit of the cursor display. Default: upper edge of the screen (0).
*
* @param DownLimitY
* @parent <Common>
* @type string
* @default Graphics.height
* @desc The Y coordinate that is the lower limit of the cursor display. Default: Bottom edge of the screen (Graphics.height).
*
* @param UpdateCursorPosition
* @parent <Common>
* @type boolean
* @default false
* @desc Updates the cursor position every frame. For use with battle systems where the position changes in real time.
*/
/*:ja
* @target MV MZ
* @plugindesc v1.042 戦闘時、選択中の対象にカーソルを表示
* @author 砂川赳 (http://newrpg.seesaa.net/)
* @url http://newrpg.seesaa.net/article/482370647.html
*
* @help 戦闘時、選択中の対象にカーソルを表示します。
* それに伴い、様々な調整が可能です。
*
* 初期値ではサイドビューを想定していますが、
* 設定を調整すれば、フロントビューでも使えます。
*
* 方向キーを押した時に対象の位置関係を参照して、
* カーソルの遷移先を判定するような高度な機能はありません。
* キーを押すと単純に前後のIDの対象に移るだけです。
*
* ■使用法
* 導入するだけで挙動が変わります。
* カーソル画像は初期状態では設定されていませんので、
* 対象の名前表示だけが行われます。
*
* 紹介ページにカーソルのサンプルを用意しています。
* ご参考にしていただければ。
*
* 後はプラグインパラメータを好きなように調整してください。
*
* なお、アクター側のパラメータの大半は空白でも構いません。
* その場合は、自動的に敵側のパラメータが参照されます。
* ※カーソル画像およびX座標の調整分は左右反転されます。
*
* ■利用規約
* 特に制約はありません。
* 改変、再配布自由、商用可、権利表示も任意です。
* 作者は責任を負いませんが、不具合については可能な範囲で対応します。
*
* @param <EnemySide>
* @text <敵側>
*
* @param HideEnemyNameList
* @parent <EnemySide>
* @text 敵名リストを非表示
* @type boolean
* @default true
* @desc デフォルトの敵名リストを非表示にします。
*
* @param SwitchEnemyUpDown
* @parent <EnemySide>
* @text 敵の上下切替
* @type boolean
* @default true
* @desc 敵の選択を上下で切替できるようにします。
* 『敵名リストを非表示』がオンの場合のみ有効です。
*
* @param SwitchEnemyLeftRight
* @parent <EnemySide>
* @text 敵の左右切替
* @type select
* @option 無効 @value
* @option 左で次へ @value left
* @option 右で次へ @value right
* @default left
* @desc 敵の選択を左右で切替できるようにします。
* 『敵名リストを非表示』がオンの場合のみ有効です。
*
* @param EnemyTargetCursor
* @parent <EnemySide>
* @text 敵カーソルの画像
* @type file
* @dir img/pictures
* @desc 敵を対象にした際のカーソル画像を指定します。
* 画像はピクチャーフォルダに配置してください。
*
* @param EnemyCursorPosition
* @parent <EnemySide>
* @text 敵のカーソル基準点
* @type select
* @option 足元 @value foot
* @option 中央 @value center
* @option 頭上 @value head
* @default center
* @desc 敵を対象にした際のカーソル画像の上下の基準点です。
* 敵名ウィンドウもこれを基準にします。
*
* @param EnemyCursorAdjustX
* @parent <EnemySide>
* @text 敵のカーソル調整X
* @type number
* @min -999 @max 999
* @default 60
* @desc 敵を対象にした際のカーソル画像のX座標を調整します。
*
* @param EnemyCursorAdjustY
* @parent <EnemySide>
* @text 敵のカーソル調整Y
* @type number
* @min -999 @max 999
* @default 0
* @desc 敵を対象にした際のカーソル画像のY座標を調整します。
*
* @param ShowTargetEnemyName
* @parent <EnemySide>
* @text 選択中の敵名を表示
* @type boolean
* @default true
* @desc 選択中の敵の名前を表示します。
*
* @param EnemyNameWindowHeight
* @parent <EnemySide>
* @text 敵名ウィンドウの縦幅
* @type number
* @default 72
* @desc 敵名ウィンドウの縦幅です。
* 初期値は72です。
*
* @param EnemyNameWindowOpacity
* @parent <EnemySide>
* @text 敵名ウィンドウの不透明度
* @type number
* @default 255
* @desc 敵名ウィンドウの不透明度(0~255)です。
*
* @param EnemyNameWindowAdjustX
* @parent <EnemySide>
* @text 敵名ウィンドウの調整X
* @type number
* @min -999 @max 999
* @default 0
* @desc 敵名ウィンドウのX座標を調整します。
*
* @param EnemyNameWindowAdjustY
* @parent <EnemySide>
* @text 敵名ウィンドウの調整Y
* @type number
* @min -999 @max 999
* @default 60
* @desc 敵名ウィンドウのY座標を調整します。
*
* @param EnemyNameFontSize
* @parent <EnemySide>
* @text 敵名フォントサイズ
* @type number
* @desc 敵名のフォントサイズです。
* 空欄ならシステムの設定値を使用します。
*
* @param EnemyNameTextAdjustY
* @parent <EnemySide>
* @text 敵名テキストの調整Y
* @type number
* @min -999 @max 999
* @default 0
* @desc 敵名ウィンドウに表示されるテキストのY座標を調整します。
*
* @param <ActorSide>
* @text <アクター側>
*
* @param SwitchActorUpDown
* @parent <ActorSide>
* @text アクターの上下切替
* @type boolean
* @default true
* @desc アクターの選択を上下で切替できるようにします。
*
* @param SwitchActorLeftRight
* @parent <ActorSide>
* @text アクターの左右切替
* @type boolean
* @default true
* @desc アクターの選択を左右で切替できるようにします。
* こちらはMZの標準動作です。
*
* @param ActorTargetCursor
* @parent <ActorSide>
* @text アクターカーソルの画像
* @type file
* @dir img/pictures
* @desc アクターを対象にした際のカーソル画像を指定します。
* 空欄なら敵のものを左右反転します。
*
* @param ActorCursorPosition
* @parent <ActorSide>
* @text アクターカーソル基準点
* @type select
* @option 足元 @value foot
* @option 中央 @value center
* @option 頭上 @value head
* @desc アクターを対象にした際のカーソル画像の上下の基準点です。
* 空欄なら敵と同じ値を使用します。
*
* @param ActorCursorAdjustX
* @parent <ActorSide>
* @text アクターカーソル調整X
* @type number
* @min -999 @max 999
* @desc アクターを対象にした際のカーソル画像のX座標を調整します。
* 空欄なら敵の値を左右反転して使用します。
*
* @param ActorCursorAdjustY
* @parent <ActorSide>
* @text アクターカーソル調整Y
* @type number
* @min -999 @max 999
* @desc アクターを対象にした際のカーソル画像のY座標を調整します。
* 空欄なら敵と同じ値を使用します。
*
* @param ShowTargetActorName
* @parent <ActorSide>
* @text 選択中のアクター名を表示
* @type boolean
* @desc 選択中のアクターの名前を表示します。
* 空欄なら敵と同じ値を使用します。
*
* @param ActorNameWindowHeight
* @parent <ActorSide>
* @text アクター名ウィンドウの縦幅
* @type number
* @desc アクター名ウィンドウの縦幅です。
* 空欄なら敵と同じ値を使用します。
*
* @param ActorNameWindowOpacity
* @parent <ActorSide>
* @text アクター名ウィンドウ不透明度
* @type number
* @desc アクター名ウィンドウの不透明度(0~255)です。
* 空欄なら敵と同じ値を使用します。
*
* @param ActorNameWindowAdjustX
* @parent <ActorSide>
* @text アクター名ウィンドウの調整X
* @type number
* @min -999 @max 999
* @desc アクター名ウィンドウのX座標を調整します。
* 空欄なら敵の値を左右反転して使用します。
*
* @param ActorNameWindowAdjustY
* @parent <ActorSide>
* @text アクター名ウィンドウの調整Y
* @type number
* @min -999 @max 999
* @desc アクター名ウィンドウのY座標を調整します。
* 空欄なら敵と同じ値を使用します。
*
* @param ActorNameFontSize
* @parent <ActorSide>
* @text アクター名フォントサイズ
* @type number
* @desc アクター名のフォントサイズです。
* 空欄なら敵と同じ値を使用します。
*
* @param ActorNameTextAdjustY
* @parent <ActorSide>
* @text アクター名テキストの調整Y
* @type number
* @min -999 @max 999
* @desc アクター名ウィンドウに表示されるテキストのY座標を調整します。
* 空欄なら敵と同じ値を使用します。
*
* @param <Common>
* @text <共通設定>
*
* @param LeftLimitX
* @parent <Common>
* @text 左の限界X座標
* @type string
* @default 0
* @desc カーソル表示の左限界となるX座標です。
* 初期値は画面左端(0)
*
* @param RightLimitX
* @parent <Common>
* @text 右の限界X座標
* @type string
* @default Graphics.width
* @desc カーソル表示の右限界となるX座標です。
* 初期値は画面右端(Graphics.width)
*
* @param UpLimitY
* @parent <Common>
* @text 上の限界Y座標
* @type string
* @default 0
* @desc カーソル表示の上限界となるY座標です。
* 初期値は画面上端(0)
*
* @param DownLimitY
* @parent <Common>
* @text 下の限界Y座標
* @type string
* @default Graphics.height
* @desc カーソル表示の下限界となるY座標です。
* 初期値は画面下端(Graphics.height)
*
* @param UpdateCursorPosition
* @parent <Common>
* @text カーソル位置を常時更新
* @type boolean
* @default false
* @desc カーソル位置を毎フレーム更新します。
* リアルタイムで位置が変動する戦闘システムとの併用に。
*/
(function() {
"use strict";
/**
* バージョン互換対応
*/
if (!Array.prototype.find) {
Array.prototype.find = function (predicate) {
if (this === null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
};
}
function toBoolean(val, def) {
// 空白なら初期値を返す
if (val === "" || val === undefined) {
return def;
// 既にboolean型なら、そのまま返す
} else if (typeof val === "boolean") {
return val;
}
// 文字列ならboolean型に変換して返す
return val.toLowerCase() == "true";
}
function toNumber(str, def) {
if (str == undefined || str == "") {
return def;
}
return isNaN(str) ? def : +(str || def);
}
function setDefault(str, def) {
return str ? str : def;
}
function isBlank(str) {
return str === "" || str === undefined || str === null;
}
const parameters = PluginManager.parameters("NRP_BattleTargetCursor");
const pHideEnemyNameList = toBoolean(parameters["HideEnemyNameList"], true);
const pSwitchEnemyUpDown = toBoolean(parameters["SwitchEnemyUpDown"], true);
const pSwitchEnemyLeftRight = setDefault(parameters["SwitchEnemyLeftRight"]);
const pEnemyTargetCursor = parameters["EnemyTargetCursor"];
const pEnemyCursorPosition = parameters["EnemyCursorPosition"];
const pEnemyCursorAdjustX = toNumber(parameters["EnemyCursorAdjustX"], 0);
const pEnemyCursorAdjustY = toNumber(parameters["EnemyCursorAdjustY"], 0);
const pShowTargetEnemyName = toBoolean(parameters["ShowTargetEnemyName"], true);
const pEnemyNameWindowHeight = toNumber(parameters["EnemyNameWindowHeight"], 72);
const pEnemyNameWindowOpacity = toNumber(parameters["EnemyNameWindowOpacity"], 255);
const pEnemyNameWindowAdjustX = toNumber(parameters["EnemyNameWindowAdjustX"], 0);
const pEnemyNameWindowAdjustY = toNumber(parameters["EnemyNameWindowAdjustY"], 0);
const pEnemyNameFontSize = toNumber(parameters["EnemyNameFontSize"]);
const pEnemyNameTextAdjustY = toNumber(parameters["EnemyNameTextAdjustY"], 0);
const pSwitchActorUpDown = toBoolean(parameters["SwitchActorUpDown"], true);
const pSwitchActorLeftRight = toBoolean(parameters["SwitchActorLeftRight"], true);
// 以下Enemyの値をデフォルト値とする。
// ただし、画像およびX座標系は加工するため別途処理。
const pActorTargetCursor = parameters["ActorTargetCursor"];
const pActorCursorPosition = setDefault(parameters["ActorCursorPosition"], pEnemyCursorPosition);
const pActorCursorAdjustX = parameters["ActorCursorAdjustX"];
const pActorCursorAdjustY = toNumber(parameters["ActorCursorAdjustY"], pEnemyCursorAdjustY);
const pShowTargetActorName = toBoolean(parameters["ShowTargetActorName"], pShowTargetEnemyName);
const pActorNameWindowHeight = toNumber(parameters["ActorNameWindowHeight"], pEnemyNameWindowHeight);
const pActorNameWindowOpacity = toNumber(parameters["ActorNameWindowOpacity"], pEnemyNameWindowOpacity);
const pActorNameWindowAdjustX = parameters["ActorNameWindowAdjustX"];
const pActorNameWindowAdjustY = toNumber(parameters["ActorNameWindowAdjustY"], pEnemyNameWindowAdjustY);
const pActorNameFontSize = toNumber(parameters["ActorNameFontSize"], pEnemyNameFontSize);
const pActorNameTextAdjustY = toNumber(parameters["ActorNameTextAdjustY"], pEnemyNameTextAdjustY);
const pLeftLimitX = setDefault(parameters["LeftLimitX"], "0");
const pRightLimitX = setDefault(parameters["RightLimitX"], "Graphics.width");
const pUpLimitY = setDefault(parameters["UpLimitY"], "0");
const pDownLimitY = setDefault(parameters["DownLimitY"], "Graphics.height");
const pUpdateCursorPosition = toBoolean(parameters["UpdateCursorPosition"], false);
// 敵名リストを非表示
if (pHideEnemyNameList) {
/**
* 【上書】最大列数を1に変更
* これにより、上下での切替を実現する。
*/
Window_BattleEnemy.prototype.maxCols = function() {
return 1;
};
/**
* ●NRP_PageWindowとの競合対策
*/
Window_BattleEnemy.prototype.isUsePage = function() {
return false;
};
/**
* ●敵名ウィンドウ表示
*/
const _Window_BattleEnemy_show = Window_BattleEnemy.prototype.show;
Window_BattleEnemy.prototype.show = function() {
_Window_BattleEnemy_show.apply(this, arguments);
// 非表示
// ※機能はそのまま使うのでhideにはしない。
// ※MVで微妙に何かが見えるので位置を-100に設定しておく。
this.move(-100, -100, 0, 0);
};
// MZにしか存在しない関数なので考慮
if (Scene_Battle.prototype.startEnemySelection) {
/**
* ●敵選択開始
*/
const _Scene_Battle_startEnemySelection = Scene_Battle.prototype.startEnemySelection;
Scene_Battle.prototype.startEnemySelection = function() {
// ステータスウィンドウの表示状態を保持する。
// ※通常攻撃時にウィンドウを残しておくため。
const keepVisible = this._statusWindow.visible;
_Scene_Battle_startEnemySelection.apply(this, arguments);
this._statusWindow.visible = keepVisible;
};
}
}
/**
* 戦闘画面用にWindowを追加する。
*/
const _Scene_Battle_prototype_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function() {
_Scene_Battle_prototype_createAllWindows.apply(this, arguments);
//--------------------------------------
// 敵ウィンドウ生成
//--------------------------------------
// MV
if (Utils.RPGMAKER_NAME == "MV") {
this._enemyNameWindow = new Window_BattleEnemyName(0, 0, this._enemyWindow);
// MZ
} else {
// この時点ではサイズ不明なので、とりあえずGraphicsの全領域を確保
// ※確保しておかないと文字が表示できない。
this._enemyNameWindow = new Window_BattleEnemyName(
new Rectangle(0, 0, Graphics.boxWidth, Graphics.boxHeight), this._enemyWindow);
}
this.addChild(this._enemyNameWindow);
// 追加ウィンドウへアクセスできるように設定
this._enemyWindow._enemyNameWindow = this._enemyNameWindow;
//--------------------------------------
// アクターウィンドウ生成
//--------------------------------------
// MV
if (Utils.RPGMAKER_NAME == "MV") {
this._actorNameWindow = new Window_BattleActorName(0, 0, this._actorWindow);
// MZ
} else {
// この時点ではサイズ不明なので、とりあえずGraphicsの全領域を確保
// ※確保しておかないと文字が表示できない。
this._actorNameWindow = new Window_BattleActorName(
new Rectangle(0, 0, Graphics.boxWidth, Graphics.boxHeight), this._actorWindow);
}
this.addChild(this._actorNameWindow);
// 追加ウィンドウへアクセスできるように設定
this._actorWindow._actorNameWindow = this._actorNameWindow;
// 追加ウィンドウから親ウィンドウへアクセスできるように設定
this._actorNameWindow._parentWindow = this._actorWindow;
};
/**
* ●敵選択
*/
const _Window_BattleEnemy_select = Window_BattleEnemy.prototype.select;
Window_BattleEnemy.prototype.select = function(index) {
_Window_BattleEnemy_select.apply(this, arguments);
if (this._enemyNameWindow) {
const enemy = this.enemy();
if (enemy) {
this._enemyNameWindow.setEnemy(enemy);
this._enemyNameWindow.select(index);
} else {
this._enemyNameWindow.hide();
}
}
};
/**
* ●敵選択ウィンドウ非表示
*/
const _Window_BattleEnemy_hide = Window_BattleEnemy.prototype.hide;
Window_BattleEnemy.prototype.hide = function() {
_Window_BattleEnemy_hide.apply(this, arguments);
if (this._enemyNameWindow) {
this._enemyNameWindow.hide();
}
};
/**
* ●タッチ操作
*/
const _Window_BattleEnemy_processTouch = Window_BattleEnemy.prototype.processTouch;
Window_BattleEnemy.prototype.processTouch = function() {
// カーソル移動禁止の場合
if (!this.isCursorMovable()) {
Window_Selectable.prototype.processTouch.call(this);
if (this.isOpenAndActive() && $gameTemp.touchTarget) {
const target = $gameTemp.touchTarget();
if (target) {
if (this._enemies.includes(target)) {
// 選択しない
// this.select(this._enemies.indexOf(target));
if ($gameTemp.touchState() === "click") {
this.processOk();
}
}
$gameTemp.clearTouchState();
}
}
return;
}
_Window_BattleEnemy_processTouch.apply(this, arguments);
}
/**
* ●アクター選択
*/
const _Window_BattleActor_select = Window_BattleActor.prototype.select;
Window_BattleActor.prototype.select = function(index) {
_Window_BattleActor_select.apply(this, arguments);
if (this._actorNameWindow) {
const actor = this.actor(index);
if (actor) {
this._actorNameWindow.setActor(actor);
this._actorNameWindow.select(index);
} else {
this._actorNameWindow.hide();
}
}
};
/**
* ●アクター選択ウィンドウ非表示
*/
const _Window_BattleActor_hide = Window_BattleActor.prototype.hide;
Window_BattleActor.prototype.hide = function() {
_Window_BattleActor_hide.apply(this, arguments);
if (this._actorNameWindow) {
this._actorNameWindow.hide();
}
};
/**
* ●タッチ操作
*/
const _Window_BattleActor_processTouch = Window_BattleActor.prototype.processTouch;
Window_BattleActor.prototype.processTouch = function() {
// カーソル移動禁止の場合
if (!this.isCursorMovable()) {
Window_BattleStatus.prototype.processTouch.call(this);
if (this.isOpenAndActive() && $gameTemp.touchTarget) {
const target = $gameTemp.touchTarget();
if (target) {
const members = $gameParty.battleMembers();
if (members.includes(target)) {
// 選択しない
// this.select(members.indexOf(target));
if ($gameTemp.touchState() === "click") {
this.processOk();
}
}
$gameTemp.clearTouchState();
}
}
return;
}
_Window_BattleActor_processTouch.apply(this, arguments);
};
//-----------------------------------------------------------------------------
// 敵名表示用の追加ウィンドウ
//-----------------------------------------------------------------------------
function Window_BattleEnemyName() {
this.initialize(...arguments);
}
Window_BattleEnemyName.prototype = Object.create(Window_Selectable.prototype);
Window_BattleEnemyName.prototype.constructor = Window_BattleEnemyName;
// MV
if (Utils.RPGMAKER_NAME == "MV") {
Window_BattleEnemyName.prototype.initialize = function(x, y, parentWindow) {
this._enemy = undefined;
const width = Graphics.boxWidth;
const height = pEnemyNameWindowHeight;
// 親ウィンドウへアクセスできるように設定
this._parentWindow = parentWindow;
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
// // 暗くするかどうか。
// this.setBackgroundType(1);
this.refresh();
this.hide();
// ウィンドウの不透明度
this.opacity = pEnemyNameWindowOpacity;
};
// MZ
} else {
Window_BattleEnemyName.prototype.initialize = function(rect, parentWindow) {
this._enemy = undefined;
// 親ウィンドウへアクセスできるように設定
this._parentWindow = parentWindow;
Window_Selectable.prototype.initialize.call(this, rect);
// 暗くするかどうか。
// ※うまくいかないので注釈化
// this.setBackgroundType(1);
this.refresh();
this.hide();
// ウィンドウの不透明度
this.opacity = pEnemyNameWindowOpacity;
// 余白(機能未実装)
// this.padding = 0;
};
}
Window_BattleEnemyName.prototype.maxCols = function() {
return 1;
};
Window_BattleEnemyName.prototype.maxItems = function() {
return 1;
};
Window_BattleEnemyName.prototype.setEnemy = function(enemy) {
return this._enemy = enemy;
};
if (pUpdateCursorPosition) {
/**
* ●更新
*/
Window_BattleEnemyName.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
if (this.visible) {
// 対象名を更新
// ※外部プラグインによって、リアルタイムで位置が変更されることを考慮
this.showTargetName();
// 敵名を表示しない場合は、親ウィンドウと選択が一致したら更新
} else if (!pShowTargetEnemyName
&& this._index != null && this._parentWindow._index == this._index) {
this.showTargetName();
}
};
}
/**
* ●選択時(カーソル移動時)
*/
Window_BattleEnemyName.prototype.select = function(index) {
this._index = index;
this.showTargetName();
};
/**
* ●対象名を表示
*/
Window_BattleEnemyName.prototype.showTargetName = function() {
// 全体選択時は非表示
if (this.cursorAll()) {
this.hide();
return;
}
const enemy = this._enemy;
if (!enemy) {
return;
}
// 敵のカーソル画像描画
const sprite = getSprite(enemy);
const spriteset = getSpriteset();
if (spriteset) {
dispCursorSprite(spriteset._enemyCursorSprite, sprite);
}
// 対象名を表示しない場合は終了
if (!pShowTargetEnemyName) {
return;
}
// 指定があればフォントサイズを設定
if (pEnemyNameFontSize) {
this.contents.fontSize = pEnemyNameFontSize;