DayZ 1.24
Loading...
Searching...
No Matches
ShockHandler Class Reference
Collaboration diagram for ShockHandler:
[legend]

Protected Member Functions

void ShockHandler (PlayerBase player)
 
void Update (float deltaT)
 
float GetCurrentShock ()
 
float GetShock ()
 
void SetShock (float dealtShock)
 
void Synchronize ()
 
float SetMultiplier (float mult)
 

Protected Attributes

float m_Shock
 
float m_ShockValueMax
 
float m_ShockValueThreshold
 
PlayerBase m_Player
 
const float UPDATE_THRESHOLD = 3
 
const float VALUE_CHECK_INTERVAL = 0.95
 
float m_CumulatedShock
 
ref Param1< floatm_Param
 

Private Member Functions

void DealShock ()
 
void CheckValue (bool forceUpdate)
 
float NormalizeShockVal (float shock)
 
float LerpVignette (float x, float y, float deltaT)
 
void ShockHitEffect (float compareBase)
 

Private Attributes

float m_TimeSinceLastTick = VALUE_CHECK_INTERVAL + 1
 
float m_ShockMultiplier = 1
 
float m_PrevVignette
 
float m_LerpRes
 
const int LIGHT_SHOCK_HIT = 33
 
const int MID_SHOCK_HIT = 67
 
const int HEAVY_SHOCK_HIT = 100
 
const int INTENSITY_FACTOR = 1
 
const float PULSE_PERIOD = 0.5
 
const float PULSE_AMPLITUDE = 0.05
 
float m_PulseTimer
 

Detailed Description

Definition at line 1 of file ShockHandler.c.

Constructor & Destructor Documentation

◆ ShockHandler()

void ShockHandler::ShockHandler ( PlayerBase player)
inlineprotected

Definition at line 28 of file ShockHandler.c.

29 {
31 m_Player.m_CurrentShock = m_Player.GetMaxHealth("", "Shock");
32 m_PrevVignette = m_Player.m_CurrentShock * 0.01; //Equivalent to divided by 100
33 m_ShockValueMax = m_Player.GetMaxHealth("", "Shock");
35 m_Param = new Param1<float>(0);
36 }
float m_ShockValueMax
Definition ShockHandler.c:4
ref Param1< float > m_Param
PlayerBase m_Player
Definition ShockHandler.c:6
float m_PrevVignette
float m_ShockValueThreshold
Definition ShockHandler.c:5

References m_Param, m_Player, m_PrevVignette, m_ShockValueMax, and m_ShockValueThreshold.

Member Function Documentation

◆ CheckValue()

void ShockHandler::CheckValue ( bool forceUpdate)
inlineprivate

Definition at line 118 of file ShockHandler.c.

119 {
120 m_CumulatedShock += m_Shock; // increment on both client and server
121
122 if (forceUpdate)
123 m_PrevVignette = NormalizeShockVal(m_Player.m_CurrentShock);
124
125 if (GetGame().IsServer())
126 {
127 m_Player.m_CurrentShock = m_Player.GetHealth("", "Shock");
128
129 /*
130 if (m_Player.m_CurrentShock <= 0)
131 m_Player.SetHealthMax("", "Shock");
132 */
134 {
136 DealShock();
138 m_Shock = 0;
139
140 Synchronize();
141 }
142 }
143 }
float m_ShockMultiplier
float m_CumulatedShock
const float UPDATE_THRESHOLD
Definition ShockHandler.c:8
float NormalizeShockVal(float shock)
void Synchronize()
proto native CGame GetGame()

References DealShock(), GetGame(), m_CumulatedShock, m_Player, m_PrevVignette, m_Shock, m_ShockMultiplier, NormalizeShockVal(), Synchronize(), and UPDATE_THRESHOLD.

Referenced by SetShock(), and Update().

◆ DealShock()

void ShockHandler::DealShock ( )
inlineprivate

Definition at line 111 of file ShockHandler.c.

112 {
113 if (GetGame().IsServer())
114 m_Player.GiveShock(-m_CumulatedShock);
115 }

References GetGame(), m_CumulatedShock, and m_Player.

Referenced by CheckValue().

◆ GetCurrentShock()

float ShockHandler::GetCurrentShock ( )
inlineprotected

Definition at line 94 of file ShockHandler.c.

95 {
96 return m_Player.m_CurrentShock;
97 }

References m_Player.

◆ GetShock()

float ShockHandler::GetShock ( )
inlineprotected

Definition at line 99 of file ShockHandler.c.

100 {
101 return m_Shock;
102 }

References m_Shock.

◆ LerpVignette()

float ShockHandler::LerpVignette ( float x,
float y,
float deltaT )
inlineprivate

Definition at line 163 of file ShockHandler.c.

164 {
165 float output;
166 output = Math.Lerp(x, y, deltaT);
167 return output;
168 }
Icon x
Icon y
Definition EnMath.c:7
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.

References Math::Lerp(), x, and y.

Referenced by Update().

◆ NormalizeShockVal()

float ShockHandler::NormalizeShockVal ( float shock)
inlineprivate

Definition at line 156 of file ShockHandler.c.

157 {
158 float base = m_Player.GetMaxHealth("", "Shock") * INTENSITY_FACTOR;
159 float normShock = shock / base;
160 return normShock;
161 }
const int INTENSITY_FACTOR

References INTENSITY_FACTOR, and m_Player.

Referenced by CheckValue(), and Update().

◆ SetMultiplier()

float ShockHandler::SetMultiplier ( float mult)
inlineprotected

Definition at line 150 of file ShockHandler.c.

151 {
153 return m_ShockMultiplier;
154 }

References m_ShockMultiplier.

◆ SetShock()

void ShockHandler::SetShock ( float dealtShock)
inlineprotected

Definition at line 104 of file ShockHandler.c.

105 {
107 CheckValue(false);
108 }
void CheckValue(bool forceUpdate)

References CheckValue(), and m_Shock.

◆ ShockHitEffect()

void ShockHandler::ShockHitEffect ( float compareBase)
inlineprivate

Definition at line 171 of file ShockHandler.c.

172 {
173 float shockDifference = compareBase - m_Player.m_CurrentShock;
174 //Print(shockDifference);
176 {
177 if (m_CumulatedShock < 25)
178 m_Player.SpawnShockEffect(MiscGameplayFunctions.Normalize(LIGHT_SHOCK_HIT, 100));
179 else if (m_CumulatedShock < 50)
180 m_Player.SpawnShockEffect(MiscGameplayFunctions.Normalize(MID_SHOCK_HIT, 100));
181 else
182 m_Player.SpawnShockEffect(MiscGameplayFunctions.Normalize(HEAVY_SHOCK_HIT, 100));
183 }
184 }
const int HEAVY_SHOCK_HIT
const int MID_SHOCK_HIT
const int LIGHT_SHOCK_HIT

References HEAVY_SHOCK_HIT, LIGHT_SHOCK_HIT, m_CumulatedShock, m_Player, MID_SHOCK_HIT, and UPDATE_THRESHOLD.

Referenced by Update().

◆ Synchronize()

void ShockHandler::Synchronize ( )
inlineprotected

Definition at line 145 of file ShockHandler.c.

146 {
148 }
static void SendShock(DayZPlayer pPlayer, float shockValue)

References m_Player, and DayZPlayerSyncJunctures::SendShock().

Referenced by CheckValue().

◆ Update()

void ShockHandler::Update ( float deltaT)
inlineprotected

Definition at line 38 of file ShockHandler.c.

39 {
41
43
44 if (GetGame().IsClient())
45 {
46 //Deactivate tunnel vignette when player falls unconscious
47 if (m_Player.IsUnconscious())
48 {
50 return;
51 }
52
53 //Deactivate if above visible threshold (also stops "zero bobbing" being sent all the time
54 if (m_Player.m_CurrentShock >= m_ShockValueThreshold)
55 {
57 return;
58 }
59
60 //Add bobbing to create pulsing effect
61 float val = 0.0;
62 if (m_Player.m_CurrentShock > m_ShockValueMax * 0.8)
64 float val_adjusted;
65
66 if (m_Player.m_CurrentShock != (m_PrevVignette * 100))
67 {
68 //Interpolate between previous level and currently synchronized shock level
70
72 }
73 else
75
76 m_Param.param1 = val_adjusted;
78 }
79
81 {
82 //Play the shock hit event (multiply prevVignette by 100 to "Un-Normalize" value)
83 if (GetGame().IsClient())
84 {
86 m_PrevVignette = m_Player.m_CurrentShock * 0.01;
87 }
88
89 CheckValue(false);
91 }
92 }
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Definition Easing.c:3
static float EaseInQuart(float t)
Definition Easing.c:56
float m_PulseTimer
const float PULSE_AMPLITUDE
void ShockHitEffect(float compareBase)
const float PULSE_PERIOD
float LerpVignette(float x, float y, float deltaT)
float m_TimeSinceLastTick
const float VALUE_CHECK_INTERVAL
Definition ShockHandler.c:9

References CheckValue(), Easing::EaseInQuart(), GetGame(), LerpVignette(), m_LerpRes, m_Param, m_Player, m_PrevVignette, m_PulseTimer, m_ShockValueMax, m_ShockValueThreshold, m_TimeSinceLastTick, NormalizeShockVal(), PULSE_AMPLITUDE, PULSE_PERIOD, ShockHitEffect(), and VALUE_CHECK_INTERVAL.

Member Data Documentation

◆ HEAVY_SHOCK_HIT

const int ShockHandler::HEAVY_SHOCK_HIT = 100
private

Definition at line 18 of file ShockHandler.c.

Referenced by ShockHitEffect().

◆ INTENSITY_FACTOR

const int ShockHandler::INTENSITY_FACTOR = 1
private

Definition at line 19 of file ShockHandler.c.

Referenced by NormalizeShockVal().

◆ LIGHT_SHOCK_HIT

const int ShockHandler::LIGHT_SHOCK_HIT = 33
private

Definition at line 16 of file ShockHandler.c.

Referenced by ShockHitEffect().

◆ m_CumulatedShock

float ShockHandler::m_CumulatedShock
protected

Definition at line 10 of file ShockHandler.c.

Referenced by CheckValue(), DealShock(), and ShockHitEffect().

◆ m_LerpRes

float ShockHandler::m_LerpRes
private

Definition at line 14 of file ShockHandler.c.

Referenced by Update().

◆ m_Param

ref Param1<float> ShockHandler::m_Param
protected

Definition at line 26 of file ShockHandler.c.

Referenced by ShockHandler(), and Update().

◆ m_Player

PlayerBase ShockHandler::m_Player
protected

◆ m_PrevVignette

float ShockHandler::m_PrevVignette
private

Definition at line 13 of file ShockHandler.c.

Referenced by CheckValue(), ShockHandler(), and Update().

◆ m_PulseTimer

float ShockHandler::m_PulseTimer
private

Definition at line 24 of file ShockHandler.c.

Referenced by Update().

◆ m_Shock

float ShockHandler::m_Shock
protected

Definition at line 3 of file ShockHandler.c.

Referenced by CheckValue(), GetShock(), and SetShock().

◆ m_ShockMultiplier

float ShockHandler::m_ShockMultiplier = 1
private

Definition at line 12 of file ShockHandler.c.

Referenced by CheckValue(), and SetMultiplier().

◆ m_ShockValueMax

float ShockHandler::m_ShockValueMax
protected

Definition at line 4 of file ShockHandler.c.

Referenced by ShockHandler(), and Update().

◆ m_ShockValueThreshold

float ShockHandler::m_ShockValueThreshold
protected

Definition at line 5 of file ShockHandler.c.

Referenced by ShockHandler(), and Update().

◆ m_TimeSinceLastTick

float ShockHandler::m_TimeSinceLastTick = VALUE_CHECK_INTERVAL + 1
private

Definition at line 11 of file ShockHandler.c.

Referenced by Update().

◆ MID_SHOCK_HIT

const int ShockHandler::MID_SHOCK_HIT = 67
private

Definition at line 17 of file ShockHandler.c.

Referenced by ShockHitEffect().

◆ PULSE_AMPLITUDE

const float ShockHandler::PULSE_AMPLITUDE = 0.05
private

Definition at line 23 of file ShockHandler.c.

Referenced by Update().

◆ PULSE_PERIOD

const float ShockHandler::PULSE_PERIOD = 0.5
private

Definition at line 22 of file ShockHandler.c.

Referenced by Update().

◆ UPDATE_THRESHOLD

const float ShockHandler::UPDATE_THRESHOLD = 3
protected

Definition at line 8 of file ShockHandler.c.

Referenced by CheckValue(), and ShockHitEffect().

◆ VALUE_CHECK_INTERVAL

const float ShockHandler::VALUE_CHECK_INTERVAL = 0.95
protected

Definition at line 9 of file ShockHandler.c.

Referenced by Update().


The documentation for this class was generated from the following file: