169 lines
5.9 KiB
C#
169 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Cal;
|
|
using Cal.DataTable;
|
|
|
|
namespace ET
|
|
{
|
|
public static class ItemHelper
|
|
{
|
|
private static float randomMax;
|
|
const float randomMin = -0.20f;
|
|
public static void GenerateRandomMainAttribute(EquipItem self, Cal.DataTable.EquipBase equipBase, float randomMax)
|
|
{
|
|
ItemHelper.randomMax = randomMax;
|
|
if (equipBase.Hp != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.最大生命, GetRandom());
|
|
}
|
|
if (equipBase.Mp != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.最大精力, GetRandom());
|
|
}
|
|
if (equipBase.Str != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.力量, GetRandom());
|
|
}
|
|
if (equipBase.Quk != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.敏捷, GetRandom());
|
|
}
|
|
if (equipBase.Spi != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.精神, GetRandom());
|
|
}
|
|
if (equipBase.Wim != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.智慧, GetRandom());
|
|
}
|
|
if (equipBase.Phy != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.体质, GetRandom());
|
|
}
|
|
if (equipBase.Sta != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.耐力, GetRandom());
|
|
}
|
|
if (equipBase.PhyAtk != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.物理攻击, GetRandom());
|
|
}
|
|
if (equipBase.SpiAtk != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.精神攻击, GetRandom());
|
|
}
|
|
if (equipBase.PhyDef != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.物理防御, GetRandom());
|
|
}
|
|
if (equipBase.SpiDef != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.精神防御, GetRandom());
|
|
}
|
|
if (equipBase.Pcrir != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.物理暴击系数, GetRandom());
|
|
}
|
|
if (equipBase.Mcrir != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.精神暴击系数, GetRandom());
|
|
}
|
|
if (equipBase.Pcri != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.物理暴击效果, GetRandom());
|
|
}
|
|
if (equipBase.Mcri != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.精神暴击效果, GetRandom());
|
|
}
|
|
if (equipBase.Rpcrir != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.抗物理暴击系数, GetRandom());
|
|
}
|
|
if (equipBase.Rmcrir != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.抗精神暴击系数, GetRandom());
|
|
}
|
|
if (equipBase.Rpcri != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.抗物理暴击效果, GetRandom());
|
|
}
|
|
if (equipBase.Rmcri != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.抗精神暴击效果, GetRandom());
|
|
}
|
|
if (equipBase.Dvo != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.辅助值, GetRandom());
|
|
}
|
|
if (equipBase.Nphyi != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.物理免伤, GetRandom());
|
|
}
|
|
if (equipBase.Nmeni != 0)
|
|
{
|
|
self.SetMainAttribute(AttributeType.精神免伤, GetRandom());
|
|
}
|
|
}
|
|
|
|
|
|
static List<int> qualityWeightList = new() { 0, 1025, 856, 1 };
|
|
public static void GenerateAdditionalAttribute(EquipItem self, int useLevel)
|
|
{
|
|
self.addtionalAttributes.Clear();
|
|
int randCount = 0;
|
|
if (MathHelper.IsHit(0.6f))
|
|
randCount = 1;
|
|
else
|
|
if (MathHelper.IsHit(0.2f))
|
|
randCount = 2;
|
|
for (int i = 0; i < randCount; i++)
|
|
{
|
|
//稀有度
|
|
int quality = MathHelper.GetProbabilityIndexByWeight(qualityWeightList);
|
|
var vidList =EquipAffixConfigCategory.Instance. vidDic[quality];
|
|
if (vidList == null || vidList.Count == 0) continue;
|
|
int vidCount = vidList.Count;
|
|
int vid = vidList[RandomHelper.RandomNumber(0, vidCount)];
|
|
var levelList =EquipAffixConfigCategory.Instance. levelDic[vid];
|
|
if (levelList == null || levelList.Count == 0) continue;
|
|
int level = levelList[levelList.Count-1];
|
|
for (int j = 0; j < levelList.Count; j++)
|
|
{
|
|
if (useLevel < levelList[j])
|
|
{
|
|
if (j == 0) break;
|
|
level = levelList[j - 1];
|
|
break;
|
|
}
|
|
}
|
|
EquipAffixConfig equipAffix = EquipAffixConfigCategory.Instance.Get(vid*100000 + quality*10000+level);
|
|
if (equipAffix == null)
|
|
{
|
|
Log.Error($"affix == null where vid = {vid} level = {level}");
|
|
continue;
|
|
}
|
|
self.addtionalAttributes.Add((int)equipAffix.Id);
|
|
}
|
|
}
|
|
|
|
public static float GetRandom()
|
|
{
|
|
return GetRandom(randomMax);
|
|
}
|
|
public static float GetRandom(float randomMax)
|
|
{
|
|
float maxRandomMultier = randomMax;
|
|
if (MathHelper.IsHit(0.4f))
|
|
{
|
|
maxRandomMultier -= 0.07f;
|
|
}
|
|
if (MathHelper.IsHit(0.1f))
|
|
{
|
|
maxRandomMultier -= 0.13f;
|
|
}
|
|
return RandomHelper.RandomFloat(randomMin, maxRandomMultier);
|
|
}
|
|
}
|
|
}
|