DayZ 1.24
Loading...
Searching...
No Matches
BleedChanceData.c
Go to the documentation of this file.
1typedef map<int, float> BleedChanceMaxMap; //<bloodDamageReceived,chanceMax>
2
5{
6 private static const float BLOOD_HITPOINTS_UNIVERSAL = 100.0;
7
9
17
18 static void InitMeleeChanceMap()
19 {
20 if (m_DamageTypeMap.Contains("Melee"))
21 ErrorEx("'Melee' damage type bleed chances already initialized!");
22
24
25 //keys have to be integers, recalculated later
26 bleedChanceMaxMap.Set(0, 0.0);
27 bleedChanceMaxMap.Set(10, 5.0);
28 bleedChanceMaxMap.Set(20, 15.0);
29 bleedChanceMaxMap.Set(30, 23.4);
30 bleedChanceMaxMap.Set(40, 31.2);
31 bleedChanceMaxMap.Set(50, 39.0);
32 bleedChanceMaxMap.Set(60, 46.8);
33 bleedChanceMaxMap.Set(70, 54.6);
34 bleedChanceMaxMap.Set(80, 62.4);
35 bleedChanceMaxMap.Set(90, 70.2);
37
39 }
40
42 {
43 if (m_DamageTypeMap.Contains("Infected"))
44 ErrorEx("'Infected' damage type bleed chances already initialized!");
45
47
48 //keys have to be integers, recalculated later
49 bleedChanceMaxMap.Set(0, 0.0);
50 bleedChanceMaxMap.Set(10, 5.0);
51 bleedChanceMaxMap.Set(20, 15.0);
52 bleedChanceMaxMap.Set(30, 27.5);
53 bleedChanceMaxMap.Set(40, 40.0);
54 bleedChanceMaxMap.Set(50, 55.0);
55 bleedChanceMaxMap.Set(60, 60.0);
56 bleedChanceMaxMap.Set(70, 70.0);
57 bleedChanceMaxMap.Set(80, 75.0);
58 bleedChanceMaxMap.Set(90, 85.0);
60
61 m_DamageTypeMap.Set("Infected", bleedChanceMaxMap);
62 }
63
64 static void Cleanup()
65 {
66 delete m_DamageTypeMap;
67 }
68
71 {
73 if (!bleedChanceMap)
74 return false;
75
79
80#ifdef DEVELOPER
82 {
83 Debug.BleedingChancesLog(armor.ToString(), "BleedChanceData", "n/a", "armor:");
84 Debug.BleedingChancesLog(bleedThreshold.ToString(), "BleedChanceData", "n/a", "bleedThreshold:");
85 }
86#endif
87
88 //unexpected values, unhandled
90 {
91 bleedChance = 1.0;
92
93#ifdef DEVELOPER
95 Debug.BleedingChancesLog(bleedChance.ToString(), "BleedChanceData", "n/a", "Unhandleed values, default bleeding chance used:");
96#endif
97
98 return true;
99 }
100
101 if (bleedChanceMap.Contains(valueLower))
103 else
104 {
105 float chanceMaxActual;
106
107 float floor = Math.Floor(valueLower / 10) * 10;
108 float ceil = Math.Ceil(valueLower / 10) * 10;
109 float pos = Math.InverseLerp(floor, ceil, valueLower);
110
111 float chanceMin = bleedChanceMap.Get(floor);
112 float chanceMax = bleedChanceMap.Get(ceil);
113
116 }
117
118#ifdef DEVELOPER
120 Debug.BleedingChancesLog(bleedChance.ToString(), "BleedChanceData", "n/a", "bleeding chance:");
121#endif
122
123 return true;
124 }
125}
map< int, float > BleedChanceMaxMap
Static data of bleeding chance probabilities; currently used for melee only.
static void InitMeleeChanceMap()
static bool CalculateBleedChance(string damageType, float bloodDamage, float bleedThreshold, out float bleedChance)
returns 'false' when damageType is unhandled
static void InitInfectedChanceMap()
static void Cleanup()
static void InitBleedChanceData()
static ref map< string, ref BleedChanceMaxMap > m_DamageTypeMap
static const float BLOOD_HITPOINTS_UNIVERSAL
Definition Debug.c:14
static void BleedingChancesLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:213
static bool IsBleedingChancesLogEnable()
Definition Debug.c:814
TODO doc.
Definition EnScript.c:118
Definition EnMath.c:7
enum ShapeType ErrorEx
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Floor(float f)
Returns floor of value.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float Min(float x, float y)
Returns smaller of two given values.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto float Ceil(float f)
Returns ceil of value.