‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_helicopter_sounds.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\audio_shared;
4 #using scripts\shared\music_shared;
5 #using scripts\shared\system_shared;
6 #using scripts\shared\util_shared;
7 
8 #using scripts\shared\clientfield_shared;
9 
10 #insert scripts\shared\shared.gsh;
11 #insert scripts\shared\version.gsh;
12 
13 #using scripts\mp\_helicopter_sounds;
14 #using scripts\mp\_util;
15 
16 // *************************************************
17 // INIT HELI SOUNDS
18 //
19 // List of availible sound specific bones
20 // "SND_Cockpit"
21 // "SND_INT_F_L"
22 // "SND_INT_F_R"
23 // "SND_INT_R_L"
24 // "SND_INT_R_R"
25 // "SND_INT_Rotor"
26 // "SND_Rotor"
27 // "SND_Tail_Rotor"
28 // "SND_UNDER_Body"
29 // "SND_WIND_Left"
30 // "SND_WIND_Right"
31 //
32 // *************************************************
33 
34 #namespace helicopter_sounds;
35 
36 ‪REGISTER_SYSTEM( "helicopter_sounds", &‪__init__, undefined )
37 
38 function ‪__init__()
39 {
40  //clientfield::register("vehicle", "vehicle_is_firing", VERSION_SHIP, 1, "int",&vehicle_is_firing_function, CF_HOST_ONLY, !CF_CALLBACK_ZERO_ON_NEW_ENT);
41  //clientfield::register("helicopter", "vehicle_is_firing", VERSION_SHIP, 1, "int",&vehicle_is_firing_function, CF_HOST_ONLY, !CF_CALLBACK_ZERO_ON_NEW_ENT);
42  //clientfield::register("actor", "player_is_gunner", VERSION_SHIP, 1, "int",&chppoer_gunner_loop, CF_HOST_ONLY, !CF_CALLBACK_ZERO_ON_NEW_ENT);
43 
44  level._entityShutDownCBFunc = &‪helicopter_sounds::heli_linkto_sound_ents_delete;
45  level.heliSoundValues = [];
46 
47  // heli_type, part_type, max_speed_vol, min_vol, max_vol, max_speed_pitch, min_pitch, max_pitch
48 
49  ‪init_heli_sound_values( "cobra", "turbine", 65, 0.6, 0.8, 65, 1, 1.1 );
50  ‪init_heli_sound_values( "cobra", "top_rotor", 45, 0.7, 1, 45, 0.95, 1.1);
51  ‪init_heli_sound_values( "cobra", "tail_rotor", 45, 0.5, 1, 45, 0.95, 1.1);
52 
53  ‪init_heli_sound_values( "hind", "turbine", 65, 0.6, 0.8, 65, 1, 1.1 );
54  ‪init_heli_sound_values( "hind", "top_rotor", 45, 0.7, 1, 45, 0.95, 1.1);
55  ‪init_heli_sound_values( "hind", "tail_rotor", 45, 0.5, 1, 45, 0.95, 1.1);
56 
57  ‪init_heli_sound_values( "supply", "turbine", 65, 0.7, 1, 65, 1, 1.1 );
58  ‪init_heli_sound_values( "supply", "top_rotor", 35, 0.95, 1, 100, 1, 1.1 );
59  ‪init_heli_sound_values( "supply", "tail_rotor", 35, 0.95, 1, 45, 1, 1.1 );
60 
61  ‪init_heli_sound_values( "huey", "turbine", 65, 0.7, 0.8, 65, 1, 1.1 );
62  ‪init_heli_sound_values( "huey", "top_rotor", 45, 0.8, 1, 45, 0.95, 1.1);
63  ‪init_heli_sound_values( "huey", "tail_rotor", 45, 0.6, 1, 45, 0.95, 1.0);
64  ‪init_heli_sound_values( "huey", "wind_rt", 45, 0.6, 1, 45, 0.95, 1.0);
65  ‪init_heli_sound_values( "huey", "wind_lft", 45, 0.6, 1, 45, 0.95, 1.0);
66 
67  ‪init_heli_sound_values( "qrdrone", "turbine_idle", 30, 0.8, 0.0, 16, .9, 1.1 );
68  ‪init_heli_sound_values( "qrdrone", "turbine_moving",30, 0.0, 0.9, 20, .9, 1.1 );
69  ‪init_heli_sound_values( "qrdrone", "turn", 5, 0, 1, 1, 1, 1 );
70 
71  ‪init_heli_sound_values( "heli_guard", "turbine", 10, 0.9, 1, 30, .9, 1.05 );
72  ‪init_heli_sound_values( "heli_guard", "rotor", 10, 0.9, 1, 30, .9, 1.1 );
73 
74 }
75 
76 function ‪vehicle_is_firing_function(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
77 {
78  /# println("vehicle is firing : " + newVal); #/
79 
80  if (newVal == 0)
81  {
82  self.isFiring = false;
83  }
84  else
85  {
86  self.isFiring = true;
87  }
88 
89 }
90 
91 
92 function ‪init_heli_sound_values( heli_type, part_type, max_speed_vol, min_vol, max_vol, max_speed_pitch, min_pitch, max_pitch )
93 {
94  if ( !isdefined( level.heliSoundValues[heli_type] ) )
95  {
96  level.heliSoundValues[heli_type] = [];
97  }
98  if ( !isdefined( level.heliSoundValues[heli_type][part_type] ) )
99  {
100  level.heliSoundValues[heli_type][part_type] = spawnStruct();
101  }
102 
103  level.heliSoundValues[heli_type][part_type].speedVolumeMax = max_speed_vol;
104  level.heliSoundValues[heli_type][part_type].speedPitchMax = max_speed_pitch;
105  level.heliSoundValues[heli_type][part_type].volumeMin = min_vol;
106  level.heliSoundValues[heli_type][part_type].volumeMax = max_vol;
107  level.heliSoundValues[heli_type][part_type].pitchMin = min_pitch;
108  level.heliSoundValues[heli_type][part_type].pitchMax = max_pitch;
109 }
110 
111 
112 
113 function ‪init_heli_sounds_gunner() //tag, type, bone, run
114 {
115  ‪setup_heli_sounds( "lfe", "engine", "snd_cockpit", "veh_huey_rotor_lfe" ); // Distant LFE
116  ‪setup_heli_sounds( "turbine", "engine", "snd_rotor", "veh_huey_turbine" ); // Turbine
117  ‪setup_heli_sounds( "top_rotor", "engine", "snd_rotor", "veh_huey_rotor" ); // Top Rotor
118  ‪setup_heli_sounds( "tail_rotor", "engine", "snd_tail_rotor", "veh_huey_tail" ); // Tail Rotor
119  ‪setup_heli_sounds( "wind_rt", "engine", "snd_wind_right", "veh_huey_door_wind"); // Wind right
120  //setup_heli_sounds( "wind_lft", "engine", "snd_wind_left", "veh_huey_door_wind"); // Wind left
121  ‪setup_heli_sounds( "radio", "engine", "snd_cockpit", "veh_huey_radio"); // radio cockpit
122  self.warning_tag = "snd_cockpit";
123 }
124 
125 function ‪init_heli_sounds_player_controlled() //tag, type, bone, run
126 {
127  ‪setup_heli_sounds( "lfe", "engine", "snd_cockpit", "veh_cobra_rotor_lfe" ); // Distant LFE
128  ‪setup_heli_sounds( "turbine", "engine", "snd_rotor", "veh_cobra_turbine" ); // Turbine
129  ‪setup_heli_sounds( "top_rotor", "engine", "snd_rotor", "veh_cobra_rotor" ); // Top Rotor
130  ‪setup_heli_sounds( "tail_rotor", "engine", "snd_tail_rotor", "veh_cobra_tail" ); // Tail Rotor
131  self.warning_tag = "snd_cockpit";
132 }
133 
134 function ‪init_heli_sounds_supply() //tag, type, bone, run
135 {
136  ‪setup_heli_sounds( "lfe", "engine", undefined, "veh_supply_rotor_lfe" ); // Distant LFE
137  ‪setup_heli_sounds( "turbine", "engine", undefined, "veh_supply_turbine" ); // Turbine
138  ‪setup_heli_sounds( "top_rotor", "engine", undefined, "veh_supply_rotor" ); // Top Rotor
139  self.warning_tag = undefined;
140 }
141 
142 function ‪init_heli_sounds_ai_attack() //tag, type, bone, run
143 {
144  ‪setup_heli_sounds( "lfe", "engine", undefined, "veh_hind_rotor_lfe" ); // Distant LFE
145  ‪setup_heli_sounds( "turbine", "engine", undefined, "veh_hind_turbine" ); // Turbine
146  ‪setup_heli_sounds( "top_rotor", "engine", undefined, "veh_hind_rotor" ); // Top Rotor
147  ‪setup_heli_sounds( "tail_rotor", "engine", undefined, "veh_hind_tail" ); // Tail Rotor
148 
149  self.warning_tag = undefined;
150 }
151 
152 function ‪init_heli_sounds_player_drone() //tag, type, bone, run
153 {
154  ‪setup_heli_sounds( "turbine_idle", "engine", "tag_body", "veh_qrdrone_turbine_idle" ); // Turbine
155  ‪setup_heli_sounds( "turbine_moving", "engine", "tag_body", "veh_qrdrone_turbine_moving" ); // Turbine
156  ‪setup_heli_sounds( "turn", "engine", "tag_body", "veh_qrdrone_idle_rotate" ); // Rotate angle
157  self.warning_tag = undefined;
158 }
159 
160 function ‪init_heli_sounds_heli_guard() //tag, type, bone, run
161 {
162  ‪setup_heli_sounds( "lfe", "engine", undefined, "veh_overwatch_lfe" ); // Distant LFE
163  ‪setup_heli_sounds( "turbine", "engine", undefined, "veh_overwatch_turbine" ); // Turbine
164  ‪setup_heli_sounds( "rotor", "engine", undefined, "veh_overwatch_rotor" ); // Rotor
165  self.warning_tag = undefined;
166 }
167 
168 
169 function ‪sound_linkto( parent, tag )
170 {
171  if( isdefined( tag ) )
172  self linkto( parent, tag );
173  else
174  self linkto( parent, "tag_body" );
175 }
176 
177 function ‪setup_heli_sounds( bone_location, type, tag, run, dmg1, dmg2, dmg3 )
178 {
179  self.heli[bone_location] = spawnStruct();
180  self.heli[bone_location].sound_type = type;
181 
182  self.heli[bone_location].run = ‪spawn( 0, self.origin, "script_origin" );
183  self.heli[bone_location].run ‪sound_linkto( self, tag );
184  self.heli[bone_location].run.alias = run;
185 
186  self thread ‪heli_loop_sound_delete( self.heli[bone_location].run );
187 
188  if( isdefined( dmg1 ) )
189  {
190  self.heli[bone_location].idle = ‪spawn( 0, self.origin, "script_origin" );
191  self.heli[bone_location].idle ‪sound_linkto( self, tag );
192  self.heli[bone_location].idle.alias = dmg1;
193 
194  self thread ‪heli_loop_sound_delete( self.heli[bone_location].dmg1 );
195  }
196  if( isdefined( dmg2 ) )
197  {
198  self.heli[bone_location].idle = ‪spawn( 0, self.origin, "script_origin" );
199  self.heli[bone_location].idle ‪sound_linkto( self, tag );
200  self.heli[bone_location].idle.alias = dmg2;
201 
202  self thread ‪heli_loop_sound_delete( self.heli[bone_location].dmg2 );
203  }
204  if( isdefined( dmg3 ) )
205  {
206  self.heli[bone_location].idle = ‪spawn( 0, self.origin, "script_origin" );
207  self.heli[bone_location].idle ‪sound_linkto( self, tag );
208  self.heli[bone_location].idle.alias = dmg3;
209 
210  self thread ‪heli_loop_sound_delete( self.heli[bone_location].dmg3 );
211  }
212 }
213 
215 {
216  self.surface_type = [];
217  // dirt
218  self.surface_type["default"] = "dirt";
219  self.surface_type["metal"] = "dirt";
220  self.surface_type["concrete"] = "dirt";
221  self.surface_type["wood"] = "dirt";
222  self.surface_type["dirt"] = "dirt";
223  self.surface_type["gravel"] = "dirt";
224  self.surface_type["grass"] = "dirt";
225  self.surface_type["mud"] = "dirt";
226  self.surface_type["snow"] = "dirt";
227  self.surface_type["asphalt"] = "dirt";
228  self.surface_type["brick"] = "dirt";
229  self.surface_type["glass"] = "dirt";
230  self.surface_type["plaster"] = "dirt";
231  self.surface_type["sand"] = "dirt";
232  self.surface_type["rock"] = "dirt";
233  // water
234  self.surface_type["water"] = "water";
235  // foliage
236  self.surface_type["foliage"] = "dirt";
237  //self.surface_type["foliage"] = "foliage";
238 
239  // create ents
240  self ‪setup_terrain_sounds( "dirt", "veh_chopper_prop_wash_dirt" );
241  self ‪setup_terrain_sounds( "water", "veh_chopper_prop_wash_water" );
242  //self setup_terrain_sounds( "foliage", "veh_chopper_prop_wash_foliage" );
243 }
244 
245 function ‪setup_terrain_sounds( surface_type, alias ) //self == helicopter
246 {
247  self.terrain_ent_array[surface_type] = ‪spawn( 0, self.origin, "script_origin" );
248  self.terrain_ent_array[surface_type].alias = alias;
249 
250  self thread ‪heli_loop_sound_delete( self.terrain_ent_array[surface_type] );
251 }
252 function ‪setup_terrain_brass_sounds( surface_type, alias ) //self == helicopter
253 {
254  self.terrain_brass_ent_array[surface_type] = ‪spawn( 0, self.origin, "script_origin" );
255  self.terrain_brass_ent_array[surface_type].alias = alias;
256 
257  self thread ‪heli_loop_sound_delete( self.terrain_brass_ent_array[surface_type] );
258 }
259 function ‪start_helicopter_sounds( localClientNum )
260 {
261  //printLn( "^5 ********* in start_helicopter_sounds ***********" );
262 
263  if( isdefined( self.sounddef ) )
264  {
265  self.heli = [];
266  self.terrain = [];
267  self.sound_ents = [];
268  self.cur_speed = 0;
269  self.mph_to_inches_per_sec = 17.6;
270  self.speed_of_wind = 20;//40; // in MPH
271  self.idle_run_trans_speed = 5; // in MPH
272 
273  switch( self.sounddef )
274  {
275  // cobra_mp - Default Attack heli - Cobra
276  case "veh_heli_ai_mp":
277  //self init_heli_sounds_ai_attack();
278  //self play_attack_ai_sounds();
279  break;
280 
281  // Overwatch - killstreak heli
282  case "veh_heli_guard_mp":
283  //self init_heli_sounds_heli_guard();
284  //self play_heli_guard_sounds();
285  break;
286 
287  // heli_supplydrop_mp - Supply drop killstreak heli - Chinoock
288  case "veh_heli_supplydrop_mp":
289  //self init_heli_sounds_supply();
290  //self play_supply_sounds();
291  break;
292 
293  // heli_gunner_mp - is the player gunner killstreak - Huey
294  case "veh_heli_gunner_mp":
295  //self init_heli_sounds_gunner();
296  //self play_gunner_sounds();
297  break;
298 
299  // heli_player_controlled_mp - is the player helicopter killstreak - hind
300  case "veh_heli_player_gunner_mp":
301  //self init_heli_sounds_player_controlled();
302  //self play_player_controlled_sounds();
303  break;
304 
305  case "veh_drn_qrdrone_mp":
306  //self init_heli_sounds_player_drone();
307  //self play_player_drone_sounds();
308  break;
309 
310  default:
311  /# printLn( "^5helicopter type: " + self.vehicletype + " vehicletype; playing no helicopter sounds" ); #/
312  break;
313  }
314  self ‪init_terrain_sounds();
315  self thread ‪terrain_trace();
316  }
317  else
318  {
319  /# printLn( "^6start_helicopter_sounds(): helicopter type not defined" ); #/
320  }
321 }
322 
323 function ‪heli_loop_sound_delete( real_ent )
324 {
325  self waittill( "entityshutdown" );
326  real_ent Unlink();
327  //wait (3);
328  real_ent StopAllLoopSounds( 4 );
329  real_ent delete();
330 }
331 
332 function ‪heli_linkto_sound_ents_delete( localClientNum, entity )
333 {
334  entity notify( "entityshutdown" );
335 }
336 
337 function ‪heli_sound_play( heli_bone )
338 {
339  switch( heli_bone.sound_type )
340  {
341  case "engine":
342  heli_bone.run playloopsound( heli_bone.run.alias, 2 );
343  break;
344  case "wind":
345  break;
346  default:
347  /# printLn( "^6 unknown helicopter type: " + heli_bone.type + " expecting \"wind\" or \"engine\""); #/
348  break;
349  }
350 }
351 
352 // *************************************************
353 // PLAY HELICOPTER SOUNDS SECTION
354 // This section plays the Helicopter sounds
355 // heli_sound_play () - Starts a thread to play a loop unaffected by the entity speed
356 // heli_idle_run_transition () - Starts a thread that will pitch and volume the loop based on the arguments
357 // heli_bone - The tag to play the loop on, this is set to a bone in the init
358 // max_speed_vol - the speed at which volume will stop attenuation
359 // min_vol - This is the volume of the loop when not moving
360 // max_vol - This is the volume of the loop when at max_speed_vol
361 // max_speed_pitch - The speed at which pitch will no longer change
362 // min_pitch - This is the pitch of the loop when not moving
363 // max_pitch - This is the amount of pitch when at max_speed_vol
364 // *************************************************
365 function ‪play_player_controlled_sounds() // self == helicopter Cobra
366 {
367  // ******* heli Cobra sounds, this is the player controled mp heli **************
368  self ‪heli_sound_play( self.heli["lfe"] ); // non-occulded, non-pitched 3d lfe
369  self thread ‪heli_idle_run_transition( "cobra", "turbine" );
370  self thread ‪heli_idle_run_transition( "cobra", "top_rotor");
371  self thread ‪heli_idle_run_transition( "cobra", "tail_rotor");
372 }
373 
374 function ‪play_attack_ai_sounds() // self == helicopter
375 {
376  // ******* heli Hind sounds, this is the AI controled mp heli **************
377  self ‪heli_sound_play( self.heli["lfe"] ); // non-occulded, non-pitched 3d lfe
378  self thread ‪heli_idle_run_transition( "hind", "turbine" );
379  self thread ‪heli_idle_run_transition( "hind", "top_rotor");
380  self thread ‪heli_idle_run_transition( "hind", "tail_rotor");
381 }
382 
383 function ‪play_supply_sounds() // self == helicopter
384 {
385  // ******* heli Chinoock sounds, this is the AI controled mp supply helicopter **************
386  self thread ‪heli_idle_run_transition( "supply", "turbine" );
387  self thread ‪heli_idle_run_transition( "supply", "top_rotor");
388  self ‪heli_sound_play( self.heli["lfe"] ); // non-occulded, non-pitched 3d lfe
389 }
390 
391 function ‪play_gunner_sounds() // self == helicopter
392 {
393  // ******* heli Huey sounds, this is the AI controled mp gunner helicopter, player hangs out side and fires **************
394  self ‪heli_sound_play( self.heli["lfe"] );
395  self ‪heli_sound_play( self.heli["radio"] ); // non-occulded, non-pitched 3d lfe
396  self thread ‪heli_idle_run_transition( "huey", "turbine" );
397  self thread ‪heli_idle_run_transition( "huey", "top_rotor");
398  self thread ‪heli_idle_run_transition( "huey", "tail_rotor");
399  self thread ‪heli_idle_run_transition( "huey", "wind_rt" );
400  //self thread heli_idle_run_transition( "huey", "wind_lft");
401 }
402 
403 function ‪play_player_drone_sounds() // self == helicopter Cobra
404 {
405  // ******* qrdrone **************
406  //self thread heli_idle_run_transition( "qrdrone", "turbine_idle", 0.1, 1 );
407  //self thread heli_idle_run_transition( "qrdrone", "turbine_moving", 0.1, 1 );
408  //self thread drone_up_down_transition();
409  //self thread drone_rotate_angle( "qrdrone", "turn" );
410 }
411 
413 {
414  self ‪heli_sound_play( self.heli["lfe"] );
415  self thread ‪heli_idle_run_transition( "heli_guard", "turbine" );
416  self thread ‪heli_idle_run_transition( "heli_guard", "rotor" );
417  self thread ‪terrain_trace_brass ();
418  //self thread tempBrassNotify ();
419 }
420 /*
421 function tempBrassNotify ()
422 {
423  while (1)
424  {
425  level waittill ("isfir");
426  self.isfiring = true;
427  level waittill ("nofir");
428  self.isfiring = false;
429  }
430 }
431 */
432 // *************************************************
433 // END OF PLAY HELICOPTER SOUNDS SECTION
434 // *************************************************
435 
436 // *************************************************
437 // HELICOPTER VOLUME/PITCH CHANGES
438 // *************************************************
439 function ‪heli_idle_run_transition( heli_type, heli_part, wait_time, updown )
440 {
441  self endon( "entityshutdown" );
442 
443  heli_bone = self.heli[heli_part];
444 
445  run_id = heli_bone.run playloopsound( heli_bone.run.alias, 0.5 );
446 
447  if (!isdefined( wait_time ) )
448  wait_time = 0.5;
449 
450  while( isdefined( self ) )
451  {
452  //audio::scale_speed( min_speed, max_speed, min_vol, max_vol, cur_speed );
453  if( !isdefined( level.heliSoundValues[heli_type] ) || !isdefined( level.heliSoundValues[heli_type][heli_part] ) )
454  {
455  /# printLn( "^5a speed vol/pitch parameter was not defined." ); #/
456  return;
457  }
458 
459  max_speed_vol = level.heliSoundValues[heli_type][heli_part].speedVolumeMax;
460  min_vol = level.heliSoundValues[heli_type][heli_part].volumeMin;
461  max_vol = level.heliSoundValues[heli_type][heli_part].volumeMax;
462  max_speed_pitch = level.heliSoundValues[heli_type][heli_part].speedPitchMax;
463  min_pitch = level.heliSoundValues[heli_type][heli_part].pitchMin;
464  max_pitch = level.heliSoundValues[heli_type][heli_part].pitchMax;
465 
466  /*
467  self.cur_speed = abs (self getspeed()) / self.mph_to_inches_per_sec;
468  */
469 
470  plr_vel = self getvelocity();
471  self.cur_speed = abs (sqrt (VectorDot (plr_vel,plr_vel)) ) / self.mph_to_inches_per_sec;
472 
473 
474  run_volume = ‪audio::scale_speed( self.idle_run_trans_speed, max_speed_vol, min_vol, max_vol, self.cur_speed );
475  run_pitch = ‪audio::scale_speed( self.idle_run_trans_speed, max_speed_pitch, min_pitch, max_pitch, self.cur_speed );
476 
477 
478  //attenuate move loop volume when moving vertically
479  if (isdefined(updown))
480  {
481  if (!isdefined (self.qrdrone_z_difference))
482  {
483  self.qrdrone_z_difference = 0;
484  }
485 
486  run_volume_vertical = ‪audio::scale_speed( 5, 50, 0, 1, abs (self.qrdrone_z_difference) );
487 
488  run_volume = run_volume - run_volume_vertical;
489  }
490 
491 
492 
493  if( isdefined( run_volume ) && isdefined( run_pitch ) )
494  {
495  //run_volume = 1;
496  //run_pitch = 1;
497 
498  //setSoundVolume( run_id, run_volume );
499  //setSoundPitch( run_id, run_pitch );
500  //setSoundPitchRate( run_id, 0.15 );
501  heli_bone.run setloopstate(heli_bone.run.alias, run_volume, run_pitch, 1, .15);
502  }
503 
504  wait( wait_time );
505  }
506 }
507 // *************************************************
508 // HELICOPTER BRASS ON GROUND SOUNDS
509 // *************************************************
511 {
512  self endon( "entityshutdown" );
513 
514  self ‪setup_terrain_brass_sounds( "dirt", "prj_brass_loop_dirt" );
515  self ‪setup_terrain_brass_sounds( "water", "prj_brass_loop_water" );
516 
517  self.isFiring = false;
518 
519  ‪trace = undefined;
520  trace_ent = self;
521 
522  pre_terrain = undefined;
523  next_terrain = undefined;
524 
525  pre_trace_real_ent = undefined;
526  trace_real_ent = undefined;
527  pre_origin = ( 100000, 100000, 100000 );
528 
529  while( isdefined( self ) )
530  {
531  wait( 1 + RandomFloatRange( 0.0, 0.2) );
532 
533  // do checks only if we moved more than a feet
534  if( DistanceSquared( pre_origin, trace_ent.origin ) < 144 )
535  {
536  continue;
537  }
538 
539  pre_origin = trace_ent.origin;
540 
541  ‪trace = tracepoint( trace_ent.origin, trace_ent.origin - ( 0, 0, 100000 ) );
542  //println( "btrace " + trace_ent.origin );
543  trace_surface_type = ‪trace["surfacetype"];
544 
545  if( !isdefined( ‪trace ) )
546  continue;
547 
548  pre_terrain = next_terrain;
549  next_terrain = trace_surface_type;
550  if( !isdefined( pre_terrain ) || !isdefined( next_terrain ) )
551  {
552  //printLn( "heli_script: this is in non defined trerrain" );
553  continue;
554  }
555 
556  if( !isdefined( self.surface_type[next_terrain] ) || !isdefined( self.surface_type[pre_terrain] ) )
557  {
558  continue;
559  }
560 
561  surf_type = self.surface_type[next_terrain];
562  trace_real_ent = self.terrain_brass_ent_array[surf_type];
563 
564  pre_surf_type = self.surface_type[pre_terrain];
565  pre_trace_real_ent = self.terrain_brass_ent_array[pre_surf_type];
566 
567  if( !isdefined( ‪trace["position"] ) )
568  {
569  if( isdefined( pre_trace_real_ent ) )
570  {
571  pre_trace_real_ent StopAllLoopSounds( 0.5 );
572  //printLn( "^5heli_script: STOP playing terrain sound (position undefined): " + pre_surf_type );
573  }
574  continue;
575  }
576  if (!self.isFiring)
577  {
578  pre_trace_real_ent StopAllLoopSounds( 0.5 );
579  }
580  //update origin
581  trace_real_ent.origin = ‪trace["position"];
582  pre_trace_real_ent.origin = ‪trace["position"];
583  if( isdefined( surf_type ) && self.isFiring )
584  {
585  if( ( surf_type == pre_surf_type ) && ( pre_trace_real_ent IsPlayingLoopSound() ) )
586  continue;
587 
588  //printLn( "^5heli_script: STOP playing terrain sound: " + pre_surf_type + " surface '" + pre_terrain + "'" );
589  pre_trace_real_ent StopAllLoopSounds( 0.5 );
590 
591  //printLn( "^6heli_script: START playing terrain sound: " + surf_type + " surface '" + next_terrain + "'" );
592  trace_real_ent PlayLoopSound( trace_real_ent.alias, 0.75 );
593  }
594  }
595 }
596 
597 // *************************************************
598 // HELICOPTER TERRAIN SOUNDS (PROP WASH)
599 // *************************************************
601 {
602  self endon( "entityshutdown" );
603 
604  ‪trace = undefined;
605  trace_ent = self;
606 
607  pre_terrain = undefined;
608  next_terrain = undefined;
609 
610  pre_trace_real_ent = undefined;
611  trace_real_ent = undefined;
612  pre_origin = ( 100000, 100000, 100000 );
613 
614  while( isdefined( self ) )
615  {
616  wait( 1 + RandomFloatRange( 0.0, 0.2) );
617 
618  // do checks only if we moved more than a feet
619  if( DistanceSquared( pre_origin, trace_ent.origin ) < 144 )
620  {
621  continue;
622  }
623 
624  pre_origin = trace_ent.origin;
625 
626  ‪trace = tracepoint( trace_ent.origin, trace_ent.origin - ( 0, 0, 100000 ) );
627  //println( "btrace " + trace_ent.origin );
628  trace_surface_type = ‪trace["surfacetype"];
629 
630  if( !isdefined( ‪trace ) )
631  continue;
632 
633  pre_terrain = next_terrain;
634  next_terrain = trace_surface_type;
635  if( !isdefined( pre_terrain ) || !isdefined( next_terrain ) )
636  {
637  //printLn( "heli_script: this is in non defined trerrain" );
638  continue;
639  }
640 
641  if( !isdefined( self.surface_type[next_terrain] ) || !isdefined( self.surface_type[pre_terrain] ) )
642  {
643  continue;
644  }
645 
646  surf_type = self.surface_type[next_terrain];
647  trace_real_ent = self.terrain_ent_array[surf_type];
648 
649  pre_surf_type = self.surface_type[pre_terrain];
650  pre_trace_real_ent = self.terrain_ent_array[pre_surf_type];
651 
652  if( !isdefined( ‪trace["position"] ) )
653  {
654  if( isdefined( pre_trace_real_ent ) )
655  {
656  pre_trace_real_ent StopAllLoopSounds( 0.5 );
657  //printLn( "^5heli_script: STOP playing terrain sound (position undefined): " + pre_surf_type );
658  }
659  continue;
660  }
661 
662  //update origin
663  trace_real_ent.origin = ‪trace["position"];
664  pre_trace_real_ent.origin = ‪trace["position"];
665  if( isdefined( surf_type ) )
666  {
667  if( ( surf_type == pre_surf_type ) && ( pre_trace_real_ent IsPlayingLoopSound() ) )
668  continue;
669 
670  //printLn( "^5heli_script: STOP playing terrain sound: " + pre_surf_type + " surface '" + pre_terrain + "'" );
671  pre_trace_real_ent StopAllLoopSounds( 0.5 );
672 
673  //printLn( "^6heli_script: START playing terrain sound: " + surf_type + " surface '" + next_terrain + "'" );
674  trace_real_ent PlayLoopSound( trace_real_ent.alias, 0.5 );
675  }
676  }
677 }
678 
679 function ‪aircraft_dustkick(localClientNum)
680 {
681 
682 /# printLn( "^stated aircraft_dustkick" ); #/
683  self endon( "entityshutdown" );
684 
685  maxHeight = 1200;
686  minHeight = 350;
687 
688  if ( self.vehicletype == "qrdrone_mp" )
689  {
690  maxHeight = 120;
691  minHeight = 1;
692  }
693 
694  slowestRepeatWait = 0.15;
695  fastestRepeatWait = 0.05;
696 
697  numFramesPerTrace = 3;
698  doTraceThisFrame = numFramesPerTrace;
699 
700  defaultRepeatRate = 1.0;
701  repeatRate = defaultRepeatRate;
702 
703  ‪trace = undefined;
704  d = undefined;
705 
706  trace_ent = self;
707 
708  while( isdefined( self ) )
709  {
710  if( repeatRate <= 0 )
711  {
712  repeatRate = defaultRepeatRate;
713  }
714 
715  if (!‪util::server_wait( localClientNum, repeatRate ))
716  { // wait failed, we may have rewinded
717  continue;
718  }
719 
720  if( !isdefined( self ) )
721  {
722  return;
723  }
724 
725  doTraceThisFrame -- ;
726 
727 
728  if( doTraceThisFrame <= 0 )
729  {
730  doTraceThisFrame = numFramesPerTrace;
731 
732  ‪trace = bullettrace( trace_ent.origin, trace_ent.origin -( 0, 0, 100000 ), false, trace_ent );
733  /*
734  trace["entity"]
735  trace["fraction"]
736  trace["normal"]
737  trace["position"]
738  trace["surfacetype"]
739  */
740 
741  d = distance( trace_ent.origin, ‪trace["position"] );
742 
743  repeatRate = ( ( d - minHeight ) /( maxHeight - minHeight ) ) *( slowestRepeatWait - fastestRepeatWait ) + fastestRepeatWait;
744  }
745 
746  if( !isdefined( ‪trace ) )
747  {
748  continue;
749  }
750 
751  assert( isdefined( d ) );
752 
753  if( d > maxHeight )
754  {
755  repeatRate = defaultRepeatRate;
756  continue;
757  }
758 
759  if( isdefined( ‪trace["entity"] ) )
760  {
761  repeatRate = defaultRepeatRate;
762  continue;
763  }
764 
765  if( !isdefined( ‪trace["position"] ) )
766  {
767  repeatRate = defaultRepeatRate;
768  continue;
769  }
770 
771  if( !isdefined( ‪trace["surfacetype"] ) )
772  {
773  ‪trace["surfacetype"] = "dirt";
774  }
775 
776  //-- Glocke (12/16/2008) converted to prints from asserts while I come up with a better solution with Laufer
777  if ( !IsDefined( self.treadfxnamearray ) || !isdefined( self.treadfxnamearray[‪trace["surfacetype"]] ) )
778  {
779  /#
780  if ( isdefined( self.vehicletype ) )
781  {
782  println("SCRIPT PRINT: Unknown surface type " + ‪trace["surfacetype"] + " for vehicle type " + self.vehicletype);
783  }
784  else
785  {
786  println("SCRIPT PRINT: Unknown surface type " + ‪trace["surfacetype"] + " for vehicle of undefined vehicletype" );
787  }
788  #/
789  return;
790  }
791  //assert( isdefined( vehicle.treadfxnamearray[trace["surfacetype"]] ), "UNKNOWN SURFACE TYPE: " + trace["surfacetype"] );
792 
793 
794  if( isdefined( self.treadfxnamearray[‪trace["surfacetype"]] ) )
795  {
796  //printLn( "^6this is defaulting dirt" );
797  //println("SCRIPT PRINT: Unknown surface type " + trace["surfacetype"] + " for vehicle type " + self.vehicletype);
798  playfx( localClientNum, self.treadfxnamearray[‪trace["surfacetype"]], ‪trace["position"] );
799  //print3d( trace["position"], "+" + self.treadfxnamearray[trace["surfacetype"]], ( 0, 1, 0 ), 1, 3, 30 );
800  }
801  }
802 }
803 
804 function ‪play_targeting_sound( ‪play, sound, handle )
805 {
806  sound_ent = ‪get_lock_sound_ent();
807  if ( ‪play )
808  {
809  return sound_ent PlayLoopSound ( sound );
810  }
811  else if ( isdefined(handle) )
812  {
813  sound_ent StopAllLoopSounds( 0.1 );
814  return undefined;
815  }
816 }
817 
819 {
820  self.lockingSound = ‪play_targeting_sound( ‪play, "veh_hind_alarm_missile_locking_mp", self.lockingSound );
821 }
822 
824 {
825  self.lockedSound = ‪play_targeting_sound( ‪play, "veh_hind_alarm_missile_locked_mp", self.lockedSound );
826 }
827 
829 {
830  self.firedSound = ‪play_targeting_sound( ‪play, "veh_hind_alarm_missile_fired", self.firedSound );
831 }
832 
834 {
835  sound_ent = ‪get_leaving_sound_ent();
836  if ( ‪play )
837  {
838  self.leavingBattlefieldSound = sound_ent PlayLoopSound ( "veh_helicopter_alarm" );
839  }
840  else if ( isdefined(self.leavingBattlefieldSound) && self.leavingBattlefieldSound )
841  {
842  sound_ent StopAllLoopSounds( 0.1 );
843  }
844 }
845 
846 function ‪get_heli_sound_ent( sound_ent )
847 {
848  if ( !isdefined(sound_ent))
849  {
850  tag = "tag_origin";
851  if ( isdefined(self.warning_tag) )
852  {
853  tag = self.warning_tag;
854  }
855  sound_ent = ‪spawn( 0, self GetTagOrigin( tag ), "script_origin" );
856  sound_ent linkto( self, tag );
857 
858  self thread ‪heli_sound_ent_delete( sound_ent );
859  }
860 
861  return sound_ent;
862 }
863 
865 {
866  self.lock_sound_ent = ‪get_heli_sound_ent( self.lock_sound_ent );
867 
868  return self.lock_sound_ent;
869 }
870 
872 {
873  self.leaving_sound_ent = ‪get_heli_sound_ent( self.leaving_sound_ent );
874 
875  return self.leaving_sound_ent;
876 }
877 
878 function ‪heli_sound_ent_delete( real_ent )
879 {
880  self waittill( "entityshutdown" );
881  real_ent StopAllLoopSounds( 0.1 );
882  real_ent delete();
883 }
884 
885 
886 
888 {
889  self endon( "entityshutdown" );
890 
891  volumerate = 1;
892 
893  qr_ent_up = ‪spawn( 0, self.origin, "script_origin" );
894  qr_ent_down = ‪spawn( 0, self.origin, "script_origin" );
895  qr_ent_either = ‪spawn( 0, self.origin, "script_origin" );
896 
897  qr_ent_up thread ‪qr_ent_cleanup(self);
898  qr_ent_down thread ‪qr_ent_cleanup(self);
899  qr_ent_either thread ‪qr_ent_cleanup(self);
900 
901  self.qrdrone_z_difference = 0;
902 
903  down = qr_ent_down playloopsound ("veh_qrdrone_move_down");
904  //setSoundVolume( down, 0 );
905  qr_ent_down setloopstate("veh_qrdrone_move_down", 0, 0);
906 
907 
908  up = qr_ent_up playloopsound ("veh_qrdrone_move_up");
909  //setSoundVolume( up, 0 );
910  qr_ent_up setloopstate("veh_qrdrone_move_up", 0, 0);
911 
912 
913  either = qr_ent_either playloopsound ("veh_qrdrone_vertical");
914  //setSoundVolume( either, 0 );
915  qr_ent_either setloopstate("veh_qrdrone_vertical", 0, 0);
916 
917 
918  tag = "tag_body";
919  qr_ent_up linkto (self, tag);
920  qr_ent_down linkto (self, tag);
921  qr_ent_either linkto (self, tag);
922 
923  //self thread drone_button_watch("BUTTON_RSHLDR");
924  //self thread drone_button_watch("BUTTON_LSHLDR");
925  self thread ‪drone_button_watch();
926 
927  while(1)
928  {
929  last_pos = self.origin[2];
930  wait (.1);
931  //curr_pos = self.origin[2];
932 
933  self.qrdrone_z_difference = (last_pos - self.origin[2]);
934 
935  if ( self.qrdrone_z_difference < 0)
936  {
937  up_difference = self.qrdrone_z_difference * -1;
938  run_volume_up = ‪audio::scale_speed( 5, 40, 0, 1, up_difference );
939  run_pitch_up = ‪audio::scale_speed( 5, 40, .9, 1.1, up_difference );
940 
941  run_volume_either = ‪audio::scale_speed( 5, 50, 0, 1, up_difference );
942  run_pitch_either = ‪audio::scale_speed( 5, 50, .9, 1.1, up_difference );
943  }
944  else
945  {
946  run_volume_up = 0;
947  run_pitch_up = 1;
948 
949  run_volume_either = ‪audio::scale_speed( 5, 50, 0, 1, self.qrdrone_z_difference );
950  run_pitch_either = ‪audio::scale_speed( 5, 50, .95, .8, self.qrdrone_z_difference );
951  }
952 
953  run_volume_down = ‪audio::scale_speed( 5, 50, 0, 1, self.qrdrone_z_difference );
954  run_pitch_down = ‪audio::scale_speed( 5, 50, 1, .8, self.qrdrone_z_difference );
955 
956  /*
957  setSoundVolumeRate (up, volumerate);
958  setSoundVolumeRate (down, volumerate);
959  setSoundVolumeRate (either, volumerate);
960 
961  setSoundVolume( up, run_volume_up );
962  setSoundPitch( up, run_pitch_up );
963  setSoundVolume( down, run_volume_down );
964  setSoundPitch( down, run_pitch_down );
965 
966  setSoundVolume( either, run_volume_either );
967  setSoundPitch( either, run_pitch_either );
968  */
969 
970  qr_ent_down setloopstate("veh_qrdrone_move_down", run_volume_down, run_pitch_down, volumerate);
971 
972  qr_ent_up setloopstate("veh_qrdrone_move_up", run_volume_up, run_pitch_up, volumerate);
973 
974  qr_ent_either setloopstate("veh_qrdrone_vertical", run_volume_either, run_pitch_either, volumerate);
975 
976  }
977 }
978 
979 
980 function ‪qr_ent_cleanup(veh_ent)
981 {
982  veh_ent waittill ("entityshutdown");
983  self delete();
984 }
985 
986 
987 function ‪drone_rotate_angle( heli_type, heli_part ) //self == drone
988 {
989  self endon( "entityshutdown" );
990  level endon( "save_restore" );
991 
992  volumerate = 2.5;
993 
994  qr_ent_angle = ‪spawn( 0, self.origin, "script_origin" );
995  qr_ent_angle thread ‪qr_ent_cleanup (self);
996 
997  angle = qr_ent_angle playloopsound ("veh_qrdrone_idle_rotate");
998  setSoundVolume( angle, 0 );
999 
1000  tag = "tag_body";
1001  qr_ent_angle linkto (self, tag);
1002 
1003 
1004  while( 1 )
1005  {
1006 
1007  last_angle = abs( self.angles[1] );
1008 
1009  wait (.1);
1010 
1011  turning_speed = last_angle - abs( self.angles[1] );
1012 
1013  abs_turning_speed = abs(turning_speed);
1014 
1015 
1016 
1017  jet_stick_vol = ‪audio::scale_speed ( 0, 5, 0, .4, abs_turning_speed);
1018  jet_stick_pitch = ‪audio::scale_speed ( 0, 4, .9, 1.05, abs_turning_speed);
1019 
1020  //setSoundVolumeRate (angle, volumerate);
1021  //setSoundVolume ( angle, jet_stick_vol );
1022  //setSoundPitch ( angle, jet_stick_pitch );
1023 
1024  qr_ent_angle setloopstate("veh_qrdrone_idle_rotate", jet_stick_vol, jet_stick_pitch, volumerate);
1025  }
1026 }
1027 
1028 
1029 
1031 {
1032  self endon( "entityshutdown" );
1033 
1034  player = getlocalplayers()[0];
1035  return_to_zero= true;
1036 
1037  while (1)
1038  {
1039  if ( abs (self.qrdrone_z_difference) > 5 && return_to_zero)
1040  {
1041  self playsound (0, "veh_qrdrone_move_start");
1042  return_to_zero = false;
1043 
1044  /*
1045  while (abs (self.qrdrone_z_difference) > 10)
1046  {
1047  wait (.05);
1048  }
1049 
1050  check_speed = audio::scale_speed( 5, 50, 0, 1, self.qrdrone_z_difference );
1051  while (check_speed < .1)
1052  {
1053  wait (.05);
1054  check_speed = audio::scale_speed( 5, 50, 0, 1, self.qrdrone_z_difference );
1055  }
1056  */
1057 
1058  }
1059 
1060  else if (abs (self.qrdrone_z_difference) < 5 && !return_to_zero )
1061  {
1062  return_to_zero = true;
1063  }
1064  wait (.05);
1065  }
1066 }
‪init_heli_sounds_gunner
‪function init_heli_sounds_gunner()
Definition: _helicopter_sounds.csc:113
‪play_targeting_sound
‪function play_targeting_sound(play, sound, handle)
Definition: _helicopter_sounds.csc:804
‪play_leaving_battlefield_alarm
‪function play_leaving_battlefield_alarm(play)
Definition: _helicopter_sounds.csc:833
‪__init__
‪function __init__()
Definition: _helicopter_sounds.csc:38
‪play_locked_sound
‪function play_locked_sound(play)
Definition: _helicopter_sounds.csc:823
‪drone_up_down_transition
‪function drone_up_down_transition()
Definition: _helicopter_sounds.csc:887
‪play_fired_sound
‪function play_fired_sound(play)
Definition: _helicopter_sounds.csc:828
‪setup_terrain_brass_sounds
‪function setup_terrain_brass_sounds(surface_type, alias)
Definition: _helicopter_sounds.csc:252
‪setup_heli_sounds
‪function setup_heli_sounds(bone_location, type, tag, run, dmg1, dmg2, dmg3)
Definition: _helicopter_sounds.csc:177
‪play_player_drone_sounds
‪function play_player_drone_sounds()
Definition: _helicopter_sounds.csc:403
‪play
‪function play(animation, v_origin_or_ent, v_angles_or_tag, n_rate=1, n_blend_in=.2, n_blend_out=.2, n_lerp, b_link=false)
Definition: animation_shared.csc:44
‪get_heli_sound_ent
‪function get_heli_sound_ent(sound_ent)
Definition: _helicopter_sounds.csc:846
‪drone_button_watch
‪function drone_button_watch()
Definition: _helicopter_sounds.csc:1030
‪get_lock_sound_ent
‪function get_lock_sound_ent()
Definition: _helicopter_sounds.csc:864
‪init_heli_sounds_supply
‪function init_heli_sounds_supply()
Definition: _helicopter_sounds.csc:134
‪heli_idle_run_transition
‪function heli_idle_run_transition(heli_type, heli_part, wait_time, updown)
Definition: _helicopter_sounds.csc:439
‪trace
‪function trace(from, to, target)
Definition: grapple.gsc:369
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪vehicle_is_firing_function
‪function vehicle_is_firing_function(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _helicopter_sounds.csc:76
‪sound_linkto
‪function sound_linkto(parent, tag)
Definition: _helicopter_sounds.csc:169
‪init_heli_sound_values
‪function init_heli_sound_values(heli_type, part_type, max_speed_vol, min_vol, max_vol, max_speed_pitch, min_pitch, max_pitch)
Definition: _helicopter_sounds.csc:92
‪scale_speed
‪function scale_speed(x1, x2, y1, y2, z)
Definition: audio_shared.csc:752
‪play_player_controlled_sounds
‪function play_player_controlled_sounds()
Definition: _helicopter_sounds.csc:365
‪init_heli_sounds_player_controlled
‪function init_heli_sounds_player_controlled()
Definition: _helicopter_sounds.csc:125
‪play_gunner_sounds
‪function play_gunner_sounds()
Definition: _helicopter_sounds.csc:391
‪init_heli_sounds_ai_attack
‪function init_heli_sounds_ai_attack()
Definition: _helicopter_sounds.csc:142
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪init_heli_sounds_player_drone
‪function init_heli_sounds_player_drone()
Definition: _helicopter_sounds.csc:152
‪heli_linkto_sound_ents_delete
‪function heli_linkto_sound_ents_delete(localClientNum, entity)
Definition: _helicopter_sounds.csc:332
‪aircraft_dustkick
‪function aircraft_dustkick(localClientNum)
Definition: _helicopter_sounds.csc:679
‪start_helicopter_sounds
‪function start_helicopter_sounds(localClientNum)
Definition: _helicopter_sounds.csc:259
‪qr_ent_cleanup
‪function qr_ent_cleanup(veh_ent)
Definition: _helicopter_sounds.csc:980
‪setup_terrain_sounds
‪function setup_terrain_sounds(surface_type, alias)
Definition: _helicopter_sounds.csc:245
‪drone_rotate_angle
‪function drone_rotate_angle(heli_type, heli_part)
Definition: _helicopter_sounds.csc:987
‪play_supply_sounds
‪function play_supply_sounds()
Definition: _helicopter_sounds.csc:383
‪terrain_trace
‪function terrain_trace()
Definition: _helicopter_sounds.csc:600
‪heli_sound_play
‪function heli_sound_play(heli_bone)
Definition: _helicopter_sounds.csc:337
‪heli_sound_ent_delete
‪function heli_sound_ent_delete(real_ent)
Definition: _helicopter_sounds.csc:878
‪server_wait
‪function server_wait(localClientNum, seconds, waitBetweenChecks, level_endon)
Definition: util_shared.csc:1125
‪play_heli_guard_sounds
‪function play_heli_guard_sounds()
Definition: _helicopter_sounds.csc:412
‪play_attack_ai_sounds
‪function play_attack_ai_sounds()
Definition: _helicopter_sounds.csc:374
‪play_targeted_sound
‪function play_targeted_sound(play)
Definition: _helicopter_sounds.csc:818
‪get_leaving_sound_ent
‪function get_leaving_sound_ent()
Definition: _helicopter_sounds.csc:871
‪heli_loop_sound_delete
‪function heli_loop_sound_delete(real_ent)
Definition: _helicopter_sounds.csc:323
‪init_terrain_sounds
‪function init_terrain_sounds()
Definition: _helicopter_sounds.csc:214
‪init_heli_sounds_heli_guard
‪function init_heli_sounds_heli_guard()
Definition: _helicopter_sounds.csc:160
‪terrain_trace_brass
‪function terrain_trace_brass()
Definition: _helicopter_sounds.csc:510