#using scripts\codescripts\struct; #using scripts\shared\array_shared; #using scripts\shared\flag_shared; function main() { setup_pa_speakers(); setup_location_available_array(); setup_pa_alias_variation_arrays(); level thread play_pa_intercom(); level thread vox_emergency_broadcast_init(); } function play_alarm_sfx() //Self is individual speaker entity { if( !isdefined( self.str_current_playing_alias ) ) { return; } self StopSound( self.str_current_playing_alias ); wait ( .05 ); //self PlaySound( "amb_city_intercom_interrupt" ); //wait ( 1.5 ); //n_delay_time_in_sec = ( RandomInt( 100 ) + 1 ) /350; //wait ( n_delay_time_in_sec ); self PlayLoopSound ( "amb_vortex_alarm" ); while ( level flag::get( "city_vortex_sequence_playing" ) ) { wait ( 1 ); } self StopLoopSound(); } function setup_location_available_array() { for ( i = 0; i < 5; i++ ) { level.a_n_location_available[ i ] = i; } } function setup_pa_speakers() { level.a_e_pa_speakers_all = []; level.a_e_pa_speakers_medical = []; s_speakers = struct::get_array( "snd_medical_pa" ,"targetname" ); foreach( speakerstruct in s_speakers ) { e_snd = spawn( "script_model", speakerstruct.origin ); level.a_e_pa_speakers_medical[level.a_e_pa_speakers_medical.size] = e_snd; level.a_e_pa_speakers_all[level.a_e_pa_speakers_all.size] = e_snd; e_snd.script_string = speakerstruct.script_string; } level.a_e_pa_speakers_science = []; s_speakers = struct::get_array( "snd_science_pa" ,"targetname" ); foreach( speakerstruct in s_speakers ) { e_snd = spawn( "script_model", speakerstruct.origin ); level.a_e_pa_speakers_science[level.a_e_pa_speakers_science.size] = e_snd; level.a_e_pa_speakers_all[level.a_e_pa_speakers_all.size] = e_snd; e_snd.script_string = speakerstruct.script_string; } level.a_e_pa_speakers_housing = []; s_speakers = struct::get_array( "snd_housing_pa" ,"targetname" ); foreach( speakerstruct in s_speakers ) { e_snd = spawn( "script_model", speakerstruct.origin ); level.a_e_pa_speakers_housing[level.a_e_pa_speakers_housing.size] = e_snd; level.a_e_pa_speakers_all[level.a_e_pa_speakers_all.size] = e_snd; e_snd.script_string = speakerstruct.script_string; } level.a_e_pa_speakers_security = []; s_speakers = struct::get_array( "snd_security_pa" ,"targetname" ); foreach( speakerstruct in s_speakers ) { e_snd = spawn( "script_model", speakerstruct.origin ); level.a_e_pa_speakers_security[level.a_e_pa_speakers_security.size] = e_snd; level.a_e_pa_speakers_all[level.a_e_pa_speakers_all.size] = e_snd; e_snd.script_string = speakerstruct.script_string; } level.a_e_pa_speakers_loop = []; s_speakers = struct::get_array( "snd_loop_pa" ,"targetname" ); foreach( speakerstruct in s_speakers ) { e_snd = spawn( "script_model", speakerstruct.origin ); level.a_e_pa_speakers_loop[level.a_e_pa_speakers_loop.size] = e_snd; level.a_e_pa_speakers_all[level.a_e_pa_speakers_all.size] = e_snd; } for ( i = 0; i < 5; i++ ) { level.a_n_location_ident[ i ] = i; } } function setup_pa_alias_variation_arrays() { level.a_n_alias_counts = array( 20, 20, 20, 20, 10 ); foreach (location in level.a_n_location_ident) { for (i = 0; i < level.a_n_alias_counts[ location ]; i++) { level.a_n_line_variation[ location ][ i ] = i + 1; //+1 since alias line numbers are indexed at 1 to match the fdx script. } } } function setup_individual_pa_alias_variation_array( n_location_ident ) { for (i = 0; i < level.a_n_alias_counts[ n_location_ident ]; i++) { level.a_n_line_variation[ n_location_ident ][ i ] = i; } } function play_pa_intercom() { while( 1 ) { if( !level flag::get( "city_vortex_sequence_playing" ) ) { n_location_ident = array::random( level.a_n_location_available ); a_e_pa_locations = get_pa_locations( n_location_ident ); str_sound_alias = get_pa_sound_alias( n_location_ident ); foreach (location in a_e_pa_locations) { if( isdefined( location.script_string ) && location.script_string == "indoor" ) { str_sound_alias_indoor = str_sound_alias + "_ind"; location PlaySound( str_sound_alias_indoor ); location.str_current_playing_alias = str_sound_alias_indoor; } else { location PlaySound( str_sound_alias ); location.str_current_playing_alias = str_sound_alias; } } level.a_n_location_available = array::exclude( level.a_n_location_available, n_location_ident ); if ( level.a_n_location_available.size == 0 ) { setup_location_available_array(); } } wait( RandomFloatRange( 10, 15 ) ); } } function get_pa_locations( n_location_ident ) { switch ( n_location_ident ) { case 0: s_pa_speaker_locations = level.a_e_pa_speakers_medical; break; case 1: s_pa_speaker_locations = level.a_e_pa_speakers_science; break; case 2: s_pa_speaker_locations = level.a_e_pa_speakers_housing; break; case 3: s_pa_speaker_locations = level.a_e_pa_speakers_security; break; case 4: s_pa_speaker_locations = level.a_e_pa_speakers_loop; break; } return s_pa_speaker_locations; } function get_pa_sound_alias( n_location_ident ) { switch ( n_location_ident ) { case 0: str_alias_prefix = "vox_pavo_medical_"; n_total_lines = 20; break; case 1: str_alias_prefix = "vox_pavo_science_"; n_total_lines = 20; break; case 2: str_alias_prefix = "vox_pavo_housing_"; n_total_lines = 20; break; case 3: str_alias_prefix = "vox_pavo_security_"; n_total_lines = 20; break; case 4: str_alias_prefix = "vox_pavo_loop_"; n_total_lines = 10; break; } n_variation = get_next_line_variation( n_location_ident ); str_sound_alias = str_alias_prefix + n_variation; return str_sound_alias; } function get_next_line_variation( n_location_ident ) { if ( level.a_n_line_variation[ n_location_ident ].size == 0 ) { setup_individual_pa_alias_variation_array( n_location_ident ); } line_variation = array::random( level.a_n_line_variation[ n_location_ident ] ); level.a_n_line_variation[ n_location_ident ] = array::exclude( level.a_n_line_variation[ n_location_ident ], ( line_variation ) ); return line_variation; } function vox_emergency_broadcast_init() { a_s_speakers = struct::get_array( "snd_emergency" ,"targetname" ); level thread vortex_sequence_done_watcher(); if( !isdefined( a_s_speakers ) ) { return; } for (i = 0; i < 10; i++) { a_str_emergency_aliases[i] = "vox_emer_emergency_" + ( i + 1 ); } vox_emergency_broadcast_play( a_s_speakers, a_str_emergency_aliases ); } function vox_emergency_broadcast_play( a_s_speakers, a_str_emergency_aliases ) { level endon( "disconnect" ); i = 0; while( 1 ) { foreach ( speaker in a_s_speakers ) { PlaySoundAtPosition( a_str_emergency_aliases[i], speaker.origin ); } if( i == 9 ) { i = 0; } else { i++; } wait( RandomFloatRange( 120, 180 ) ); } } function vortex_sequence_done_watcher() { level endon ("disconnect"); while( 1) { level waittill ( "snd_vortex_sequence_done" ); level flag::clear( "city_vortex_sequence_playing" ); wait( 1 ); } }