ω ・ =)っ インターネットで検索したら参考になりそうなページがあったにゃ~。
ω ・ =) TextManagerは今回はいじらなくてもいいかにゃ~。
ω ・ =) というわけで簡単に言うと、メニュー画面(Scene_Menu)を開いたときに休息ってコマンドを追加して、休息コマンドを選択したときに特定のコモンイベントを実行するようにしてみたにゃ~。
ω ・ =) さっそくプロジェクトのjsフォルダにあるrpg_scene.jsファイルを見てみるかにゃ~。
ω ・ =) 「Scene_Menu.prototype.createCommandWindow」ってそれっぽくにゃいかにゃ~?
Scene_Menu.prototype.createCommandWindow = function() {
this._commandWindow = new Window_MenuCommand(0, 0);
this._commandWindow.setHandler('item', this.commandItem.bind(this));
this._commandWindow.setHandler('skill', this.commandPersonal.bind(this));
this._commandWindow.setHandler('equip', this.commandPersonal.bind(this));
this._commandWindow.setHandler('status', this.commandPersonal.bind(this));
this._commandWindow.setHandler('formation', this.commandFormation.bind(this));
this._commandWindow.setHandler('options', this.commandOptions.bind(this));
this._commandWindow.setHandler('save', this.commandSave.bind(this));
this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._commandWindow);
};
ω ・ =) 表示させたい場所に同じように追記してみようかにゃ~。
ω ・ =)b rpg_scene.jsってファイルを直接書き換えると、アップデートされたときにめんどくさいからプラグインでこの部分を書き換えるようにするといいかにゃ~。
Scene_Menu.prototype.createCommandWindow = function() {
this._commandWindow = new Window_MenuCommand(0, 0);
this._commandWindow.setHandler('item', this.commandItem.bind(this));
this._commandWindow.setHandler('skill', this.commandPersonal.bind(this));
this._commandWindow.setHandler('equip', this.commandPersonal.bind(this));
this._commandWindow.setHandler('status', this.commandPersonal.bind(this));
this._commandWindow.setHandler('formation', this.commandFormation.bind(this));
this._commandWindow.setHandler('rest', this.commandRest.bind(this));
this._commandWindow.setHandler('options', this.commandOptions.bind(this));
this._commandWindow.setHandler('save', this.commandSave.bind(this));
this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._commandWindow);
};
ω ・ =) まんなかあたりに「rest」って追加してるにゃ~。
ω ・ =) 次はこの「commandRest」がどういう動作をするか定義するにゃ~。
Scene_Menu.prototype.commandRest = function() {
this.popScene();
$gameTemp.reserveCommonEvent(46);
};
ω ・ =) メニュー画面からマップ画面に戻って(this.popScene())、コモンイベントを実行($gameTemp.reserveCommonEvent(46))してるにゃ~。
ω ・ =) 最後は、休息コマンドの具体的な表示を定義するにゃ~。
ω ・ =) 表示部分だから「rpg_windows.js」かにゃ~。
ω ・ =) 「Window_MenuCommand.prototype.addOriginalCommands」かにゃ~?中は何も書かれてにゃいにゃ…。
ω- =) 他のコマンドの記述を参考に、書き換えるようにすればいいんじゃにゃいかにゃ~。
Window_MenuCommand.prototype.addOriginalCommands = function() {
this.addCommand('休息', 'rest', true);
};
ω ・ =) こんな感じで休息コマンドを追加できたにゃ~。
ω- =) 任意に実行できるようにするのはいいけど、回復のバランスも考えにゃいといけにゃいよにゃ~。
ω ・ =) ま~くんも一緒に考えてくれるって言ってるしにゃんとかにゃるかにゃ~。