mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
新增月城柳伤害计算等
This commit is contained in:
parent
5bacdbbbc9
commit
208cb0ae05
5 changed files with 293 additions and 162 deletions
|
|
@ -28,21 +28,28 @@ export interface skill {
|
|||
redirect?: string
|
||||
/** 禁用伤害计算cache */
|
||||
banCache?: boolean
|
||||
/** 是否计算该技能 */
|
||||
check?: (({ avatar, buffM, calc }: {
|
||||
avatar: ZZZAvatarInfo
|
||||
buffM: BuffManager
|
||||
calc: Calculator
|
||||
}) => boolean)
|
||||
/** 自定义计算逻辑 */
|
||||
dmg?: (calc: Calculator) => damage
|
||||
/** 额外处理 */
|
||||
before?: ({ skill, avatar, usefulBuffs, calc }: {
|
||||
before?: ({ avatar, calc, usefulBuffs, detail, skill }: {
|
||||
avatar: ZZZAvatarInfo
|
||||
calc: Calculator
|
||||
detail: damage['detail']
|
||||
usefulBuffs: buff[]
|
||||
/** 技能自身 */
|
||||
skill: skill
|
||||
avatar: ZZZAvatarInfo
|
||||
usefulBuffs: buff[]
|
||||
calc: Calculator
|
||||
}) => void
|
||||
after?: ({ avatar, damage, calc, usefulBuffs }: {
|
||||
after?: ({ avatar, calc, usefulBuffs, damage }: {
|
||||
avatar: ZZZAvatarInfo
|
||||
damage: damage
|
||||
calc: Calculator
|
||||
usefulBuffs: buff[]
|
||||
damage: damage
|
||||
}) => void
|
||||
}
|
||||
|
||||
|
|
@ -55,6 +62,8 @@ export interface damage {
|
|||
Multiplier: number
|
||||
/** 攻击力 */
|
||||
ATK: number
|
||||
/** 基础伤害区 */
|
||||
BasicArea: number
|
||||
/** 暴击率 */
|
||||
CRITRate: number
|
||||
/** 暴伤伤害 */
|
||||
|
|
@ -186,6 +195,7 @@ export class Calculator {
|
|||
return this.calc_skill(MySkill)
|
||||
}
|
||||
if (!skill.banCache && this.damageCache[skill.type]) return this.damageCache[skill.type]
|
||||
if (skill.check && !skill.check({ avatar: this.avatar, buffM: this.buffM, calc: this })) return
|
||||
logger.debug(`${logger.green(skill.type)}${skill.name}伤害计算:`)
|
||||
if (skill.dmg) {
|
||||
const dmg = skill.dmg(this)
|
||||
|
|
@ -198,69 +208,61 @@ export class Calculator {
|
|||
element: skill.element,
|
||||
range: skill.redirect ? [skill.type, skill.redirect] : [skill.type]
|
||||
}, this)
|
||||
if (skill.before) skill.before({ skill, avatar: this.avatar, usefulBuffs, calc: this })
|
||||
let Multiplier = 0
|
||||
const detail = {} as damage['detail']
|
||||
if (skill.before) skill.before({ avatar: this.avatar, calc: this, detail, skill, usefulBuffs, })
|
||||
const isAnomaly = typeof anomalyEnum[skill.type as anomaly] === 'number'
|
||||
if (skill.fixedMultiplier) Multiplier = skill.fixedMultiplier
|
||||
else if (isAnomaly) {
|
||||
Multiplier = (
|
||||
skill.type === '紊乱' ?
|
||||
this.get_DiscoverMultiplier(skill) :
|
||||
this.get_AnomalyMultiplier(skill, usefulBuffs, skill.name.includes('每') ? 1 : 0)
|
||||
) || 0
|
||||
} else {
|
||||
if (skill.skillMultiplier) Multiplier = skill.skillMultiplier[this.get_SkillLevel(skill.type[0]) - 1]
|
||||
else Multiplier = this.get_Multiplier(skill.type)
|
||||
if (!detail.BasicArea) {
|
||||
if (!detail.Multiplier) {
|
||||
if (skill.fixedMultiplier) {
|
||||
detail.Multiplier = skill.fixedMultiplier
|
||||
} else if (isAnomaly) {
|
||||
detail.Multiplier = (
|
||||
skill.type === '紊乱' ?
|
||||
this.get_DiscoverMultiplier(skill) :
|
||||
this.get_AnomalyMultiplier(skill, usefulBuffs, skill.name.includes('每') ? 1 : 0)
|
||||
) || 0
|
||||
} else {
|
||||
if (skill.skillMultiplier) detail.Multiplier = skill.skillMultiplier[this.get_SkillLevel(skill.type[0]) - 1]
|
||||
else detail.Multiplier = this.get_Multiplier(skill.type)
|
||||
}
|
||||
const ExtraMultiplier = this.get_ExtraMultiplier(skill, usefulBuffs)
|
||||
detail.Multiplier += ExtraMultiplier
|
||||
if (!detail.Multiplier) return logger.warn('技能倍率缺失:', skill)
|
||||
if (ExtraMultiplier) logger.debug(`最终倍率:${detail.Multiplier}`)
|
||||
}
|
||||
detail.ATK ??= this.get_ATK(skill, usefulBuffs)
|
||||
}
|
||||
const ExtraMultiplier = this.get_ExtraMultiplier(skill, usefulBuffs)
|
||||
Multiplier += ExtraMultiplier
|
||||
if (!Multiplier) return logger.warn('技能倍率缺失:', skill)
|
||||
if (ExtraMultiplier) logger.debug(`最终倍率:${Multiplier}`)
|
||||
const ATK = this.get_ATK(skill, usefulBuffs)
|
||||
let CRITRate = 0, CRITDMG = 0, AnomalyCRITRate = 0, AnomalyCRITDMG = 0
|
||||
let AnomalyProficiencyArea = 0, AnomalyBoostArea = 0, LevelArea = 0
|
||||
let CriticalArea = 0
|
||||
detail.BasicArea ??= detail.ATK * detail.Multiplier
|
||||
logger.debug(`基础伤害区:${detail.BasicArea}`)
|
||||
if (isAnomaly) {
|
||||
AnomalyProficiencyArea = this.get_AnomalyProficiencyArea(skill, usefulBuffs)
|
||||
AnomalyBoostArea = this.get_AnomalyBoostArea(skill, usefulBuffs)
|
||||
LevelArea = this.get_LevelArea()
|
||||
AnomalyCRITRate = this.get_AnomalyCRITRate(skill, usefulBuffs)
|
||||
AnomalyCRITDMG = this.get_AnomalyCRITDMG(skill, usefulBuffs)
|
||||
CriticalArea = 1 + AnomalyCRITRate * (AnomalyCRITDMG - 1)
|
||||
detail.AnomalyProficiencyArea ??= this.get_AnomalyProficiencyArea(skill, usefulBuffs)
|
||||
detail.AnomalyBoostArea ??= this.get_AnomalyBoostArea(skill, usefulBuffs)
|
||||
detail.LevelArea ??= this.get_LevelArea()
|
||||
detail.AnomalyCRITRate ??= this.get_AnomalyCRITRate(skill, usefulBuffs)
|
||||
detail.AnomalyCRITDMG ??= this.get_AnomalyCRITDMG(skill, usefulBuffs)
|
||||
detail.CriticalArea ??= 1 + detail.AnomalyCRITRate * (detail.AnomalyCRITDMG - 1)
|
||||
} else {
|
||||
CRITRate = this.get_CRITRate(skill, usefulBuffs)
|
||||
CRITDMG = this.get_CRITDMG(skill, usefulBuffs)
|
||||
CriticalArea = 1 + CRITRate * (CRITDMG - 1)
|
||||
detail.CRITRate ??= this.get_CRITRate(skill, usefulBuffs)
|
||||
detail.CRITDMG ??= this.get_CRITDMG(skill, usefulBuffs)
|
||||
detail.CriticalArea ??= 1 + detail.CRITRate * (detail.CRITDMG - 1)
|
||||
}
|
||||
logger.debug(`暴击期望:${CriticalArea}`)
|
||||
const BoostArea = this.get_BoostArea(skill, usefulBuffs)
|
||||
const VulnerabilityArea = this.get_VulnerabilityArea(skill, usefulBuffs)
|
||||
const ResistanceArea = this.get_ResistanceArea(skill, usefulBuffs)
|
||||
const DefenceArea = this.get_DefenceArea(skill, usefulBuffs)
|
||||
logger.debug(`暴击期望:${detail.CriticalArea}`)
|
||||
detail.BoostArea ??= this.get_BoostArea(skill, usefulBuffs)
|
||||
detail.VulnerabilityArea ??= this.get_VulnerabilityArea(skill, usefulBuffs)
|
||||
detail.ResistanceArea ??= this.get_ResistanceArea(skill, usefulBuffs)
|
||||
detail.DefenceArea ??= this.get_DefenceArea(skill, usefulBuffs)
|
||||
const {
|
||||
BasicArea, CRITDMG, CriticalArea, BoostArea, VulnerabilityArea, ResistanceArea, DefenceArea,
|
||||
AnomalyProficiencyArea, LevelArea, AnomalyBoostArea, AnomalyCRITRate, AnomalyCRITDMG
|
||||
} = detail
|
||||
const result: damage['result'] = isAnomaly ?
|
||||
{
|
||||
critDMG: AnomalyCRITRate ? ATK * Multiplier * AnomalyCRITDMG * BoostArea * VulnerabilityArea * ResistanceArea * DefenceArea * AnomalyProficiencyArea * LevelArea * AnomalyBoostArea : 0,
|
||||
expectDMG: ATK * Multiplier * CriticalArea * BoostArea * VulnerabilityArea * ResistanceArea * DefenceArea * AnomalyProficiencyArea * LevelArea * AnomalyBoostArea
|
||||
critDMG: AnomalyCRITRate ? BasicArea * AnomalyCRITDMG * BoostArea * VulnerabilityArea * ResistanceArea * DefenceArea * AnomalyProficiencyArea * LevelArea * AnomalyBoostArea : 0,
|
||||
expectDMG: BasicArea * CriticalArea * BoostArea * VulnerabilityArea * ResistanceArea * DefenceArea * AnomalyProficiencyArea * LevelArea * AnomalyBoostArea
|
||||
} : {
|
||||
critDMG: ATK * Multiplier * CRITDMG * BoostArea * VulnerabilityArea * ResistanceArea * DefenceArea,
|
||||
expectDMG: ATK * Multiplier * CriticalArea * BoostArea * VulnerabilityArea * ResistanceArea * DefenceArea
|
||||
critDMG: BasicArea * CRITDMG * BoostArea * VulnerabilityArea * ResistanceArea * DefenceArea,
|
||||
expectDMG: BasicArea * CriticalArea * BoostArea * VulnerabilityArea * ResistanceArea * DefenceArea
|
||||
}
|
||||
const detail: damage['detail'] = {
|
||||
Multiplier,
|
||||
ATK,
|
||||
CRITRate,
|
||||
CRITDMG,
|
||||
CriticalArea,
|
||||
BoostArea,
|
||||
VulnerabilityArea,
|
||||
ResistanceArea,
|
||||
DefenceArea,
|
||||
AnomalyCRITRate,
|
||||
AnomalyCRITDMG,
|
||||
AnomalyProficiencyArea,
|
||||
AnomalyBoostArea,
|
||||
LevelArea
|
||||
}
|
||||
const damage: damage = { skill, detail, result }
|
||||
if (skill.after) {
|
||||
damage.add = (d) => {
|
||||
|
|
@ -330,16 +332,16 @@ export class Calculator {
|
|||
*/
|
||||
get_Multiplier(type: string) {
|
||||
const skillLevel = this.get_SkillLevel(type[0])
|
||||
logger.debug(`等级:${skillLevel}`)
|
||||
logger.debug(`${type[0]}等级:${skillLevel}`)
|
||||
const Multiplier = charData[this.avatar.id].skill[type]?.[skillLevel - 1]
|
||||
logger.debug(`倍率:${Multiplier}`)
|
||||
logger.debug(`技能倍率:${Multiplier}`)
|
||||
return Multiplier
|
||||
}
|
||||
|
||||
get_AnomalyData(skill: skill) {
|
||||
get_AnomalyData(type: skill['type']) {
|
||||
let a = AnomalyData.filter(({ element_type }) => element_type === this.avatar.element_type)
|
||||
if (skill.type === '紊乱') a = a.filter(({ discover }) => discover)
|
||||
else a = a.filter(({ name, multiplier }) => name === skill.type && multiplier)
|
||||
if (type === '紊乱') a = a.filter(({ discover }) => discover)
|
||||
else a = a.filter(({ name, multiplier }) => name === type && multiplier)
|
||||
if (a.length === 1) return a[0]
|
||||
a = a.filter(({ sub_element_type }) => sub_element_type === this.avatar.sub_element_type)
|
||||
return a[0]
|
||||
|
|
@ -347,7 +349,7 @@ export class Calculator {
|
|||
|
||||
/** 获取属性异常倍率 */
|
||||
get_AnomalyMultiplier(skill: skill, usefulBuffs: buff[], times = 0) {
|
||||
const anomalyData = this.get_AnomalyData(skill)
|
||||
const anomalyData = this.get_AnomalyData(skill.type)
|
||||
if (!anomalyData) return
|
||||
let Multiplier = anomalyData.multiplier
|
||||
if (anomalyData.duration && anomalyData.interval) {
|
||||
|
|
@ -361,7 +363,7 @@ export class Calculator {
|
|||
|
||||
/** 获取紊乱倍率 */
|
||||
get_DiscoverMultiplier(skill: skill) {
|
||||
const anomalyData = this.get_AnomalyData(skill)
|
||||
const anomalyData = this.get_AnomalyData(skill.type)
|
||||
if (!anomalyData) return
|
||||
const AnomalyDuration = this.get_AnomalyDuration({
|
||||
...skill,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue