59 lines
No EOL
2.2 KiB
JavaScript
59 lines
No EOL
2.2 KiB
JavaScript
/*:
|
||
* @target MZ
|
||
* @plugindesc ヒット時のみダメージ計算前にカットインCE v1.1
|
||
* @author Umu
|
||
* @help
|
||
* スキル/アイテムのメモ欄に <HitCutinCE:123> の形で記述。
|
||
* 123 は再生したい共通イベントID。マルチターゲットでも 1 回だけ再生します。
|
||
* 利用自由。
|
||
*/
|
||
(() => {
|
||
"use strict";
|
||
const TAG = /<HitCutinCE\s*:\s*(\d+)>/i;
|
||
|
||
//―― ① ヒット確定後(Game_Action.apply)でログに Cutin を差し込む
|
||
const _apply = Game_Action.prototype.apply;
|
||
Game_Action.prototype.apply = function (target) {
|
||
_apply.call(this, target);
|
||
if (!this._cutinQueued && target.result().isHit()) {
|
||
const m = this.item().note.match(TAG);
|
||
if (m) {
|
||
BattleManager._logWindow.push("performCutin", Number(m[1]));
|
||
this._cutinQueued = true; // 1アクション1回
|
||
}
|
||
}
|
||
};
|
||
|
||
//―― ② ログウィンドウに Cutin コマンドを実装
|
||
Window_BattleLog.prototype.performCutin = function (ceId) {
|
||
this._cutinInterpreter = new Game_Interpreter();
|
||
this._cutinInterpreter.setup($dataCommonEvents[ceId].list);
|
||
this.setWaitMode("cutin");
|
||
};
|
||
|
||
//―― ③ 待機処理:Interpreter が走っている間 Busy を維持
|
||
const _updateWait = Window_BattleLog.prototype.updateWait;
|
||
Window_BattleLog.prototype.updateWait = function () {
|
||
if (this._waitMode === "cutin") {
|
||
if (this._cutinInterpreter.isRunning()) {
|
||
this._cutinInterpreter.update();
|
||
return true; // まだ実行中なのでウェイト
|
||
}
|
||
this._cutinInterpreter = null; // 終了
|
||
this._waitMode = "";
|
||
}
|
||
return _updateWait.call(this);
|
||
};
|
||
|
||
//―― ④ push された "performCutin" を実行できるように callNextMethod を拡張
|
||
const _callNext = Window_BattleLog.prototype.callNextMethod;
|
||
Window_BattleLog.prototype.callNextMethod = function () {
|
||
const method = this._methods[0];
|
||
if (method && method.name === "performCutin") {
|
||
this.performCutin(...method.params);
|
||
this._methods.shift();
|
||
} else {
|
||
_callNext.call(this);
|
||
}
|
||
};
|
||
})(); |