DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
PlayerSoundEventBase.c
Go to the documentation of this file.
2{
3 GENERAL = 0x00000001,
4 MELEE = 0x00000002,
5 STAMINA = 0x00000004,
6 DAMAGE = 0x00000008,
7 DUMMY = 0x00000010,
8 INJURY = 0x00000020,
9 DROWNING = 0x00000040,
10 //HEAT_COMFORT = 0x00000080,
11}
12
13enum EPlayerSoundEventParam
14{
16 HIGHEST_PRIORITY = 0x00000002,
17 /*
18 STAMINA = 0x00000004,
19 DAMAGE = 0x00000008,
20 DUMMY = 0x00000010,
21 INJURY = 0x00000020,
22 HEAT_COMFORT = 0x00000040,
23 */
24
25 // ONLY COUNT BELLOW
27
28}
29
31{
38
41
42 bool IsDummy()
43 {
44 return m_IsDummyType;
45 }
46
48 {
50 }
51
52 // !can this event play during hold breath
54 {
55 return false;
56 }
57
59 {
61 }
62
64 {
66 OnEnd();
67 }
68
70 {
72 }
73
75 {
76 return true;
77 }
78
80 {
81 if(IsDummy())
82 {
83 return IsDummyFinished();
84 }
85 else
86 {
87 return !IsSoundCallbackExist();
88 }
89 }
90
92 {
94 }
95
96
97 void OnTick(float delta_time)
98 {
100 {
102 //---------- Playback event -------------
103 if( delta_time > 0 && m_ProcessPlaybackEvent )//delta_time 0 is for remotes
104 {
105
106 m_PlayTime += delta_time;
107 //this is not 100% precise as the playback position is not obtained from the sound system
108 float playback01 = Math.Clamp(m_PlayTime / m_SoundSetCallback.GetLength(),0,1);
109 SendEvent(playback01);
110 //---------- Playback event -------------
111 }
112 }
113 }
114
115 bool CanPlay(PlayerBase player)
116 {
117 player.GetMovementState(m_Hms);
118
119 if (player.IsHoldingBreath() && !HasHoldBreathException())
120 {
121 return false;
122 }
123 if (player.m_IsDrowning || (player.IsSwimming() && m_Hms.m_iMovement != 0))
124 {
125 return false;
126 }
127 return true;
128 }
129
130 void Init(PlayerBase player)
131 {
132 InitEx(player,0);
133 }
134
135 void InitEx(PlayerBase player, int param)
136 {
137 m_Player = player;
138 m_Param = param;
139 if (param & EPlayerSoundEventParam.HIGHEST_PRIORITY)
140 {
142 }
143 }
144
145 void OnEnd()
146 {
148 SendEvent(1);
149 }
150
151 void SendEvent(float time)
152 {
153 if(m_PlayTime < 0 || !m_SoundSetCallback)//negative m_PlayTime value indicates the event has already been sent for playback01 = 1
154 return;
155
156 m_Player.OnVoiceEventPlayback(this, m_SoundSetCallback, time);
157 if(time >= 1)
158 m_PlayTime = -float.MAX;
159 }
160
162 {
163
164 }
165
166 override void OnPlay(PlayerBase player)
167 {
168 super.OnPlay(player);
169 //Print("start playing -------------------->" + m_Type);
170 player.OnVoiceEvent(this);
171 //m_Player.OnVoiceEventDuration(m_SoundSetCallback, 0);
172 }
173
174 override bool Play()
175 {
176 if(!super.Play())
177 return false;
178
179 if( !IsDummy() )
180 {
182
184 {
185 AbstractWaveEvents events = AbstractWaveEvents.Cast(m_SoundSetCallback.GetUserData());
186 events.Event_OnSoundWaveEnded.Insert( OnEnd );
187 events.Event_OnSoundWaveStopped.Insert( OnInterupt );
188 return true;
189 }
190 else
191 return false;
192 }
193 else
194 {
196 return true;
197 }
198 return false;
199
200 }
201}
eBleedingSourceType m_Type
override Widget Init()
Definition DayZGame.c:122
DayZPlayer m_Player
Definition Hand_Events.c:42
override bool CanPlay()
Definition MindStates.c:16
private void OnTick(PlayerBase player, float deltaT)
EPlayerSoundEventType GetPriorityOverTypes()
enum EPlayerSoundEventType HIGHEST_PRIORITY
enum EPlayerSoundEventType SKIP_CONTROLLED_PLAYER
void ~PlayerSoundEventBase()
EPlayerSoundEventType
float m_PlayTime
bool m_IsDummyType
ref HumanMovementState m_Hms
float m_DummySoundLength
float m_DummyStartTime
EPlayerSoundEventType m_HasPriorityOverTypes
bool IsDummy()
bool m_ProcessPlaybackEvent
void InitEx(PlayerBase player, int param)
bool IsFinished()
enum EPlayerSoundEventType ENUM_COUNT
bool IsDummyFinished()
void OnInterupt()
int GetSoundVoiceAnimEventClassID()
static proto native void SendEvent(StatsEventData data)
universal analytics event
protected EAnimPlayState Play()
AbstractWave m_SoundSetCallback
Definition SoundEvents.c:86
int m_SoundVoiceAnimEventClassID
Definition SoundEvents.c:89
bool IsSoundCallbackExist()
int m_Param
Definition SoundEvents.c:93
proto void SetPosition(vector position)
proto Managed GetUserData()
proto float GetLength()
WARNING: Blocking! Waits for header to load.
proto int GetTime()
returns mission time in milliseconds
AbstractWave ProcessVoiceEvent(string pEventType, string pUserString, int pUserInt)
int m_iMovement
current stance (DayZPlayerConstants.STANCEIDX_ERECT, ...), only if the command has a stance
Definition human.c:1118
Definition EnMath.c:7
override void OnPlay(PlayerBase player)
Definition JumpEvents.c:17
override bool HasPriorityOverCurrent(PlayerBase player, EPlayerSoundEventID other_state_id, EPlayerSoundEventType type_other)
override bool HasHoldBreathException()
override void OnEnd()
Definition JumpEvents.c:24
const float MAX
Definition EnConvert.c:99
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'.