DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ CalculateBleedChance()

static bool BleedChanceData::CalculateBleedChance ( string damageType,
float bloodDamage,
float bleedThreshold,
out float bleedChance )
inlinestaticprivate

returns 'false' when damageType is unhandled

См. определение в файле BleedChanceData.c строка 70

71 {
72 map<int,float> bleedChanceMap = m_DamageTypeMap.Get(damageType);
73 if (!bleedChanceMap)
74 return false;
75
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;
79
80 #ifdef ENABLE_LOGGING
81 if (LogManager.IsBleedingChancesLogEnable())
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
89 if (valueLower > BLOOD_HITPOINTS_UNIVERSAL)
90 {
91 bleedChance = 1.0;
92
93 #ifdef ENABLE_LOGGING
94 if (LogManager.IsBleedingChancesLogEnable())
95 {
96 Debug.BleedingChancesLog(bleedChance.ToString(), "BleedChanceData" , "n/a", "Unhandleed values, default bleeding chance used:");
97 }
98 #endif
99
100 return true;
101 }
102
103 if (bleedChanceMap.Contains(valueLower))
104 {
105 bleedChance = bleedChanceMap.Get(valueLower) * valueHigher / 10000;
106 }
107 else
108 {
109 float chanceMaxActual;
110
111 float floor = Math.Floor(valueLower / 10) * 10;
112 float ceil = Math.Ceil(valueLower / 10) * 10;
113 float pos = Math.InverseLerp(floor,ceil,valueLower);
114
115 float chanceMin = bleedChanceMap.Get(floor);
116 float chanceMax = bleedChanceMap.Get(ceil);
117
118 chanceMaxActual = Math.Lerp(chanceMin,chanceMax,pos);
119 bleedChance = valueHigher * chanceMaxActual / 10000;
120 }
121
122 #ifdef ENABLE_LOGGING
123 if (LogManager.IsBleedingChancesLogEnable())
124 {
125 Debug.BleedingChancesLog(bleedChance.ToString(), "BleedChanceData" , "n/a", "bleeding chance:");
126 }
127 #endif
128
129 return true;
130 }
map
Определения ControlsXboxNew.c:4
void Debug()
Определения UniversalTemperatureSource.c:349
static ref map< string, ref BleedChanceMaxMap > m_DamageTypeMap
Определения BleedChanceData.c:8
static const float BLOOD_HITPOINTS_UNIVERSAL
Определения BleedChanceData.c:6
proto string ToString(bool simple=true)

Перекрестные ссылки Debug::BleedingChancesLog(), BLOOD_HITPOINTS_UNIVERSAL, Math::Ceil(), Math::Floor(), Math::InverseLerp(), LogManager::IsBleedingChancesLogEnable(), Math::Lerp(), m_DamageTypeMap, Math::Max(), Math::Min() и float::ToString().

Используется в BleedingSourcesManagerBase::ProcessHit().