2022-08-22 20:53:31 +00:00
|
|
|
|
/*
|
|
|
|
|
* 伤害计算 - 计算伤害
|
|
|
|
|
* */
|
2024-01-02 15:49:08 +00:00
|
|
|
|
import { eleBaseDmg, erTitle, breakBaseDmg, cryBaseDmg } from './DmgCalcMeta.js'
|
2022-08-24 01:07:06 +00:00
|
|
|
|
import DmgMastery from './DmgMastery.js'
|
2024-03-28 12:46:14 +00:00
|
|
|
|
import lodash from 'lodash'
|
2022-08-22 20:53:31 +00:00
|
|
|
|
|
|
|
|
|
let DmgCalc = {
|
|
|
|
|
calcRet (fnArgs = {}, data = {}) {
|
|
|
|
|
let {
|
|
|
|
|
pctNum, // 技能倍率
|
|
|
|
|
talent, // 天赋类型
|
|
|
|
|
ele, // 元素反应
|
|
|
|
|
basicNum, // 基础数值
|
2023-09-06 09:29:48 +00:00
|
|
|
|
mode, // 模式
|
2023-11-06 20:34:05 +00:00
|
|
|
|
dynamicData // 动态伤害计算数据
|
|
|
|
|
} = fnArgs
|
|
|
|
|
let {
|
2023-09-06 09:29:48 +00:00
|
|
|
|
dynamicDmg = 0, // 动态增伤
|
2023-11-06 20:34:05 +00:00
|
|
|
|
dynamicPhy = 0, // 动态物伤
|
|
|
|
|
dynamicCpct = 0, // 动态暴击率
|
2023-10-10 18:49:38 +00:00
|
|
|
|
dynamicCdmg = 0, // 动态暴击伤害
|
2024-02-17 14:25:42 +00:00
|
|
|
|
dynamicEnemydmg = 0 // 动态易伤
|
2023-11-06 20:34:05 +00:00
|
|
|
|
} = dynamicData
|
2022-08-22 20:53:31 +00:00
|
|
|
|
let {
|
|
|
|
|
ds, // 数据集
|
|
|
|
|
attr, // 属性
|
|
|
|
|
level, // 面板数据
|
|
|
|
|
enemyLv, // 敌人等级
|
2023-05-22 19:19:45 +00:00
|
|
|
|
showDetail = false, // 是否展示详情
|
|
|
|
|
game
|
2022-08-22 20:53:31 +00:00
|
|
|
|
} = data
|
|
|
|
|
let calc = ds.calc
|
|
|
|
|
|
2024-02-17 14:25:42 +00:00
|
|
|
|
let { atk, dmg, phy, cdmg, cpct, enemydmg } = attr
|
2022-11-05 11:31:07 +00:00
|
|
|
|
|
2022-08-22 20:53:31 +00:00
|
|
|
|
// 攻击区
|
|
|
|
|
let atkNum = calc(atk)
|
|
|
|
|
|
|
|
|
|
// 倍率独立乘区
|
|
|
|
|
let multiNum = attr.multi / 100
|
2022-11-05 15:47:44 +00:00
|
|
|
|
|
2022-08-22 20:53:31 +00:00
|
|
|
|
// 增伤区
|
2023-09-06 09:29:48 +00:00
|
|
|
|
let dmgNum = (1 + dmg.base / 100 + dmg.plus / 100 + dynamicDmg / 100)
|
2022-08-22 20:53:31 +00:00
|
|
|
|
|
|
|
|
|
if (ele === 'phy') {
|
2023-11-06 20:34:05 +00:00
|
|
|
|
dmgNum = (1 + phy.base / 100 + phy.plus / 100 + dynamicPhy / 100)
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-13 18:39:27 +00:00
|
|
|
|
// 易伤区
|
2024-02-17 14:25:42 +00:00
|
|
|
|
let enemydmgNum = 1
|
2023-08-13 18:39:27 +00:00
|
|
|
|
if (game === 'sr') {
|
2024-02-17 14:25:42 +00:00
|
|
|
|
enemydmgNum = 1 + enemydmg.base / 100 + enemydmg.plus / 100 + dynamicEnemydmg / 100
|
2023-08-13 18:39:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-06 20:34:05 +00:00
|
|
|
|
// 暴击区
|
|
|
|
|
let cpctNum = cpct.base / 100 + cpct.plus / 100 + dynamicCpct / 100
|
2022-08-22 20:53:31 +00:00
|
|
|
|
|
|
|
|
|
// 爆伤区
|
2023-09-06 09:29:48 +00:00
|
|
|
|
let cdmgNum = cdmg.base / 100 + cdmg.plus / 100 + dynamicCdmg / 100
|
2022-08-22 20:53:31 +00:00
|
|
|
|
|
|
|
|
|
let enemyDef = attr.enemy.def / 100
|
|
|
|
|
let enemyIgnore = attr.enemy.ignore / 100
|
|
|
|
|
|
|
|
|
|
let plusNum = 0
|
|
|
|
|
|
2024-01-27 18:15:22 +00:00
|
|
|
|
pctNum = pctNum / 100
|
2024-03-28 12:46:14 +00:00
|
|
|
|
if (talent) {
|
|
|
|
|
lodash.forEach(talent.split(','), (t) => {
|
|
|
|
|
if (attr[t]) {
|
|
|
|
|
let ds = attr[t]
|
2022-08-22 20:53:31 +00:00
|
|
|
|
|
2024-03-28 12:46:14 +00:00
|
|
|
|
pctNum += ds.pct / 100
|
|
|
|
|
dmgNum += ds.dmg / 100
|
|
|
|
|
enemydmgNum += game === 'gs' ? 0 : ds.enemydmg / 100
|
|
|
|
|
cpctNum += ds.cpct / 100
|
|
|
|
|
cdmgNum += ds.cdmg / 100
|
|
|
|
|
enemyDef += ds.def / 100
|
|
|
|
|
enemyIgnore += ds.ignore / 100
|
|
|
|
|
multiNum += ds.multi / 100
|
|
|
|
|
plusNum += ds.plus
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 防御区
|
|
|
|
|
let defNum = (level + 100) / ((level + 100) + (enemyLv + 100) * (1 - enemyDef) * (1 - enemyIgnore))
|
2023-05-22 19:19:45 +00:00
|
|
|
|
if (game === 'sr') {
|
2023-08-13 18:39:27 +00:00
|
|
|
|
let enemyDefdown = enemyDef + enemyIgnore <= 1 ? enemyDef + enemyIgnore : 1
|
|
|
|
|
defNum = (200 + level * 10) / ((200 + level * 10) + (200 + enemyLv * 10) * (1 - enemyDefdown))
|
2023-05-22 19:19:45 +00:00
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
|
|
|
|
|
// 抗性区
|
|
|
|
|
let kx = attr.kx
|
|
|
|
|
let kNum = 0.9
|
2023-05-22 19:19:45 +00:00
|
|
|
|
if (game === 'sr') {
|
2023-12-28 15:12:49 +00:00
|
|
|
|
kNum = 1 + (kx / 100)
|
2022-08-22 20:53:31 +00:00
|
|
|
|
} else {
|
2023-05-22 19:19:45 +00:00
|
|
|
|
if (ele === 'swirl') {
|
|
|
|
|
kx = attr.fykx
|
|
|
|
|
}
|
|
|
|
|
kx = 10 - (kx || 0)
|
|
|
|
|
if (kx >= 75) {
|
|
|
|
|
kNum = 1 / (1 + 3 * kx / 100)
|
|
|
|
|
} else if (kx >= 0) {
|
|
|
|
|
kNum = (100 - kx) / 100
|
|
|
|
|
} else {
|
|
|
|
|
kNum = 1 - kx / 200
|
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-28 15:12:49 +00:00
|
|
|
|
// 减伤区
|
|
|
|
|
let dmgReduceNum = 1
|
|
|
|
|
if (game === 'sr') {
|
|
|
|
|
dmgReduceNum = 0.9
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-22 20:53:31 +00:00
|
|
|
|
cpctNum = Math.max(0, Math.min(1, cpctNum))
|
|
|
|
|
if (cpctNum === 0) {
|
|
|
|
|
cdmgNum = 0
|
|
|
|
|
}
|
2022-11-05 15:47:44 +00:00
|
|
|
|
|
|
|
|
|
const isEle = ele !== false && ele !== 'phy'
|
2022-11-05 11:31:07 +00:00
|
|
|
|
// 反应区
|
2023-08-13 18:39:27 +00:00
|
|
|
|
let eleNum = 1
|
|
|
|
|
let eleBase = 1
|
|
|
|
|
if (game === 'gs') {
|
|
|
|
|
eleNum = isEle ? DmgMastery.getBasePct(ele, attr.element) : 1
|
|
|
|
|
eleBase = isEle ? 1 + attr[ele] / 100 + DmgMastery.getMultiple(ele, calc(attr.mastery)) : 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let stanceNum = 1
|
|
|
|
|
if (game === 'sr') {
|
|
|
|
|
switch (ele) {
|
|
|
|
|
case 'shock':
|
|
|
|
|
case 'burn':
|
|
|
|
|
case 'windShear':
|
|
|
|
|
case 'bleed':
|
|
|
|
|
case 'entanglement':
|
|
|
|
|
case 'lightningBreak':
|
|
|
|
|
case 'fireBreak':
|
|
|
|
|
case 'windBreak':
|
|
|
|
|
case 'physicalBreak':
|
|
|
|
|
case 'quantumBreak':
|
2023-12-28 15:12:49 +00:00
|
|
|
|
case 'imaginaryBreak':
|
|
|
|
|
case 'iceBreak': {
|
2023-08-13 18:39:27 +00:00
|
|
|
|
eleNum = DmgMastery.getBasePct(ele, attr.element)
|
|
|
|
|
stanceNum = 1 + calc(attr.stance) / 100
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-21 05:06:42 +00:00
|
|
|
|
let dmgBase = (mode === 'basic') ? basicNum + plusNum : atkNum * pctNum * (1 + multiNum) + plusNum
|
2022-08-22 20:53:31 +00:00
|
|
|
|
let ret = {}
|
2022-11-05 11:31:07 +00:00
|
|
|
|
|
2022-11-05 15:47:44 +00:00
|
|
|
|
switch (ele) {
|
2022-11-05 11:31:07 +00:00
|
|
|
|
case 'vaporize':
|
2022-11-05 15:47:44 +00:00
|
|
|
|
case 'melt': {
|
2022-11-05 11:31:07 +00:00
|
|
|
|
ret = {
|
|
|
|
|
dmg: dmgBase * dmgNum * (1 + cdmgNum) * defNum * kNum * eleBase * eleNum,
|
|
|
|
|
avg: dmgBase * dmgNum * (1 + cpctNum * cdmgNum) * defNum * kNum * eleBase * eleNum
|
|
|
|
|
}
|
|
|
|
|
break
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
2022-11-05 11:31:07 +00:00
|
|
|
|
|
|
|
|
|
case 'burning':
|
2022-11-05 15:47:44 +00:00
|
|
|
|
case 'superConduct':
|
2022-11-05 11:31:07 +00:00
|
|
|
|
case 'swirl':
|
2022-11-05 15:47:44 +00:00
|
|
|
|
case 'electroCharged':
|
2022-11-05 11:31:07 +00:00
|
|
|
|
case 'shatter':
|
|
|
|
|
case 'overloaded':
|
|
|
|
|
case 'bloom':
|
|
|
|
|
case 'burgeon':
|
2022-11-05 15:47:44 +00:00
|
|
|
|
case 'hyperBloom': {
|
2022-11-05 11:31:07 +00:00
|
|
|
|
eleBase *= eleBaseDmg[level]
|
|
|
|
|
ret = { avg: eleBase * eleNum * kNum }
|
|
|
|
|
break
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
2022-11-05 15:47:44 +00:00
|
|
|
|
|
2024-02-17 14:25:42 +00:00
|
|
|
|
case 'crystallize': {
|
2024-01-02 15:47:19 +00:00
|
|
|
|
eleBase *= cryBaseDmg[level]
|
2024-01-02 16:05:12 +00:00
|
|
|
|
ret = { avg: eleBase * (calc(attr.shield) / 100) * (attr.shield.inc / 100) }
|
2024-01-02 15:47:19 +00:00
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-05 11:31:07 +00:00
|
|
|
|
case 'aggravate':
|
2022-11-05 15:47:44 +00:00
|
|
|
|
case 'spread': {
|
2022-11-05 11:31:07 +00:00
|
|
|
|
eleBase *= eleBaseDmg[level]
|
|
|
|
|
dmgBase += eleBase * eleNum
|
|
|
|
|
ret = {
|
|
|
|
|
dmg: dmgBase * dmgNum * (1 + cdmgNum) * defNum * kNum,
|
|
|
|
|
avg: dmgBase * dmgNum * (1 + cpctNum * cdmgNum) * defNum * kNum
|
|
|
|
|
}
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 23:14:23 +00:00
|
|
|
|
// 技能持续伤害 = 伤害值乘区 * 增伤区 * 易伤区 * 防御区 * 抗性区 * 减伤区
|
2023-08-13 18:39:27 +00:00
|
|
|
|
case 'skillDot': {
|
|
|
|
|
ret = {
|
2024-02-17 14:25:42 +00:00
|
|
|
|
avg: dmgBase * dmgNum * enemydmgNum * defNum * kNum * dmgReduceNum
|
2023-08-13 18:39:27 +00:00
|
|
|
|
}
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-13 13:47:26 +00:00
|
|
|
|
// 未计算:1. 层数(风化、纠缠) 2. 韧性条系数(击破、纠缠) 3. 削韧值(超击破)、超击破伤害提高
|
2023-12-28 15:12:49 +00:00
|
|
|
|
// 常规击破伤害均需要计算减伤区(即按韧性条存在处理) 特例:阮梅终结技/秘技击破伤害不计算减伤
|
|
|
|
|
// 击破伤害 = 基础伤害 * 属性击破伤害系数 * (1+击破特攻%) * 易伤区 * 防御区 * 抗性区 * 减伤区 * (敌方韧性+2)/4 * 层数系数
|
|
|
|
|
// 击破持续伤害 = 基础伤害 * 属性持续伤害系数 * (1+击破特攻%) * 易伤区 * 防御区 * 抗性区 * 减伤区 * 层数系数
|
2024-05-13 13:47:26 +00:00
|
|
|
|
// 超击破伤害 = 基础伤害 * (1+击破特攻%) * 易伤区 * 防御区 * 抗性区 * 减伤区 * (1+超击破伤害提高) * 技能最终削韧值
|
|
|
|
|
// 技能最终削韧值 = 技能基础削韧值 ×(1+削韧值提高)×(1+弱点击破效率提高)
|
|
|
|
|
// 超击破伤害提高 截至2.2版本该乘区仅能由同谐开拓者提供,与常规增伤区无关,暂时只在calc.js中手动计算
|
2023-08-13 18:39:27 +00:00
|
|
|
|
case 'shock':
|
|
|
|
|
case 'burn':
|
|
|
|
|
case 'windShear':
|
|
|
|
|
case 'bleed':
|
|
|
|
|
case 'entanglement':
|
|
|
|
|
case 'lightningBreak':
|
|
|
|
|
case 'fireBreak':
|
|
|
|
|
case 'windBreak':
|
|
|
|
|
case 'physicalBreak':
|
2024-02-17 14:25:42 +00:00
|
|
|
|
case 'quantumBreak':
|
2023-12-28 15:12:49 +00:00
|
|
|
|
case 'imaginaryBreak':
|
2024-05-13 13:47:26 +00:00
|
|
|
|
case 'iceBreak':
|
|
|
|
|
case 'superBreak': {
|
|
|
|
|
let breakBase = 1
|
|
|
|
|
breakBase *= breakBaseDmg[level]
|
2023-08-13 18:39:27 +00:00
|
|
|
|
ret = {
|
2024-05-13 13:47:26 +00:00
|
|
|
|
avg: breakBase * eleNum * stanceNum * enemydmgNum * defNum * kNum * dmgReduceNum
|
2023-08-13 18:39:27 +00:00
|
|
|
|
}
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-05 15:47:44 +00:00
|
|
|
|
default: {
|
2022-11-05 11:31:07 +00:00
|
|
|
|
ret = {
|
2024-02-17 14:25:42 +00:00
|
|
|
|
dmg: dmgBase * dmgNum * enemydmgNum * (1 + cdmgNum) * defNum * kNum * dmgReduceNum,
|
|
|
|
|
avg: dmgBase * dmgNum * enemydmgNum * (1 + cpctNum * cdmgNum) * defNum * kNum * dmgReduceNum
|
2022-11-05 15:47:44 +00:00
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-05 11:31:07 +00:00
|
|
|
|
|
2022-08-22 20:53:31 +00:00
|
|
|
|
if (showDetail) {
|
2022-11-06 04:27:45 +00:00
|
|
|
|
console.log('Attr', attr)
|
2024-02-17 14:25:42 +00:00
|
|
|
|
console.log({ mode, dmgBase, atkNum, pctNum, multiNum, plusNum, dmgNum, enemydmgNum, stanceNum, cpctNum, cdmgNum, defNum, eleNum, kNum, dmgReduceNum })
|
2022-11-06 04:27:45 +00:00
|
|
|
|
console.log('Ret', ret)
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
},
|
|
|
|
|
getDmgFn (data) {
|
2023-05-21 18:13:38 +00:00
|
|
|
|
let { showDetail, attr, ds, game } = data
|
2022-08-23 00:18:41 +00:00
|
|
|
|
let { calc } = ds
|
2022-08-22 20:53:31 +00:00
|
|
|
|
|
2023-09-06 09:29:48 +00:00
|
|
|
|
let dmgFn = function (pctNum = 0, talent = false, ele = false, basicNum = 0, mode = 'talent', dynamicData = false) {
|
2022-11-16 18:39:20 +00:00
|
|
|
|
if (ele) {
|
|
|
|
|
ele = erTitle[ele] || ele
|
|
|
|
|
}
|
2023-05-21 18:13:38 +00:00
|
|
|
|
if (game === 'sr') {
|
|
|
|
|
// 星铁meta数据天赋为百分比前数字
|
|
|
|
|
pctNum = pctNum * 100
|
|
|
|
|
}
|
2023-11-06 20:34:05 +00:00
|
|
|
|
return DmgCalc.calcRet({ pctNum, talent, ele, basicNum, mode, dynamicData }, data)
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-06 09:29:48 +00:00
|
|
|
|
dmgFn.basic = function (basicNum = 0, talent = false, ele = false, dynamicData = false) {
|
|
|
|
|
return dmgFn(0, talent, ele, basicNum, 'basic', dynamicData)
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
2022-11-06 19:43:56 +00:00
|
|
|
|
|
2024-02-17 14:25:42 +00:00
|
|
|
|
dmgFn.reaction = function (ele = false, talent = 'fy') {
|
2024-05-09 15:32:56 +00:00
|
|
|
|
switch (ele) {
|
|
|
|
|
// 击破持续伤害
|
|
|
|
|
case 'shock':
|
|
|
|
|
case 'burn':
|
|
|
|
|
case 'windShear':
|
|
|
|
|
case 'bleed': {
|
|
|
|
|
talent = 'dot'
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
// 击破伤害
|
2024-05-13 13:47:26 +00:00
|
|
|
|
case 'superBreak':
|
2024-05-09 15:32:56 +00:00
|
|
|
|
case 'lightningBreak':
|
|
|
|
|
case 'fireBreak':
|
|
|
|
|
case 'windBreak':
|
|
|
|
|
case 'physicalBreak':
|
|
|
|
|
case 'quantumBreak':
|
|
|
|
|
case 'imaginaryBreak':
|
|
|
|
|
case 'iceBreak': {
|
|
|
|
|
talent = 'break'
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break
|
|
|
|
|
}
|
2024-02-17 14:25:42 +00:00
|
|
|
|
return dmgFn(0, talent, ele, 0, 'basic')
|
2022-11-06 07:22:28 +00:00
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
|
2023-09-06 09:29:48 +00:00
|
|
|
|
dmgFn.dynamic = function (pctNum = 0, talent = false, dynamicData = false, ele = false) {
|
|
|
|
|
return dmgFn(pctNum, talent, ele, 0, 'talent', dynamicData)
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-22 20:53:31 +00:00
|
|
|
|
// 计算治疗
|
|
|
|
|
dmgFn.heal = function (num) {
|
|
|
|
|
if (showDetail) {
|
|
|
|
|
console.log(num, calc(attr.heal), attr.heal.inc)
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
avg: num * (1 + calc(attr.heal) / 100 + attr.heal.inc / 100)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算护盾
|
|
|
|
|
dmgFn.shield = function (num) {
|
2022-11-19 12:54:11 +00:00
|
|
|
|
if (showDetail) {
|
|
|
|
|
console.log(num, calc(attr.shield), calc(attr.shield.inc))
|
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
return {
|
|
|
|
|
avg: num * (calc(attr.shield) / 100) * (attr.shield.inc / 100)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 扩散方法
|
2022-11-05 11:31:07 +00:00
|
|
|
|
dmgFn.swirl = function () {
|
|
|
|
|
return dmgFn(0, 'fy', 'swirl')
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dmgFn
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
export default DmgCalc
|