#include maps\_utility; #include maps\_equalizer; #include common_scripts\utility; /* Example map_amb.gsc file: main() { // Set the underlying ambient track level.ambient_track [ "exterior" ] = "ambient_test"; thread maps\_utility::set_ambient( "exterior" ); // Set the eq filter for the ambient channels // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // define a filter and give it a name // or use one of the presets( see _equalizer.gsc ) // arguments are: name, band, type, freq, gain, q // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // maps\_equalizer::defineFilter( "test", 0, "lowshelf", 3000, 6, 2 ); // maps\_equalizer::defineFilter( "test", 1, "highshelf", 3000, -12, 2 ); // maps\_equalizer::defineFilter( "test", 2, "bell", 1500, 6, 3 ); // attach the filter to a region and channel // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- add_channel_to_filter( track, channel ) ambientDelay( "exterior", 1.3, 3.4 );// Trackname, min and max delay between ambient events ambientEvent( "exterior", "burnville_foley_13b", 0.3 ); ambientEvent( "exterior", "boat_sink", 0.6 ); ambientEvent( "exterior", "bullet_large_canvas", 0.3 ); ambientEvent( "exterior", "explo_boat", 1.3 ); ambientEvent( "exterior", "Stuka_hit", 0.1 ); ambientEventStart( "exterior" ); } */ init() { level.ambient_zones = []; // this function can be overwritten to do custom stuff when an ambience trigger is hit if ( !isdefined( level.global_ambience_blend_func ) ) level.global_ambience_blend_func = ::empty_amb; add_zone( "ac130" ); add_zone( "alley" ); add_zone( "bunker" ); add_zone( "city" ); add_zone( "container" ); add_zone( "exterior" ); add_zone( "exterior1" ); add_zone( "exterior2" ); add_zone( "exterior3" ); add_zone( "exterior4" ); add_zone( "exterior5" ); add_zone( "forrest" ); add_zone( "hangar" ); add_zone( "interior" ); add_zone( "interior_metal" ); add_zone( "interior_stone" ); add_zone( "interior_vehicle" ); add_zone( "interior_wood" ); add_zone( "mountains" ); add_zone( "pipe" ); add_zone( "shanty" ); add_zone( "snow_base" ); add_zone( "snow_cliff" ); add_zone( "tunnel" ); add_zone( "underpass" ); /# create_ambience_hud(); #/ if ( !isdefined( level.ambientEventEnt ) ) level.ambientEventEnt = []; if ( !isDefined( level.ambient_reverb ) ) level.ambient_reverb = []; if ( !isDefined( level.ambient_eq ) ) level.ambient_eq = []; if ( !isDefined( level.fxfireloopmod ) ) level.fxfireloopmod = 1; level.reverb_track = ""; level.eq_main_track = 0; level.eq_mix_track = 1; level.eq_track[ level.eq_main_track ] = ""; level.eq_track[ level.eq_mix_track ] = ""; // used to change the meaning of interior / exterior / rain ambience midlevel. level.ambient_modifier[ "interior" ] = ""; level.ambient_modifier[ "exterior" ] = ""; level.ambient_modifier[ "rain" ] = ""; // loads any predefined filters in _equalizer.gsc loadPresets(); thread hud_hide_with_cg_draw_hud(); } empty_amb( p, i, o ) { } // starts this ambient track activateAmbient( ambient ) { thread set_ambience_single( ambient ); } ambientVolume() { for ( ;; ) { self waittill( "trigger" ); activateAmbient( "interior" ); while ( level.player isTouching( self ) ) wait 0.1; activateAmbient( "exterior" ); } } /* ============= ///ScriptDocBegin "Name: create_ambient_event( , , )" "Summary: Create an ambient event system. It plays random ambient sounds." "Module: Ambient" "MandatoryArg: : What to name it" "MandatoryArg: : The minimum time between sounds" "MandatoryArg: : The max time between sounds" "Example: event = create_ambient_event( "dcburning_bunker1", 5.0, 15.0 );" "SPMP: singleplayer" ///ScriptDocEnd ============= */ create_ambient_event( track, min_time, max_time ) { assertex( isdefined( level.eq_defs ), "_load must run before loading the _amb file for a map." ); assertex( !isdefined( level.ambientEventEnt[ track ] ), "Already created ambient event " + track ); assertEX( max_time > min_time, "Ambient max must be greater than min for track " + track ); event = spawnstruct(); event.min = min_time; event.range = max_time - min_time; event.event_alias = []; event.event_alias_no_block = []; event.track = track; level.ambientEventEnt[ track ] = event; /# event thread assert_event_has_aliases(); #/ return event; } assert_event_has_aliases() { waittillframeend; assertex( self.event_alias.size > 0 || self.event_alias_no_block.size > 0, "Added ambient event system " + self.track + " with no aliases." ); } /* ============= ///ScriptDocBegin "Name: add_to_ambient_event( , )" "Summary: Add a sound alias to an ambient event system." "Module: Ambient" "CallOn: An ambient event system (spawnstruct)" "MandatoryArg: : The sound alias" "MandatoryArg: : How often to play relative to other aliases in the system" "Example: event add_to_ambient_event( "elm_quake_sub_rumble", 1.0 );" "SPMP: singleplayer" ///ScriptDocEnd ============= */ add_to_ambient_event( name, weight ) { assertex( !isdefined( self.event_alias[ name ] ), "Cant change an ambient event weight for an alias (track " + self.track + ", alias " + name + ")" ); self.event_alias[ name ] = weight; } /* ============= ///ScriptDocBegin "Name: add_to_ambient_event_no_block( , )" "Summary: Add a sound alias to an ambient event system. This sound will not block other ambiences from playing after it." "Module: Ambient" "CallOn: An ambient event system (spawnstruct)" "MandatoryArg: : The sound alias" "MandatoryArg: : How often to play relative to other aliases in the system" "Example: event add_to_ambient_event( "elm_quake_sub_rumble", 1.0 );" "SPMP: singleplayer" ///ScriptDocEnd ============= */ add_to_ambient_event_no_block( name, weight ) { assertex( !isdefined( self.event_alias_no_block[ name ] ), "Cant change an ambient event weight for an alias (track " + self.track + ", alias " + name + ")" ); self.event_alias_no_block[ name ] = weight; } /* ============= ///ScriptDocBegin "Name: map_to_reverb_eq( )" "Summary: Map an ambient event system to reverb or eq tracks. So when the ambient event is activated, appropriate reverb and eq get activated too." "Module: Ambient" "CallOn: An ambient event system (spawnstruct)" "MandatoryArg: : The eq/reverb type to map to. For example exterior, bunker, alley, etc." "Example: event map_to_reverb_eq( "bunker" );" "SPMP: singleplayer" ///ScriptDocEnd ============= */ map_to_reverb_eq( eqReverb ) { // assertex( !isdefined( self.remap ), "Tried to remap reverb/eq mapping " + self.track ); // self.remap = eqReverb; // copy the reverb/eq settings over the specified settings level.eq_defs[ self.track ] = level.eq_defs[ eqReverb ]; level.ambient_eq[ self.track ] = level.ambient_eq[ eqReverb ]; level.ambient_reverb[ self.track ] = level.ambient_reverb[ eqReverb ]; } ambientDelay( track, min, max ) { create_ambient_event( track, min, max ); } ambientEvent( track, name, weight ) { assertEX( isdefined( level.ambientEventEnt ), "ambientDelay has not been run" ); assertEX( isdefined( level.ambientEventEnt[ track ] ), "ambientDelay has not been run" ); level.ambientEventEnt[ track ] add_to_ambient_event( name, weight ); } ambientEvent_no_block( track, name, weight ) { assertEX( isdefined( level.ambientEventEnt ), "ambientDelay has not been run" ); assertEX( isdefined( level.ambientEventEnt[ track ] ), "ambientDelay has not been run" ); level.ambientEventEnt[ track ] add_to_ambient_event_no_block( name, weight ); } getRemap( track ) { // if ( isdefined( self.remap ) ) // return self.remap; if ( track == "exterior" && isdefined( level.remap_exterior ) ) return level.remap_exterior; return track; } deactivate_reverb() { level.reverb_track = ""; level.player deactivatereverb( "snd_enveffectsprio_level", 2 ); clear_hud( "reverb" ); } ambientReverb( track ) { level notify( "reverb_overwrite" ); level endon( "reverb_overwrite" ); // first check if this track is remapped to a specific reverb track = getRemap( track ); reverb = level.ambient_reverb[ track ]; if ( !isdefined( reverb ) ) { deactivate_reverb(); return; } if ( level.reverb_track == track ) { // already doing this one return; } level.reverb_track = track; use_reverb_settings( track ); } use_reverb_settings( track ) { // red flashing overwrites reverb if ( level.player ent_flag( "player_has_red_flashing_overlay" ) ) return; reverb = level.ambient_reverb[ track ]; level.player setReverb( reverb[ "priority" ], reverb[ "roomtype" ], reverb[ "drylevel" ], reverb[ "wetlevel" ], reverb[ "fadetime" ] ); /# set_hud_track( "reverb", track ); #/ } /* ============= ///ScriptDocBegin "Name: map_exterior_to_reverb_eq( )" "Summary: Reverb and EQ will use this setting when "exterior" ambience is triggered." "Module: Ambient" "MandatoryArg: : The reverb/eq that exterior gets mapped to." "Example: map_exterior_to_reverb_eq( "snow_base" );" "SPMP: singleplayer" ///ScriptDocEnd ============= */ map_exterior_to_reverb_eq( reverb_eq ) { level.remap_exterior = reverb_eq; } ambientMapTo( track, eqReverb ) { assertEX( isdefined( level.ambientEventEnt ), "ambientDelay has not been run" ); assertEX( isdefined( level.ambientEventEnt[ track ] ), "ambientDelay has not been run" ); level.ambientEventEnt[ track ] map_to_reverb_eq( eqReverb ); } setup_new_eq_settings( track, eqIndex ) { // this track may be a remapped from an ambient event track. track = getRemap( track ); if ( !isdefined( track ) || !isdefined( level.ambient_eq[ track ] ) ) { deactivate_index( eqIndex ); return false; } if ( level.eq_track[ eqIndex ] == track ) { // already doing this one return false; } level.eq_track[ eqIndex ] = track; use_eq_settings( track, eqIndex ); return true; } /* ============= ///ScriptDocBegin "Name: blend_to_eq_track( ,