重构清理敌人类

This commit is contained in:
2026-09-15 11:07:01 +08:00
parent 421f8bf619
commit 88ed35e757
34 changed files with 568 additions and 457 deletions
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using SepCore.Definition;
@@ -239,10 +239,11 @@ namespace SepCore.CustomUtility
public static int CalcDamageHP(int attack, StatProperty attackStat, StatProperty defenseStat,
StatProperty dodgeStat)
{
// 1. 处理闪避(闪避率取值 (0, 0.9),不允许拉满闪避)
// 1. 处理闪避(从全局表读取闪避率上限)
float maxDodge = GameEntry.Luban.Global.MaxDodgeRate / 1000f;
if (dodgeStat != null)
{
if (Random.value < Mathf.Clamp(dodgeStat.Value, 0, 0.9f)) return 0;
if (Random.value < Mathf.Clamp(dodgeStat.Value, 0f, maxDodge)) return 0;
}
// 2. 处理攻击加成 最终伤害 = (基础伤害 + 伤害提升固定值) * 伤害提升率
@@ -258,9 +259,10 @@ namespace SepCore.CustomUtility
damage = (damage - defenseStat.Value) / defenseStat.Percent;
}
// 将伤害限制为正整数,避免堆防御导致无法造成伤害
if (damage < 1) return 1;
else return Mathf.CeilToInt(damage);
// 4. 将伤害限制为保底伤害,避免堆防御导致无法造成伤害
int minDamage = GameEntry.Luban.Global.MinDamage;
if (damage < minDamage) return minDamage;
return Mathf.CeilToInt(damage);
}
[StructLayout(LayoutKind.Auto)]