7 float m_BrokenLegsCoef;
8 float m_BleedingHandsCoef;
9 float m_BleedingFeetCoef;
10 float m_BleedingLegsCoef;
11 float m_GlovesHealthCoef;
12 float m_ShoesHealthCoef;
13 float m_PantsHealthCoef;
14 float m_BleedingChanceCoef;
15 float m_BleedingChanceLegsCoef;
21 static const string FALL_DAMAGE_AMMO_SHOCK =
"FallDamageShock";
23 static const string FALL_DAMAGE_AMMO_HEALTH_ATTACHMENT =
"FallDamageHealthAttachment";
24 static const string FALL_DAMAGE_AMMO_HEALTH_OTHER_ATTACHMENTS =
"FallDamageHealthOtherAttachments";
55 private static const float BROKENLEGS_HEALTH_DAMAGE_MAX = 125;
57 private static const string BLEEDING_HANDS_SELECTIONS[2] = {
"LeftForeArmRoll",
"RightForeArmRoll"};
58 private static const string BLEEDING_FEET_SELECTIONS[2] = {
"LeftFoot",
"RightFoot"};
59 private static const string BLEEDING_LEGS_SELECTIONS[2] = {
"LeftLeg",
"RightLeg"};
79 PreloadAmmoTypeData();
141 playerBase.DamageAllLegs(BROKENLEGS_HEALTH_DAMAGE_MAX *
m_FallDamageData.m_BrokenLegsCoef);
150 playerBase.ForceUpdateInjuredState();
158 int randomizedSign = -1;
159 if (
Math.RandomIntInclusive(1, 2) % 2 == 1)
162 float randomizationValue = 0;
176 return pValue + (randomizedSign * pValue * randomizationValue);
183 int bleedingSelectionIndex;
184 BleedingSourcesManagerServer bleedingManager = pPlayer.GetBleedingManagerServer();
185 if (
Math.RandomFloatInclusive(0.0, 1.0) <=
m_FallDamageData.m_BleedingChanceCoef &&
m_FallDamageData.m_BleedingHandsCoef == 1.0 && pPlayer.FindAttachmentBySlotName(
"Gloves") ==
null)
187 bleedingSelectionIndex =
Math.RandomInt(0, 2);
188 bleedingManager.AttemptAddBleedingSourceBySelection(BLEEDING_HANDS_SELECTIONS[bleedingSelectionIndex]);
191 if (
Math.RandomFloatInclusive(0.0, 1.0) <=
m_FallDamageData.m_BleedingChanceCoef &&
m_FallDamageData.m_BleedingFeetCoef == 1.0 && pPlayer.FindAttachmentBySlotName(
"Feet") ==
null)
194 bleedingSelectionIndex =
Math.RandomInt(0, 2);
195 bleedingManager.AttemptAddBleedingSourceBySelection(BLEEDING_FEET_SELECTIONS[bleedingSelectionIndex]);
200 bleedingSelectionIndex =
Math.RandomInt(0, 2);
201 bleedingManager.AttemptAddBleedingSourceBySelection(BLEEDING_LEGS_SELECTIONS[bleedingSelectionIndex]);
207 EntityAI gloves = pPlayer.FindAttachmentBySlotName(
"Gloves");
209 gloves.ProcessDirectDamage(DT_CUSTOM, pPlayer,
"", FALL_DAMAGE_AMMO_HEALTH_OTHER_ATTACHMENTS, gloves.WorldToModel(gloves.GetPosition()),
m_FallDamageData.m_GlovesHealthCoef);
211 EntityAI shoes = pPlayer.FindAttachmentBySlotName(
"Feet");
213 shoes.ProcessDirectDamage(DT_CUSTOM, pPlayer,
"", FALL_DAMAGE_AMMO_HEALTH_OTHER_ATTACHMENTS, shoes.WorldToModel(shoes.GetPosition()),
m_FallDamageData.m_ShoesHealthCoef);
215 EntityAI pants = pPlayer.FindAttachmentBySlotName(
"Legs");
217 pants.ProcessDirectDamage(DT_CUSTOM, pPlayer,
"", FALL_DAMAGE_AMMO_HEALTH_ATTACHMENT, pants.WorldToModel(pants.GetPosition()),
m_FallDamageData.m_PantsHealthCoef);
220 #ifdef DIAG_DEVELOPER
221 FallDamageDebugData GetFallDamageDebugData()
223 FallDamageDebugData data =
new FallDamageDebugData();
229 void ShowFallDamageDebugInfo(
bool enabled)
231 FallDamageDebugData data = GetFallDamageDebugData();
232 DisplayFallDamageDebugInfo(enabled, data);
235 private static string LandTypeToString(
int landType)
250 private void PreloadAmmoTypeData()
252 if (m_AmmoTypeData ==
null)
256 m_AmmoTypeData.Insert(FALL_DAMAGE_AMMO_SHOCK, GetValuesFromAmmoType(FALL_DAMAGE_AMMO_SHOCK)[2]);
257 m_AmmoTypeData.Insert(FALL_DAMAGE_AMMO_HEALTH_OTHER_ATTACHMENTS, GetValuesFromAmmoType(FALL_DAMAGE_AMMO_HEALTH_OTHER_ATTACHMENTS)[0]);
258 m_AmmoTypeData.Insert(FALL_DAMAGE_AMMO_HEALTH_ATTACHMENT, GetValuesFromAmmoType(FALL_DAMAGE_AMMO_HEALTH_ATTACHMENT)[0]);
261 private vector GetValuesFromAmmoType(
string pAmmoType)
264 values[0] =
GetGame().ConfigGetFloat(
string.Format(
"CfgAmmo %1 DamageApplied Health damage", pAmmoType));
265 values[1] =
GetGame().ConfigGetFloat(
string.Format(
"CfgAmmo %1 DamageApplied Blood damage", pAmmoType));
266 values[2] =
GetGame().ConfigGetFloat(
string.Format(
"CfgAmmo %1 DamageApplied Shock damage", pAmmoType));
271 static void DisplayFallDamageDebugInfo(
bool enabled, FallDamageDebugData data)
279 DbgUI.Text(
string.Format(
"Height:\t%1",
Math.Clamp(data.m_Height, 0,
float.MAX)));
280 DbgUI.Text(
string.Format(
"Land Type:\t%1 (%2)", data.m_LandType, LandTypeToString(data.m_LandType)));
282 DbgUI.Text(
"Health");
285 DbgUI.Text(
string.Format(
" coef:%1 dmg:%2", data.m_ShockCoef, m_AmmoTypeData[FALL_DAMAGE_AMMO_SHOCK] * data.m_ShockCoef));
286 DbgUI.Text(
"Broken Legs:");
287 DbgUI.Text(
string.Format(
" coef:%1 dmg:%2", data.m_BrokenLegsCoef, BROKENLEGS_HEALTH_DAMAGE_MAX * data.m_BrokenLegsCoef));
288 DbgUI.Text(
"Gloves damage:");
289 DbgUI.Text(
string.Format(
" coef:%1 dmg:%2", data.m_GlovesHealthCoef, m_AmmoTypeData[FALL_DAMAGE_AMMO_HEALTH_OTHER_ATTACHMENTS] * data.m_GlovesHealthCoef));
290 DbgUI.Text(
"Shoes damage:");
291 DbgUI.Text(
string.Format(
" coef:%1 dmg:%2", data.m_ShoesHealthCoef, m_AmmoTypeData[FALL_DAMAGE_AMMO_HEALTH_OTHER_ATTACHMENTS] * data.m_ShoesHealthCoef));
292 DbgUI.Text(
"Pants damage:");
293 DbgUI.Text(
string.Format(
" coef:%1 dmg:%2" , data.m_PantsHealthCoef, m_AmmoTypeData[FALL_DAMAGE_AMMO_HEALTH_ATTACHMENT] * data.m_PantsHealthCoef));
294 DbgUI.Text(
"Bleeding coefs:");
295 DbgUI.Text(
string.Format(
" hands:%1", data.m_BleedingHandsCoef));
296 DbgUI.Text(
string.Format(
" feet:%1", data.m_BleedingFeetCoef));
297 DbgUI.Text(
string.Format(
" legs:%1", data.m_BleedingLegsCoef));
298 DbgUI.Text(
string.Format(
" H&F chance:%1", data.m_BleedingChanceCoef));
305 void FillDebugFallDamageData(FallDamageDebugData data)
335 #ifdef DIAG_DEVELOPER
336 class FallDamageDebugData :
Param
342 float m_BrokenLegsCoef;
343 float m_GlovesHealthCoef;
344 float m_ShoesHealthCoef;
345 float m_PantsHealthCoef;
346 float m_BleedingHandsCoef;
347 float m_BleedingFeetCoef;
348 float m_BleedingLegsCoef;
349 float m_BleedingChanceCoef;
353 m_Height = fallDamage.GetHeight();
354 m_LandType = fallDamage.GetLandType();
356 fallDamage.FillDebugFallDamageData(
this);
361 return ctx.Write(m_Height) && ctx.Write(m_LandType) && ctx.Write(m_HealthCoef) && ctx.Write(m_ShockCoef) && ctx.Write(m_BrokenLegsCoef) && ctx.Write(m_GlovesHealthCoef) && ctx.Write(m_ShoesHealthCoef) && ctx.Write(m_PantsHealthCoef) && ctx.Write(m_BleedingHandsCoef) && ctx.Write(m_BleedingFeetCoef) && ctx.Write(m_BleedingLegsCoef);
366 return ctx.Read(m_Height) && ctx.Read(m_LandType) && ctx.Read(m_HealthCoef) && ctx.Read(m_ShockCoef) && ctx.Write(m_BrokenLegsCoef) && ctx.Read(m_GlovesHealthCoef) && ctx.Read(m_ShoesHealthCoef) && ctx.Read(m_PantsHealthCoef) && ctx.Read(m_BleedingHandsCoef) && ctx.Read(m_BleedingFeetCoef) && ctx.Read(m_BleedingLegsCoef);