diff --git a/Assets/GameMain/DataTables/tbenemyconfig.bytes b/Assets/GameMain/DataTables/tbenemyconfig.bytes index 766f79d..48e58a5 100644 Binary files a/Assets/GameMain/DataTables/tbenemyconfig.bytes and b/Assets/GameMain/DataTables/tbenemyconfig.bytes differ diff --git a/Assets/GameMain/DataTables/tbenemyconfig.json b/Assets/GameMain/DataTables/tbenemyconfig.json index 90c0b5c..a4f0371 100644 --- a/Assets/GameMain/DataTables/tbenemyconfig.json +++ b/Assets/GameMain/DataTables/tbenemyconfig.json @@ -9,7 +9,7 @@ "attackRange": 1.5, "speed": 3, "coinDrop": 5, - "expDrop": 1, + "expDrop": 20, "dropPercent": 0.3, "scale": 1, "color": "#44FF44", @@ -25,7 +25,7 @@ "attackRange": 8, "speed": 2.5, "coinDrop": 4, - "expDrop": 2, + "expDrop": 20, "dropPercent": 0.2, "scale": 1, "color": "#FF44FF", @@ -41,7 +41,7 @@ "attackRange": 1.2, "speed": 6, "coinDrop": 3, - "expDrop": 1, + "expDrop": 25, "dropPercent": 0.4, "scale": 0.5, "color": "#FF4444", @@ -57,7 +57,7 @@ "attackRange": 1.8, "speed": 2.5, "coinDrop": 6, - "expDrop": 2, + "expDrop": 25, "dropPercent": 0.3, "scale": 1.3, "color": "#CCCCCC", @@ -73,7 +73,7 @@ "attackRange": 2.5, "speed": 1.5, "coinDrop": 10, - "expDrop": 3, + "expDrop": 30, "dropPercent": 0.25, "scale": 2, "color": "#888888", @@ -89,7 +89,7 @@ "attackRange": 10, "speed": 3, "coinDrop": 5, - "expDrop": 2, + "expDrop": 30, "dropPercent": 0.3, "scale": 0.8, "color": "#88CCFF", @@ -105,7 +105,7 @@ "attackRange": 12, "speed": 2, "coinDrop": 8, - "expDrop": 3, + "expDrop": 30, "dropPercent": 0.2, "scale": 1.2, "color": "#FF8800", diff --git a/Assets/GameMain/Scripts/Runtime/Battle/CharacterStat.cs b/Assets/GameMain/Scripts/Runtime/Battle/CharacterStat.cs index b756e88..a457383 100644 --- a/Assets/GameMain/Scripts/Runtime/Battle/CharacterStat.cs +++ b/Assets/GameMain/Scripts/Runtime/Battle/CharacterStat.cs @@ -193,7 +193,21 @@ namespace SepCore.Battle } } - float finalValue = ((BaseValue + sumFlat) * (1f + sumPercentAdd)) * prodPercentMult; + float finalValue; + if (Type is StatType.CritChance or StatType.Dodge or StatType.LifeSteal) + { + // 概率/比率型属性(暴击率、闪避率、生命窃取):底数通常为 0~1 的小数概率。 + // 无论是 Flat(如道具填 0.27)还是 PercentAdd(如升级奖励填 0.30),本质上均为点数直接加算(+30% 概率)。 + // 若沿用标量乘法公式,由于 BaseValue 为 0,会导致 (0 + 0) * (1 + 0.30) = 0,从而百分比奖励完全失效。 + finalValue = (BaseValue + sumFlat + sumPercentAdd) * prodPercentMult; + } + else + { + // 标量属性与倍率属性(MaxHp、MoveSpeed、DamagePercent、AttackSpeed 等): + // (Base + Flat) * (1 + PercentAdd) * PercentMult + finalValue = ((BaseValue + sumFlat) * (1f + sumPercentAdd)) * prodPercentMult; + } + return ClampStat(finalValue); } diff --git a/Assets/Tests/Gameplay/EditMode/AttributePipelineTests.cs b/Assets/Tests/Gameplay/EditMode/AttributePipelineTests.cs index 46048e8..172aab5 100644 --- a/Assets/Tests/Gameplay/EditMode/AttributePipelineTests.cs +++ b/Assets/Tests/Gameplay/EditMode/AttributePipelineTests.cs @@ -253,5 +253,30 @@ namespace VampireLike.Tests.Gameplay.EditMode string multDesc = SepCore.CustomUtility.ItemDescUtility.Describe(multMod); Assert.IsTrue(multDesc.Contains("x1.25"), $"Expected x1.25 in: {multDesc}"); } + + [Test] + public void RateStats_CritChanceAndDodge_ZeroBaseValue_CorrectlyAccumulatesPercentAddModifiers() + { + var pipeline = new AttributePipeline(); + + // 1. 验证默认初值为 0 + Assert.AreEqual(0f, pipeline.GetValue(StatType.CritChance), 1e-4f); + Assert.AreEqual(0f, pipeline.GetValue(StatType.Dodge), 1e-4f); + + // 2. 模拟选了两个 +30% 暴击率奖励(即升级奖励 1015,ModifierType 为 PercentAdd 0.30) + pipeline.AddModifier(StatType.CritChance, new StatModifier(0.30f, ModifierType.PercentAdd)); + Assert.AreEqual(0.30f, pipeline.GetValue(StatType.CritChance), 1e-4f); + + pipeline.AddModifier(StatType.CritChance, new StatModifier(0.30f, ModifierType.PercentAdd)); + Assert.AreEqual(0.60f, pipeline.GetValue(StatType.CritChance), 1e-4f); // 此时暴击率应正确累加到 60% + + // 3. 模拟叠加 Flat 词条道具(如磨刀石 +27% 暴击率,ModifierType 为 Flat 0.27) + pipeline.AddModifier(StatType.CritChance, new StatModifier(0.27f, ModifierType.Flat)); + Assert.AreEqual(0.87f, pipeline.GetValue(StatType.CritChance), 1e-4f); // 0.60 + 0.27 = 0.87 + + // 4. 验证闪避率同理:0 基础值下 PercentAdd 0.15 正确累加为 15% 闪避 + pipeline.AddModifier(StatType.Dodge, new StatModifier(0.15f, ModifierType.PercentAdd)); + Assert.AreEqual(0.15f, pipeline.GetValue(StatType.Dodge), 1e-4f); + } } } diff --git a/数据表/Datas/EnemyConfig_敌人配置.xlsx b/数据表/Datas/EnemyConfig_敌人配置.xlsx index 1438ddb..a0f41e1 100644 Binary files a/数据表/Datas/EnemyConfig_敌人配置.xlsx and b/数据表/Datas/EnemyConfig_敌人配置.xlsx differ