CTT/Server/Hotfix/Game/Common/BuffDamageCalculate/PhyBuffDamageCalculate.cs

72 lines
4.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Cal;
using System;
using System.Collections.Generic;
namespace ET
{
public static class PhyBuffDamageCalculate
{
public static void Calculate(NumericComponent num, NumericComponent numTarget, ValueCalculate valueCalculate_Self, ValueCalculate valueCalculate_Target, int skillId, out BallisticData data)
{
data = new BallisticData();
float baseHurt1 = 0, baseHurt2 = 0;
//攻击数值 = 攻击*技能百分比+技能数值威力
//基础伤害=攻击数值*攻击数值/(攻击数值+对方防御)
float def = numTarget.Get(NumericType.PhyDef) + 0.01f;
float mineLevel = numTarget.Get(NumericType.Level);
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);
//攻击能力 = 攻击 * 技能百分比 + 36*力量
float attackValue1 = num1.Get(numericType1) * percValue1 / 100 + ConstDefine.DamageStrTimes*num.Get(NumericType.Str);
//减伤百分比=自身防御/(攻击方等级X200+自身防御);
//最终伤害=对方基础攻击X(1-减伤百分比)*(1-自身减伤百分比)-体力*14-耐力*48
float reduce = def / (num.Get(NumericType.Level) * ConstDefine.DamageLevelTimes + def);
baseHurt1 = attackValue1 * (1 - reduce) * (1+num.Get( NumericType.PhyDA) - numTarget.Get(NumericType.Nphyi)) - numTarget.Get(NumericType.Phy) *mineLevel/ ConstDefine.DamagePhyTimes - numTarget.Get(NumericType.Sta) * mineLevel/ConstDefine.DamageStaTimes;
if (baseHurt1 <= 0) baseHurt1 = 0;
}
}
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);
float attackValue2 = num2.Get(numericType2) * percValue2 / 100 + ConstDefine.DamageStrTimes * num.Get(NumericType.Str);
float reduce = def / (num.Get(NumericType.Level) * ConstDefine.DamageLevelTimes + def);
baseHurt2 = attackValue2 * (1 - reduce) * (1+num.Get( NumericType.PhyDA) - numTarget.Get(NumericType.Nphyi)) - numTarget.Get(NumericType.Phy) * mineLevel/ConstDefine.DamagePhyTimes - numTarget.Get(NumericType.Sta) *mineLevel/ ConstDefine.DamageStaTimes;
if (baseHurt2 <= 0) baseHurt2 = 0;
}
}
float baseHurt = baseHurt1 + baseHurt2;
//!++测试
//data.isCrit = RandomHelper.RandomFloat() <= 0.6f;
if (num.Parent.GetComponent<ModifierContainerComponent>().HasState(ModifierStateType.))
{
data.isCrit = true;
}
else
{
//暴击概率=0.05f + 0.6f*(暴击率/(爆击率+对方暴击率抵抗))
float crirBase = num.Get(NumericType.Pcrir);
float cri = 0.05f + 0.6f * (crirBase * crirBase / (crirBase + numTarget.Get(NumericType.Rpcrir) + 0.01f));
//暴击概率 = 暴击概率>0.8f ? 0.8f:暴击概率
cri = cri >ConstDefine. MaxCritRate ?ConstDefine. MaxCritRate : cri;
//是否暴击 = 0-1 的随机数 <= 暴击概率
data.isCrit = RandomHelper.RandomFloat() <= cri;
}
//暴击伤害倍率 = 有暴击?(暴击伤害*2 + FirstCritDamage)/(暴击伤害*0.6f +暴击伤害抵抗 + 11f
float criBase = num.Get(NumericType.Pcri);
float criHurt = data.isCrit ? ((criBase * 2 + ConstDefine.BaseCritDamage) / (criBase * 0.6f + numTarget.Get(NumericType.Rpcri) + 1)) : 1;
data.value = baseHurt * criHurt * RandomHelper.RandomFloat(0.9f, 1.1f);
if (data.value <= 0) data.value = 1;
}
}
}