//============================================================================= // TMPlugin - スキルコスト拡張 // バージョン: 1.2.0 // 最終更新日: 2018/08/23 // 配布元 : http://hikimoki.sakura.ne.jp/ //----------------------------------------------------------------------------- // Copyright (c) 2016 tomoaky // Released under the MIT license. // http://opensource.org/licenses/mit-license.php //============================================================================= /*: @plugindesc Skills that consume HP or items instead of MP or TP @author tomoaky @url https://github.com/munokura/tomoaky-MV-plugins @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/tomoaky-MV-plugins ). Original plugin by tomoaky. ----- TMPlugin - Skill Cost Extension ver1.2.0 How to Use: You can add a cost by adding a tag to the skill's Note field. If the cost is an item set as "non-consumable" in the database, it will be treated as necessary but not consumed when using the skill. If HP is set as the cost, the skill cannot be used if the remaining HP is equal to the cost. However, if the skill has the hpCostNoSafety tag, the skill can be used even if the remaining HP is less than the cost. Naturally, the actor who used it will be Collapse. If experience points are set as the cost and the expCostNoLevelDown tag is also set, the skill cannot be used if paying the cost would result in a level loss. There are no plugin commands. This plugin has been tested with RPG Maker MV Version 1.6.1. This plugin is distributed under the MIT License and is free for commercial use, modification, redistribution, and other uses. Additional information on plugin parameters: hpVNumberId (mpVNumberId / tpVNumberId) The user's remaining HP immediately before the cost is consumed is assigned to the specified variable. You can reference the value of variable 1 by writing $gameVariables.value(1) in the damage calculation formula. You can also reference remaining HP by writing a.hp in the damage calculation formula, but this will be the value after the cost is consumed. hpCostVNId (mpCostVNId / tpCostVNId) The user's HP consumed immediately before the cost is consumed is assigned to the specified variable. You can Reflection this in the damage calculation formula in the same way as hpVNumberId. Memo Tag (Skill): # Sets the skill cost to 10 HP # Sets the skill cost to 50% of maximum HP # Sets the skill cost to 25% of remaining HP # Allows incapacitation by paying the HP cost # Sets the skill cost to 100% of maximum MP # Sets the skill cost to 50% of remaining MP # Excludes the effect of the "MP Cost Rate" trait from the MP cost # Sets the skill cost to 50% of remaining TP # When the skill's TP cost is insufficient, it can be activated by consuming all TP # Sets two items #1 as the skill cost. # Sets one weapon #2 as the skill cost. # Sets one armor #5 as the skill cost. # Sets 50 experience points as the skill cost. # Disables level down due to experience points. # Sets 100 gold as the skill cost. # Sets the value of game variable #3, 1, as the skill cost. Special usage of the vnCost tag: Only the vnCost memo tag allows you to use control characters to set the contents of the variable as a parameter. For example, when using a skill with the above tag, if the value of variable 14 is 16 and the value of variable 15 is 3, then 3 points will be consumed from the value of variable 16. @param hpVNumberId @desc Just before damage calculation and cost consumption, assign the "remaining HP of the actor" to this variable. @default 0 @type variable @param mpVNumberId @desc Just before damage calculation and cost consumption, assign the "remaining MP of the actor" to this variable. @default 0 @type variable @param tpVNumberId @desc Just before damage calculation and cost consumption, assign the "remaining TP of the actor" to this variable. @default 0 @type variable @param hpCostVNId @desc Just before damage calculation and cost consumption, assign "HP consumed by the actor" to this variable. @default 0 @type variable @param mpCostVNId @desc Just before damage calculation and cost consumption, assign the "MP consumed by the actor" to this variable. @default 0 @type variable @param tpCostVNId @desc Just before damage calculation and cost consumption, assign the "TP consumed by the actor" to this variable. @default 0 @type variable @param ignoreEnemyItemCost @desc How to handle when an enemy uses an item-consuming skill @default 1 @type select @option Consume a party item @value 0 @option Do not consume @value 1 */ /*:ja @plugindesc MPやTPの代わりにHPやアイテムを消費するスキルを @author tomoaky @url https://github.com/munokura/tomoaky-MV-plugins @license MIT License @help TMPlugin - スキルコスト拡張 ver1.2.0 使い方: スキルのメモ欄にタグを書き込むことでコストを追加できます。 データベースで 消耗しない に設定したアイテムをコストとした場合、 スキル使用時に必要だが消費はしないという扱いになります。 HPをコストとして設定した場合、残りHPがコストと同値では 使用できません。ただし、スキルに hpCostNoSafety タグがある場合は 残りHPがコスト以下でもスキルが使用できます。 当然使用したアクターは戦闘不能になります。 経験値をコストとして設定し、一緒に expCostNoLevelDown タグを 設定している場合、コストの支払いによってレベルが下がる状況では スキルの使用ができなくなります。 プラグインコマンドはありません。 このプラグインは RPGツクールMV Version 1.6.1 で動作確認をしています。 このプラグインはMITライセンスのもとに配布しています、商用利用、 改造、再配布など、自由にお使いいただけます。 プラグインパラメータの補足: hpVNumberId ( mpVNumberId / tpVNumberId ) コスト消費の直前、使用者の残りHPの値を、設定した変数に代入します。 ダメージ計算式に $gameVariables.value(1) と書けば、 変数 1 番の値を参照することができます。 ダメージ計算式に a.hp と書いた場合も残りHPを参照できますが、 こちらはコストを消費した後の値となります。 hpCostVNId ( mpCostVNId / tpCostVNId ) コスト消費の直前、使用者が消費するHPの値を、設定した変数に代入します。 hpVNumberId と同様の方法でダメージ計算式に反映させることができます。 メモ欄タグ(スキル): # スキルのコストとしてHP10を設定 # スキルのコストとして最大HPの50%を設定 # スキルのコストとして残りHPの25%を設定 # HPコスト支払いによる戦闘不能を許可する # スキルのコストとして最大MPの100%を設定 # スキルのコストとして残りMPの50%を設定 # MPコストから特徴『MP消費率』の効果を除外 # スキルのコストとして残りTPの50%を設定 # スキルのTPコスト不足時、TP全消費で発動可能 # スキルのコストとしてアイテム1番2個を設定 # スキルのコストとして武器2番1個を設定 # スキルのコストとして防具5番1個を設定 # スキルのコストとして経験値50を設定 # 経験値コストによるレベルダウンを禁止 # スキルのコストとしてお金100Gを設定 # スキルのコストとしてゲーム変数3番の値1を設定 vnCostタグの特殊な使い方: メモ欄タグ vnCost のみ制御文字を利用して変数の中身をパラメータとして 設定することができます。 たとえば上記のようなタグがついたスキルを使用する際に、変数14番の 値が 16 、変数15番の値が 3 だった場合は、変数16番の値を3消費 することになります。 @param hpVNumberId @desc ダメージ計算とコスト消費の直前のタイミングで、 この変数に『行動者の残りHP』を代入する @default 0 @type variable @param mpVNumberId @desc ダメージ計算とコスト消費の直前のタイミングで、 この変数に『行動者の残りMP』を代入する @default 0 @type variable @param tpVNumberId @desc ダメージ計算とコスト消費の直前のタイミングで、 この変数に『行動者の残りTP』を代入する @default 0 @type variable @param hpCostVNId @desc ダメージ計算とコスト消費の直前のタイミングで、 この変数に『行動者が消費するhP』を代入する @default 0 @type variable @param mpCostVNId @desc ダメージ計算とコスト消費の直前のタイミングで、 この変数に『行動者が消費するMP』を代入する @default 0 @type variable @param tpCostVNId @desc ダメージ計算とコスト消費の直前のタイミングで、 この変数に『行動者が消費するTP』を代入する @default 0 @type variable @param ignoreEnemyItemCost @desc 敵がアイテム消費スキルを使用する際の処理方法 @default 1 @type select @option パーティのアイテムを消費する @value 0 @option 消費しない @value 1 */ var Imported = Imported || {}; Imported.TMSkillCostEx = true; (function() { var parameters = PluginManager.parameters('TMSkillCostEx'); var HpVNumberId = +(parameters['hpVNumberId'] || 0); var MpVNumberId = +(parameters['mpVNumberId'] || 0); var TpVNumberId = +(parameters['tpVNumberId'] || 0); var HpCostVNId = +(parameters['hpCostVNId'] || 0); var MpCostVNId = +(parameters['mpCostVNId'] || 0); var TpCostVNId = +(parameters['tpCostVNId'] || 0); var IgnoreEnemyItemCost = +(parameters['ignoreEnemyItemCost'] || 1); //----------------------------------------------------------------------------- // Game_BattleBase // Game_BattlerBase.prototype.skillHpCost = function(skill) { var result = 0; if (skill.meta.hpCost) { result += +skill.meta.hpCost; } if (skill.meta.hpRateCost) { result += +skill.meta.hpRateCost * this.mhp / 100; } if (skill.meta.hpCRateCost) { result += +skill.meta.hpCRateCost * this._hp / 100; } return Math.floor(result); }; Game_BattlerBase.prototype.skillMpCost = function(skill) { var result = skill.mpCost; if (skill.meta.mpRateCost) { result += +skill.meta.mpRateCost * this.mmp / 100; } if (skill.meta.mpCRateCost) { result += +skill.meta.mpCRateCost * this._mp / 100; } if (!skill.meta.mpCostNoMcr) { result *= this.mcr; } return Math.floor(result); }; Game_BattlerBase.prototype.skillTpCost = function(skill) { var result = skill.tpCost; if (skill.meta.tpCRateCost) { result += +skill.meta.tpCRateCost * this._tp / 100; } result = Math.floor(result); if (skill.meta.ignoreTpCost && result > this._tp) { result = this._tp; } return result; }; Game_BattlerBase.prototype.skillItemCost = function(skill) { if (!this.isActor() && IgnoreEnemyItemCost === 1) { return null; } if (skill.meta.itemCost) { var re = /(i|w|a)(\d+)\*(\d+)/i; var match = re.exec(skill.meta.itemCost); if (match) { var itemCost = {}; var s = match[1].toUpperCase(); if (s === 'I') { itemCost.item = $dataItems[+match[2]]; } else if (s === 'W') { itemCost.item = $dataWeapons[+match[2]]; } else { itemCost.item = $dataArmors[+match[2]]; } itemCost.num = +match[3]; return itemCost; } } return null; }; Game_BattlerBase.prototype.skillExpCost = function(skill) { return !this.isEnemy() && skill.meta.expCost ? +skill.meta.expCost : 0; }; Game_BattlerBase.prototype.skillGoldCost = function(skill) { return !this.isEnemy() && skill.meta.goldCost ? +skill.meta.goldCost : 0; }; Game_BattlerBase.prototype.skillVNumberCost = function(skill) { if (skill.meta.vnCost) { var result = {}; var vnCost = skill.meta.vnCost.split('*'); var re = /\\V\[(\d+)\]/i; var match = re.exec(vnCost[0]); result.index = match ? $gameVariables.value(+match[1]) : +vnCost[0]; var match = re.exec(vnCost[1]); result.num = match ? $gameVariables.value(+match[1]) : +vnCost[1]; return result; } return null; }; var _Game_BattleBase_canPaySkillCost = Game_BattlerBase.prototype.canPaySkillCost; Game_BattlerBase.prototype.canPaySkillCost = function(skill) { if (!this.canPaySkillHpCost(skill) || !this.canPaySkillItemCost(skill) || !this.canPaySkillExpCost(skill) || !this.canPaySkillGoldCost(skill) || !this.canPaySkillVNumberCost(skill)) { return false; } return _Game_BattleBase_canPaySkillCost.call(this, skill); }; Game_BattlerBase.prototype.canPaySkillHpCost = function(skill) { if (skill.meta.hpCostNoSafety) { return true; } var hpCost = this.skillHpCost(skill); return hpCost <= 0 || this._hp > hpCost; }; Game_BattlerBase.prototype.canPaySkillItemCost = function(skill) { var itemCost = this.skillItemCost(skill); return !itemCost || $gameParty.numItems(itemCost.item) >= itemCost.num; }; Game_BattlerBase.prototype.canPaySkillExpCost = function(skill) { var expCost = this.skillExpCost(skill); return expCost === 0 || (this.currentExp() >= expCost && (!skill.meta.expCostNoLevelDown || this.currentExp() - expCost >= this.currentLevelExp())); }; Game_BattlerBase.prototype.canPaySkillGoldCost = function(skill) { return $gameParty.gold() >= this.skillGoldCost(skill); }; Game_BattlerBase.prototype.canPaySkillVNumberCost = function(skill) { var vnCost = this.skillVNumberCost(skill); return !vnCost || $gameVariables.value(vnCost.index) >= vnCost.num; }; var _Game_BattleBase_paySkillCost = Game_BattlerBase.prototype.paySkillCost; Game_BattlerBase.prototype.paySkillCost = function(skill) { if (HpVNumberId > 0) { $gameVariables.setValue(HpVNumberId, this._hp); } if (MpVNumberId > 0) { $gameVariables.setValue(MpVNumberId, this._mp); } if (TpVNumberId > 0) { $gameVariables.setValue(TpVNumberId, this._tp); } if (HpCostVNId > 0) { $gameVariables.setValue(HpCostVNId, this.skillMpCost(skill)); } if (MpCostVNId > 0) { $gameVariables.setValue(MpCostVNId, this.skillMpCost(skill)); } if (TpCostVNId > 0) { $gameVariables.setValue(TpCostVNId, this.skillMpCost(skill)); } this.paySkillHpCost(skill); this.paySkillItemCost(skill); this.paySkillExpCost(skill); this.paySkillGoldCost(skill); this.paySkillVNumberCost(skill); _Game_BattleBase_paySkillCost.call(this, skill); }; Game_BattlerBase.prototype.paySkillHpCost = function(skill) { this._hp -= Math.min(this.skillHpCost(skill), this._hp); }; Game_BattlerBase.prototype.paySkillItemCost = function(skill) { var itemCost = this.skillItemCost(skill); if (itemCost && this.isItemCostValid(itemCost.item)) { $gameParty.loseItem(itemCost.item, itemCost.num, false) } }; Game_BattlerBase.prototype.isItemCostValid = function(item) { return !DataManager.isItem(item) || item.consumable; }; Game_BattlerBase.prototype.paySkillExpCost = function(skill) { var expCost = this.skillExpCost(skill); if (expCost) { var newExp = this.currentExp() - expCost; this.changeExp(newExp, this.shouldDisplayLevelUp()); } }; Game_BattlerBase.prototype.paySkillGoldCost = function(skill) { $gameParty.loseGold(this.skillGoldCost(skill)); }; Game_BattlerBase.prototype.paySkillVNumberCost = function(skill) { var vnCost = this.skillVNumberCost(skill); if (vnCost) { var n = $gameVariables.value(vnCost.index) - vnCost.num; $gameVariables.setValue(vnCost.index, n); } }; })();