//============================================================================= // CursedAction.js // ---------------------------------------------------------------------------- // (C)2018 Triacontane // This software is released under the MIT License. // http://opensource.org/licenses/mit-license.php // ---------------------------------------------------------------------------- // Version // 1.0.2 2021/08/26 呪い確率を設定する英名のメモ欄「CurseRate」が機能していなかった問題を修正 // 1.0.1 2020/02/26 特定条件化で戦闘行動の強制を実行するとエラーになる問題を修正 // 1.0.0 2018/06/16 初版 // ---------------------------------------------------------------------------- // [Blog] : https://triacontane.blogspot.jp/ // [Twitter]: https://twitter.com/triacontane/ // [GitHub] : https://github.com/triacontane/ //============================================================================= /*: @url https://triacontane.blogspot.com/ @plugindesc Curse 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 ----- CursedAction.js During battle, you can have the character take an action different from the specified one. You can also set the conditions and probability for the action to change. Enter the following in the Note field of the characteristic database (※1). # Uses skill ID [20] regardless of the selected action. # 50% chance of using the skill specified in Skill 1. # Skill 1's usage condition becomes the evaluation result of script [s]. *1 Applies to actors, jobs, weapons/armor, states, and Enemies. To specify multiple actions simultaneously, specify them as follows: If multiple action conditions are met, the action will be determined randomly. This plugin does not have any plugin commands. Terms of Use: You may modify and redistribute it without permission from the author, and there are no restrictions on its use (commercial use, use under 18+, etc.). This plugin is now yours. @param priority @desc Choose your priority between auto-combat and chaos settings. @type select @default 2 @option low priority @value 0 @option Prioritizes auto-battle @value 1 @option Auto-battle takes priority over chaos @value 2 @param message @text Cursed Message @desc This is the message to display when a curse changes behavior. %1 will be converted to the butler's name. @param commandPrefix @text Note field prefix @desc This is the prefix to specify when the name of the Note field or plugin command overlaps with that of another plugin. Normally, it is not necessary to specify this. */ /*:ja @plugindesc 呪いのプラグイン @author トリアコンタン @param priority @text 優先度 @desc 自動戦闘および混乱の設定との優先度を選択します。 @default 2 @type select @option 優先度低 @value 0 @option 自動戦闘より優先 @value 1 @option 自動戦闘、混乱より優先 @value 2 @param message @text 呪いのメッセージ @desc 呪いによって行動が変化した場合に表示するメッセージです。%1でバトラー名に変換されます。 @default @param commandPrefix @text メモ欄接頭辞 @desc 他のプラグインとメモ欄もしくはプラグインコマンドの名称が被ったときに指定する接頭辞です。通常は指定不要です。 @default @help CursedAction.js 戦闘中、指定した行動とは異なる行動を取らせることができます。 行動が変化する条件や確率も設定できます。 特徴を有するデータベース(※1)のメモ欄に以下の通り入力してください。 <呪いスキル1:20> # 選択した行動にかかわらずID[20]のスキルを使用 # 同上 <呪い確率1:50> # スキル1で指定したスキルの使用確率が50%になる # 同上 <呪い条件1:s> # スキル1の使用条件がスクリプト[s]の評価結果になる # 同上 ※1 アクター、職業、武器防具、ステート、敵キャラが該当します。 複数の行動を同時指定したい場合は以下のように指定します。 <呪いスキル2:21> <呪い確率2:50> <呪い条件2:s> 複数の行動の条件を満たした場合はランダムで行動が決まります。 このプラグインにはプラグインコマンドはありません。 利用規約: 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等) についても制限はありません。 このプラグインはもうあなたのものです。 */ (function () { 'use strict'; /** * Get database meta information. * @param object Database item * @param name Meta name * @returns {String} meta value */ var getMetaValue = function (object, name) { var tagName = param.commandPrefix + name; return object.meta.hasOwnProperty(tagName) ? convertEscapeCharacters(object.meta[tagName]) : null; }; /** * Get database meta information.(for multi language) * @param object Database item * @param names Meta name array (for multi language) * @returns {String} meta value */ var getMetaValues = function (object, names) { var metaValue; names.some(function (name) { metaValue = getMetaValue(object, name); return metaValue !== null; }); return metaValue; }; /** * Convert escape characters.(require any window object) * @param text Target text * @returns {String} Converted text */ var convertEscapeCharacters = function (text) { var windowLayer = SceneManager._scene._windowLayer; return windowLayer ? windowLayer.children[0].convertEscapeCharacters(text.toString()) : 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('CursedAction'); /** * Game_Action:呪い行動を実行します。 */ var _Game_Action_prepare = Game_Action.prototype.prepare; Game_Action.prototype.prepare = function () { _Game_Action_prepare.apply(this, arguments); var skillId = this.subject().getCursedSkillIdIfExist(); if (skillId) { this.setSkill(skillId); } }; /** * Game_Battler:呪い行動の作成処理を追加します。 */ Game_Battler.prototype.getCursedSkillIdIfExist = function () { this._cursedActionList = []; if (!this.canCurse()) { return null; } this.createCursedActionList(); if (this.isCursed()) { return this._cursedActionList[Math.randomInt(this._cursedActionList.length)]; } else { return null; } }; Game_Battler.prototype.createCursedActionList = function () { var index = 1; while (this.addCursedAction(index)) { index++; } }; Game_Battler.prototype.addCursedAction = function (index) { var skillIdText = this.getMetaInfoCursedAction(['呪いスキル', 'CurseSkill'], index); if (skillIdText) { var rate = this.getMetaInfoCursedAction(['呪い確率', 'CurseRate'], index); if (rate && parseInt(rate) < Math.randomInt(100)) { return true; } var cond = this.getMetaInfoCursedAction(['呪い条件', 'CurseCond'], index); if (cond && !eval(cond)) { return true; } this._cursedActionList.push(parseInt(skillIdText)); } return skillIdText; }; Game_Battler.prototype.getMetaInfoCursedAction = function (names, index) { var value = null; this.traitObjects().some(function (traitObject) { var meta = getMetaValues(traitObject, [names[0] + index, names[1] + index]); if (meta) { value = meta; } return meta; }); return value; }; Game_Battler.prototype.isCursed = function () { var list = this._cursedActionList; return list && list.length > 0; }; Game_Battler.prototype.canCurse = function () { return !(param.priority < 2 && this.isConfused()) && !this._forcing; }; /** * Game_Actor:呪い行動の作成処理を追加します。 */ Game_Actor.prototype.canCurse = function () { return Game_Battler.prototype.canCurse.call(this) && !(param.priority < 1 && this.isAutoBattle()); }; var _Window_BattleLog_startAction = Window_BattleLog.prototype.startAction; Window_BattleLog.prototype.startAction = function (subject, action, targets) { if (subject.isCursed() && param.message) { this.push('addText', param.message.format(subject.name())); } _Window_BattleLog_startAction.apply(this, arguments); }; })();