Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
playersoundeventhandler.c
Go to the documentation of this file.
2 {
19  MELEE_ATTACK_HEAVY
24  HOT,
33  //--------------
34  // Count bellow, put enums above
35  //--------------
37 }
38 
39 class PlayerSoundEventHandler extends SoundEventHandler
40 {
42  const int SOUND_EVENTS_MAX = EPlayerSoundEventID.ENUM_COUNT;
43  static ref PlayerSoundEventBase m_AvailableStates[SOUND_EVENTS_MAX];
44  static ref map<int,int> m_ConfigIDToScriptIDmapping = new ref map<int,int> ;
47 
48 
50  {
51  m_Player = player;
52 
53  if(!m_UpdateTimer && !m_Player.IsControlledPlayer())
54  {
55  m_UpdateTimer = new Timer();
56  m_UpdateTimer.Run(1, this, "OnTick", null, true);//ticking for remotes, the controlled player is ticking on command handler at higher intervals
57  }
58 
61  RegisterState(new FatigueSoundEvent());
69  RegisterState(new DamageHeavySoundEvent());
75  RegisterState(new MeleeAttackHeavyEvent());
81  RegisterState(new HotSoundEvent());
84  RegisterState(new StaminaLowFilterLower());
86  RegisterState(new DrowningEvent2());
89 
90 
91  }
92 
94  {
95  int index = state.GetSoundEventID();
96  m_AvailableStates[index] = state;
97  m_ConfigIDToScriptIDmapping.Insert(state.GetSoundVoiceAnimEventClassID(),index);
98  }
99 
100 
101  void OnTick(float delta_time)
102  {
103  if (m_CurrentState)
104  {
105  if( m_CurrentState.IsFinished())
106  m_CurrentState = null;
107  else
108  m_CurrentState.OnTick(delta_time);
109  }
110  }
111 
112  int ConvertAnimIDtoEventID(int anim_id)
113  {
114  return m_ConfigIDToScriptIDmapping.Get(anim_id);
115  }
116 
117  override static EPlayerSoundEventType GetSoundEventType(int id)
118  {
119  return m_AvailableStates[id].GetSoundEventType();
120  }
121 
122  override int GetCurrentStateEventID()
123  {
124  if(m_CurrentState)
125  {
126  return m_CurrentState.GetSoundEventID();
127  }
128  return -1;
129  }
130 
132  {
133  if(m_CurrentState)
134  {
135  return m_CurrentState.GetSoundEventType();
136  }
137  return -1;
138  }
139 
140  override bool PlayRequestEx(EPlayerSoundEventID id, bool sent_from_server = false, int param = 0)
141  {
142  if (id < 0 || id > (SOUND_EVENTS_MAX - 1))
143  {
144  Error("EPlayerSoundEventID out of bounds");
145  }
146 
147  PlayerSoundEventBase requested_state = m_AvailableStates[id];
148  if ( sent_from_server && (param & EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER) && m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT )
149  {
150  return false;
151  }
152 
153  if ( !requested_state.CanPlay(m_Player) )
154  {
155  return false;
156  }
157 
158  if (m_CurrentState)
159  {
160  if (param & EPlayerSoundEventParam.HIGHEST_PRIORITY)
161  {
162  m_CurrentState.Stop();
163  }
164  else
165  {
166  int current_type = m_CurrentState.GetSoundEventType();
167  //int requested_type = requested_state.GetSoundEventType();
168 
169  if ( (requested_state.GetPriorityOverTypes() & current_type) == 0 )
170  {
171  return false;
172  }
173  if (!requested_state.HasPriorityOverCurrent(m_Player, id, current_type) )
174  {
175  return false;
176  }
177 
178  m_CurrentState.Stop();
179  }
180  }
181  m_CurrentState = PlayerSoundEventBase.Cast(requested_state.ClassName().ToType().Spawn());
182  m_CurrentState.InitEx(m_Player, param);
183  if (m_CurrentState.Play())
184  {
185  m_CurrentState.OnPlay(m_Player);
186  }
187  return true;
188  }
189 
190 
191  override bool PlayRequest(EPlayerSoundEventID id, bool sent_from_server = false)
192  {
193  return PlayRequestEx(id, sent_from_server);
194  }
195 
196 }
StaminaNormalDummy
void StaminaNormalDummy()
Definition: staminaevents.c:93
ENUM_COUNT
@ ENUM_COUNT
Definition: playersoundeventhandler.c:36
EXHAUSTED_BREATH
@ EXHAUSTED_BREATH
Definition: playersoundeventhandler.c:4
SOUND_EVENTS_MAX
const int SOUND_EVENTS_MAX
Definition: playersoundeventhandler.c:42
ReleaseBreathSoundEvent
class ExhaustedBreathSoundEvent extends HoldBreathSoundEventBase ReleaseBreathSoundEvent()
Definition: holdbreathevents.c:52
ExhaustedBreathSoundEvent
void ExhaustedBreathSoundEvent()
Definition: holdbreathevents.c:26
HoldBreathSoundEvent
class HoldBreathSoundEventBase extends PlayerSoundEventBase HoldBreathSoundEvent()
Definition: holdbreathevents.c:18
StaminaUpHeavy
class StaminaDownHeavy extends StaminaSoundEventBase StaminaUpHeavy()
Definition: staminaevents.c:68
FREEZING
@ FREEZING
Definition: playersoundeventhandler.c:23
INJURED_HIGH
@ INJURED_HIGH
Definition: playersoundeventhandler.c:22
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
DamageLightSoundEvent
class DamageSoundEvents extends PlayerSoundEventBase DamageLightSoundEvent()
Definition: damageevents.c:23
CoughSoundEvent
class SymptomSoundEventBase extends PlayerSoundEventBase CoughSoundEvent()
Definition: symptomevents.c:17
StaminaDownHeavy
void StaminaDownHeavy()
Definition: staminaevents.c:2
STAMINA_UP_END
@ STAMINA_UP_END
Definition: playersoundeventhandler.c:10
GetCurrentStateEventID
override int GetCurrentStateEventID()
Definition: playersoundeventhandler.c:122
SYMPTOM_LAUGHTER
@ SYMPTOM_LAUGHTER
Definition: playersoundeventhandler.c:15
STAMINA_UP_LIGHT
@ STAMINA_UP_LIGHT
Definition: playersoundeventhandler.c:8
SneezeSoundEvent
class LaugherSoundEvent extends SymptomSoundEventBase SneezeSoundEvent()
Definition: symptomevents.c:35
GetCurrentStateEventType
override int GetCurrentStateEventType()
Definition: playersoundeventhandler.c:131
JumpSoundEvent
class JumpEventsBase extends PlayerSoundEventBase JumpSoundEvent()
Definition: jumpevents.c:35
TAKING_DMG_LIGHT
@ TAKING_DMG_LIGHT
Definition: playersoundeventhandler.c:12
STAMINA_LOW_FILTER_UPPER
@ STAMINA_LOW_FILTER_UPPER
Definition: playersoundeventhandler.c:26
InjuryHeavySoundEvent
class InjuryMediumSoundEvent extends InjurySoundEvents InjuryHeavySoundEvent()
Definition: injuryevents.c:43
OnTick
void OnTick(float delta_time)
Definition: playersoundeventhandler.c:101
MELEE_ATTACK_LIGHT
@ MELEE_ATTACK_LIGHT
Definition: playersoundeventhandler.c:18
LaugherSoundEvent
void LaugherSoundEvent()
Definition: symptomevents.c:2
RELEASE_BREATH
@ RELEASE_BREATH
Definition: playersoundeventhandler.c:5
PlayerSoundEventHandler
void PlayerSoundEventHandler(PlayerBase player)
Definition: playersoundeventhandler.c:49
INJURED_LIGHT
@ INJURED_LIGHT
Definition: playersoundeventhandler.c:20
DROWNING_PAIN
@ DROWNING_PAIN
Definition: playersoundeventhandler.c:30
TAKING_DMG_HEAVY
@ TAKING_DMG_HEAVY
Definition: playersoundeventhandler.c:13
THIRST
@ THIRST
Definition: playersoundeventhandler.c:32
FreezingSoundEvent
class HeatComfortEventsBase extends PlayerSoundEventBase FreezingSoundEvent()
Definition: heatcomfortevents.c:18
StaminaUpEnd
class StaminaUpLight extends StaminaSoundEventBase StaminaUpEnd()
Definition: staminaevents.c:86
ThirstSoundEvent
class PickupHeavySoundEvent extends PlayerSoundEventBase ThirstSoundEvent()
Definition: miscevents.c:14
SYMPTOM_SNEEZE
@ SYMPTOM_SNEEZE
Definition: playersoundeventhandler.c:16
StaminaLowFilterUpper
void StaminaLowFilterUpper()
Definition: staminaevents.c:93
RegisterState
void RegisterState(PlayerSoundEventBase state)
Definition: playersoundeventhandler.c:93
STAMINA_NORMAL_DUMMY
@ STAMINA_NORMAL_DUMMY
Definition: playersoundeventhandler.c:11
PlayRequestEx
override bool PlayRequestEx(EPlayerSoundEventID id, bool sent_from_server=false, int param=0)
Definition: playersoundeventhandler.c:140
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
PlayerSoundEventBase
Definition: damageevents.c:1
STAMINA_DOWN_HEAVY
@ STAMINA_DOWN_HEAVY
Definition: playersoundeventhandler.c:7
DROWNING_BREATH
@ DROWNING_BREATH
Definition: playersoundeventhandler.c:29
STAMINA_DOWN_LIGHT
@ STAMINA_DOWN_LIGHT
Definition: playersoundeventhandler.c:6
StaminaLowFilterMid
class StaminaLowFilterUpper extends StaminaLowFilterBase StaminaLowFilterMid()
Definition: staminaevents.c:131
STAMINA_LOW_FILTER_MID
@ STAMINA_LOW_FILTER_MID
Definition: playersoundeventhandler.c:27
PICKUP_HEAVY
@ PICKUP_HEAVY
Definition: playersoundeventhandler.c:31
m_UpdateTimer
ref Timer m_UpdateTimer
Definition: playersoundeventhandler.c:46
STAMINA_UP_HEAVY
@ STAMINA_UP_HEAVY
Definition: playersoundeventhandler.c:9
m_CurrentState
ref PlayerSoundEventBase m_CurrentState
Definition: playersoundeventhandler.c:45
JUMP
@ JUMP
Definition: playersoundeventhandler.c:17
m_Player
enum EPlayerSoundEventID m_Player
ConvertAnimIDtoEventID
int ConvertAnimIDtoEventID(int anim_id)
Definition: playersoundeventhandler.c:112
INJURED_MEDIUM
@ INJURED_MEDIUM
Definition: playersoundeventhandler.c:21
HOT
@ HOT
Definition: playersoundeventhandler.c:24
MeleeAttackLightEvent
class MeleeAttackSoundEvents extends PlayerSoundEventBase MeleeAttackLightEvent()
Definition: meleeattack.c:33
PickupHeavySoundEvent
void PickupHeavySoundEvent()
Definition: miscevents.c:2
DrowningEvent1
class DrowningSoundEventBase extends PlayerSoundEventBase DrowningEvent1()
Definition: drowningevents.c:22
SYMPTOM_COUGH
@ SYMPTOM_COUGH
Definition: playersoundeventhandler.c:14
StaminaDownLight
class StaminaSoundEventBase extends PlayerSoundEventBase StaminaDownLight()
Definition: staminaevents.c:50
InjuryMediumSoundEvent
void InjuryMediumSoundEvent()
Definition: injuryevents.c:2
EPlayerSoundEventType
EPlayerSoundEventType
Definition: playersoundeventbase.c:1
Timer
Definition: dayzplayerimplement.c:62
PlayRequest
override bool PlayRequest(EPlayerSoundEventID id, bool sent_from_server=false)
Definition: playersoundeventhandler.c:191
STAMINA_LOW_FILTER_LOWER
@ STAMINA_LOW_FILTER_LOWER
Definition: playersoundeventhandler.c:28
EPlayerSoundEventID
EPlayerSoundEventID
Definition: playersoundeventhandler.c:1
StaminaUpLight
void StaminaUpLight()
Definition: staminaevents.c:2
InjuryLightSoundEvent
class InjurySoundEvents extends PlayerSoundEventBase InjuryLightSoundEvent()
Definition: injuryevents.c:23
SYMPTOM_FATIGUE
@ SYMPTOM_FATIGUE
Definition: playersoundeventhandler.c:25
HOLD_BREATH
@ HOLD_BREATH
Definition: playersoundeventhandler.c:3
DayZPlayerInstanceType
DayZPlayerInstanceType
defined in C++
Definition: dayzplayer.c:1058