-
Notifications
You must be signed in to change notification settings - Fork 0
/
HEATDamage.cs
82 lines (71 loc) · 2.37 KB
/
HEATDamage.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace PFW.Damage
{
class HeatDamage:Damage
{
public struct HeatData
{
/// <summary>
/// The power of the shot
/// </summary>
public float Power;
/// <summary>
/// Multiplier for armor degradation
/// </summary>
public float Degradation;
/// <summary>
/// Multiplier for health damage
/// </summary>
public float HealthDamageFactor;
}
private HeatData _heatData;
public HeatDamage(HeatData data, Target target)
: base(DamageTypes.HEAT, target)
{
_heatData = data;
}
public override Target CalculateDamage()
{
Target finalState = this.CurrentTarget;
HeatData heat = _heatData;
// No air friction attenuation as HEAT round detonates on surface of the armor
if (finalState.EraData.Value > 0.0f) {
// Calculate effects of ERA
float finalEra = Math.Max(
0.0f,
finalState.EraData.Value - heat.Power * finalState.EraData.HeatFractionMultiplier
);
finalState.EraData.Value = finalEra;
heat.Power = CalculatePostEraPower(
heat.Power,
finalState.EraData.HeatFractionMultiplier
);
}
// Armor degradation
float finalArmor = Math.Max(
0.0f,
finalState.Armor - (heat.Power / finalState.Armor) * heat.Degradation
);
finalState.Armor = finalArmor;
// Calculate final damage
float finalDamage = Math.Max(
0.0f,
(heat.Power - finalState.Armor) * heat.HealthDamageFactor
);
float finalHealth = Math.Max(
0.0f,
finalState.Health - finalDamage
);
finalState.Health = finalHealth;
return finalState;
}
private static float CalculatePostEraPower(float power, float eraFractionMultiplier)
{
return power * (1 - eraFractionMultiplier);
}
}
}