I've been looking through the Bannerlord damage calculation code (CombatStatCalculator.cs) and while I don't know C#, most of the code is fairly self-explanatory. However, I don't have the knowledge to interpret the blunt case in either ComputeRawDamageOld and ComputeRawDamageNew (it's basically the same code so I'm only showing one example here).
The code I don't understand is everything from label_5: downwards.
So how is the blunt damage being calculated here? I'm confused about the purpose of the goto and why it is outside the curly brackets.
The code I don't understand is everything from label_5: downwards.
插入代码块:
public static float ComputeRawDamageNew(
DamageTypes damageType,
float magnitude,
float armorEffectiveness,
float absorbedDamageRatio)
{
float num1 = 0.0f;
float factorByDamageType = CombatStatCalculator.GetBluntDamageFactorByDamageType(damageType);
float num2 = magnitude * factorByDamageType;
float num3 = (float) (100.0 / (100.0 + (double) armorEffectiveness));
float num4 = num1 + num2 * num3;
float num5;
switch (damageType)
{
case DamageTypes.Cut:
num5 = Math.Max(0.0f, (float) ((double) magnitude * (double) num3 - (double) armorEffectiveness * 0.5));
break;
case DamageTypes.Pierce:
num5 = Math.Max(0.0f, (float) ((double) magnitude * (double) num3 - (double) armorEffectiveness * 0.330000013113022));
break;
case DamageTypes.Blunt:
label_5:
return num4 * absorbedDamageRatio;
default:
return 0.0f;
}
num4 += num5 * (1f - factorByDamageType);
goto label_5;
}
So how is the blunt damage being calculated here? I'm confused about the purpose of the goto and why it is outside the curly brackets.

