‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_audio.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\array_shared;
4 #using scripts\shared\audio_shared;
5 #using scripts\shared\callbacks_shared;
6 #using scripts\shared\clientfield_shared;
7 #using scripts\shared\system_shared;
8 #using scripts\shared\util_shared;
9 
10 #insert scripts\shared\shared.gsh;
11 #insert scripts\shared\version.gsh;
12 
13 #using scripts\shared\util_shared;
14 
15 #namespace zm_audio;
16 
17 ‪REGISTER_SYSTEM( "zm_audio", &‪__init__, undefined )
18 
19 function ‪__init__()
20 {
21  // "allplayers" may need to be used instead of "toplayer" because it is possible the player in question is being spectated
23 
24  //to prevent exert sounds on the client from stepping on VO sounds on the server.
26 
27  if( !isdefined( level.exert_sounds ) )
28  {
29  level.exert_sounds = [];
30  }
31 
32  // sniper hold breath
33  level.exert_sounds[0]["playerbreathinsound"] = "vox_exert_generic_inhale";
34 
35  // sniper exhale
36  level.exert_sounds[0]["playerbreathoutsound"] = "vox_exert_generic_exhale";
37 
38  // sniper hold breath
39  level.exert_sounds[0]["playerbreathgaspsound"] = "vox_exert_generic_exhale";
40 
41  // falling damage
42  level.exert_sounds[0]["falldamage"] = "vox_exert_generic_pain";
43 
44  // mantle launch
45  level.exert_sounds[0]["mantlesoundplayer"] = "vox_exert_generic_mantle";
46 
47  // melee swipe
48  level.exert_sounds[0]["meleeswipesoundplayer"] = "vox_exert_generic_knifeswipe";
49 
50  // DTP land ** this may need to be expanded to take surface type into account
51  level.exert_sounds[0]["dtplandsoundplayer"] = "vox_exert_generic_pain";
52 
53  // custom character exerts - most of the exert sounds will be set up here
54  //if (isdefined(level.setupCustomCharacterExerts))
55  // [[level.setupCustomCharacterExerts]]();
56 
57  level thread ‪gameover_snapshot();
58 
60 }
61 
62 function ‪on_player_spawned(localclientnum)
63 {
64  //audio::snd_set_snapshot( "zmb_game_start" );
65 }
66 
67 function ‪delay_set_exert_id(newVal)
68 {
69  self endon("entityshutdown");
70  self endon("sndEndExertOverride");
71  wait 0.5;
72  self.player_exert_id = newVal;
73 }
74 
75 function ‪charindex_cb( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
76 {
77  if (!bNewEnt)
78  {
79  self.player_exert_id = newVal;
80  self._first_frame_exert_id_recieved = true;
81  self notify( "sndEndExertOverride" );
82  }
83  else if(!isdefined(self._first_frame_exert_id_recieved))
84  {
85  self._first_frame_exert_id_recieved = true;
86  self thread ‪delay_set_exert_id(newVal);
87  }
88 }
89 
90 function ‪isspeaking_cb( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
91 {
92  if (!bNewEnt)
93  {
94  self.isSpeaking = newVal;
95  }
96  else
97  {
98  self.isSpeaking = 0;
99  }
100 }
101 
102 
103 //GAMETYPE GENERAL AUDIO FUNCTIONS
104 function ‪zmbMusLooper()
105 {
106  ent = ‪spawn( 0, (0,0,0), "script_origin" );
107  playsound( 0, "mus_zmb_gamemode_start", (0,0,0) );
108  wait(10);
109  ent playloopsound( "mus_zmb_gamemode_loop", .05 );
110  ent thread ‪waitfor_music_stop();
111 }
113 {
114  level waittill( "stpm" );
115  self StopAllLoopSounds( .1 );
116  playsound( 0, "mus_zmb_gamemode_end", (0,0,0) );
117  wait(1);
118  self delete();
119 }
120 
121 function ‪playerFallDamageSound(client_num, firstperson)
122 {
123  self ‪playerExert( client_num, "falldamage" );
124  /*
125  sound_alias = "vox_plr_0_exert_breathing_hurt";
126  if ( firstperson )
127  {
128  sound_alias = "vox_plr_0_exert_breathing_hurt";
129  self playsound( client_num, sound_alias );
130  }
131  */
132 }
133 
134 
136 {
138 
139  players = GetLocalPlayers();
140  for (i = 0; i<players.size; i++)
141  thread ‪audio_player_connect( i );
142 
143 }
144 
145 function ‪audio_player_connect( localClientNum )
146 {
147  thread ‪sndVoNotifyPlain( localClientNum, "playerbreathinsound" );
148  thread ‪sndVoNotifyPlain( localClientNum, "playerbreathoutsound" );
149  thread ‪sndVoNotifyPlain( localClientNum, "playerbreathgaspsound" );
150  thread ‪sndVoNotifyPlain( localClientNum, "mantlesoundplayer" );
151  thread ‪sndVoNotifyPlain( localClientNum, "meleeswipesoundplayer" );
152  //thread sndMeleeSwipe( localClientNum, "meleeswipesoundplayer" );
153  thread ‪sndVoNotifyDTP( localClientNum, "dtplandsoundplayer" );
154 }
155 
156 
157 function ‪playerExert( localClientNum, exert )
158 {
159  if(IsDefined(self.isSpeaking) && self.isSpeaking == 1)
160  {
161  return;
162  }
163 
164  if( ‪IS_TRUE( self.beast_mode ) )
165  return;
166 
167  id = level.exert_sounds[0][exert];
168 
169  if( isArray(level.exert_sounds[0][exert]))
170  {
171  id = array::random(level.exert_sounds[0][exert]);
172  }
173 
174  if ( isdefined(self.player_exert_id) )
175  {
176  if(IsArray(level.exert_sounds[self.player_exert_id][exert]))
177  {
178  id = array::random(level.exert_sounds[self.player_exert_id][exert]);
179  }
180  else
181  {
182  id = level.exert_sounds[self.player_exert_id][exert];
183  }
184  }
185 
186  if( isdefined( id ) )
187  self playsound ( localClientNum, id);
188 }
189 
190 function ‪sndVoNotifyDTP( localClientNum, notifyString )
191 {
192  level notify( "kill_sndVoNotifyDTP" + localClientNum + notifystring );
193  level endon( "kill_sndVoNotifyDTP" + localClientNum + notifystring );
194 
195  player = undefined;
196  while( !IsDefined( player ) )
197  {
198  player = GetNonPredictedLocalPlayer(localClientNum);
199  wait( 0.05 );
200  }
201  player endon("disconnect");
202 
203  for(;;)
204  {
205  player waittill ( notifyString, surfaceType );
206  // for now we are ignoring the surface type
207  player ‪playerExert( localClientNum, notifyString );
208  }
209 }
210 
211 function ‪sndMeleeSwipe( localClientNum, notifyString )
212 {
213  player = undefined;
214  while( !IsDefined( player ) )
215  {
216  player = GetNonPredictedLocalPlayer(localClientNum);
217  wait( 0.05 );
218  }
219  player endon("disconnect");
220  for(;;)
221  {
222  player waittill ( notifyString );
223  currentweapon = GetCurrentWeapon( localClientNum );
224 
225  if( ‪IS_TRUE( level.sndNoMeleeOnClient ) )
226  {
227  return;
228  }
229 
230  if (‪IS_TRUE(player.is_player_zombie))
231  {
232  playsound( 0, "zmb_melee_whoosh_zmb_plr", player.origin );
233  }
234  else if( currentweapon.name == "bowie_knife" )
235  {
236  playsound( 0, "zmb_bowie_swing_plr", player.origin );
237  }
238  else if( currentweapon.name == "spoon_zm_alcatraz" )
239  {
240  playsound( 0, "zmb_spoon_swing_plr", player.origin );
241  }
242  else if( currentweapon.name == "spork_zm_alcatraz" )
243  {
244  playsound( 0, "zmb_spork_swing_plr", player.origin );
245  }
246  else
247  {
248  playsound( 0, "zmb_melee_whoosh_plr", player.origin );
249  }
250  }
251 }
252 
253 function ‪sndVoNotifyPlain( localClientNum, notifyString )
254 {
255  level notify( "kill_sndVoNotifyPlain" + localClientNum + notifystring );
256  level endon( "kill_sndVoNotifyPlain" + localClientNum + notifystring );
257 
258  player = undefined;
259  while( !IsDefined( player ) )
260  {
261  player = GetNonPredictedLocalPlayer(localClientNum);
262  wait( 0.05 );
263  }
264  player endon("disconnect");
265 
266  for(;;)
267  {
268  player waittill ( notifyString );
269 
270  if( ‪IS_TRUE( player.is_player_zombie ) )
271  continue;
272 
273  player ‪playerExert( localClientNum, notifyString );
274  }
275 }
276 
277 
279 {
280  level ‪util::waittill_any( "demo_jump", "demo_player_switch", "snd_clear_script_duck" );
281 
282  wait(1);
283 
284  ‪audio::snd_set_snapshot( "default" );
285 
286  level thread ‪gameover_snapshot();
287 }
288 
289 
291 {
292  level waittill( "zesn" );
293  ‪audio::snd_set_snapshot( "zmb_game_over" );
294  level thread ‪end_gameover_snapshot();
295 }
296 
297 function ‪sndSetZombieContext(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
298 {
299  if( newVal == 1 )
300  {
301  self setsoundentcontext("grass", "no_grass");
302  }
303  else
304  {
305  self setsoundentcontext("grass", "in_grass");
306  }
307 }
308 
309 function ‪sndZmbLaststand(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
310 {
311  if( newVal )
312  {
313  PlaySound( localClientNum, "chr_health_laststand_enter", (0,0,0) );
314  self.inLastStand = true;
315  setsoundcontext ("laststand", "active");
316 
317  if( !IsSplitScreen() )
318  {
319  forceambientroom( "sndHealth_LastStand" );
320  }
321  }
322  else
323  {
324  if( ‪IS_TRUE( self.inLastStand ) )
325  {
326  playsound( localClientNum, "chr_health_laststand_exit", (0,0,0) );
327  self.inLastStand = false;
328 
329  if( !IsSplitScreen() )
330  {
331  forceambientroom( "" );
332  }
333  }
334 
335  setsoundcontext ("laststand", "");
336  }
337 
338 }
‪waitfor_music_stop
‪function waitfor_music_stop()
Definition: _zm_audio.csc:112
‪sndZmbLaststand
‪function sndZmbLaststand(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _zm_audio.csc:309
‪playerFallDamageSound
‪function playerFallDamageSound(client_num, firstperson)
Definition: _zm_audio.csc:121
‪__init__
‪function __init__()
Definition: _zm_audio.csc:19
‪CF_CALLBACK_ZERO_ON_NEW_ENT
‪#define CF_CALLBACK_ZERO_ON_NEW_ENT
Definition: version.gsh:103
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪playerExert
‪function playerExert(localClientNum, exert)
Definition: _zm_audio.csc:157
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪sndMeleeSwipe
‪function sndMeleeSwipe(localClientNum, notifyString)
Definition: _zm_audio.csc:211
‪sndVoNotifyDTP
‪function sndVoNotifyDTP(localClientNum, notifyString)
Definition: _zm_audio.csc:190
‪charindex_cb
‪function charindex_cb(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _zm_audio.csc:75
‪delay_set_exert_id
‪function delay_set_exert_id(newVal)
Definition: _zm_audio.csc:67
‪on_spawned
‪function on_spawned(func, obj)
Definition: callbacks_shared.csc:245
‪on_localclient_connect
‪function on_localclient_connect(localClientNum)
Definition: ctf.csc:20
‪CF_HOST_ONLY
‪#define CF_HOST_ONLY
Definition: version.gsh:102
‪waittill_any
‪function waittill_any(str_notify1, str_notify2, str_notify3, str_notify4, str_notify5)
Definition: util_shared.csc:375
‪sndVoNotifyPlain
‪function sndVoNotifyPlain(localClientNum, notifyString)
Definition: _zm_audio.csc:253
‪clientVoiceSetup
‪function clientVoiceSetup()
Definition: _zm_audio.csc:135
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪zmbMusLooper
‪function zmbMusLooper()
Definition: _zm_audio.csc:104
‪gameover_snapshot
‪function gameover_snapshot()
Definition: _zm_audio.csc:290
‪isspeaking_cb
‪function isspeaking_cb(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _zm_audio.csc:90
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪end_gameover_snapshot
‪function end_gameover_snapshot()
Definition: _zm_audio.csc:278
‪snd_set_snapshot
‪function snd_set_snapshot(state)
Definition: audio_shared.csc:184
‪sndSetZombieContext
‪function sndSetZombieContext(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _zm_audio.csc:297
‪audio_player_connect
‪function audio_player_connect(localClientNum)
Definition: _zm_audio.csc:145
‪on_player_spawned
‪function on_player_spawned(localclientnum)
Definition: _zm_audio.csc:62