/*: * @plugindesc 攻撃時属性に相性を作りを命中率を回避率の計算に適応させる * @target MZ * @url * @author 通りすがりの「」 * * @help CalcHitByStrongAndWeakWeapons.js * * 受動側と攻撃側の攻撃時属性を参照して命中率に加算・減算するプラグインです * 三すくみのような実装が可能です * * === 逆転の使い方 === * 通常の武器属性に加えて、逆転に指定した属性を設定してください * 例 * 攻撃時属性 剣 * 攻撃時属性 逆転 * ※命中率の計算式を弄るプラグインと競合する可能性があるので注意してください * * 寝るの大事 * * @param strong_and_weak * @desc 表示するステータスとその位置を設定します。 * @type struct[] * @default ["{\"strong\":\"1\",\"weak\":\"3\",\"rate\":\"20\",\"damage\":\"1\"}"] * * @param reverse * @desc 相性関係を逆転させる攻撃属性を選択 * 0 の場合逆転を行いません * @default 0 */ // Version // 0.0.1 2024/03/11 初版 /*~struct~status: * @param strong * @desc 強くする攻撃時属性を選択 * @default 0 * * @param weak * @desc 弱くする攻撃時属性を選択 * @default 0 * * @param rate * @desc 命中率に加算・減算する値(%) * @default 20 * * @param damage * @desc damageに加算・減算する値 * @default 1 * * */ (()=> { var paramParse = function(obj) { return JSON.parse(JSON.stringify(obj, paramReplace)); }; var paramReplace = function(key, value) { try { return JSON.parse(value || null); } catch (e) { return value; } }; var pluginName = 'CalcHitByStrongAndWeakWeapons'; var parameters = PluginManager.parameters(pluginName); var strong_and_weak = paramParse(parameters['strong_and_weak']); var reverse = Number(parameters['reverse'] || 0); Game_Action.prototype.itemHit = function(target) { //console.log(parameters) //console.log(strong_and_weak) var baserate = this.item().successRate; var affinity_rate =0 var attackElements = this.subject().attackElements() var targetElements = target.attackElements() console.log( this.subject()._name) strong_and_weak.forEach(function(list_element) { attackElements.forEach(function(attack_element) { targetElements.forEach(function(target_element) { if (list_element.strong == attack_element && list_element.weak == target_element ) { console.log("plus") affinity_rate += list_element.rate } if (list_element.strong == target_element && list_element.weak == attack_element ) { console.log("minus") affinity_rate -= list_element.rate } }) }) }); if (attackElements.indexof(reverse) != -1) { affinity_rate *= -1 } if (targetElements.indexof(reverse) != -1) { affinity_rate *= -1 } if (this.isPhysical()) { return this.item().successRate * 0.01 * this.subject().hit + affinity_rate * 0.01; } else { return this.item().successRate * 0.01 + affinity_rate * 0.01; } }; const _Game_Action_evalDamageFormula = Game_Action.prototype.evalDamageFormula; Game_Action.prototype.evalDamageFormula = function(target) { let atkCorrection = 0; var attackElements = this.subject().attackElements() var targetElements = target.attackElements() //console.log( this.subject()._name) strong_and_weak.forEach(function(list_element) { attackElements.forEach(function(attack_element) { targetElements.forEach(function(target_element) { if (list_element.strong == attack_element && list_element.weak == target_element ) { //console.log("plus") atkCorrection += list_element.damage } if (list_element.strong == target_element && list_element.weak == attack_element ) { //console.log("minus") atkCorrection -= list_element.damage } }) }) }); if (attackElements.includes(reverse) ) { atkCorrection *= -1 } if (targetElements.includes(reverse) ) { atkCorrection *= -1 } // 一時的に攻撃者の攻撃力を補正する this.subject()._paramPlus[2] += atkCorrection; // atk(攻撃力)はパラメータインデックス2に対応 const result = _Game_Action_evalDamageFormula.call(this, target); this.subject()._paramPlus[2] -= atkCorrection; // 補正を元に戻す return result; } })();