//============================================================================ // HelpWindow_Extension.js // // --------------------------------------------------------------------------- // by ecf5DTTzl6h6lJj02 // 2019/10/03 //============================================================================ /*: * @plugindesc ヘルプウィンドウで指定パラメータを表示する機能を追加するプラグインです。 * 詳しくはヘルプをどうぞ。 * @author ecf5DTTzl6h6lJj02 * * * @help * ヘルプウィンドウに指定パラメータを表示する機能を追加するプラグインです。 * スキルの説明欄での使用を想定しています。 * それ以外での使用は想定していませんので、ご注意ください。 * * プラグインコマンドはありません。 * * ■表示できる項目と表示方法 * スキル の 説明 欄に入力する際に %項目名 と記述することで、 * 表示の際に、そのパラメータの数値に置き換わります。 * * ○使用できる項目名 * ・mp_cost * 消費MPを表示します。 MP消費率が設定されている場合は計算されます。 * ・tp_cost * 消費TPを表示します。 * ・power * スキルの威力を表示します。 * スキルのダメージ計算式から b.○○○ * X で表わされる対象の防御に関する項を * 0にしたものを計算して表示します。 * * 利用規約: * この作品は マテリアル・コモンズ・ブルー・ライセンスの下に提供されています。 * https://materialcommons.tk/mtcm-b-summary/ * */ (function(){ //ヘルプテキスト設定 var HE_setText = Window_Help.prototype.setText; Window_Help.prototype.setText = function(text){ //ミニインフォとバトルレイアウト変更を同時使用している際に、 //ヘルプテキストが正しく渡されないことがあるので、取得しなおす。 if(Imported['MiniInformationWindow'] && Imported['BattleLayout-SaGa'] && $gameParty.inBattle()){ item = SceneManager._scene._actorCommandWindow.currentExt(); text = (item ? item.description : ''); } if(this._text !== text){ if(text.includes("%mp_cost") || text.includes("%tp_cost") || text.includes("%power")){ text = this.processText(text); } } HE_setText.call(this, text); this.refresh(); }; //ヘルプテキストの代替文字(%項目名)の処理 Window_Help.prototype.processText = function(text){ //プラグイン使用状況や、場面によって、アクター や アイテム の取得方法を変更 if( $gameParty.inBattle()){ //バトル中のスキルやアイテム(但しアイテムでは機能しない) actor = SceneManager._scene._actorCommandWindow._actor; //ミニインフォメーションウィンドウと、バトルレイアウト変更SaGaを同時使用しているとき if(Imported['MiniInformationWindow'] && Imported['BattleLayout-SaGa']){ item = SceneManager._scene._actorCommandWindow.currentExt(); } //ミニインフォとバトルレイアウト変更は同時使用していないが、スキルウィンドウが開いているとき else if(SceneManager._scene._skillWindow.active){ item = SceneManager._scene._skillWindow.item(); } //それ以外(アイテム画面) else{ item = SceneManager._scene._itemWindow.item(); } } else{ //メニュー画面からのスキルやアイテム(但しアイテムでは機能しない) actor = SceneManager._scene._actor; item = SceneManager._scene._itemWindow.item(); } if(text.includes("%mp_cost")){ text = text.replace(/\%mp_cost/g, String(actor.skillMpCost(item))); } if(text.includes("%tp_cost")){ text = text.replace(/\%tp_cost/g, String(actor.skillTpCost(item))); } if(text.includes("%power")){ text = text.replace(/\%power/g, String(this.calcItemPower(item, actor))); } return text; }; //スキル威力計算処理 Window_Help.prototype.calcItemPower = function(item, actor){ formula = item.damage.formula; formula = formula.replace(/\s/g, ""); formula = formula.replace(/a\./g, "actor."); //formula = formula.replace(/-/g, ""); formula = formula.replace(/b\.[a-z]*\*{0,}[0-9]{0,}\.{0,}[0-9]{0,}/g, "0"); return Math.floor(eval(formula)); }; //アクターコマンド ヘルプウィンドウの更新 //バトルレイアウト変更-Saga と ミニインフォメーションウィンドウを同時使用したときの //対応のための再定義 Window_ActorCommand.prototype.updateHelp = function() { Window_Selectable.prototype.updateHelp.call(this); if (Imported['MiniInformationWindow']) { var item = this.currentExt(); var a = null; var actor = this._actor; if (item && item.description){ var text = item.description; //めんどくさいので、この中で %項目名 を全部処理 if(text.includes("%mp_cost")){ text = text.replace(/\%mp_cost/g, String(actor.skillMpCost(item))); } if(text.includes("%tp_cost")){ text = text.replace(/\%tp_cost/g, String(actor.skillTpCost(item))); } if(text.includes("%power")){ var formula = item.damage.formula; formula = formula.replace(/\s/g, ""); formula = formula.replace(/a\./g, "actor."); formula = formula.replace(/b\.[a-z]*\*{0,}[0-9]{0,}\.{0,}[0-9]{0,}/g, "0"); text = text.replace(/%power/g, String( Math.floor(eval(formula)))); } text = text.replace(/\\n/gi,'\n'); //a = {name:item.name,data:text.split('\n')}; a = {data:text.split('\n')}; } this.setHelpWindowItem(a); } }; })();