mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-22 06:58:24 +00:00
略微优化伤害计算逻辑
This commit is contained in:
parent
b1dc157d5c
commit
03d585484f
25
models/dmg/AttrItem.js
Normal file
25
models/dmg/AttrItem.js
Normal file
@ -0,0 +1,25 @@
|
||||
export default class AttrItem {
|
||||
constructor (ds) {
|
||||
this.base = ds.base * 1 || 0
|
||||
this.plus = ds.plus * 1 || 0
|
||||
this.pct = ds.pct * 1 || 0
|
||||
this.inc = ds.inc * 1 || 0
|
||||
}
|
||||
|
||||
static create (ds) {
|
||||
return new AttrItem(ds)
|
||||
/*
|
||||
return {
|
||||
base: ds.base * 1 || 0,
|
||||
plus: ds.plus * 1 || 0,
|
||||
pct: ds.pct * 1 || 0,
|
||||
inc: ds.inc * 1 || 0
|
||||
} */
|
||||
}
|
||||
|
||||
toString () {
|
||||
return (this.base || 0) + (this.plus || 0) + ((this.base || 0) * (this.pct || 0) / 100)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import { eleBaseDmg } from './DmgCalcMeta.js'
|
||||
import lodash from 'lodash'
|
||||
import DmgMastery from './DmgMastery.js'
|
||||
import { Format, Meta } from '#miao'
|
||||
import AttrItem from './AttrItem.js'
|
||||
|
||||
let DmgAttr = {
|
||||
// 计算并返回指定属性值
|
||||
@ -13,30 +14,35 @@ let DmgAttr = {
|
||||
},
|
||||
|
||||
// 获取profile对应attr属性值
|
||||
getAttr ({ id, attr, weapon, char, game = 'gs' }) {
|
||||
getAttr ({ originalAttr, attr, weapon, char, game = 'gs' }) {
|
||||
let ret = {}
|
||||
|
||||
if (originalAttr) {
|
||||
ret = lodash.merge({}, originalAttr)
|
||||
}
|
||||
|
||||
|
||||
// 基础属性
|
||||
lodash.forEach('atk,def,hp'.split(','), (key) => {
|
||||
ret[key] = {
|
||||
ret[key] = AttrItem.create(originalAttr?.[key] || {
|
||||
base: attr[`${key}Base`] * 1 || 0,
|
||||
plus: attr[key] * 1 - attr[`${key}Base`] * 1 || 0,
|
||||
pct: 0
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
lodash.forEach((game === 'gs' ? 'mastery,recharge,cpct,cdmg,heal,dmg,phy' : 'speed,recharge,cpct,cdmg,heal,dmg,enemyDmg,effPct,effDef,stance').split(','), (key) => {
|
||||
ret[key] = {
|
||||
ret[key] = AttrItem.create(originalAttr?.[key] || {
|
||||
base: attr[key] * 1 || 0, // 基础值
|
||||
plus: 0, // 加成值
|
||||
pct: 0, // 百分比加成
|
||||
inc: 0 // 提高:护盾增效&治疗增效
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// 技能属性记录
|
||||
lodash.forEach((game === 'gs' ? 'a,a2,a3,e,q' : 'a,a2,a3,e,e2,q,t').split(','), (key) => {
|
||||
ret[key] = {
|
||||
ret[key] = ret[key] || {
|
||||
pct: 0, // 倍率加成
|
||||
multi: 0, // 独立倍率乘区加成,宵宫E等
|
||||
|
||||
@ -51,44 +57,46 @@ let DmgAttr = {
|
||||
}
|
||||
})
|
||||
|
||||
ret.enemy = {
|
||||
ret.enemy = ret.enemy || {
|
||||
def: 0, // 降低防御
|
||||
ignore: 0, // 无视防御
|
||||
phy: 0 // 物理防御
|
||||
}
|
||||
|
||||
ret.shield = {
|
||||
ret.shield = AttrItem.create(originalAttr?.shield || {
|
||||
base: 100, // 基础
|
||||
plus: 0, // 护盾强效
|
||||
inc: 100 // 吸收倍率
|
||||
}
|
||||
})
|
||||
|
||||
ret.weapon = weapon // 武器
|
||||
ret.weaponTypeName = char.weaponTypeName // 武器类型
|
||||
ret.element = Format.elemName(char.elem) // 元素类型
|
||||
ret.refine = ((weapon.affix || ret.refine || 1) * 1 - 1) || 0 // 武器精炼
|
||||
ret.multi = 0 // 倍率独立乘区
|
||||
ret.kx = 0 // 敌人抗性降低
|
||||
if (game === 'gs') {
|
||||
ret.vaporize = 0 // 蒸发
|
||||
ret.melt = 0 // 融化
|
||||
ret.burning = 0 // 燃烧
|
||||
ret.superConduct = 0 // 超导
|
||||
ret.swirl = 0 // 扩散
|
||||
ret.electroCharged = 0 // 感电
|
||||
ret.shatter = 0 // 碎冰
|
||||
ret.overloaded = 0 // 超载
|
||||
ret.bloom = 0 // 绽放
|
||||
ret.burgeon = 0 // 烈绽放
|
||||
ret.hyperBloom = 0 // 超绽放
|
||||
ret.aggravate = 0 // 超激化
|
||||
ret.spread = 0 // 蔓激化
|
||||
ret.fykx = 0 // 敌人反应抗性降低
|
||||
} else if (game === 'sr') {
|
||||
// 技能持续伤害与弱点击破持续伤害
|
||||
ret.dot = {
|
||||
dmg: 0, // 伤害提高
|
||||
enemydmg: 0 // 承受伤害提高
|
||||
if (!originalAttr) {
|
||||
ret.weapon = weapon // 武器
|
||||
ret.weaponTypeName = char.weaponTypeName // 武器类型
|
||||
ret.element = Format.elemName(char.elem) // 元素类型
|
||||
ret.refine = ((weapon.affix || ret.refine || 1) * 1 - 1) || 0 // 武器精炼
|
||||
ret.multi = 0 // 倍率独立乘区
|
||||
ret.kx = 0 // 敌人抗性降低
|
||||
if (game === 'gs') {
|
||||
ret.vaporize = 0 // 蒸发
|
||||
ret.melt = 0 // 融化
|
||||
ret.burning = 0 // 燃烧
|
||||
ret.superConduct = 0 // 超导
|
||||
ret.swirl = 0 // 扩散
|
||||
ret.electroCharged = 0 // 感电
|
||||
ret.shatter = 0 // 碎冰
|
||||
ret.overloaded = 0 // 超载
|
||||
ret.bloom = 0 // 绽放
|
||||
ret.burgeon = 0 // 烈绽放
|
||||
ret.hyperBloom = 0 // 超绽放
|
||||
ret.aggravate = 0 // 超激化
|
||||
ret.spread = 0 // 蔓激化
|
||||
ret.fykx = 0 // 敌人反应抗性降低
|
||||
} else if (game === 'sr') {
|
||||
// 技能持续伤害与弱点击破持续伤害
|
||||
ret.dot = {
|
||||
dmg: 0, // 伤害提高
|
||||
enemydmg: 0 // 承受伤害提高
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret
|
||||
@ -103,15 +111,14 @@ let DmgAttr = {
|
||||
refine: attr.refine,
|
||||
weaponTypeName: attr.weaponTypeName,
|
||||
weapon: attr.weapon,
|
||||
element: Format.elemName(attr.element) || attr.element,
|
||||
// 计算属性
|
||||
element: Format.elemName(attr.element) || attr.element, // 计算属性
|
||||
calc: DmgAttr.getAttrValue
|
||||
}
|
||||
},
|
||||
|
||||
// 计算属性
|
||||
calcAttr ({ originalAttr, buffs, meta, params = {}, incAttr = '', reduceAttr = '', talent = '', game = 'gs' }) {
|
||||
let attr = lodash.merge({}, originalAttr)
|
||||
let attr = DmgAttr.getAttr({ originalAttr, game: originalAttr.game })
|
||||
let msg = []
|
||||
let { attrMap } = Meta.getMeta(game, 'arti')
|
||||
|
||||
@ -156,13 +163,10 @@ let DmgAttr = {
|
||||
|
||||
if (buff.mastery) {
|
||||
let mKey = {
|
||||
vaporize: '蒸发',
|
||||
melt: '融化',
|
||||
swirl: '扩散'
|
||||
vaporize: '蒸发', melt: '融化', swirl: '扩散'
|
||||
}
|
||||
let mKey2 = {
|
||||
aggravate: '超激化',
|
||||
spread: '蔓激化'
|
||||
aggravate: '超激化', spread: '蔓激化'
|
||||
}
|
||||
|
||||
let mastery = Math.max(0, attr.mastery.base + attr.mastery.plus)
|
||||
@ -184,8 +188,12 @@ let DmgAttr = {
|
||||
if (lodash.isFunction(val)) {
|
||||
val = val(ds)
|
||||
}
|
||||
if (!val) {
|
||||
return
|
||||
}
|
||||
|
||||
title = title.replace(`[${key}]`, Format.comma(val, 1))
|
||||
|
||||
// 技能提高
|
||||
let tRet = /^(a|a2|a3|e|q|t)(Def|Ignore|Dmg|Plus|Pct|Cpct|Cdmg|Multi)$/.exec(key)
|
||||
if (tRet) {
|
||||
@ -194,6 +202,9 @@ let DmgAttr = {
|
||||
}
|
||||
let aRet = /^(hp|def|atk|mastery|cpct|cdmg|heal|recharge|dmg|phy|shield|speed)(Plus|Pct|Inc)?$/.exec(key)
|
||||
if (aRet) {
|
||||
if (aRet[1] === 'hp') {
|
||||
console.log(val, key, attr[aRet[1]], val)
|
||||
}
|
||||
attr[aRet[1]][aRet[2] ? aRet[2].toLowerCase() : 'plus'] += val * 1 || 0
|
||||
return
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ const Serv = {
|
||||
if (!req) {
|
||||
return false
|
||||
}
|
||||
let serv = Serv.getServ(e.uid, player.game)
|
||||
let serv = Serv.getServ(e.uid || player.uid, player.game)
|
||||
let { uid } = player
|
||||
try {
|
||||
player._update = []
|
||||
|
@ -1,29 +1,29 @@
|
||||
export const details = [{
|
||||
title: 'E众水歌者治疗',
|
||||
dmg: ({ talent, attr, calc }, { heal }) =>
|
||||
heal(talent.e['众水的歌者治疗量2'][0] * calc(attr.hp) / 100 + talent.e['众水的歌者治疗量2'][1] * 1)
|
||||
dmg: ({ talent, attr }, { heal }) =>
|
||||
heal(talent.e['众水的歌者治疗量2'][0] * attr.hp / 100 + talent.e['众水的歌者治疗量2'][1] * 1)
|
||||
}, {
|
||||
title: 'E海薇玛夫人(海马)·伤害',
|
||||
dmg: ({ talent, attr, calc }, { basic }) => basic(calc(attr.hp) * talent.e['海薇玛夫人伤害'] / 100 * 1.4, 'e')
|
||||
dmg: ({ talent, attr }, { basic }) => basic(attr.hp * talent.e['海薇玛夫人伤害'] / 100 * 1.4, 'e')
|
||||
}, {
|
||||
title: 'E乌瑟勋爵(章鱼)·伤害',
|
||||
dmg: ({ talent, attr, calc }, { basic }) => basic(calc(attr.hp) * talent.e['乌瑟勋爵伤害'] / 100 * 1.4, 'e')
|
||||
dmg: ({ talent, attr }, { basic }) => basic(attr.hp * talent.e['乌瑟勋爵伤害'] / 100 * 1.4, 'e')
|
||||
}, {
|
||||
title: 'E谢贝蕾妲小姐(螃蟹)·伤害',
|
||||
dmgKey: 'e',
|
||||
dmg: ({ talent, attr, calc }, { basic }) => basic(calc(attr.hp) * talent.e['谢贝蕾妲小姐伤害'] / 100 * 1.4, 'e')
|
||||
dmg: ({ talent, attr }, { basic }) => basic(attr.hp * talent.e['谢贝蕾妲小姐伤害'] / 100 * 1.4, 'e')
|
||||
}, {
|
||||
title: 'E谢贝蕾妲小姐(螃蟹)·蒸发',
|
||||
dmgKey: 'e',
|
||||
dmg: ({ talent, attr, calc }, { basic }) => basic(calc(attr.hp) * talent.e['谢贝蕾妲小姐伤害'] / 100 * 1.4, 'e', '蒸发')
|
||||
dmg: ({ talent, attr }, { basic }) => basic(attr.hp * talent.e['谢贝蕾妲小姐伤害'] / 100 * 1.4, 'e', '蒸发')
|
||||
}, {
|
||||
title: 'Q万众狂欢·伤害',
|
||||
params: { talentQ: true },
|
||||
dmg: ({ talent, attr, calc, cons }, { basic }) => basic(calc(attr.hp) * (talent.q['技能伤害'] / 100), 'q')
|
||||
dmg: ({ talent, attr, cons }, { basic }) => basic(attr.hp * (talent.q['技能伤害'] / 100), 'q')
|
||||
}, {
|
||||
title: 'Q万众狂欢伤害·蒸发',
|
||||
params: { talentQ: true },
|
||||
dmg: ({ talent, attr, calc, cons }, { basic }) => basic(calc(attr.hp) * (talent.q['技能伤害'] / 100), 'q', '蒸发')
|
||||
dmg: ({ talent, attr, cons }, { basic }) => basic(attr.hp * (talent.q['技能伤害'] / 100), 'q', '蒸发')
|
||||
}]
|
||||
|
||||
export const mainAttr = 'hp,mastery,cpct,cdmg'
|
||||
@ -40,7 +40,7 @@ export const buffs = [{
|
||||
}, {
|
||||
title: '芙宁娜被动:基于生命值,提升召唤物伤害[eDmg]%',
|
||||
data: {
|
||||
eDmg: ({ calc, attr }) => Math.min(28, (calc(attr.hp)) / 1000 * 0.7)
|
||||
eDmg: ({ attr }) => Math.min(28, attr.hp / 1000 * 0.7)
|
||||
}
|
||||
}, {
|
||||
title: '芙宁娜1命:气氛值层数上限提升100',
|
||||
|
@ -4,8 +4,8 @@ export const details = [{
|
||||
dmg: ({ talent }, dmg) => dmg(talent.e['技能伤害'], 'e')
|
||||
}, {
|
||||
title: 'E刹那之花伤害',
|
||||
dmg: ({ talent, attr, calc }, { basic }) => {
|
||||
let ret = talent.e['刹那之花伤害'] * calc(attr.def) / 100 + attr.e.plus
|
||||
dmg: ({ talent, attr }, { basic }) => {
|
||||
let ret = talent.e['刹那之花伤害'] * attr.def / 100 + attr.e.plus
|
||||
return basic(ret, 'e')
|
||||
}
|
||||
}, {
|
||||
@ -13,8 +13,8 @@ export const details = [{
|
||||
params: {
|
||||
half: true
|
||||
},
|
||||
dmg: ({ talent, attr, calc }, { basic }) => {
|
||||
let ret = talent.e['刹那之花伤害'] * calc(attr.def) / 100 + attr.e.plus
|
||||
dmg: ({ talent, attr }, { basic }) => {
|
||||
let ret = talent.e['刹那之花伤害'] * attr.def / 100 + attr.e.plus
|
||||
return basic(ret, 'e')
|
||||
}
|
||||
}, {
|
||||
@ -41,6 +41,6 @@ export const buffs = [{
|
||||
cons: 2,
|
||||
sort: 9,
|
||||
data: {
|
||||
qPlus: ({ params, attr, calc }) => params.buff === 0 ? 0 : calc(attr.def) * 1.2
|
||||
qPlus: ({ params, attr }) => params.buff === 0 ? 0 : attr.def * 1.2
|
||||
}
|
||||
}]
|
||||
|
Loading…
Reference in New Issue
Block a user