Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
shockhitreaction.c
Go to the documentation of this file.
2 {
3  const float INTENSITY_COEF_OVERALL = 0.8; //intensity percentage multiplier
4  const float INTENSITY_COEF_BLUR = 1;
5  const float INTENSITY_COEF_COLOR = 0.2;
6  const float INTENSITY_COEF_VIGNETTE = 0.7;
7  const float DURATION_MIN = 0.6;
8 
9  ref Param3<float,float,float> m_EffectParam;
10 
11  float m_HitDuration;
12  float m_BreakPoint;
13  float m_TimeActive;
14  float m_ShockIntensityMax;
15 
16  void ShockDealtEffect(float intensity_max)
17  {
18  float duration_coef = Math.Clamp(intensity_max,DURATION_MIN,1);
19  m_HitDuration = 1 * duration_coef;
20  m_BreakPoint = 0.2 * duration_coef;
21  m_ShockIntensityMax = Math.Clamp(intensity_max,0,1);
22 
23  m_EffectParam = new Param3<float,float,float>(0,0,0);
24  //Print(intensity_max);
25  //Print("HitSyncDebug | ShockDealtEffect: " + GetGame().GetPlayer().GetSimulationTimeStamp());
26  }
27 
28  void ~ShockDealtEffect()
29  {
30  if (GetGame())
31  PPERequesterBank.GetRequester(PPERequester_ShockHitReaction).Stop();
32  }
33 
34  void Update(float deltatime)
35  {
36  float value;
37 
38  if ( m_TimeActive <= m_BreakPoint )
39  {
40  value = Math.InverseLerp(0, m_BreakPoint, m_TimeActive);
41  }
42  else
43  {
44  float tmp_value = Math.InverseLerp(m_BreakPoint, m_HitDuration, m_TimeActive);
45  value = 1 - tmp_value;
46  }
47 
48  m_TimeActive += deltatime;
49  value = Math.Clamp(value,0,1);
50 
51  //value calculations
52  float val = Math.Clamp(Math.Lerp(0, m_ShockIntensityMax, value),0,m_ShockIntensityMax);
53  float val_color = Math.Clamp(val * INTENSITY_COEF_COLOR,0,m_ShockIntensityMax);
54 
55  //Postprocess application
56  float blur = val * INTENSITY_COEF_OVERALL * INTENSITY_COEF_BLUR;
57  float factor = val_color * INTENSITY_COEF_OVERALL;
58  float vignette = val * INTENSITY_COEF_OVERALL * INTENSITY_COEF_VIGNETTE;
59 
60  m_EffectParam.param1 = blur;
61  m_EffectParam.param2 = vignette;
62  m_EffectParam.param3 = factor;
63  PPERequesterBank.GetRequester(PPERequester_ShockHitReaction).Start(m_EffectParam);
64 
65  if ( m_TimeActive >= m_HitDuration )
66  {
67  delete this;
68  }
69  }
70 }
GetGame
proto native CGame GetGame()
ShockDealtEffect
Definition: shockhitreaction.c:1
Param3< float, float, float >
m_TimeActive
class DamageDealtEffect m_TimeActive
Math
Definition: enmath.c:6