#角色详情 伤害计算增加魈、胡桃

This commit is contained in:
yoimiya-kokomi 2022-04-25 02:50:17 +08:00
parent b43b59dd47
commit bc8fb2360a
5 changed files with 151 additions and 47 deletions

View File

@ -585,26 +585,23 @@ export async function renderProfile(e, char, render) {
let avatar = await getAvatar(e, char, MysApi);
let talent = await getTalent(e, avatar);
if(!talent.id){
if (global.debugView === "web-debug") {
let file = process.cwd() + "/tools/avatar.json";
avatar._talent = talent;
fs.writeFileSync(file, JSON.stringify(avatar));
}
if (!talent.id) {
return true;
}
let posIdx = {
"生之花": {
idx: 1
},
"死之羽": {
idx: 2
},
"时之沙": {
idx: 3
},
"空之杯": {
idx: 4
},
"理之冠": {
idx: 5
}
"生之花": { idx: 1 },
"死之羽": { idx: 2 },
"时之沙": { idx: 3 },
"空之杯": { idx: 4 },
"理之冠": { idx: 5 }
};
let reliquaries = [], totalMark = 0, totalMaxMark = 0;
@ -635,8 +632,9 @@ export async function renderProfile(e, char, render) {
}
});
let enemyLv = await selfUser.getCfg(`char.enemyLv`, 91);
let dmgMsg = [], dmgData = [];
let dmgCalc = await Calc.calcData(profile, char, avatar, talent);
let dmgCalc = await Calc.calcData({ profile, char, avatar, talent, enemyLv });
if (dmgCalc && dmgCalc.ret) {
lodash.forEach(dmgCalc.ret, (ds) => {
ds.dmg = Format.comma(ds.dmg, 0);
@ -659,6 +657,7 @@ export async function renderProfile(e, char, render) {
dmgData,
dmgMsg,
reliquaries,
enemyLv,
totalMark: c(totalMark, 1),
totalMaxMark,
markScore: Reliquaries.getMarkScore(totalMark, totalMaxMark),

View File

@ -1,7 +1,11 @@
import fs from "fs";
import lodash from "lodash";
import Format from "./Format.js";
import {buffs} from "../resources/meta/reliquaries/calc.js";
const eleMap = {
Electro: "雷",
Pyro: "火"
}
let Calc = {
@ -20,7 +24,7 @@ let Calc = {
}
if (details) {
return {details, buffs, defParams}
return { details, buffs, defParams }
}
return false;
},
@ -28,7 +32,7 @@ let Calc = {
// 获取基础属性
attr(profile, avatar) {
let ret = {},
{attr} = profile;
{ attr } = profile;
// 基础属性
lodash.forEach("atk,def,hp".split(","), (key) => {
@ -47,7 +51,7 @@ let Calc = {
}
})
lodash.forEach({cRate: "cpct", cDmg: "cdmg", hInc: "heal"}, (val, key) => {
lodash.forEach({ cRate: "cpct", cDmg: "cdmg", hInc: "heal" }, (val, key) => {
ret[val] = {
base: attr[key] * 1 || 0,
plus: 0,
@ -83,9 +87,12 @@ let Calc = {
}
ret.weaponType = avatar.weapon.type_name;
ret.element = avatar.element;
ret.element = eleMap[avatar.element];
ret.refine = (avatar.weapon.affix_level * 1 - 1) || 0;
ret.zf = 0;
ret.rh = 0;
return ret;
},
@ -137,15 +144,28 @@ let Calc = {
...meta,
attr,
params,
refine: attr.refine
refine: attr.refine,
calc(ds) {
return (ds.base || 0) + (ds.plus || 0) + ((ds.base || 0) * (ds.pct || 0) / 100)
}
};
// 如果存在rule则进行计算
if (buff.rule && !buff.rule(ds)) {
if (buff.check && !buff.check(ds)) {
return;
}
let title = buff.title;
if (buff.mastery) {
let mastery = attr.mastery.base + attr.mastery.plus;
let masteryNum = 2.78 * mastery / (mastery + 1400) * 100;
buff.data = buff.data || {};
lodash.forEach(buff.mastery.split(","), (key) => {
buff.data[key] = masteryNum;
})
}
lodash.forEach(buff.data, (val, key) => {
if (lodash.isFunction(val)) {
@ -166,6 +186,11 @@ let Calc = {
}
if (key === "enemyDef") {
attr.enemy.def += val * 1 || 0;
return;
}
if (["zf", "rh"].includes(key)) {
attr[key] += val * 1 || 0;
}
});
msg.push(title);
@ -197,7 +222,7 @@ let Calc = {
if (ds.refine) {
ds.data = ds.data || {};
lodash.forEach(ds.refine, (r, key) => {
ds.data[key] = ({refine}) => r[refine] * (ds.buffCount || 1);
ds.data[key] = ({ refine }) => r[refine] * (ds.buffCount || 1);
})
}
})
@ -236,7 +261,7 @@ let Calc = {
})
return retBuffs;
},
async calcData(profile, char, avatar, talentData) {
async calcData({ profile, char, avatar, talentData }) {
let charCalcData = await Calc.getCharCalcRule(char.name);
//avatar.element;
@ -251,7 +276,7 @@ let Calc = {
talent
}
let {buffs, details, defParams} = charCalcData;
let { buffs, details, defParams } = charCalcData;
defParams = defParams || {};
@ -267,7 +292,7 @@ let Calc = {
buffs = lodash.sortBy(buffs, ["sort"]);
let {msg} = Calc.calcAttr(originalAttr, buffs, meta, defParams || {});
let { msg } = Calc.calcAttr(originalAttr, buffs, meta, defParams || {});
let ret = [];
@ -275,15 +300,15 @@ let Calc = {
let params = lodash.merge({}, defParams, detail.params || {});
let {attr} = Calc.calcAttr(originalAttr, buffs, meta, params);
let { attr } = Calc.calcAttr(originalAttr, buffs, meta, params);
let dmg = function (pctNum = 0, talent = false) {
let {atk, dmg, cdmg, cpct} = attr;
let dmg = function (pctNum = 0, talent = false, ele = false) {
let { atk, dmg, cdmg, cpct } = attr;
// 攻击区
let atkNum = (atk.base + atk.plus + atk.base * atk.pct / 100);
// 增伤区
let dmgNum = (1 + dmg.base/100 + dmg.plus / 100);
let dmgNum = (1 + dmg.base / 100 + dmg.plus / 100);
//console.log({ base: Format.comma(dmg.base, 2), plus: Format.comma(dmg.plus, 2) })
@ -309,32 +334,42 @@ let Calc = {
}
// 防御区
let enemyLv = 91, lv = 90;
let enemyLv = 86, lv = avatar.level;
let defNum = (lv + 100) / ((lv + 100) + (enemyLv + 100) * (1 - enemyDef) * (1 - enemyIgnore));
// 抗性区
let kNum = 0.9;
// 计算最终伤害
let ret = {
dmg: atkNum * pctNum * dmgNum * (1 + cdmgNum) * defNum * kNum,
avg: atkNum * pctNum * dmgNum * (1 + cpctNum * cdmgNum) * defNum * kNum
// 反应区
let eleNum = 1;
if (ele) {
eleNum = { zf: 1.5, rh: 2 }[ele] || 1;
if (attr[ele]) {
eleNum = eleNum * (1 + attr[ele] / 100);
}
}
//console.log(attr, {atkNum, pctNum, dmgNum, cpctNum, cdmgNum, defNum}, ret)
// 计算最终伤害
let ret = {
dmg: atkNum * pctNum * dmgNum * (1 + cdmgNum) * defNum * kNum * eleNum,
avg: atkNum * pctNum * dmgNum * (1 + cpctNum * cdmgNum) * defNum * kNum * eleNum
}
if (global.debugView === "web-debug") {
console.log(attr, { atkNum, pctNum, dmgNum, cpctNum, cdmgNum, defNum, eleNum }, ret)
}
return ret;
};
if (detail.dmg) {
let dmgRet = detail.dmg({attr, talent}, dmg);
let dmgRet = detail.dmg({ attr, talent }, dmg);
ret.push({
title: detail.title,
...dmgRet
})
}
})
return {
ret,
msg

View File

@ -0,0 +1,28 @@
export const details = [{
title: "半血开E重击",
dmg: ({ talent, attr }, dmg) => dmg(talent.a["重击伤害"], "a2")
}, {
title: "半血开E重击蒸发",
dmg: ({ talent, attr }, dmg) => dmg(talent.a["重击伤害"], "a2", "zf")
}, {
title: "半血开E后Q",
dmg: ({ talent, attr }, dmg) => dmg(talent.q["低血量时技能伤害"], "q")
}];
export const buffs = [{
title: `被动天赋半血获得33%火伤加成`,
data: {
"dmg": 33
}
}, {
title: "元素精通:蒸发融化伤害提高[zf]%",
mastery: "zf,rh"
}, {
title: "胡桃E获得[atkPlus]点攻击力加成",
data: {
atkPlus: ({ talent, attr, calc }) => {
return talent.e['攻击力提高'] * calc(attr.hp) / 100;
}
}
}];

View File

@ -0,0 +1,42 @@
export const details = [{
title: "裸E",
dmg: ({ talent }, dmg) => dmg(talent.e["技能伤害"], "e")
}, {
title: "满层被动E",
params: { e: 1 },
dmg: ({ talent }, dmg) => dmg(talent.e["技能伤害"], "e")
}, {
title: "开Q后首插",
params: {
layer: 1
},
dmg: ({ talent }, dmg) => dmg(talent.a["低空/高空坠地冲击伤害"][1], "a3")
}, {
title: "开Q后尾插",
params: {
layer: 5
},
dmg: ({ talent }, dmg) => dmg(talent.a["低空/高空坠地冲击伤害"][1], "a3")
}];
export const defParams = {
layer: 0
}
export const buffs = [{
title: `魈天赋开Q后每3秒伤害提升5%满层提高25%`,
data: {
dmg: ({ params }) => params.layer * 5
}
}, {
title: "魈大招:下落攻击伤害提升[a3Dmg]%",
data: {
a3Dmg: ({ talent }) => talent.q['普通攻击/重击/下落攻击伤害提升']
}
}, {
title: "魈被动3层E使E的伤害提高45%",
data: {
eDmg: ({ params }) => params.e ? 45 : 0
}
}];

View File

@ -16,9 +16,9 @@ let polearm = {
}
},
"匣里灭辰": {
title: "对于水或或元素影响的敌人造成伤害提高[dmgPct]%",
title: "对于水或或元素影响的敌人造成伤害提高[dmg]%",
refine: {
dmgPct: [20, 24, 28, 32, 36]
dmg: [20, 24, 28, 32, 36]
}
},
"千岩长枪": {
@ -68,10 +68,10 @@ let polearm = {
}
},
"和璞鸢": {
title: "满层攻击力提高[atkPct]%,伤害提升[dmgPct]%",
title: "满层攻击力提高[atkPct]%,伤害提升[dmg]%",
refine: {
atkPct: [3.2 * 7, 3.9 * 7, 4.6 * 7, 5.3 * 7, 6 * 7],
dmgPct: [12, 15, 18, 21, 24]
dmg: [12, 15, 18, 21, 24]
}
},
"天空之脊": {
@ -81,12 +81,12 @@ let polearm = {
}
},
"护摩之杖": {
title: "角色生命低于50%时获得攻击力提升[atkPlus]",
title: "角色生命低于50%时额外获得[atkPlus]攻击力",
data: {
atkPlus: ({ attr, refine }) => {
let { hp } = attr,
totalHp = hp.base + hp.plus + hp.pct * hp.base / 100;
return totalHp * [1, 1.2, 1.4, 1.6, 1.8][refine] / 100
return totalHp * ([0.8, 1, 1.2, 1.4, 1.6][refine] + [1, 1.2, 1.4, 1.6, 1.8][refine]) / 100
}
}
},