-
Notifications
You must be signed in to change notification settings - Fork 0
/
NRP_LearnSkillListReserve.js
1211 lines (1102 loc) · 44.4 KB
/
NRP_LearnSkillListReserve.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_LearnSkillListReserve.js
//=============================================================================
/*:
* @target MZ
* @plugindesc v1.001 A list-style skill learning system reservation functionality.
* @author Takeshi Sunagawa (https://newrpg.seesaa.net/)
* @base NRP_LearnSkillList
* @orderAfter NRP_LearnSkillList
* @orderAfter NRP_ForgetLowerSkill
* @url https://newrpg.seesaa.net/article/503945159.html
*
* @help Add a reservation function
* to the list-style skill learning system plugin (NRP_LearnSkillList.js).
*
* It is assumed that NRP_LearnSkillList.js
* in the main body is registered.
*
* ◆Function
* You can reserve a skill for which you do not have enough SP
* by selecting it on the Skill Learning scene.
* Reserved skills are automatically learned
* when SP meets the requirements.
* In addition, the skill learning scene will be opened automatically.
* ※The skill learning screen opens
* after the end of a battle or an event.
* It can also be called up immediately
* during an event with a plugin command.
* ※If more than one actor learns a skill at the same time,
* the skill learning scene is opened for the actor closest
* to the front of the party.
*
* -------------------------------------------------------------------
* [Plugin Command]
* -------------------------------------------------------------------
* ◆CallReserveSkillScene
* Executing this command after learning a reserved skill
* calls up the skill learning scene.
* If there is no applicable skill, it will be ignored.
*
* -------------------------------------------------------------------
* [Notice]
* -------------------------------------------------------------------
* ◆Learning text at level up
* In addition to "NormalLearnText", there is a separate
* "LevelUpLearnText" message when a reserved skill is learned.
*
* This is due to the specification that the skill learning text
* at level-up usually omits the actor's name.
*
* Example: Reid is now 2 Level!
* Heal learned!
*
* When a reserved skill is acquired at the same time as level-up
* by "LevelUpSkillPoint" in NRP_LearnSkillList.js,
* this message will be displayed.
*
* ◆About the Icon Index
* Icon indexes can be used for reserved skill learning messages.
*
* \i[%3]%2 learned!
*
* If set as above, the icon will be displayed.
*
* Note that by default, icons cannot be set
* for "Obtain Skill" in the terms.
* Please refer to the Extra Feature in NRP_ForgetLowerSkill.js.
* https://newrpg.seesaa.net/article/483693029.html
*
* ◆Gaining skill points through items
* Skill points gained by items (<AddSkillPoint>) are not supported.
*
* There is no major hindrance, but skill points may remain
* in a reserved status even though they meet the requirements.
*
* ◆Reserve Members
* If the setting is set to not display the level-up of reserve members,
* the reserved skill learning message will also not be displayed.
* In that case, it would be safer to exclude the reserve members
* from learning the skill, or to allow them
* to learn the skill but not to call the learning scene.
*
* -------------------------------------------------------------------
* [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.
*
* @-----------------------------------------------------
* @ [Plugin Commands]
* @-----------------------------------------------------
*
* @command CallReserveSkillScene
* @desc When executed after a reserved skill has been learned, it calls up the learning scene. If there is no applicable skill, it will be ignored.
*
* @-----------------------------------------------------
* @ [Plugin Parameters]
* @-----------------------------------------------------
*
* @param LearnTimingBattle
* @type boolean
* @default true
* @desc Allow the process of learning reserved skills during battle.
*
* @param LearnTimingNotBattle
* @type boolean
* @default true
* @desc Allow the process of acquiring reserved skills outside of battle.
*
* @param ReserveSkillColor
* @type string
* @default #ffff00
* @desc Specify the text color (color code) of the skill being reserved.
*
* @param ReserveSkillOpacity
* @type number
* @default 255
* @desc Specify the opacity (0~255) of the text of the skill being reserved. If blank, it will be 160.
*
* @param ReserveSkillSe
* @type file
* @dir audio/se
* @default Switch2
* @desc The file name of the SE to be played when the skill is reserved.
*
* @param ReserveConfirmText
* @type multiline_string
* @default Not enough %2.
Would you like to reserve %3?
* @desc Confirmation message for reserving a skill. %1:Consume SP, %2:SP Name, %3:Skill Name
*
* @param ReserveYesText
* @type string
* @default OK
* @desc Specify text for reserving skills.
*
* @param ReserveNoText
* @type string
* @default Cancel
* @desc Specify text if you do not want to reserve the skill.
*
* @param ReserveCancelConfirmText
* @type multiline_string
* @default %3 is reserved.
Would you like to cancel?
* @desc A confirmation text for canceling a reservation for a skill. %1:Consume SP, %2:SP Name, %3:Skill Name
*
* @param ReserveCancelYesText
* @type string
* @default Cancel Reservation
* @desc Specify text for canceling a skill reservation.
*
* @param ReserveCancelNoText
* @type string
* @default No Change
* @desc The text for not canceling a reservation for a skill.
*
* @param NormalLearnText
* @type string
* @default %1 learned %2!
* @desc The text when the reservation skill is normally learned.。
* %1:Actor Name, %2:Skill Name, %3:Icon Index
*
* @param NormalLearnTextChangePage
* @parent NormalLearnText
* @type select
* @option 0:No Page Break @value 0
* @option 1:First Page Break @value 1
* @option 2:All Page Break @value 2
* @default 2
* @desc A page break system for the normal skill learning text.
* It's assumed when several actos learn a skill at the same time.
*
* @param NormalLearnTextBackground
* @parent NormalLearnText
* @type select
* @option Normal @value 0
* @option Dimmer @value 1
* @option Transparency @value 2
* @default 0
* @desc The background of the message window for the normal skill learning text.
*
* @param LevelUpLearnText
* @type string
* @default %2 learned!
* @desc The text when the reservation skills are learned at a level up.
* %1:Actor Name, %2:Skill Name, %3:Icon Index
*
* @param <BenchMember>
*
* @param BenchMemberNotTarget
* @parent <BenchMember>
* @type boolean
* @default false
* @desc The reserve member does not learn reservation skills.
*
* @param BenchMemberNotCallScene
* @parent <BenchMember>
* @type boolean
* @default false
* @desc In the case of reserved members, the learning scene is not called when learning reserved skills.
*/
/*:ja
* @target MZ
* @plugindesc v1.001 リスト形式のスキル習得システムの予約機能。
* @author 砂川赳(https://newrpg.seesaa.net/)
* @base NRP_LearnSkillList
* @orderAfter NRP_LearnSkillList
* @orderAfter NRP_ForgetLowerSkill
* @url https://newrpg.seesaa.net/article/503945159.html
*
* @help リスト形式のスキル習得システムプラグイン(NRP_LearnSkillList.js)に
* 予約機能を追加します。
*
* 本体のNRP_LearnSkillList.jsが登録されていることが前提です。
*
* ◆機能
* スキル習得画面でSPが足りないスキルを選択すると、予約できます。
* 予約したスキルはSPが条件を満たした時点で、自動的に習得されます。
* さらにスキル習得画面が自動で開かれます。
* ※スキル習得画面が開くタイミングは戦闘終了後またはイベント終了後です。
* イベント途中でもプラグインコマンドで強制的に呼び出すこともできます。
* ※同時に複数のアクターがスキルを習得した場合は、
* 最も先頭に近いアクターのスキル習得画面が開かれます。
*
* -------------------------------------------------------------------
* ■プラグインコマンド
* -------------------------------------------------------------------
* ◆予約スキル習得後に画面呼出
* 予約スキル習得後にこのコマンドを実行すると、スキル習得画面を呼び出します。
* 該当スキルがない場合は無視されます。
*
* -------------------------------------------------------------------
* ■注意点
* -------------------------------------------------------------------
* ◆レベルアップ時の習得文
* 予約スキルを覚えた時のメッセージには『通常時の習得文』の他に、
* 『レベルアップ時の習得文』が別途存在します。
*
* これはレベルアップ時のスキル習得文は通常、
* アクターの名前を省略する仕様のためです。
*
* 例:リードはレベル 2 に上がった!
* ヒールⅠを覚えた!
*
* NRP_LearnSkillList.jsの『レベルアップ時のSP』によって、
* レベルアップと同時に予約スキルを習得した場合は、
* こちらのメッセージが表示されます。
*
* ◆アイコン番号について
* 予約スキルの習得メッセージにはアイコン番号が使用できます。
*
* \i[%3]%2を覚えた!
*
* というように設定すれば、アイコンが表示されます。
*
* なお、通常だと用語にあるスキル習得文には、
* アイコンは設定できませんが、NRP_ForgetLowerSkill.jsの
* おまけ機能で使えるので参考にしてください。
* https://newrpg.seesaa.net/article/483693029.html
*
* ◆アイテムによるスキルポイントの獲得
* アイテム(<AddSkillPoint>)によって、
* スキルポイントを加算した場合には対応していません。
*
* 特に大きな支障はありませんが、スキルポイントが条件を
* 満たしているのに予約状態のままになることがあります。
*
* ◆控えメンバー
* 控えメンバーのレベルアップを表示しない設定になっている場合は、
* 予約スキルの習得メッセージも表示できなくなります。
* その場合は控えメンバーはスキル習得の対象外にするか、
* もしくは習得はできても習得画面を呼ばなようにしたほうが無難だと思います。
*
* -------------------------------------------------------------------
* ■利用規約
* -------------------------------------------------------------------
* 特に制約はありません。
* 改変、再配布自由、商用可、権利表示も任意です。
* 作者は責任を負いませんが、不具合については可能な範囲で対応します。
*
* @-----------------------------------------------------
* @ プラグインコマンド
* @-----------------------------------------------------
*
* @command CallReserveSkillScene
* @text 予約スキル習得後に画面呼出
* @desc 予約スキル習得後に実行すると、習得画面を呼び出します。
* 該当スキルがない場合は無視されます。
*
* @-----------------------------------------------------
* @ プラグインパラメータ
* @-----------------------------------------------------
*
* @param LearnTimingBattle
* @text 戦闘時に習得
* @type boolean
* @default true
* @desc 戦闘時に予約スキルの習得処理を行います。
*
* @param LearnTimingNotBattle
* @text 非戦闘時に習得
* @type boolean
* @default true
* @desc 非戦闘時に予約スキルの習得処理を行います。
*
* @param ReserveSkillColor
* @text 予約スキルの文字色
* @type string
* @default #ffff00
* @desc 予約中のスキルの文字色(カラーコード)を指定します。
*
* @param ReserveSkillOpacity
* @text 予約スキルの不透明度
* @type number
* @default 255
* @desc 予約中のスキルの文字の不透明度(0~255)を指定します。
* 空欄なら習得不可のスキルと同じ不透明度(160)になります。
*
* @param ReserveSkillSe
* @text スキル予約時の効果音名
* @type file
* @dir audio/se
* @default Switch2
* @desc スキルを予約したときに再生するSEのファイル名を指定します。
*
* @param ReserveConfirmText
* @text 予約時の文章(確認)
* @type multiline_string
* @default %2が不足しています。
%3を予約しますか?
* @desc スキルを予約する際の確認用文章です。%1:消費するSP値, %2:SP名, %3:取得するスキル名
*
* @param ReserveYesText
* @text 予約時の文章(はい)
* @type string
* @default 予約する
* @desc スキルを予約する場合のテキストを指定します。
*
* @param ReserveNoText
* @text 予約時の文章(いいえ)
* @type string
* @default 予約しない
* @desc スキルを予約しない場合のテキストを指定します。
*
* @param ReserveCancelConfirmText
* @text 予約取消時の文章(確認)
* @type multiline_string
* @default %3は予約中です。
取り消しますか?
* @desc スキルの予約を取り消す際の確認用文章です。%1:消費するSP値, %2:SP名, %3:取得するスキル名
*
* @param ReserveCancelYesText
* @text 予約取消時の文章(はい)
* @type string
* @default 取り消す
* @desc スキルの予約を取り消す場合のテキストを指定します。
*
* @param ReserveCancelNoText
* @text 予約取消時の文章(いいえ)
* @type string
* @default 取り消さない
* @desc スキルの予約を取り消さない場合のテキストを指定します。
*
* @param NormalLearnText
* @text 通常時の習得文
* @type string
* @default %1は%2を覚えた!
* @desc 予約スキルを通常習得した際の文章です。
* %1:アクター名, %2:取得するスキル名, %3:アイコン番号
*
* @param NormalLearnTextChangePage
* @parent NormalLearnText
* @text 通常習得文の改ページ方式
* @type select
* @option 0:改ページしない @value 0
* @option 1:最初だけ改ページ @value 1
* @option 2:全員改ページ @value 2
* @default 2
* @desc 通常時のスキル習得文の改ページ方式です。
* 複数人が同時にスキルを習得した際を想定しています。
*
* @param NormalLearnTextBackground
* @parent NormalLearnText
* @text 習得文のウィンドウ背景
* @type select
* @option 0:ウィンドウ @value 0
* @option 1:暗くする @value 1
* @option 2:透明 @value 2
* @default 0
* @desc 通常時のスキル習得文のメッセージウィンドウの背景です。
*
* @param LevelUpLearnText
* @text レベルアップ時の習得文
* @type string
* @default %2を覚えた!
* @desc 予約スキルをレベルアップで習得した際の文章です。
* %1:アクター名, %2:取得するスキル名, %3:アイコン番号
*
* @param <BenchMember>
* @text <控えメンバー関連>
*
* @param BenchMemberNotTarget
* @parent <BenchMember>
* @text 控えメンバーは対象外
* @type boolean
* @default false
* @desc 控えメンバーは予約スキルの習得を行いません。
*
* @param BenchMemberNotCallScene
* @parent <BenchMember>
* @text 控えメンバーは画面を呼ばない
* @type boolean
* @default false
* @desc 控えメンバーの場合は予約スキル習得時に習得画面を呼びません。
*/
(function() {
"use strict";
/**
* ●構造体をJSで扱えるように変換
*/
function parseStruct1(arg) {
var ret = [];
JSON.parse(arg).forEach(function(str) {
ret.push(str);
});
return ret;
}
/**
* ●構造体(二重配列)をJSで扱えるように変換
*/
function parseStruct2(arg) {
const ret = [];
if (arg) {
for (const str of JSON.parse(arg)) {
ret.push(JSON.parse(str));
}
}
return ret;
}
function toNumber(str, def) {
if (str == undefined || str == "") {
return def;
}
return isNaN(str) ? def : +(str || def);
}
function toBoolean(str, def) {
if (str === true || str === "true") {
return true;
} else if (str === false || str === "false") {
return false;
}
return def;
}
function setDefault(str, def) {
if (str == undefined || str == "") {
return def;
}
return str;
}
const PLUGIN_NAME = "NRP_LearnSkillListReserve";
const parameters = PluginManager.parameters(PLUGIN_NAME);
const pLearnTimingBattle = toBoolean(parameters["LearnTimingBattle"], false);
const pLearnTimingNotBattle = toBoolean(parameters["LearnTimingNotBattle"], false);
const pReserveSkillColor = setDefault(parameters["ReserveSkillColor"]);
const pReserveSkillOpacity = toNumber(parameters["ReserveSkillOpacity"]);
const pReserveSkillSe = setDefault(parameters["ReserveSkillSe"]);
const pReserveConfirmText = setDefault(parameters["ReserveConfirmText"]);
const pReserveYesText = setDefault(parameters["ReserveYesText"]);
const pReserveNoText = setDefault(parameters["ReserveNoText"]);
const pReserveCancelConfirmText = setDefault(parameters["ReserveCancelConfirmText"]);
const pReserveCancelYesText = setDefault(parameters["ReserveCancelYesText"]);
const pReserveCancelNoText = setDefault(parameters["ReserveCancelNoText"]);
const pNormalLearnText = setDefault(parameters["NormalLearnText"]);
const pNormalLearnTextChangePage = toNumber(parameters["NormalLearnTextChangePage"], 0);
const pNormalLearnTextBackground = toNumber(parameters["NormalLearnTextBackground"], 0);
const pLevelUpLearnText = setDefault(parameters["LevelUpLearnText"]);
const pBenchMemberNotTarget = toBoolean(parameters["BenchMemberNotTarget"], false);
const pBenchMemberNotCallScene = toBoolean(parameters["BenchMemberNotCallScene"], false);
const PLUGIN_NAME_BASE = "NRP_LearnSkillList";
const baseParameters = PluginManager.parameters(PLUGIN_NAME_BASE);
const pSkillPointName = setDefault(baseParameters["SkillPointName"], "");
const pSkillPointType = setDefault(parameters["SkillPointType"]);
const pSkillPointVariable = setDefault(baseParameters["SkillPointVariable"]);
// 定数
const SKILL_POINT_KEY = "skillPoint";
// 予約習得後にスキル習得画面を開くアクターID
let mReserveSkillActorId = null;
// 強制呼び出しフラグ
let mForceCallFlg = false;
//-----------------------------------------------------------------------------
// MZ用プラグインコマンド
//-----------------------------------------------------------------------------
// MVには存在しないため、空で定義しておかないとエラーになる。
if (!PluginManager.registerCommand) {
PluginManager.registerCommand = function() {}
}
/**
* ●予約スキル習得後画面呼出
*/
PluginManager.registerCommand(PLUGIN_NAME, "CallReserveSkillScene", function(args) {
// 予約スキルを習得した場合はスキル習得画面呼び出し
if (mReserveSkillActorId) {
// メッセージ表示を行う場合
if ($gameMessage.hasText()) {
// 一旦、強制呼び出しフラグをオンにしてメッセージ終了後に呼び出し
mForceCallFlg = true;
// それ以外は普通に呼び出し
} else {
// アクターをセット
$gameParty.setMenuActor($gameActors.actor(mReserveSkillActorId));
// スキル習得画面呼び出し
SceneManager.push(Scene_LearnSkillList);
}
}
});
//-----------------------------------------------------------------------------
// Scene_LearnSkillList
//-----------------------------------------------------------------------------
/**
* ●ウィンドウの生成
*/
const _Scene_LearnSkillList_create = Scene_LearnSkillList.prototype.create;
Scene_LearnSkillList.prototype.create = function() {
_Scene_LearnSkillList_create.apply(this, arguments);
// 予約確認ウィンドウ
this.createReserveConfirmWindow();
// 予約キャンセルウィンドウ
this.createReserveCancelConfirmWindow();
};
/**
* ●予約確認ウィンドウの作成
*/
Scene_LearnSkillList.prototype.createReserveConfirmWindow = function() {
const rect = this.confirmWindowRect();
this._reserveConfirmWindow = new Window_LearnSkillReserveConfirm(rect);
this._reserveConfirmWindow.setHandler("ok", this.reseveConfirmLearnOk.bind(this));
this._reserveConfirmWindow.setHandler("cancel", this.reserveConfirmLearnCancel.bind(this));
// addWindowだと下が見えなくなるのでaddChildで追加する。
this.addChild(this._reserveConfirmWindow);
this._reserveConfirmWindow.hide();
this._reserveConfirmWindow.close();
};
/**
* ●予約キャンセル確認ウィンドウの作成
*/
Scene_LearnSkillList.prototype.createReserveCancelConfirmWindow = function() {
const rect = this.confirmWindowRect();
this._reserveCancelConfirmWindow = new Window_LearnSkillReserveCancelConfirm(rect);
this._reserveCancelConfirmWindow.setHandler("ok", this.reseveCancelConfirmLearnOk.bind(this));
this._reserveCancelConfirmWindow.setHandler("cancel", this.reserveCancelConfirmLearnCancel.bind(this));
// addWindowだと下が見えなくなるのでaddChildで追加する。
this.addChild(this._reserveCancelConfirmWindow);
this._reserveCancelConfirmWindow.hide();
this._reserveCancelConfirmWindow.close();
};
/**
* ●予約確認確定
*/
Scene_LearnSkillList.prototype.reseveConfirmLearnOk = function() {
// 予約スキルを取得
const learnSkillData = this._reserveConfirmWindow.item();
const skillPoint = eval(learnSkillData.SkillPoint);
const skillId = eval(learnSkillData.Skill);
// 予約スキル情報をアクターに設定
this._actor.setReserveSkill(skillId, skillPoint);
// 効果音を演奏
if (pReserveSkillSe) {
AudioManager.playSe({"name":pReserveSkillSe, "volume":90, "pitch":100, "pan":0})
}
// 予約確認ウィンドウを閉じる
this._reserveConfirmWindow.close();
// スキルリストに戻る
this._skillListWindow.activate();
// リフレッシュ
this._skillListWindow.refresh();
};
/**
* ●予約確認キャンセル
*/
Scene_LearnSkillList.prototype.reserveConfirmLearnCancel = function() {
// 予約確認ウィンドウを閉じる
this._reserveConfirmWindow.close();
// スキルリストに戻る
this._skillListWindow.activate();
};
/**
* ●予約キャンセル確認確定
*/
Scene_LearnSkillList.prototype.reseveCancelConfirmLearnOk = function() {
// 予約スキルをクリア
this._actor.clearReserveSkill();
// 予約キャンセル確認ウィンドウを閉じる
this._reserveCancelConfirmWindow.close();
// スキルリストに戻る
this._skillListWindow.activate();
// リフレッシュ
this._skillListWindow.refresh();
};
/**
* ●予約キャンセル確認キャンセル
*/
Scene_LearnSkillList.prototype.reserveCancelConfirmLearnCancel = function() {
// 予約確認ウィンドウを閉じる
this._reserveCancelConfirmWindow.close();
// スキルリストに戻る
this._skillListWindow.activate();
};
/**
* ●スキルリスト選択時
*/
const _Scene_LearnSkillList_onSkillListOk = Scene_LearnSkillList.prototype.onSkillListOk;
Scene_LearnSkillList.prototype.onSkillListOk = function() {
const item = this._skillListWindow.item();
// 予約中の場合は予約キャンセルウィンドウを表示
if (this._actor.reserveSkillId() == eval(item.Skill)) {
// 予約キャンセルウィンドウにスキルデータを設定
this._reserveCancelConfirmWindow.setSkillData(item);
// 予約キャンセルウィンドウを表示
this._reserveCancelConfirmWindow.show();
this._reserveCancelConfirmWindow.open();
this._reserveCancelConfirmWindow.activate();
this._reserveCancelConfirmWindow.select(0);
return;
}
// SPが足りない場合は予約確認ウィンドウを表示
const skillPoint = eval(item.SkillPoint);
if (this._actor.currentSkillPoint() < skillPoint) {
// 予約確認ウィンドウにスキルデータを設定
this._reserveConfirmWindow.setSkillData(item);
// 予約確認ウィンドウを表示
this._reserveConfirmWindow.show();
this._reserveConfirmWindow.open();
this._reserveConfirmWindow.activate();
this._reserveConfirmWindow.select(0);
return;
}
_Scene_LearnSkillList_onSkillListOk.apply(this, arguments);
};
/**
* ●終了処理
*/
const _Scene_LearnSkillList_terminate = Scene_LearnSkillList.prototype.terminate;
Scene_LearnSkillList.prototype.terminate = function() {
_Scene_LearnSkillList_terminate.apply(this, arguments);
// 予約から呼び出された場合はマップ画面へ戻る。
if (mReserveSkillActorId) {
mReserveSkillActorId = null;
SceneManager.goto(Scene_Map);
}
}
// ----------------------------------------------------------------------------
// Scene_Map
// ----------------------------------------------------------------------------
/**
* ●マップ開始
*/
const _Scene_Map_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
// 予約スキルを習得した場合はスキル周到画面呼び出し
if (mReserveSkillActorId) {
// アクターをセット
$gameParty.setMenuActor($gameActors.actor(mReserveSkillActorId));
// 一瞬マップが表示されてしまうため黒くする。
this._fadeOpacity = 255;
this.updateColorFilter();
// スキル習得画面呼び出し
SceneManager.push(Scene_LearnSkillList);
return;
}
_Scene_Map_start.apply(this, arguments);
};
//-----------------------------------------------------------------------------
// Window_LearnSkillList
//-----------------------------------------------------------------------------
/**
* 【上書】現在の項目が有効かどうか?
*/
Window_LearnSkillList.prototype.isCurrentItemEnabled = function() {
const item = this.item();
// 覚えられるスキルが一つもない場合
if (!item) {
return false;
}
// 習得済の場合
const skillId = eval(item.Skill);
if (this._actor.isLearnedSkill(skillId)) {
return false;
}
// 条件を満たしていない
if (!this.isMatchSkillData(item)) {
return false;
}
// SPが足りない場合でも予約のために有効と判定
return true;
};
/**
* ●項目を描画
*/
const _Window_LearnSkillList_drawItem = Window_LearnSkillList.prototype.drawItem;
Window_LearnSkillList.prototype.drawItem = function(index) {
const learnSkillData = this.itemAt(index);
const skillId = eval(learnSkillData.Skill)
// 予約スキルの場合は色を変更
if (learnSkillData && this._actor.reserveSkillId() == skillId) {
const costWidth = this.costWidth();
const rect = this.itemLineRect(index);
// 習得不可かつ不透明度の指定がある場合
// ※基本的に予約スキルは習得不可の想定だが、
// 他の経路からSPが加算された結果、習得可能なまま予約されている状態も想定。
if (!this.isEnabled(learnSkillData) && pReserveSkillOpacity) {
this.contents.paintOpacity = pReserveSkillOpacity;
// それ以外は既定の不透明度を設定
} else {
this.changePaintOpacity(this.isEnabled(learnSkillData));
}
this.changeTextColor(pReserveSkillColor);
this.drawItemName(learnSkillData, rect.x, rect.y, rect.width - costWidth);
this.resetTextColor();
this.changePaintOpacity(this.isEnabled(learnSkillData));
this.drawSkillCost(learnSkillData, rect.x, rect.y, rect.width);
this.changePaintOpacity(1);
return;
}
_Window_LearnSkillList_drawItem.apply(this, arguments);
};
//-----------------------------------------------------------------------------
// Window_LearnSkillReserveConfirm
//
// 予約確認用のウィンドウ
// ※Window_LearnSkillConfirmを流用
function Window_LearnSkillReserveConfirm() {
this.initialize(...arguments);
}
Window_LearnSkillReserveConfirm.prototype = Object.create(Window_LearnSkillConfirm.prototype);
Window_LearnSkillReserveConfirm.prototype.constructor = Window_LearnSkillReserveConfirm;
Window_LearnSkillReserveConfirm.prototype.makeCommandList = function() {
this.addCommand(pReserveYesText, "ok");
this.addCommand(pReserveNoText, "cancel");
};
Window_LearnSkillReserveConfirm.prototype.drawAllItems = function() {
const paramSkill = this._skillData;
const dataSkill = this.dataSkill();
if (!dataSkill) {
return;
}
// 文字列の最大長を求める。
let maxWidth = 0;
// 行数カウント用
let lineCount = 0;
let skillPoint = 0;
if (paramSkill.SkillPoint) {
skillPoint = eval(paramSkill.SkillPoint);
}
for (const line of pReserveConfirmText.split("\n")) {
// %1:消費するSP値, %2:SP名, %3:取得するスキル名, %4:アイコン番号
const message = line.format(skillPoint, pSkillPointName, dataSkill.name, dataSkill.iconIndex);
// 文字列の最大長を保持しておく。
const newWidth = this.textSizeEx(message).width + this.itemPadding() * 4;
maxWidth = Math.max(maxWidth, newWidth);
// 一行ずつ描画
this.drawTextEx(message, this.itemPadding(), this.itemPadding() + lineCount * this.lineHeight());
lineCount++;
}
lineCount++;
// ウィンドウの幅と座標を文字列に合わせて調整
this.width = maxWidth;
this.height = this.lineHeight() * lineCount + this.fittingHeight(2);
this.x = (Graphics.boxWidth - this.width) / 2;
this.y = (Graphics.boxHeight - this.height) / 2;
const topIndex = this.topIndex();
for (let i = 0; i < this.maxVisibleItems(); i++) {
const index = topIndex + i;
if (index < this.maxItems()) {
this.drawItemBackground(index);
this.drawItem(index);
}
}
};
/**
* ●ウィンドウの領域設定
*/
Window_LearnSkillReserveConfirm.prototype.itemRect = function(index) {
const rect = Window_Selectable.prototype.itemRect.apply(this, arguments);
const lineCount = pReserveConfirmText.split("\n").length;
rect.y += lineCount * this.lineHeight() + this.itemPadding() * 4;
return rect;
};
//-----------------------------------------------------------------------------
// Window_LearnSkillReserveCancelConfirm
//
// 予約確認キャンセル用のウィンドウ
// ※Window_LearnSkillConfirmを流用
function Window_LearnSkillReserveCancelConfirm() {
this.initialize(...arguments);
}
Window_LearnSkillReserveCancelConfirm.prototype = Object.create(Window_LearnSkillConfirm.prototype);
Window_LearnSkillReserveCancelConfirm.prototype.constructor = Window_LearnSkillReserveCancelConfirm;
Window_LearnSkillReserveCancelConfirm.prototype.makeCommandList = function() {
this.addCommand(pReserveCancelYesText, "ok");
this.addCommand(pReserveCancelNoText, "cancel");
};
Window_LearnSkillReserveCancelConfirm.prototype.drawAllItems = function() {
const paramSkill = this._skillData;
const dataSkill = this.dataSkill();
if (!dataSkill) {
return;
}
// 文字列の最大長を求める。
let maxWidth = 0;
// 行数カウント用
let lineCount = 0;
let skillPoint = 0;
if (paramSkill.SkillPoint) {
skillPoint = eval(paramSkill.SkillPoint);
}
for (const line of pReserveCancelConfirmText.split("\n")) {
// %1:消費するSP値, %2:SP名, %3:取得するスキル名, %4:アイコン番号
const message = line.format(skillPoint, pSkillPointName, dataSkill.name, dataSkill.iconIndex);
// 文字列の最大長を保持しておく。
const newWidth = this.textSizeEx(message).width + this.itemPadding() * 4;
maxWidth = Math.max(maxWidth, newWidth);
// 一行ずつ描画
this.drawTextEx(message, this.itemPadding(), this.itemPadding() + lineCount * this.lineHeight());
lineCount++;
}
lineCount++;
// ウィンドウの幅と座標を文字列に合わせて調整
this.width = maxWidth;
this.height = this.lineHeight() * lineCount + this.fittingHeight(2);
this.x = (Graphics.boxWidth - this.width) / 2;
this.y = (Graphics.boxHeight - this.height) / 2;
const topIndex = this.topIndex();
for (let i = 0; i < this.maxVisibleItems(); i++) {
const index = topIndex + i;
if (index < this.maxItems()) {
this.drawItemBackground(index);
this.drawItem(index);
}
}
};
/**
* ●ウィンドウの領域設定
*/
Window_LearnSkillReserveCancelConfirm.prototype.itemRect = function(index) {
const rect = Window_Selectable.prototype.itemRect.apply(this, arguments);
const lineCount = pReserveCancelConfirmText.split("\n").length;
rect.y += lineCount * this.lineHeight() + this.itemPadding() * 4;
return rect;
};
//-----------------------------------------------------------------------------
// BattleManager
//-----------------------------------------------------------------------------
// 最初のスキル習得かどうか?
let mFirstLearn = false;
/**
* ●報酬の獲得
*/
const _BattleManager_gainRewards = BattleManager.gainRewards;
BattleManager.gainRewards = function() {
mFirstLearn = true;
_BattleManager_gainRewards.apply(this, arguments);
mFirstLearn = false;
};
//-----------------------------------------------------------------------------
// Game_Action
//-----------------------------------------------------------------------------
// 予約機能を対象外にするためのフラグ
let mAddSkillPoint = false;
/**
* ●効果適用
*/
const _Game_Action_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
// スキルポイントを加算する設定があるかどうか?
const addSkillPoint = this.item().meta.AddSkillPoint;
if (addSkillPoint) {
// 予約機能は対象外にする。
mAddSkillPoint = true;
}
_Game_Action_apply.apply(this, arguments);
mAddSkillPoint = false;
};
//-----------------------------------------------------------------------------
// Game_Actor
//-----------------------------------------------------------------------------
/**
* 【独自】予約スキルの設定
*/
Game_Actor.prototype.setReserveSkill = function(skillId, needSp) {
this._reserveSkillId = skillId;
this._reserveSkillSp = needSp;
};
/**
* 【独自】予約スキルのクリア
*/
Game_Actor.prototype.clearReserveSkill = function() {
this._reserveSkillId = null;
this._reserveSkillSp = null;
};
/**
* 【独自】予約スキルの取得
*/
Game_Actor.prototype.reserveSkillId = function() {
return this._reserveSkillId;
};
// レベルアップ時判定用
let mIsLevelUp = false;
// スキル習得のメッセージ表示用
let mDisplayLearnSkillId = false;
/**
* ●レベルアップ時
*/
const _Game_Actor_levelUp = Game_Actor.prototype.levelUp;
Game_Actor.prototype.levelUp = function() {
mIsLevelUp = true;
_Game_Actor_levelUp.apply(this, arguments);
mIsLevelUp = false;