-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCalculator.SimpleVariance.cs
41 lines (37 loc) · 1.44 KB
/
Calculator.SimpleVariance.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Text;
using BattleTech;
namespace WeaponRealizer
{
static partial class Calculator
{
private static class SimpleVariance
{
public static bool IsApplicable(Weapon weapon)
{
return Core.ModSettings.SimpleVariance &&
weapon.weaponDef.DamageVariance > 0;
}
public static float Calculate(Weapon weapon, float rawDamage)
{
var damagePerShot = weapon.DamagePerShot;
var adjustment = rawDamage / damagePerShot;
var variance = weapon.weaponDef.DamageVariance;
var roll = NormalDistribution.Random(
new VarianceBounds(
damagePerShot - variance,
damagePerShot + variance,
Core.ModSettings.StandardDeviationSimpleVarianceMultiplier * variance
));
var variantDamage = roll * adjustment;
var sb = new StringBuilder();
sb.AppendLine($"roll: {roll}");
sb.AppendLine($"damagePerShot: {damagePerShot}");
sb.AppendLine($"variance: {variance}");
sb.AppendLine($"adjustment: {adjustment}");
sb.AppendLine($"variantDamage: {variantDamage}");
Logger.Debug(sb.ToString());
return variantDamage;
}
}
}
}