Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
injurysoundhandler.c
Go to the documentation of this file.
2 {
3  NONE = 0,
6  HEAVY,
7 
8  // PUT NEW STATES ABOVE
10 }
11 
13 {
14  override void Init()
15  {
16  m_Id = eSoundHandlers.INJURY;
17  }
18 
19 }
20 
21 //---------------------------
22 // Client
23 //---------------------------
24 class 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 
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  if( GetGame().GetTime() > m_SoundTime)
86  {
87  float offset_time;
88  if(zone == eInjurySoundZones.NONE)
89  {
90  offset_time = 3000;
91  m_SoundTime = GetGame().GetTime() + offset_time;
92  return;
93  }
94  if(zone == eInjurySoundZones.LIGHT)
95  {
96  offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_LIGHT_MIN, SOUND_INTERVALS_LIGHT_MAX) * 1000;
97  }
98  else if(zone == eInjurySoundZones.MEDIUM)
99  {
100  offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_MEDIUM_MIN, SOUND_INTERVALS_MEDIUM_MAX) * 1000;
101  }
102  else if(zone == eInjurySoundZones.HEAVY)
103  {
104  offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_HEAVY_MIN, SOUND_INTERVALS_HEAVY_MAX) * 1000;
105  }
106  m_SoundTime = GetGame().GetTime() + offset_time;
107  PlaySound(zone);
108  }
109  }
110 
111  void PlaySound(eInjurySoundZones zone)
112  {
113  m_Player.PlaySoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
114  }
115 
116 }
117 
118 
119 //---------------------------
120 // Server
121 //---------------------------
122 class InjurySoundHandlerServer extends InjurySoundHandlerBase
123 {
124 
125 
126 
127 
128 }
GetGame
proto native CGame GetGame()
ProcessSound
void ProcessSound()
Definition: hungersoundhandler.c:28
HEAVY
HEAVY
Definition: injurysoundhandler.c:5
InjurySoundHandlerBase
Definition: injurysoundhandler.c:24
LIGHT
LIGHT
Definition: injurysoundhandler.c:3
HumanMovementState
Definition: human.c:1125
m_MovementState
ref HumanMovementState m_MovementState
movement state
Definition: dayzplayercamera3rdperson.c:155
COUNT
COUNT
Definition: injurysoundhandler.c:9
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
MEDIUM
MEDIUM
Definition: injurysoundhandler.c:4
eInjurySoundZones
eInjurySoundZones
Definition: injurysoundhandler.c:1
Init
enum eInjurySoundZones Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition: injurysoundhandler.c:14
m_Id
class GetServerModListResult m_Id
GetServersResultRow the output structure of the GetServers operation that represents one game server.
SOUND_INTERVALS_LIGHT_MIN
class HungerSoundHandlerBase extends SoundHandlerBase SOUND_INTERVALS_LIGHT_MIN
eInjuryHandlerLevels
eInjuryHandlerLevels
Definition: injuryhandler.c:18
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
eSoundHandlers
eSoundHandlers
Definition: playersoundmanager.c:4
NONE
NONE
Definition: injurysoundhandler.c:2
m_SoundTime
float m_SoundTime
Definition: hungersoundhandler.c:17
SoundHandlerBase
Definition: hungersoundhandler.c:1
PlaySound
void PlaySound()
Definition: hungersoundhandler.c:38
GetTime
float GetTime()
Definition: notificationsystem.c:35
Math
Definition: enmath.c:6
EPlayerSoundEventID
EPlayerSoundEventID
Definition: playersoundeventhandler.c:1
SOUND_INTERVALS_LIGHT_MAX
const float SOUND_INTERVALS_LIGHT_MAX
Definition: hungersoundhandler.c:16