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

56 lines
2.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*:
* @target MZ
* @plugindesc [MZ] ステート43〜49を付与中はアイテムを選択不可非表示にはしない
* @author you
* @help
* 概要:
* - アクターがステートID 43〜49のいずれかを付与中のとき、
* アイテムは一覧に表示されたままグレーアウトして選択不可になります。
* - メニュー画面、戦闘画面の両方で有効です。
*
* 備考:
* - 既存の使用可否判定MP/TP不足、メモ欄の制限、装備不可なども尊重し、
* それらで「不可」の場合は本プラグイン以前に不可になります。
* - 「非表示」にはしませんincludes判定は変更しません
* - 対象は「使用者となるアクター」です(パーティ内の誰かではなく、現在の選択アクター基準)。
*/
(() => {
// 対象ステート範囲固定仕様43〜49
const STATE_MIN = 43;
const STATE_MAX = 49;
// 現在の“使用者”アクターを取り出すユーティリティ
function currentUserActor() {
// メニュー中は menuActor、戦闘中は BattleManager.actor()
// どちらも無ければ null
return $gameParty.menuActor?.() || (typeof BattleManager !== "undefined" ? BattleManager.actor() : null) || null;
}
// 指定範囲のいずれかのステートを付与されているか
function isAffectedInRange(actor) {
if (!actor) return false;
for (let id = STATE_MIN; id <= STATE_MAX; id++) {
if (actor.isStateAffected(id)) return true;
}
return false;
}
// --- メニュー/戦闘のアイテムリストの有効判定を拡張 ---
const _Window_ItemList_isEnabled = Window_ItemList.prototype.isEnabled;
Window_ItemList.prototype.isEnabled = function(item) {
// まずは元のロジックで使用可能か
const base = _Window_ItemList_isEnabled.call(this, item);
if (!base) return false;
// 現在の使用者アクターを取得し、ステート43〜49なら不可
const actor = currentUserActor();
if (actor && isAffectedInRange(actor)) {
return false;
}
return true;
};
// 参考:非表示化はしないため includes は触りません
// Window_ItemList.prototype.includes = ... はデフォルトのまま
})();