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

68 lines
2.5 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] 変数条件で特定スキルのみ使用可(未達時は灰色で選択不可&表示維持)
* @author You
* @help
* 指定したスキル(既定: ID 269は、変数44が0のときのみ使用可能にします。
* 条件を満たさない場合でも、スキルリストには表示されますが選択不可(灰色)になります。
*
* 仕様:
* - 戦闘中/メニュー画面の両方に適用されますcanUse をフック)。
* - MP/TP/ステート等、通常の使用可否条件も引き続き判定されます。
*
* 設定を変えたい場合はパラメータで上書きしてください。
*
* @param SkillId
* @text 対象スキルID
* @type number
* @min 1
* @default 269
*
* @param VariableId
* @text 判定する変数ID
* @type variable
* @default 44
*
* @param AllowedValue
* @text 使用許可となる値
* @type number
* @default 0
*
* @param OnlyWhenLearned
* @text 習得済みのみ対象にする
* @type boolean
* @on はい
* @off いいえ
* @desc ONの場合、アクターが対象スキルを習得しているときのみ本条件を適用します。
* @default true
*/
(() => {
"use strict";
const PLUGIN_NAME = document.currentScript?.src?.match(/([^\/]+)\.js$/)?.[1] || "SkillVarGate";
const params = PluginManager.parameters(PLUGIN_NAME);
const SKILL_ID = Number(params.SkillId || 269);
const VAR_ID = Number(params.VariableId || 44);
const ALLOW = Number(params.AllowedValue || 0);
const ONLY_LEARNED = String(params.OnlyWhenLearned || "true") === "true";
const _Game_BattlerBase_canUse = Game_BattlerBase.prototype.canUse;
Game_BattlerBase.prototype.canUse = function(item) {
// 通常判定(ここで false の場合はそのまま false 返すため、先に自前チェックでも可)
// ただし「表示はされるが選択不可」にしたいだけなので、
// canUse の最終結果として false に落とせば十分。
if (DataManager.isSkill(item) && item && item.id === SKILL_ID) {
// 任意: 習得済みのみ対象にする
if (!ONLY_LEARNED || (this.isActor?.() && this.skills && this.skills().includes(item))) {
const v = $gameVariables.value(VAR_ID);
if (v !== ALLOW) {
// 条件未達: 使用不可(= リスト上は灰色で選択不可)
return false;
}
}
}
// 通常の可否判定
return _Game_BattlerBase_canUse.call(this, item);
};
})();