6 private static const float BLOOD_HITPOINTS_UNIVERSAL = 100.0;
10 static void InitBleedChanceData()
15 InitInfectedChanceMap();
18 static void InitMeleeChanceMap()
20 if (m_DamageTypeMap.Contains(
"Melee"))
21 ErrorEx(
"'Melee' damage type bleed chances already initialized!");
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);
36 bleedChanceMaxMap.Set(BLOOD_HITPOINTS_UNIVERSAL,100.0);
38 m_DamageTypeMap.Set(
"Melee",bleedChanceMaxMap);
41 static void InitInfectedChanceMap()
43 if (m_DamageTypeMap.Contains(
"Infected"))
44 ErrorEx(
"'Infected' damage type bleed chances already initialized!");
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);
59 bleedChanceMaxMap.Set(BLOOD_HITPOINTS_UNIVERSAL,100.0);
61 m_DamageTypeMap.Set(
"Infected",bleedChanceMaxMap);
66 delete m_DamageTypeMap;
70 static bool CalculateBleedChance(
string damageType,
float bloodDamage,
float bleedThreshold, out
float bleedChance)
76 float armor = bloodDamage / BLOOD_HITPOINTS_UNIVERSAL;
77 float valueHigher =
Math.Max(bleedThreshold,armor) * BLOOD_HITPOINTS_UNIVERSAL;
78 float valueLower =
Math.Min(bleedThreshold,armor) * BLOOD_HITPOINTS_UNIVERSAL;
83 Debug.BleedingChancesLog(armor.ToString(),
"BleedChanceData" ,
"n/a",
"armor:");
84 Debug.BleedingChancesLog(bleedThreshold.ToString(),
"BleedChanceData" ,
"n/a",
"bleedThreshold:");
89 if (valueLower > BLOOD_HITPOINTS_UNIVERSAL)
96 Debug.BleedingChancesLog(bleedChance.ToString(),
"BleedChanceData" ,
"n/a",
"Unhandleed values, default bleeding chance used:");
103 if (bleedChanceMap.Contains(valueLower))
105 bleedChance = bleedChanceMap.Get(valueLower) * valueHigher / 10000;
109 float chanceMaxActual;
111 float floor =
Math.Floor(valueLower / 10) * 10;
112 float ceil =
Math.Ceil(valueLower / 10) * 10;
113 float pos =
Math.InverseLerp(floor,ceil,valueLower);
115 float chanceMin = bleedChanceMap.Get(floor);
116 float chanceMax = bleedChanceMap.Get(ceil);
118 chanceMaxActual =
Math.Lerp(chanceMin,chanceMax,pos);
119 bleedChance = valueHigher * chanceMaxActual / 10000;
125 Debug.BleedingChancesLog(bleedChance.ToString(),
"BleedChanceData" ,
"n/a",
"bleeding chance:");