//============================================================================= // SealActorCommand.js // ---------------------------------------------------------------------------- // Copyright (c) 2015-2017 Triacontane // This software is released under the MIT License. // http://opensource.org/licenses/mit-license.php // ---------------------------------------------------------------------------- // Version // 1.4.0 2018/12/22 禁止コマンドの上に文字を被せられる機能を追加 // 1.3.0 2018/12/17 封印したコマンドを非表示ではなく使用禁止にできる機能を追加 // 1.2.0 2017/03/08 アイテム使用をスキルのひとつとして作成できる機能を追加 // 1.1.0 2017/02/23 封印対象にスキルを追加 // 1.0.0 2017/02/22 初版 // ---------------------------------------------------------------------------- // [Blog] : http://triacontane.blogspot.jp/ // [Twitter]: https://twitter.com/triacontane/ // [GitHub] : https://github.com/triacontane/ //============================================================================= /*: @url https://triacontane.blogspot.com/ @plugindesc Actor Command Seal Plugin @author Triacontane @license MIT License @help English Help Translator: munokura This is an unofficial English translation of the plugin help, created to support global RPG Maker users. Feedback is welcome to improve translation quality (see: https://github.com/munokura/triacontane-MV-plugins ). Original plugin by Triacontane. Please check the latest official version at: https://triacontane.blogspot.com ----- You can seal actor commands "Attack," "Defense," "Item," and "Skill." Sealed commands will disappear from the window. You can create actors, jobs, equipment, and states that cannot use specific commands. You can also specify more detailed conditions using switches and JavaScript formulas. Please enter the following in the Note field of the characteristic database. - Seals attacks when switch ID [4] is ON. - Seals defense when switch ID [5] is ON. - Seals an item when switch ID [6] is ON. - Seals a skill when switch ID [7] is ON. - Seals attacks when formula [f] is true. - Seals defense when formula [f] is true. - Seal the item when formula [f] evaluates to true - Seal the skill when formula [f] evaluates to true If you want to use inequality signs in text or scripts, write them as follows: < → < > → > # Example - Seal attack if variable [1] is 5 or less - Always seal defense Caution! Sealing all commands will prevent the game from continuing. If you want to turn item use into a skill, enter the following in the skill's Note field. After selecting the target skill, the item window will open. - Turns an item into a skill This plugin does not have any plugin commands. Terms of Use: You may modify and redistribute this plugin without permission from the author, and there are no restrictions on its use (commercial, 18+, etc.). This plugin is now yours. @param commandDisable @text Command prohibition @desc Sealed commands are disabled rather than hidden. @type boolean @default false @param disableSign @text Prohibited use sign @desc The string to be overlaid on top of the disabled command (only works if command disabling is enabled). @default \c[2]\i[1]Prohibited\i[1] */ /*:ja @plugindesc アクターコマンド封印プラグイン @author トリアコンタン @param commandDisable @text コマンド使用禁止 @desc 封印したコマンドを非表示ではなく使用禁止にします。 @default false @type boolean @param disableSign @text 使用禁止サイン @desc 使用禁止にしたコマンドのうえに被せる文字列です。(コマンド使用禁止が有効な場合のみ機能します) @default \c[2]\i[1]禁止\i[1] @help アクターコマンド「攻撃」「防御」「アイテム」「スキル」を封印できます。 封印されたコマンドはウィンドウから消失します。 特定のコマンドが使用できないアクター、職業、装備品、ステートが作成できます。 さらに、スイッチやJavaScript計算式により、細かい条件が指定できます。 特徴を有するデータベースのメモ欄に以下の通り記入してください。 # ID[4]のスイッチがONのとき攻撃を封印 # 同上 # ID[5]のスイッチがONのとき防御を封印 # 同上 # ID[6]のスイッチがONのときアイテムを封印 # 同上 # ID[7]のスイッチがONのときスキルを封印 # 同上 # 計算式[f]の結果がtrueのとき攻撃を封印 # 同上 # 計算式[f]の結果がtrueのとき防御を封印 # 同上 # 計算式[f]の結果がtrueのときアイテムを封印 # 同上 # 計算式[f]の結果がtrueのときスキルを封印 # 同上 文章、スクリプト中で不等号を使いたい場合、以下のように記述してください。 < → < > → > 例 # 変数[1]が5以下の場合攻撃封印 # 常に防御封印 注意! 全てのコマンドを封印するとゲームが続行不可になります。 アイテム使用をスキル化したい場合は、スキルのメモ欄に以下の通り 入力してください。対象スキルを選択後、アイテムウィンドウが開きます。 # アイテム使用スキル化 # 同上 このプラグインにはプラグインコマンドはありません。 利用規約: 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等) についても制限はありません。 このプラグインはもうあなたのものです。 */ (function () { 'use strict'; var metaTagPrefix = 'SAC'; var getArgNumber = function (arg, min, max) { if (arguments.length < 2) min = -Infinity; if (arguments.length < 3) max = Infinity; return (parseInt(arg) || 0).clamp(min, max); }; var getMetaValue = function (object, name) { var metaTagName = metaTagPrefix + name; return object.meta.hasOwnProperty(metaTagName) ? convertEscapeCharacters(object.meta[metaTagName]) : undefined; }; var getMetaValues = function (object, names) { for (var i = 0, n = names.length; i < n; i++) { var value = getMetaValue(object, names[i]); if (value !== undefined) return value; } return undefined; }; var convertEscapeCharacters = function (text) { if (text === true) return text; if (text == null) text = ''; text = text.replace(/>?/gi, '>'); text = text.replace(/<?/gi, '<'); var windowLayer = SceneManager._scene._windowLayer; return windowLayer ? windowLayer.children[0].convertEscapeCharacters(text) : text; }; /** * Create plugin parameter. param[paramName] ex. param.commandPrefix * @param pluginName plugin name(EncounterSwitchConditions) * @returns {Object} Created parameter */ var createPluginParameter = function (pluginName) { var paramReplacer = function (key, value) { if (value === 'null') { return value; } if (value[0] === '"' && value[value.length - 1] === '"') { return value; } try { return JSON.parse(value); } catch (e) { return value; } }; var parameter = JSON.parse(JSON.stringify(PluginManager.parameters(pluginName), paramReplacer)); PluginManager.setParameters(pluginName, parameter); return parameter; }; var param = createPluginParameter('SealActorCommand'); //============================================================================= // Game_Actor // コマンド封印が有効かどうかを判定します。 //============================================================================= Game_Actor.prototype.getSealMetaInfo = function (names) { var metaValue = null; this.traitObjects().some(function (traitObject) { metaValue = getMetaValues(traitObject, names); return metaValue; }); return metaValue; }; Game_Actor.prototype.isSealCommand = function (commandNames) { var switchId = this.getSealMetaInfo([commandNames[0] + 'Switch', commandNames[1] + '封印スイッチ']); if (switchId && $gameSwitches.value(getArgNumber(switchId))) { return true; } var formula = this.getSealMetaInfo([commandNames[0] + 'Formula', commandNames[1] + '封印計算式']); return formula && eval(formula); }; Game_Actor.prototype.isSealCommandAttack = function () { return this.isSealCommand(['Attack', '攻撃']); }; Game_Actor.prototype.isSealCommandGuard = function () { return this.isSealCommand(['Guard', '防御']); }; Game_Actor.prototype.isSealCommandItem = function () { return this.isSealCommand(['Item', '道具']); }; Game_Actor.prototype.isSealCommandSkill = function () { return this.isSealCommand(['Skill', 'スキル']); }; //============================================================================= // Window_ActorCommand // コマンドが封印されていた場合、処理を終了します。 //============================================================================= var _Window_ActorCommand_addAttackCommand = Window_ActorCommand.prototype.addAttackCommand; Window_ActorCommand.prototype.addAttackCommand = function () { if (this._actor.isSealCommandAttack()) { if (param.commandDisable) { _Window_ActorCommand_addAttackCommand.apply(this, arguments); this.disableCommand('attack'); } return; } _Window_ActorCommand_addAttackCommand.apply(this, arguments); }; var _Window_ActorCommand_addGuardCommand = Window_ActorCommand.prototype.addGuardCommand; Window_ActorCommand.prototype.addGuardCommand = function () { if (this._actor.isSealCommandGuard()) { if (param.commandDisable) { _Window_ActorCommand_addGuardCommand.apply(this, arguments); this.disableCommand('guard'); } return; } _Window_ActorCommand_addGuardCommand.apply(this, arguments); }; var _Window_ActorCommand_addItemCommand = Window_ActorCommand.prototype.addItemCommand; Window_ActorCommand.prototype.addItemCommand = function () { if (this._actor.isSealCommandItem()) { if (param.commandDisable) { _Window_ActorCommand_addItemCommand.apply(this, arguments); this.disableCommand('item'); } return; } _Window_ActorCommand_addItemCommand.apply(this, arguments); }; var _Window_ActorCommand_addSkillCommands = Window_ActorCommand.prototype.addSkillCommands; Window_ActorCommand.prototype.addSkillCommands = function () { if (this._actor.isSealCommandSkill()) { if (param.commandDisable) { _Window_ActorCommand_addSkillCommands.apply(this, arguments); this.disableCommand('skill'); } return; } _Window_ActorCommand_addSkillCommands.apply(this, arguments); }; Window_ActorCommand.prototype.disableCommand = function (symbol) { this._list.forEach(function (command) { if (command.symbol === symbol) { command.enabled = false; } }); }; var _Window_ActorCommand_drawItem = Window_ActorCommand.prototype.drawItem; Window_ActorCommand.prototype.drawItem = function (index) { _Window_ActorCommand_drawItem.apply(this, arguments); var sign = param.disableSign; if (!this.isCommandEnabled(index) && sign) { var rect = this.itemRectForText(index); var width = this.drawTextEx(sign, this.windowWidth(), 0); var height = this.calcTextHeight({ text: sign }, false); this.resetFontSettings(); this.resetTextColor(); this.changePaintOpacity(true); this.drawTextEx(sign, rect.x + rect.width / 2 - width / 2, rect.y + rect.height / 2 - height / 2); this.resetFontSettings(); this.resetTextColor(); this.changePaintOpacity(false); } }; //============================================================================= // Scene_Battle // アイテムスキルを作成します。 //============================================================================= var _Scene_Battle_onItemCancel = Scene_Battle.prototype.onItemCancel; Scene_Battle.prototype.onItemCancel = function () { if (this._selectItemSkill) { this._itemWindow.hide(); this._skillWindow.show(); this._skillWindow.activate(); this._selectItemSkill = false; } else { _Scene_Battle_onItemCancel.apply(this, arguments); } }; var _Scene_Battle_onSkillOk = Scene_Battle.prototype.onSkillOk; Scene_Battle.prototype.onSkillOk = function () { var skill = this._skillWindow.item(); if (getMetaValues(skill, ['アイテムスキル', 'ItemSkill'])) { var action = BattleManager.inputtingAction(); action.setSkill(skill.id); BattleManager.actor().setLastBattleSkill(skill); this._skillWindow.hide(); this.commandItem(); this._selectItemSkill = true; } else { _Scene_Battle_onSkillOk.apply(this, arguments); } }; var _Scene_Battle_onActorCancel = Scene_Battle.prototype.onActorCancel; Scene_Battle.prototype.onActorCancel = function () { if (this._selectItemSkill) { this._actorWindow.hide(); this._itemWindow.show(); this._itemWindow.activate(); } else { _Scene_Battle_onActorCancel.apply(this, arguments); } }; var _Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel; Scene_Battle.prototype.onEnemyCancel = function () { if (this._selectItemSkill) { this._enemyWindow.hide(); this._itemWindow.show(); this._itemWindow.activate(); } else { _Scene_Battle_onEnemyCancel.apply(this, arguments); } }; var _Scene_Battle_selectNextCommand = Scene_Battle.prototype.selectNextCommand; Scene_Battle.prototype.selectNextCommand = function () { _Scene_Battle_selectNextCommand.apply(this, arguments); this._selectItemSkill = false; }; })();