Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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 STOP_PLAYBACK = 0x00000004,
18 /*
19 STAMINA = 0x00000004,
20 DAMAGE = 0x00000008,
21 DUMMY = 0x00000010,
22 INJURY = 0x00000020,
23 HEAT_COMFORT = 0x00000040,
24 */
25
26 // ONLY COUNT BELLOW
28
29}
30
32{
39
42
43 bool IsDummy()
44 {
45 return m_IsDummyType;
46 }
47
52
53 // !can this event play during hold breath
55 {
56 return false;
57 }
58
60 {
62 }
63
65 {
67 OnEnd();
68 }
69
74
76 {
77 return true;
78 }
79
81 {
82 if(IsDummy())
83 {
84 return IsDummyFinished();
85 }
86 else
87 {
88 return !IsSoundCallbackExist();
89 }
90 }
91
93 {
94 return g_Game.GetTime() > (m_DummyStartTime + m_DummySoundLength);
95 }
96
97
98 void OnTick(float delta_time)
99 {
100 if ( m_SoundSetCallback )
101 {
102 m_SoundSetCallback.SetPosition(m_Player.GetPosition());
103 //---------- Playback event -------------
104 if( delta_time > 0 && m_ProcessPlaybackEvent )//delta_time 0 is for remotes
105 {
106
107 m_PlayTime += delta_time;
108 //this is not 100% precise as the playback position is not obtained from the sound system
109 float playback01 = Math.Clamp(m_PlayTime / m_SoundSetCallback.GetLength(),0,1);
110 SendEvent(playback01);
111 //---------- Playback event -------------
112 }
113 }
114 }
115
116 bool CanPlay(PlayerBase player)
117 {
118 player.GetMovementState(m_Hms);
119
120 if (player.IsHoldingBreath() && !HasHoldBreathException())
121 {
122 return false;
123 }
124 if (player.m_IsDrowning || (player.IsSwimming() && m_Hms.m_iMovement != 0))
125 {
126 return false;
127 }
128 return true;
129 }
130
131 void Init(PlayerBase player)
132 {
133 InitEx(player,0);
134 }
135
136 void InitEx(PlayerBase player, int param)
137 {
138 m_Player = player;
139 m_Param = param;
140 if (param & EPlayerSoundEventParam.HIGHEST_PRIORITY)
141 {
143 }
144 }
145
146 void OnEnd()
147 {
149 SendEvent(1);
150 }
151
152 void SendEvent(float time)
153 {
154 if(m_PlayTime < 0 || !m_SoundSetCallback)//negative m_PlayTime value indicates the event has already been sent for playback01 = 1
155 return;
156
157 m_Player.OnVoiceEventPlayback(this, m_SoundSetCallback, time);
158 if(time >= 1)
159 m_PlayTime = -float.MAX;
160 }
161
163 {
164
165 }
166
167 override void OnPlay(PlayerBase player)
168 {
169 super.OnPlay(player);
170 //Print("start playing -------------------->" + m_Type);
171 player.OnVoiceEvent(this);
172 //m_Player.OnVoiceEventDuration(m_SoundSetCallback, 0);
173 }
174
175 override bool Play()
176 {
177 if(!super.Play())
178 return false;
179
180 if( !IsDummy() )
181 {
182 m_SoundSetCallback = m_Player.ProcessVoiceEvent("","", m_SoundVoiceAnimEventClassID);
183
185 {
186 AbstractWaveEvents events = AbstractWaveEvents.Cast(m_SoundSetCallback.GetUserData());
189 return true;
190 }
191 else
192 return false;
193 }
194 else
195 {
196 m_DummyStartTime = g_Game.GetTime();
197 return true;
198 }
199 return false;
200
201 }
202}
eBleedingSourceType m_Type
map m_Player
Definition enmath.c:7
override bool HasPriorityOverCurrent(PlayerBase player, EPlayerSoundEventID other_state_id, EPlayerSoundEventType type_other)
override bool HasHoldBreathException()
override void OnEnd()
Definition jumpevents.c:24
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
DayZGame g_Game
Definition dayzgame.c:3942
override Widget Init()
Definition dayzgame.c:127
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'.
proto void Play()
void OnEnd()
Definition sound.c:226
ref ScriptInvoker Event_OnSoundWaveEnded
Definition sound.c:152
ref ScriptInvoker Event_OnSoundWaveStopped
Definition sound.c:149
void OnPlay()
Definition sound.c:206
override bool HasHoldBreathException()
@ MELEE
override bool CanPlay()
Definition mindstates.c:16
void OnTick(PlayerBase player, float deltaT)
Definition heavymetal.c:219
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
enum EPlayerSoundEventType STOP_PLAYBACK
float m_DummyStartTime
EPlayerSoundEventType m_HasPriorityOverTypes
bool IsDummy()
bool m_ProcessPlaybackEvent
void InitEx(PlayerBase player, int param)
bool IsFinished()
void PlayerSoundEventBase()
bool IsDummyFinished()
void OnInterupt()
int GetSoundVoiceAnimEventClassID()
@ STAMINA
static proto native void SendEvent(StatsEventData data)
universal analytics event
AbstractWave m_SoundSetCallback
Definition soundevents.c:86
int m_SoundVoiceAnimEventClassID
Definition soundevents.c:89
bool IsSoundCallbackExist()
int m_Param
Definition soundevents.c:93