sakura-gozen/js/plugins/iii/iiiFormulaWeapon.js
2025-01-14 14:06:54 -06:00

106 lines
4.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*=============================================================================
iiiFormulaWeapon.js
----------------------------------------------------------------------------
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
----------------------------------------------------------------------------
Version
1.0.0
=============================================================================*/
/*:
* @plugindesc スキルダメージ計算式にスキルに応じた武器情報を利用できるようにするプラグイン
* @target MZ
* @author iii
*
* @help iiiFormulaWeapon.js
*
* 御前試合用。
* スキルダメージ計算式にスキルidに対応したdataWeaponsのデータを渡すプラグイン。
* データベースの計算式場では「w」を指定して取得できます。
*
* ついでに「wat」で武器攻撃力を取得できるようにもしています。武器データが存在しない場合は0を返します。
*
* evalDamageFormula メソッドを再定義してしまっているため、
* 他のプラグインでevalDamageFormulaを利用している場合はそのプラグインより先に読み込むようにしてください。
*(会心カスタマイズプラグイン等のプラグインが該当します)
*
* ---
* 利用規約:
* 作者に無断で改変、再配布が可能で、利用形態商用、18禁利用等
* についても制限はありません。
* このプラグインはもうあなたのものです。
*/
(() => {
"use strict";
Game_Action.prototype.evalDamageFormula = function (target) {
try {
const item = this.item();
const a = this.subject(); // eslint-disable-line no-unused-vars
const b = target; // eslint-disable-line no-unused-vars
const v = $gameVariables._data; // eslint-disable-line no-unused-vars
//スキルIDに応じた武器関連データ取得
const w = $dataWeapons[item.id]; // eslint-disable-line no-unused-vars
const wat = w ? w.params[2] : 0; // eslint-disable-line no-unused-vars
const minDamage = 1; // eslint-disable-line no-unused-vars
const aatk = a ? a.paramBase(2) : 0; // eslint-disable-line no-unused-vars
const watk = w ? w.params[2] : 0; // 武器攻撃力
const uatk = $gameVariables.value(134); // アップグレード:力パラメータ
const bufatk = a ? a.paramRate(2) : 1; // ツクールステートの「特徴」「通常能力値」の攻撃力に該当。
const bstate = b ? b._states : 0; // 敵の現在のデバフ状態
//Upgradeシステムに対応
const wtype = w ? w.wtypeId : 0;
let wgradeCoef = 1.0;
if (wtype >= 1) {
const wgradeVid = 140 + (wtype - 1);
wgradeCoef += $gameVariables.value(wgradeVid);
}
const sign = [3, 4].includes(item.damage.type) ? -1 : 1;
const kuzushi = bstate.findIndex((bstate) => bstate === 41) != -1;
let value = 0;
if (item.meta.useDefaultFormula) {
value = Math.max(eval(item.damage.formula), 0) * sign;
} else {
if (kuzushi) {
//崩し状態の場合
value =
Math.max(
Math.max((aatk + uatk + watk) * bufatk - b.def / 5, minDamage),
0
) * sign;
//value = Math.max(Math.max( (((aatk + uatk) + (watk)) * bufatk), minDamage), 0) * sign;
//value = Math.max(Math.max( ((aatk + uatk) + (watk * wgradeCoef) * bufatk), minDamage), 0) * sign;
} else {
//通常状態でのダメージ判定:(敵の防御力を超えた場合に与えるダメージ増加)
if ((aatk + uatk + watk) * bufatk > b.def) {
//防御より攻撃が高い場合
value =
Math.max(
Math.max((aatk + uatk + watk) * bufatk - b.def / 3, minDamage),
0
) * sign;
} else {
value =
Math.max(
Math.max((aatk + uatk + watk) * bufatk - b.def, minDamage),
0
) * sign;
}
//value = Math.max(Math.max( ((aatk + uatk) + (watk * wgradeCoef) * bufatk) - b.def, minDamage), 0) * sign;
}
}
//const calcStr = "Math.max( ((aatk + uatk) + (watk * wgradeCoef)) - b.def, minDamage)";
//const vv = Math.max( ((aatk + uatk) + (watk * wgradeCoef) - b.def, minDamage);
//const value = Math.max(eval(item.damage.formula), 0) * sign;
//console.log("iiiFormulaW log" + bstate);
return isNaN(value) ? 0 : value;
} catch (e) {
return 0;
}
};
})();