Dayz Explorer 1.29.162510
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//---------------------------
24class InjurySoundHandlerClient extends InjurySoundHandlerBase
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
30 ref HumanMovementState m_MovementState = new HumanMovementState;
31 eInjurySoundZones m_InjurySoundZone;
32 eInjuryHandlerLevels m_InjuryLevel;
33 float m_SoundTime;
34
35
36 eInjurySoundZones DetermineInjuryZone(eInjuryHandlerLevels level)
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 {
54 level--;
55 }
56
57 if( speed == DayZPlayerConstants.MOVEMENTIDX_WALK )
58 {
59 level--;
60 }
61 else if(speed == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
62 {
63 level++;
64 }
65 level = Math.Clamp(level, eInjurySoundZones.NONE, eInjurySoundZones.HEAVY);
66 return level;
67 }
68
69
70 override void Update()
71 {
72 m_InjuryLevel = m_Player.m_HealthLevel;
73
74 if( m_InjuryLevel != eInjuryHandlerLevels.PRISTINE )
75 {
76 eInjurySoundZones zone = DetermineInjuryZone(m_Player.m_HealthLevel);
77 ProcessSound(zone);
78 }
79 }
80
82 {
83 //Print("injury sound zone:"+ zone);
84 // process sound here
85 int currentTime = g_Game.GetTime();
86 if( currentTime > m_SoundTime)
87 {
88 float offset_time;
89 if(zone == eInjurySoundZones.NONE)
90 {
91 offset_time = 3000;
92 m_SoundTime = currentTime + offset_time;
93 return;
94 }
95 if(zone == eInjurySoundZones.LIGHT)
96 {
97 offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_LIGHT_MIN, SOUND_INTERVALS_LIGHT_MAX) * 1000;
98 }
99 else if(zone == eInjurySoundZones.MEDIUM)
100 {
101 offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_MEDIUM_MIN, SOUND_INTERVALS_MEDIUM_MAX) * 1000;
102 }
103 else if(zone == eInjurySoundZones.HEAVY)
104 {
105 offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_HEAVY_MIN, SOUND_INTERVALS_HEAVY_MAX) * 1000;
106 }
107 m_SoundTime = g_Game.GetTime() + offset_time;
108 PlaySound(zone);
109 }
110 }
111
113 {
114 m_Player.PlaySoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
115 }
116
117}
118
119
120//---------------------------
121// Server
122//---------------------------
123class InjurySoundHandlerServer extends InjurySoundHandlerBase
124{
125
126
127
128
129}
class ServerBrowserHelperFunctions m_Id
map m_Player
Definition enmath.c:7
DayZGame g_Game
Definition dayzgame.c:3942
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
@ COUNT
@ MEDIUM
Definition estatlevels.c:5
@ NONE
body is not in simulation, nor in collision world
void Update()
Definition radialmenu.c:518
void PlaySound()
void ProcessSound()
eInjuryHandlerLevels
enum eInjurySoundZones Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
eInjurySoundZones
eSoundHandlers