DayZ 1.24
Loading...
Searching...
No Matches
InjurySoundHandler.c
Go to the documentation of this file.
2{
3 NONE = 0,
4 LIGHT,
5 MEDIUM,
6 HEAVY,
7
8 // PUT NEW STATES ABOVE
10}
11
13{
14 override void Init()
15 {
17 }
19}
20
21//---------------------------
22// Client
23//---------------------------
25{
26 const float SOUND_INTERVALS_LIGHT_MIN = 15; const float SOUND_INTERVALS_LIGHT_MAX = 30;
27 const float SOUND_INTERVALS_MEDIUM_MIN = 10; const float SOUND_INTERVALS_MEDIUM_MAX = 25;
28 const float SOUND_INTERVALS_HEAVY_MIN = 3; const float SOUND_INTERVALS_HEAVY_MAX = 12;
29
34
35
37 {
38 if (level == eInjuryHandlerLevels.PRISTINE)
39 return eInjurySoundZones.NONE;
40
41 m_Player.GetMovementState(m_MovementState);
42 int speed = m_MovementState.m_iMovement;
43 int stance = m_MovementState.m_iStanceIdx;
44
45 //int stance_lvl_down = DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_CROUCH;
46
47 if (speed == 0)
48 return eInjurySoundZones.NONE;
49
50 level--;// shift the level so that we play from higher damage
51
52 if (stance == DayZPlayerConstants.STANCEIDX_PRONE || stance == DayZPlayerConstants.STANCEIDX_CROUCH)
53 level--;
54
55 if (speed == DayZPlayerConstants.MOVEMENTIDX_WALK)
56 level--;
57 else if (speed == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
58 level++;
60 return level;
61 }
62
63
64 override void Update()
65 {
66 m_InjuryLevel = m_Player.m_HealthLevel;
67
68 if (m_InjuryLevel != eInjuryHandlerLevels.PRISTINE)
69 {
70 eInjurySoundZones zone = DetermineInjuryZone(m_Player.m_HealthLevel);
72 }
73 }
74
76 {
77 //Print("injury sound zone:"+ zone);
78 // process sound here
79 if (GetGame().GetTime() > m_SoundTime)
80 {
81 float offset_time;
82 if (zone == eInjurySoundZones.NONE)
83 {
84 offset_time = 3000;
85 m_SoundTime = GetGame().GetTime() + offset_time;
86 return;
87 }
88 if (zone == eInjurySoundZones.LIGHT)
90 else if (zone == eInjurySoundZones.MEDIUM)
91 offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_MEDIUM_MIN, SOUND_INTERVALS_MEDIUM_MAX) * 1000;
92 else if (zone == eInjurySoundZones.HEAVY)
93 offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_HEAVY_MIN, SOUND_INTERVALS_HEAVY_MAX) * 1000;
94 m_SoundTime = GetGame().GetTime() + offset_time;
96 }
97 }
98
103
104}
105
106
107//---------------------------
108// Server
109//---------------------------
111{
112
113
114}
class GetServerModListResult m_Id
GetServersResultRow the output structure of the GetServers operation that represents one game server.
ref HumanMovementState m_MovementState
movement state
DayZPlayer m_Player
Definition Hand_Events.c:42
float m_SoundTime
void PlaySound()
class HungerSoundHandlerBase extends SoundHandlerBase SOUND_INTERVALS_LIGHT_MIN
const float SOUND_INTERVALS_LIGHT_MAX
void ProcessSound()
eInjuryHandlerLevels
enum eInjurySoundZones Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
eInjurySoundZones
float GetTime()
eSoundHandlers
bool PlaySoundEvent(EPlayerSoundEventID id, bool from_anim_system=false, bool is_from_server=false)
void PlaySound(eInjurySoundZones zone)
void ProcessSound(eInjurySoundZones zone)
eInjurySoundZones DetermineInjuryZone(eInjuryHandlerLevels level)
eInjurySoundZones m_InjurySoundZone
eInjuryHandlerLevels m_InjuryLevel
Definition EnMath.c:7
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106
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'.