91 lines
2.8 KiB
JavaScript
91 lines
2.8 KiB
JavaScript
//=============================================================================
|
||
// RPG Maker MZ - IM_SkillRestrictLevel
|
||
//
|
||
// Copyright 2025 min-pub. All rights reserved.
|
||
// This source code or any portion thereof must not be
|
||
// reproduced or used without licensed in any manner whatsoever.
|
||
//=============================================================================
|
||
/*:
|
||
* @target MZ
|
||
* @plugindesc スキルのレベル制限
|
||
* @author 四号戦車
|
||
* @base PluginCommonBase
|
||
* @base PluginUtils
|
||
* @orderAfter PluginCommonBase
|
||
* @orderAfter PluginUtils
|
||
*
|
||
* @param skillList
|
||
* @text スキルリスト
|
||
* @desc 対象スキルのリスト
|
||
* @type struct<SkillSet>[]
|
||
* @default []
|
||
*
|
||
* @help IM_SkillRestrictLevel.js
|
||
*
|
||
* Version: 0.0.1
|
||
*
|
||
* 指定のスキルを指定レベル以下で利用できないようにします。
|
||
*
|
||
*/
|
||
|
||
/*~struct~SkillSet:
|
||
*
|
||
* @param skill
|
||
* @text 対象スキル
|
||
* @desc 対象のスキル
|
||
* @type skill
|
||
* @default 0
|
||
*
|
||
* @param level
|
||
* @text 使用可能レベル
|
||
* @desc スキル使用可能なレベル
|
||
* @type number
|
||
* @default 1
|
||
* @min 1
|
||
*
|
||
*/
|
||
(() => {
|
||
"use strict";
|
||
|
||
//========================================================================
|
||
// プラグイン定義
|
||
//========================================================================
|
||
const pluginName = "LevelLimit";
|
||
const script = document.currentScript;
|
||
const param = PluginUtils.reparseParameter(script);
|
||
|
||
//========================================================================
|
||
// 定数定義
|
||
//========================================================================
|
||
|
||
//========================================================================
|
||
// コアスクリプト変更部 (Window_SkillList)
|
||
//========================================================================
|
||
const _Window_SkillList_prototype_isEnabled = Window_SkillList.prototype.isEnabled;
|
||
Window_SkillList.prototype.isEnabled = function(item) {
|
||
if (_Window_SkillList_prototype_isEnabled.apply(this, arguments) === false) {
|
||
// 元々使えないスキルはそのまま使えない
|
||
return false;
|
||
}
|
||
|
||
if (!item) {
|
||
// (念のため)itemが空nullなら使えない
|
||
return false;
|
||
}
|
||
|
||
const targetSkill = param.skillList.find(registeredSkill => {
|
||
return registeredSkill.skill === item.id;
|
||
});
|
||
|
||
if (!targetSkill) {
|
||
// 登録されてないスキルなので使用可能
|
||
return true;
|
||
}
|
||
|
||
const level = this._actor.level;
|
||
|
||
// Actorのレベルが指定のレベル以上なら有効(未満ならグレーアウト)
|
||
return level >= targetSkill.level;
|
||
};
|
||
|
||
})();
|