magical-girls-runa-and-nanami/js/plugins/CGPT_BattleStartCommon.js
2026-02-28 12:33:13 -06:00

50 lines
1.9 KiB
JavaScript

/*:
* @target MZ
* @plugindesc 戦闘開始後、コマンド入力直前に指定したコモンイベントを実行する
* @author ChatGPT
*
* @param CommonEventID
* @text 実行するコモンイベントID
* @desc 戦闘開始後、最初のコマンド入力直前に実行するコモンイベント
* @type common_event
* @default 1
*
* @help
* このプラグインは、戦闘開始後、プレイヤーがコマンド入力できる直前に
* 指定したコモンイベントを実行します。
*
* 【使い方】
* 1. プラグインパラメータ「CommonEventID」に実行したい
* コモンイベントのIDを設定します。
* 2. すべての戦闘で、自動的にこのコモンイベントが
* 実行されるようになります。
*
* 【注意】
* - コモンイベントの内容によっては、最初のターンに遅延が発生する
* 可能性があります。
* - 戦闘終了時にリセットされるので、次の戦闘でも適用されます。
*/
(() => {
const parameters = PluginManager.parameters("BattleStartCommonEvent");
const commonEventId = Number(parameters["CommonEventID"] || 1);
const _Scene_Battle_start = Scene_Battle.prototype.start;
Scene_Battle.prototype.start = function() {
_Scene_Battle_start.call(this);
this._battleCommonEventWait = true; // コモンイベント待機フラグをON
};
const _Scene_Battle_update = Scene_Battle.prototype.update;
Scene_Battle.prototype.update = function() {
_Scene_Battle_update.call(this);
// コマンド入力が可能になった直後にコモンイベントを実行
if (this._battleCommonEventWait && BattleManager.isInputting()) {
this._battleCommonEventWait = false;
if (commonEventId > 0) {
$gameTemp.reserveCommonEvent(commonEventId);
}
}
};
})();