DayZ 1.24
Loading...
Searching...
No Matches
StaminaSoundHandler.c
Go to the documentation of this file.
1const float TICK_INTERVAL = 1;
2
3const float STAMINA_SOUND_TR1 = 0.55;
4const float STAMINA_SOUND_TR2 = 0.25;
5
12
14{
17}
18
20{
27 //count bellow, add above
28 COUNT
29}
30
31
33{
36
37 void Update();
38
40 {
41 return m_Id;
42 }
43
49
50 void Init();
51}
52
54{
55
56 override void Init()
57 {
58 m_Id = eSoundHandlers.STAMINA;
59 }
60
62 {
64
66
67 if (zone == eStaminaZones.ZONE1 && tendency == eStaminaTendency.DOWN)
68 stamina_state = eStaminaState.ZONE1_DOWN;
69
70 if (zone == eStaminaZones.ZONE1 && tendency == eStaminaTendency.UP)
72
73 if (zone == eStaminaZones.ZONE2 && tendency == eStaminaTendency.DOWN)
74 stamina_state = eStaminaState.ZONE2_DOWN;
75
76 if (zone == eStaminaZones.ZONE2 && tendency == eStaminaTendency.UP)
78
79 if (zone == eStaminaZones.ZONE0 && tendency == eStaminaTendency.UP)
81
82 if (zone == eStaminaZones.ZONE0 && tendency == eStaminaTendency.DOWN)
83 stamina_state = eStaminaState.ZONE0_DOWN;
84
85 return stamina_state;
86 }
87}
88
89
90//---------------------------
91// Server
92//---------------------------
94{
95 float m_Stamina;
99
104
105 // ! Called from command handler
106 override void Update()
107 {
108 m_Stamina = m_Player.GetStaminaHandler().GetStamina();
112
113 //if( stamina_delta == 0 ) return;
114
115 if (stamina_delta > 0)
117 if (stamina_delta <= 0)
119
121
123 m_Player.SetStaminaState(GetStaminaState(stamina_tendency, stamina_zone + m_StaminaZoneOffset));
124
125 //EPlayerSoundEventID sound_event_id = GetPlayerSoundEventID();
126 /*
127 //PrintString("stamina delta " +stamina_delta.ToString());
128 //PrintString("stamina zone " +m_StaminaZone.ToString());
129 //PrintString("stamina tendency " +m_StaminaTendency.ToString());
130 */
131 //PrintString(" sound event id " +sound_event_id.ToString());
132
133
134 //if( sound_event_id !=0 ) m_Player.SendSoundEvent(sound_event_id);
135 }
136
138 {
139 float stamina_normalized = Math.InverseLerp(0, m_Player.GetStaminaHandler().GetStaminaCap(), stamina);
141 //PrintString(" stamina_normalized " +stamina_normalized.ToString());
143
146
149
150 return stamina_zone;
151 }
152}
153
154
155//---------------------------
156// Client
157//---------------------------
159{
160 float m_PostponeTime = -1;
161
164 bool m_StaminaUpEndPlayed = true;
167
168
170 {
171 m_PostponeTime = GetGame().GetTime() + time;
172 }
173
174
175 override void Update()
176 {
177 if (GetGame().GetTime() < m_PostponeTime || m_Player.GetPlayerSoundEventHandler().m_CurrentState)
178 return;
179 //Print(Math.RandomFloat01());
180 eStaminaState stamina_state = m_Player.GetStaminaState();
181 switch (stamina_state)
182 {
183 case eStaminaState.ZONE1_DOWN:
184 if (m_Player.PlaySoundEvent(EPlayerSoundEventID.STAMINA_DOWN_LIGHT))
185 m_StaminaUpEndPlayed = false;
186 break;
187
188 case eStaminaState.ZONE1_UP:
189 if (m_Player.PlaySoundEvent(EPlayerSoundEventID.STAMINA_UP_LIGHT))
190 m_StaminaUpEndPlayed = false;
191 break;
192
193 case eStaminaState.ZONE2_DOWN:
194 if (m_Player.PlaySoundEvent(EPlayerSoundEventID.STAMINA_DOWN_HEAVY))
195 m_StaminaUpEndPlayed = false;
196 break;
197
198 case eStaminaState.ZONE2_UP:
199 if (m_Player.PlaySoundEvent(EPlayerSoundEventID.STAMINA_UP_HEAVY))
200 m_StaminaUpEndPlayed = false;
201 break;
202
203 case eStaminaState.ZONE0_UP:
204 if (!m_StaminaUpEndPlayed && m_Player.PlaySoundEvent(EPlayerSoundEventID.STAMINA_UP_END))
205 m_StaminaUpEndPlayed = true;
206 else
207 m_Player.PlaySoundEvent(EPlayerSoundEventID.STAMINA_NORMAL_DUMMY);
208 break;
209
210 case eStaminaState.ZONE0_DOWN:
211 m_Player.PlaySoundEvent(EPlayerSoundEventID.STAMINA_NORMAL_DUMMY);
212 break;
213 }
214 }
215}
@ COUNT
DayZPlayer m_Player
Definition Hand_Events.c:42
float GetTime()
eSoundHandlers
ref Timer m_ClientCharacterDistanceCheck
class PlayerSoundManagerServer extends PlayerSoundManagerBase m_ClientCharacterTick
enum eStaminaZones ZONE1_DOWN
const float STAMINA_SOUND_TR1
PlayerBase m_Player
enum eStaminaZones ZONE1_UP
float m_StaminaLastValue
int m_StaminaZoneOffset
enum eStaminaZones UP
eStaminaZones GetZone(float stamina)
void SoundHandlerBase(PlayerBase player)
const float STAMINA_SOUND_TR2
void SetStaminaZoneOffset(int zone_offset)
enum eStaminaZones ZONE2_DOWN
enum eStaminaZones m_Id
eStaminaZones
const float TICK_INTERVAL
enum eStaminaZones ZONE0_DOWN
enum eStaminaZones ZONE2_UP
enum eStaminaZones ZONE0_UP
class StaminaSoundHandlerBase extends SoundHandlerBase m_Stamina
StaminaHandler m_StaminaHandler
enum eStaminaZones DOWN
eSoundHandlers GetID()
bool PlaySoundEvent(EPlayerSoundEventID id, bool from_anim_system=false, bool is_from_server=false)
Definition EnMath.c:7
eStaminaState GetStaminaState(eStaminaTendency tendency, eStaminaZones zone)
override void Init()
proto native CGame GetGame()
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
void Update()