96 lines
4.2 KiB
C#
Executable File
96 lines
4.2 KiB
C#
Executable File
using Cal;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
|
||
namespace ET
|
||
{
|
||
public static class TreatBuffDamageCalculate
|
||
{
|
||
//最大暴击率
|
||
private const float MaxCritRate = 0.95f;
|
||
//基础暴击伤害
|
||
private const float BaseCritDamage = 1.5f;
|
||
public static void Calculate(NumericComponent num, NumericComponent numTarget , ValueCalculate valueCalculate_Self, ValueCalculate valueCalculate_Target, int skillId, out BallisticData data)
|
||
{
|
||
data = default;
|
||
float baseHurt1 = 0, baseHurt2 = 0;
|
||
//攻击数值 = 攻击*技能百分比+技能数值威力
|
||
//基础伤害=攻击数值*攻击数值/(攻击数值+对方防御)
|
||
if (valueCalculate_Self != null)
|
||
{
|
||
if (SkillHelper.GetParam(valueCalculate_Self.param, skillId, out float percValue1))
|
||
{
|
||
BattleHelper.GetNumType(valueCalculate_Self, NumTargetType.Self, num, numTarget, out NumericComponent num1, out NumericType numericType1);
|
||
baseHurt1 = num1.Get(numericType1) * percValue1 / 100;
|
||
}
|
||
}
|
||
if (valueCalculate_Target != null)
|
||
{
|
||
if (SkillHelper.GetParam(valueCalculate_Target.param, skillId, out float percValue2))
|
||
{
|
||
BattleHelper.GetNumType(valueCalculate_Target, NumTargetType.Target, num, numTarget, out NumericComponent num2, out NumericType numericType2);
|
||
baseHurt2 = num2.Get(numericType2) * percValue2 / 100;
|
||
}
|
||
}
|
||
float baseHurt = baseHurt1 + baseHurt2;
|
||
|
||
float phyAtk = num.Get(NumericType.PhyAtk);
|
||
float spiAtk = num.Get(NumericType.SpiAtk);
|
||
|
||
float rPcrir, rMcrir;
|
||
float criHurt;
|
||
if (phyAtk > spiAtk)
|
||
{
|
||
if (num.Parent.GetComponent<ModifierContainerComponent>().HasState(ModifierStateType.必定暴击))
|
||
{
|
||
data.isCrit = true;
|
||
}
|
||
else
|
||
{
|
||
//暴击概率=0.05f + 0.6f*(暴击率/(爆击率+对方暴击率抵抗))
|
||
float crirBase = num.Get(NumericType.Pcrir);
|
||
|
||
rPcrir = 0;
|
||
float cri = 0.05f + 0.6f * (crirBase * crirBase / (crirBase + rPcrir + 0.01f));
|
||
|
||
//暴击概率 = 暴击概率>0.8f ? 0.8f:暴击概率
|
||
cri = cri > MaxCritRate ? MaxCritRate : cri;
|
||
|
||
//是否暴击 = 0-1 的随机数 <= 暴击概率
|
||
data.isCrit = RandomHelper.RandomFloat() <= cri;
|
||
}
|
||
|
||
//暴击伤害倍率 = 有暴击?(暴击伤害*2 + FirstCritDamage)/(暴击伤害*0.6f +暴击伤害抵抗 + 1):1f
|
||
//float criBase = num.Get(NumericType.Pcri);
|
||
criHurt = data.isCrit ? BaseCritDamage : 1;
|
||
}
|
||
else
|
||
{
|
||
if (num.Parent.GetComponent<ModifierContainerComponent>().HasState(ModifierStateType.必定暴击))
|
||
{
|
||
data.isCrit = true;
|
||
}
|
||
else
|
||
{
|
||
//暴击概率=0.05f+0.6f*(暴击率/(爆击率+对方暴击率抵抗))
|
||
float crirBase = num.Get(NumericType.Mcrir);
|
||
rMcrir = 0;
|
||
float cri = 0.05f + 0.6f * (crirBase * crirBase / (crirBase + rMcrir + 0.01f));
|
||
|
||
//暴击概率 = 暴击概率>0.8f ? 0.8f:暴击概率
|
||
cri = cri > MaxCritRate ? MaxCritRate : cri;
|
||
|
||
//是否暴击 = 0-1 的随机数 <= 暴击概率
|
||
data.isCrit = RandomHelper.RandomFloat() <= cri;
|
||
}
|
||
|
||
//暴击伤害倍率 = 有暴击?(暴击伤害*2 + FirstCritDamage)/(暴击伤害*0.6f +暴击伤害抵抗 + 1):1f
|
||
//float criBase = num.Get(NumericType.Mcri);
|
||
criHurt = data.isCrit ?BaseCritDamage: 1;
|
||
}
|
||
data.value = baseHurt * criHurt*(1+num.Get(NumericType.Dvo)/10) * RandomHelper.RandomFloat(0.9f, 1.1f);
|
||
if (data.value <= 0) data.value = 1;
|
||
}
|
||
}
|
||
}
|