134 lines
5.3 KiB
JavaScript
134 lines
5.3 KiB
JavaScript
/*:
|
|
* @target MZ
|
|
* @plugindesc アクター1専用スキル再選択機能 + CTBウィンドウ制御 + バトルログ背面化
|
|
* @author
|
|
*
|
|
* @help
|
|
* 【機能】
|
|
* - アクター1がスキルを使用した後にスキルウィンドウを再表示します。
|
|
* - 変数201が5以上のときは再表示しません。
|
|
* - 指定したスキルIDは再表示の対象外にできます。
|
|
* - スキルウィンドウ表示中は行動順序ウィンドウを非表示にします。
|
|
* - キャンセルするとリングコマンドに戻ります。
|
|
* - スキルウィンドウ表示時にバトルログをヘルプウィンドウより背面へ移動します。
|
|
*/
|
|
|
|
(() => {
|
|
let lastSkillActor = null;
|
|
let lastSkillStypeId = null;
|
|
|
|
// 再オープン対象外スキルID
|
|
const EXCLUDED_SKILL_IDS = [2, 20, 22, 23, 266, 267, 268, 270, 1003, 1176, 2000];
|
|
|
|
// スキル使用時にアクターを記憶
|
|
const _Game_Battler_useItem = Game_Battler.prototype.useItem;
|
|
Game_Battler.prototype.useItem = function(item) {
|
|
_Game_Battler_useItem.call(this, item);
|
|
|
|
if (this.isActor() && DataManager.isSkill(item)) {
|
|
if (EXCLUDED_SKILL_IDS.includes(item.id)) {
|
|
console.log(`[skillContinue] useItem: スキルID${item.id}は再オープン対象外`);
|
|
return;
|
|
}
|
|
if (this.actorId() === 1 && $gameVariables.value(201) < 5) {
|
|
console.log("[skillContinue] useItem: スキル使用検出 actor =", this.name(), "stypeId =", item.stypeId);
|
|
lastSkillActor = this;
|
|
lastSkillStypeId = item.stypeId;
|
|
}
|
|
}
|
|
};
|
|
|
|
// updateフックでスキルウィンドウ再表示を検出
|
|
const _Scene_Battle_update = Scene_Battle.prototype.update;
|
|
Scene_Battle.prototype.update = function() {
|
|
_Scene_Battle_update.call(this);
|
|
|
|
if (lastSkillActor && this._actorCommandWindow.active) {
|
|
if (lastSkillActor.actorId() !== 1 || $gameVariables.value(201) >= 5) {
|
|
lastSkillActor = null;
|
|
lastSkillStypeId = null;
|
|
return;
|
|
}
|
|
|
|
if (this.SoR_ringbcom) {
|
|
if (this.SoR_ringbcom.setInvisible) this.SoR_ringbcom.setInvisible();
|
|
if ("active" in this.SoR_ringbcom) this.SoR_ringbcom.active = false;
|
|
}
|
|
|
|
this.startDirectSkillSelection(lastSkillActor, lastSkillStypeId);
|
|
lastSkillActor = null;
|
|
lastSkillStypeId = null;
|
|
}
|
|
};
|
|
|
|
// スキルウィンドウ再表示
|
|
Scene_Battle.prototype.startDirectSkillSelection = function(actor, stypeId) {
|
|
if (!actor) return;
|
|
if (actor.actorId() !== 1 || $gameVariables.value(201) >= 5) return;
|
|
|
|
BattleManager._actorIndex = actor.index();
|
|
|
|
if (this._ctbWindow?.skillHide) this._ctbWindow.skillHide();
|
|
this._actorCommandWindow.close();
|
|
this._actorCommandWindow.deactivate();
|
|
|
|
this._skillWindow.setActor(actor);
|
|
this._skillWindow.setStypeId(stypeId ?? 1);
|
|
this._skillWindow.makeItemList();
|
|
this._skillWindow.refresh();
|
|
|
|
if (this._skillWindow.maxItems() > 0) {
|
|
this._skillWindow.show();
|
|
this._skillWindow.activate();
|
|
this._skillWindow.select(0);
|
|
|
|
// ★ バトルログを MOG_BattleHud の背面に移動
|
|
if (this._logWindow && this._hudField && this._hudField.parent) {
|
|
console.log("[skillContinue] バトルログを MOG_BattleHud の背面に移動");
|
|
const parent = this._hudField.parent;
|
|
const hudIndex = parent.getChildIndex(this._hudField);
|
|
if (this._logWindow.parent !== parent) {
|
|
this._logWindow.parent.removeChild(this._logWindow);
|
|
parent.addChildAt(this._logWindow, hudIndex);
|
|
} else {
|
|
// 親が同じなら位置を再調整
|
|
parent.setChildIndex(this._logWindow, hudIndex);
|
|
}
|
|
}
|
|
} else {
|
|
this.onSkillCancel();
|
|
}
|
|
};
|
|
|
|
|
|
// キャンセル時にリングコマンドへ復帰
|
|
Scene_Battle.prototype.onSkillCancel = function() {
|
|
this._skillWindow.hide();
|
|
if (this._ctbWindow?.show) this._ctbWindow.show();
|
|
this.commandFight();
|
|
};
|
|
|
|
// 戦闘終了時に状態をクリア
|
|
const _BattleManager_endBattle = BattleManager.endBattle;
|
|
BattleManager.endBattle = function(result) {
|
|
lastSkillActor = null;
|
|
lastSkillStypeId = null;
|
|
_BattleManager_endBattle.call(this, result);
|
|
};
|
|
})();
|
|
const _Scene_Battle_commandSkill = Scene_Battle.prototype.commandSkill;
|
|
Scene_Battle.prototype.commandSkill = function() {
|
|
_Scene_Battle_commandSkill.call(this);
|
|
|
|
if (this._logWindow && this._hudField && this._hudField.parent) {
|
|
console.log("[skillContinue] commandSkill: 戦闘開始直後もバトルログをMOGヘルプ背面に移動");
|
|
const parent = this._hudField.parent;
|
|
const hudIndex = parent.getChildIndex(this._hudField);
|
|
if (this._logWindow.parent !== parent) {
|
|
this._logWindow.parent.removeChild(this._logWindow);
|
|
parent.addChildAt(this._logWindow, hudIndex);
|
|
} else {
|
|
parent.setChildIndex(this._logWindow, hudIndex);
|
|
}
|
|
}
|
|
};
|