/*:----------------------------------------------------------------------------------- * CalcHitByStrongAndWeakWeapons.js * * Copyright (C) 2024 Nino「」 * This software is released under the MIT License. * http://opensource.org/licenses/mit-license.php * ------------------------------------------------------------------------------------- */ /*: * @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 * * @param use_SRPGgear * @type boolean * @default false * * @param textGetAdvantage * @desc 有利時の表示テキスト * @type string * @default 有利 * @parent use_SRPGgear * * @param textGetDisadvantage * @desc 不利時の表示テキスト * @type string * @default 不利 * @parent use_SRPGgear * * @param xposition * @desc 表示位置のX座標 * @type number * @default 0 * @parent use_SRPGgear * * @param yposition * @desc 表示位置のY座標 * @type number * @default 0 * @parent use_SRPGgear * * @param fontsize * @desc フォントサイズ(0の場合はデフォルト) * @default 0 * @type number * @parent use_SRPGgear * */ // Version // 0.0.3 2024/4/4 左有利右不利の表示のズレを修正 // 0.0.2 2024/4/3 window_srpgpredictionに三すくみ有利不利を表示できるように // 0.0.1 2024/03/11 初版 /*~struct~status: * @param strong * @desc 強くする攻撃時属性を数値で指定 * @type number * @default 0 * * @param weak * @desc 弱くする攻撃時属性を数値で指定 * @type number * @default 0 * * * @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 = 'CalcHitBySpecial'; var parameters = PluginManager.parameters(pluginName); var strong_and_weak = paramParse(parameters['strong_and_weak']); var reverse = Number(parameters['reverse'] || 0); var use_SRPGgear = Boolean(parameters['use_SRPGgear'] || false); var _textGetAdvantage =String(parameters['textGetAdvantage'] || "有利"); var _textGetDisadvantage =String(parameters['textGetDisadvantage'] || ""); //var _xposition = -230; //var _yposition = -10; var _xposition = Number(parameters['xposition'] || 0); var _yposition = Number(parameters['yposition'] || 0); var _fontsize = Number(parameters['fontsize'] || 0); const _damageType = { default: 0, storongOnly: 1, weakOnly: 2, } const _Game_Action_evalDamageFormula = Game_Action.prototype.evalDamageFormula; Game_Action.prototype.evalDamageFormula = function(target) { let atkCorrection = 0; var weapondamage = 0; //const a = this.subject();//attacker //const b = target;//defender var attacker = this.subject(); var attackElements = attacker.attackElements() var targetElements = target.attackElements() console.log(attackElements) console.log(targetElements) //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 ) { //atkCorrection += eval(list_element.damage) atkCorrection += list_element.damage } if (list_element.strong == target_element && list_element.weak == attack_element ) { //ここは使わない } }) }) }); if (attackElements.includes(reverse) ) { atkCorrection *= -1 } if (targetElements.includes(reverse) ) { atkCorrection *= -1 } console.log(atkCorrection) if (atkCorrection == 0) { return _Game_Action_evalDamageFormula.call(this, target); } if (attacker.isActor()) { attacker.equips().forEach(function(item) { //console.log(item) if (item?.wtypeId) { if (this.isPhysical()) weapondamage += item.params[2] || 0; if (this.isMagical()) weapondamage += item.params[4] || 0; } }, this); }else if (attacker.isEnemy()) { console.log(attacker) var weapon = $dataWeapons[Number(attacker.enemy().meta.srpgWeapon)]; if (this.isPhysical()) weapondamage += weapon.params[2] || 0; if (this.isMagical()) weapondamage += weapon.params[4] || 0; }else{ console.log("わけわからん")//なんかおかしい //エラー吐かせたいけど一旦置いておく return _Game_Action_evalDamageFormula.call(this, target); } var fixDamage = weapondamage * atkCorrection; var result = 0; //console.log(fixDamage) //console.log(this.isPhysical(),this.isMagical()) if (this.isPhysical()){ attacker._paramPlus[2] += fixDamage; // atk(攻撃力)はパラメータインデックス2に対応 result = _Game_Action_evalDamageFormula.call(this, target); attacker._paramPlus[2] -= fixDamage; // 補正を元に戻す }else if (this.isMagical()){ attacker._paramPlus[4] += fixDamage; // atk(攻撃力)はパラメータインデックス2に対応 result = _Game_Action_evalDamageFormula.call(this, target); attacker._paramPlus[4] -= fixDamage; // 補正を元に戻す } // 一時的に攻撃者の攻撃力を補正する return result; } if (use_SRPGgear){ const _Window_SrpgPrediction_drawContents = Window_SrpgPrediction.prototype.drawContents; Window_SrpgPrediction.prototype.drawContents = function() { _Window_SrpgPrediction_drawContents.call(this); this.resetFontSettings(); var lineHeight = this.lineHeight(); var padding = 24; var user = this._actionArray[1]; var target = this._targetArray[1]; // 攻撃側 /* var action = user.currentAction(); var damage = action.srpgPredictionDamage(target); var hit = action.itemHit(target); var eva = action.itemEva(target); this.drawSrpgBattleActionName(user, action, this.innerWidth / 2 + padding * 2, lineHeight * 0, true); this.drawSrpgBattleHit(hit, eva, this.innerWidth / 2 + padding * 2, lineHeight * 1); this.drawSrpgBattleDistance(user, action, this.innerWidth / 2 + 172 + padding * 2, lineHeight * 1); this.drawSrpgBattleDamage(damage, this.innerWidth / 2 + padding * 2, lineHeight * 2, doubleActionRate); */ //相性表示 //console.log(user) this.drawSrpgBattleStrongAndWeak(user.attackElements(), target.attackElements(), this.innerWidth / 2 + 300 , lineHeight * 0); // 迎撃側 var reaction = target.currentAction(); //迎撃側の相性表示 this.drawSrpgBattleStrongAndWeak( target.attackElements(), user.attackElements(), 300-22 , lineHeight * 0); }; Window_SrpgPrediction.prototype.drawSrpgBattleStrongAndWeak = function(attackElements, targetElements, x, y) { // //ダメージ計算 /* console.log(user) console.log(target) */ let atkdmgCorrection = 0; /* var attackElements = user.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 ) { if(list_element.type_damage == _damageType.default || list_element.type_damage == _damageType.storongOnly ){ atkdmgCorrection += list_element.damage } } if (list_element.strong == target_element && list_element.weak == attack_element ) { //console.log("minus") if(list_element.type_damage == _damageType.default || list_element.type_damage == _damageType.weakOnly ){ atkdmgCorrection -= list_element.damage } } }) }) }); if (attackElements.includes(reverse) ) { atkdmgCorrection *= -1 } if (targetElements.includes(reverse) ) { atkdmgCorrection *= -1 } var default_font =this.contents.fontSize; this.contents.fontSize = _fontsize ? _fontsize : default_font if(atkdmgCorrection==0 ){ //一切の有利不利なし return } else if(atkdmgCorrection>0 ){ //有利 this.changeTextColor(ColorManager.tpGaugeColor2()); this.drawText(_textGetAdvantage, x+_xposition, y+_yposition, 120,'left'); this.resetTextColor(); }else if(atkdmgCorrection<0 ){ //不利 this.changeTextColor(ColorManager.deathColor()); this.drawText(_textGetDisadvantage, x+_xposition, y+_yposition, 120,'left'); this.resetTextColor(); }else{ //命中とダメージであべこべな状態 //どうしようねこれ } this.contents.fontSize = default_font } } })();