872 lines
20 KiB
Plaintext
872 lines
20 KiB
Plaintext
#include maps\mp\_utility;
|
|
#include common_scripts\utility;
|
|
|
|
init_audio()
|
|
{
|
|
if ( !IsDefined( level.audio ) )
|
|
{
|
|
level.audio = SpawnStruct();
|
|
}
|
|
|
|
init_reverb();
|
|
init_whizby();
|
|
|
|
level.onPlayerConnectAudioInit = ::OnPlayerConnectAudioInit;
|
|
}
|
|
|
|
OnPlayerConnectAudioInit()
|
|
{
|
|
self apply_reverb( "default" );
|
|
// self apply_whizby(); <-- Does not work yet... Looks like it overflows the server.
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// Reverb Section
|
|
//---------------------------------------------------------
|
|
init_reverb()
|
|
{
|
|
add_reverb( "default", "generic", 0.15, 0.9, 2 );
|
|
}
|
|
|
|
add_reverb( name, type, wetlevel, drylevel, fadetime )
|
|
{
|
|
Assert( IsDefined( type ) );
|
|
Assert( IsDefined( wetlevel ) );
|
|
Assert( IsDefined( drylevel ) );
|
|
|
|
reverb = [];
|
|
|
|
is_roomtype_valid( type );
|
|
|
|
reverb[ "roomtype" ] = type;
|
|
reverb[ "wetlevel" ] = wetlevel;
|
|
reverb[ "drylevel" ] = drylevel;
|
|
reverb[ "fadetime" ] = fadetime;
|
|
|
|
level.audio.reverb_settings[ name ] = reverb;
|
|
}
|
|
|
|
is_roomtype_valid( type )
|
|
{
|
|
/#
|
|
switch ( type )
|
|
{
|
|
case "generic":
|
|
case "paddedcell":
|
|
case "room":
|
|
case "bathroom":
|
|
case "livingroom":
|
|
case "stoneroom":
|
|
case "auditorium":
|
|
case "concerthall":
|
|
case "cave":
|
|
case "arena":
|
|
case "hangar":
|
|
case "carpetedhallway":
|
|
case "hallway":
|
|
case "stonecorridor":
|
|
case "alley":
|
|
case "forest":
|
|
case "city":
|
|
case "mountains":
|
|
case "quarry":
|
|
case "plain":
|
|
case "parkinglot":
|
|
case "sewerpipe":
|
|
case "underwater":
|
|
case "drugged":
|
|
case "dizzy":
|
|
case "psychotic":
|
|
return;
|
|
default:
|
|
AssertMsg( type + " is an Invalid Roomtype" );
|
|
break;
|
|
}
|
|
#/
|
|
}
|
|
|
|
apply_reverb( name )
|
|
{
|
|
if ( !IsDefined( level.audio.reverb_settings[ name ] ) )
|
|
{
|
|
reverb = level.audio.reverb_settings[ "default" ];
|
|
}
|
|
else
|
|
{
|
|
reverb = level.audio.reverb_settings[ name ];
|
|
}
|
|
|
|
self SetReverb( "snd_enveffectsprio_level", reverb[ "roomtype" ], reverb[ "drylevel" ], reverb[ "wetlevel" ], reverb[ "fadetime" ] );
|
|
// self SetClientDvar( "cg_levelReverbRoomType", reverb[ "roomtype" ] );
|
|
// self SetClientDvar( "cg_levelReverbDryLevel", reverb[ "drylevel" ] );
|
|
// self SetClientDvar( "cg_levelReverbWetLevel", reverb[ "wetlevel" ] );
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// whizBy Section
|
|
//---------------------------------------------------------
|
|
|
|
init_whizby()
|
|
{
|
|
SetDevDvar( "snd_newwhizby", 1 );
|
|
|
|
// Default settings -- Call wrappers in your level to overwrite.
|
|
level.audio.whizby_settings = [];
|
|
set_whizby_radius( 15.0, 30.0, 50.0 );
|
|
set_whizby_spread( 150.0, 250.0, 350.0 );
|
|
}
|
|
|
|
set_whizby_radius( near, medium, far )
|
|
{
|
|
level.audio.whizby_settings[ "radius" ] = [ near, medium, far ];
|
|
}
|
|
|
|
set_whizby_spread( near, medium, far )
|
|
{
|
|
level.audio.whizby_settings[ "spread" ] = [ near, medium, far ];
|
|
}
|
|
|
|
apply_whizby()
|
|
{
|
|
settings = level.audio.whizby_settings;
|
|
|
|
spread = settings[ "spread" ];
|
|
rad = settings[ "radius" ];
|
|
|
|
self SetWhizbySpreads( spread[ 0 ], spread[ 1 ], spread[ 2 ] );
|
|
self SetWhizbyRadii( rad[ 0 ], rad[ 1 ], rad[ 2 ] );
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_play_team_splash( ally_sfx, enemy_sfx )"
|
|
"Summary: Plays a 2d splash sound on all players based on what team they are on."
|
|
"CallOn: A Player"
|
|
"OptionalArg: < ally_sfx, enemy_sfx > : soundaliases you want to play on players that are ally or enemies."
|
|
"Example: warbird snd_play_team_splash( "my_team_captured_the_flag", "the_enemy_team_captured_the_flag" ) ;"
|
|
"SPMP: MP"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
snd_play_team_splash( ally_sfx, enemy_sfx )
|
|
{
|
|
if(!isdefined( ally_sfx ))
|
|
{
|
|
ally_sfx = "null";
|
|
}
|
|
if(!isdefined( enemy_sfx ))
|
|
{
|
|
enemy_sfx = "null";
|
|
}
|
|
|
|
if( level.teambased )
|
|
{
|
|
foreach( player in level.players )
|
|
{
|
|
if( IsDefined( player ) && IsSentient( player ) && IsSentient( self ) && player.team != self.team )
|
|
{
|
|
// Play This Sound on all enemy players in a match.
|
|
if( SoundExists( enemy_sfx ) )
|
|
{
|
|
player playlocalsound( enemy_sfx );
|
|
}
|
|
}
|
|
else if( IsDefined( player ) && IsSentient( player ) && IsSentient( self ) && player.team == self.team )
|
|
{
|
|
// Play This Sound on all friendly players in a match.
|
|
if( SoundExists( ally_sfx ) )
|
|
{
|
|
player playlocalsound( ally_sfx );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_play_on_notetrack_timer( alias, notetrack_frame, start_frame, _cleanup_time )"
|
|
"Summary: Plays a sound after."
|
|
"CallOn: An Entity"
|
|
"Manditory Arg: <alias> : soundaliases you want to play."
|
|
"Manditory Arg: <notetrack_frame> : The frame you want your sound to play on."
|
|
"Manditory Arg: <start_frame> : The starting frame number of the animation you are watching."
|
|
"OptionalArg: <_Cleanup_Time> : Time before the sound ent will be deleted (default is 8)."
|
|
"Example: level.elevator snd_play_on_notetrack_timer( "elevator_crash", 414, 225, 15 );;"
|
|
"SPMP: MP"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
snd_play_on_notetrack_timer( alias, notetrack_frame, start_frame, _cleanup_time )
|
|
{
|
|
//cleanup_time = 8;
|
|
|
|
//if( IsDefined( _cleanup_time ) )
|
|
// cleanup_time = _cleanup_time;
|
|
|
|
//frame_dif = notetrack_frame - start_frame / 30;
|
|
|
|
//wait( frame_dif );
|
|
|
|
//snd_play_linked( alias, self, cleanup_time );
|
|
|
|
}
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_play_on_notetrack( guy, animstring )"
|
|
"Summary: Listens for and Plays a sound on a notetrack event."
|
|
"CallOn: An Entity that is being animated on."
|
|
"Manditory Arg: <aliases> : array of soundaliases you want to play."
|
|
"Manditory Arg: <notetrack> : One vaild reference notetrack that exists in the animation, this must match the second arg of ScriptModelPlayAnimDeltaMotion used to call this anim.."
|
|
"Example:
|
|
***Anim - Just add valid notetrack in this case "laser_xform_up_sec1_start" ) self.lifter ScriptModelPlayAnimDeltaMotion( self.lifter.animUp, "laser_xform_up_sec1_start" );
|
|
self.lifter thread snd_play_on_notetrack( notetracktoaliasarray, "laser_xform_up_sec1_start" );
|
|
"SPMP: MP"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
snd_play_on_notetrack( aliases, notetrack, _customfunction )
|
|
{
|
|
self endon( "stop_sequencing_notetracks" );
|
|
self endon( "death" );
|
|
self sndx_play_on_notetrack_internal( aliases, notetrack, _customfunction );
|
|
}
|
|
|
|
sndx_play_on_notetrack_internal( aliases, notetrack, _customfunction )// _customfunction isn't even used. we should get rid of it.
|
|
{
|
|
for (;;)
|
|
{
|
|
self waittill( notetrack, note );
|
|
|
|
if ( isDefined( note ) && note != "end" )
|
|
{
|
|
if( isarray( aliases ))
|
|
{
|
|
alias = aliases[note];
|
|
if ( IsDefined( alias ) )
|
|
{
|
|
self playsound( alias );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( notetrack == note )
|
|
{
|
|
self playsound( aliases );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: ScriptModelPlayAnimWithNotify( <guy>, <notifyName>, <alias> )"
|
|
"Summary: Plays an animation and hooks into the notetrack, playing the alias when the notify is triggered."
|
|
"CallOn: Ignored"
|
|
"Example: ScriptModelPlayAnimWithNotify( level.thing, "sp_foo", "foo" );"
|
|
"SPMP: MP"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
ScriptModelPlayAnimWithNotify( guy, animName, notifyName, alias, customlevelend, customguyend1, customguyend2 )
|
|
{
|
|
if ( IsDefined( customlevelend ) )
|
|
{
|
|
level endon( customlevelend );
|
|
}
|
|
|
|
guy ScriptModelPlayAnimDeltaMotion( animName, notifyName );
|
|
thread ScriptModelPlayAnimWithNotify_Notetracks( guy, notifyName, alias, customlevelend, customguyend1, customguyend2 );
|
|
}
|
|
|
|
|
|
ScriptModelPlayAnimWithNotify_Notetracks( guy, notifyName, alias, customlevelend, customguyend1, customguyend2 )
|
|
{
|
|
if ( IsDefined( customlevelend ) )
|
|
{
|
|
level endon( customlevelend );
|
|
}
|
|
|
|
if ( IsDefined( customguyend1 ) )
|
|
{
|
|
guy endon( customguyend1 );
|
|
}
|
|
|
|
if ( IsDefined( customguyend2 ) )
|
|
{
|
|
guy endon( customguyend2 );
|
|
}
|
|
|
|
guy endon( "death" );
|
|
|
|
for ( ;; )
|
|
{
|
|
guy waittill( notifyName, note );
|
|
|
|
if ( isDefined( note ) && ( note == notifyName ) )
|
|
{
|
|
guy playSound( alias );
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_veh_play_loops( <array> , <ent> )"
|
|
"Summary: Plays up to 3 Loops on a vehicle by creating new sound ents and linking them to the functions self."
|
|
"CallOn: An Entity"
|
|
"OptionalArg: <loop_01, loop_02, loop_03, loop_04 > : soundaliases you want to link to this ent."
|
|
"Example: warbird snd_veh_play_loops;"
|
|
"SPMP: MP"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
|
|
snd_veh_play_loops( loop_01, loop_02, loop_03 )
|
|
{
|
|
vehicle = self;
|
|
loop_array = [ loop_01, loop_02, loop_03 ];
|
|
|
|
|
|
ent_array[0] = spawn( "script_origin", vehicle.origin );
|
|
ent_array[0] LinkToSynchronizedParent( vehicle );
|
|
ent_array[0] playloopsound( loop_01 );
|
|
|
|
|
|
ent_array[1] = spawn( "script_origin", vehicle.origin );
|
|
ent_array[1] LinkToSynchronizedParent( vehicle );
|
|
ent_array[1] playloopsound( loop_02 );
|
|
|
|
|
|
ent_array[2] = spawn( "script_origin", vehicle.origin );
|
|
ent_array[2] LinkToSynchronizedParent( vehicle );
|
|
ent_array[2] playloopsound( loop_03 );
|
|
|
|
|
|
vehicle waittill( "death" );
|
|
|
|
foreach( ent in ent_array )
|
|
{
|
|
if( isDefined( ent ) )
|
|
{
|
|
//vehicle_loop_ent setvolume(0, 0.05);
|
|
wait(0.06);
|
|
ent delete();
|
|
}
|
|
}
|
|
}
|
|
|
|
DEPRECATED_aud_map(input, env_points)
|
|
{
|
|
// input is zero to one
|
|
assert(IsDefined(input));
|
|
assert(input >= 0.0 && input <= 1.0);
|
|
assert(IsDefined(env_points));
|
|
|
|
/#
|
|
// this ensures that the given envelope is in order, otherwise we'd have to perform a sorting function.
|
|
//audx_validate_env_array(env_points);
|
|
#/
|
|
output = 0.0;
|
|
num_points = env_points.size;
|
|
|
|
// find the x-values which are relevant for the input
|
|
prev_point = env_points[0]; // grab the first point
|
|
for (i = 1; i < env_points.size; i++)
|
|
{
|
|
next_point = env_points[i];
|
|
if (input >= prev_point[0] && input <= next_point[0])
|
|
{
|
|
prev_x = prev_point[0];
|
|
next_x = next_point[0];
|
|
prev_y = prev_point[1];
|
|
next_y = next_point[1];
|
|
x_fract = (input - prev_x) / (next_x - prev_x);
|
|
output = prev_y + x_fract * (next_y - prev_y);
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
prev_point = next_point;
|
|
}
|
|
}
|
|
|
|
assert(output >= 0.0 && output <= 1.0);
|
|
|
|
return output;
|
|
}
|
|
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_play_loop_in_space( <alias_name> , <org>, <stop_loop_notify>, <fadeout_time_> )"
|
|
"Summary: Plays a loopsound in space with a stop loop notify string. "
|
|
"Module: Sound"
|
|
"CallOn: A Thread"
|
|
"MandatoryArg: <alias_name>: name of the alias"
|
|
"MandatoryArg: <org>: Vector"
|
|
"MandatoryArg: <stop_loop_notify>: Notify string used to stop the sound."
|
|
"OptionalArg: <fadeout_time_>: Changes the fadeout time of the sound once the stop loop notify is called."
|
|
"Example: "snd_play_loop_in_space( "best_fire_loop_ever" , ( 100, 1203, 10 ), "stop_best_fire_loop_ever", 0.5 )"
|
|
"SPMP: Multiplayer"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
|
|
snd_play_loop_in_space( alias_name, org, stop_loop_notify, fadeout_time_ )
|
|
{
|
|
// Default Fadeout Time.
|
|
fadeout_time = 0.2;
|
|
|
|
if(isDefined( fadeout_time_ ) )
|
|
fadeout_time = fadeout_time_;
|
|
|
|
snd_ent = spawn( "script_origin", org );
|
|
snd_ent playloopsound( alias_name );
|
|
|
|
thread sndx_play_loop_in_space_internal( snd_ent, stop_loop_notify, fadeout_time );
|
|
|
|
return snd_ent;
|
|
|
|
}
|
|
|
|
sndx_play_loop_in_space_internal( snd_ent, stop_loop_notify, fadeout_time )
|
|
{
|
|
|
|
level waittill( stop_loop_notify );
|
|
|
|
if(IsDefined( snd_ent ) )
|
|
{
|
|
snd_ent scalevolume( 0, fadeout_time );
|
|
wait( fadeout_time + 0.05 );
|
|
snd_ent delete();
|
|
}
|
|
}
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_script_timer( <update_rate> )"
|
|
"Summary: prints timestamps to easily time events in script. "
|
|
"Module: Sound"
|
|
"MandatoryArg: <update_rate>: how fast the prints happen.
|
|
"Example: "snd_script_timer( 0.1 )"
|
|
"SPMP: Multiplayer"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
snd_script_timer( speed )
|
|
{
|
|
level.timer_number = 0;
|
|
|
|
if(!IsDefined( speed ))
|
|
{
|
|
// Default Speed set to 0.1
|
|
speed = 0.1;
|
|
}
|
|
|
|
while(1)
|
|
{
|
|
iprintln( level.timer_number );
|
|
wait( speed );
|
|
level.timer_number = level.timer_number + speed;
|
|
}
|
|
}
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_play_in_space( <alias_name> , <org>, <_cleanuptime> )"
|
|
"Summary: Plays a sound in space, returns an ent and cleans it up when done. "
|
|
"Module: Sound"
|
|
"CallOn: A Thread"
|
|
"MandatoryArg: <alias_name>: name of the alias"
|
|
"MandatoryArg: <org>: Vector"
|
|
"MandatoryArg: <_cleanuptime>: Time before ents are cleaned up."
|
|
"Example: "snd_play_in_space( "playasoundhereomg" , ( 100, 1203, 10 ) )"
|
|
"SPMP: Multiplayer"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
snd_play_in_space( alias_name, org, _cleanup_time, _fadeout_time )
|
|
{
|
|
cleanup_time = 9;
|
|
fadeout_time = 0.75;
|
|
|
|
snd_ent = spawn( "script_origin", org );
|
|
snd_ent playsound( alias_name );
|
|
snd_ent thread sndx_play_in_space_internal( cleanup_time, fadeout_time );
|
|
return snd_ent;
|
|
}
|
|
|
|
sndx_play_in_space_internal( _cleanup_time, _fadeout_time )
|
|
{
|
|
cleanup_time = 9;
|
|
fadeout_time = 0.05;
|
|
snd_ent = self;
|
|
|
|
if( IsDefined( _cleanup_time ) )
|
|
cleanup_time = _cleanup_time;
|
|
|
|
if( IsDefined( _fadeout_time ) )
|
|
fadeout_time = _fadeout_time;
|
|
|
|
wait( cleanup_time );
|
|
|
|
if(IsDefined( snd_ent ) )
|
|
{
|
|
snd_ent scalevolume( 0, fadeout_time );
|
|
wait( fadeout_time + 0.05 );
|
|
|
|
if(IsDefined( snd_ent ))
|
|
snd_ent delete();
|
|
}
|
|
}
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_play_in_space_delayed( <alias_name> , <org>, <delay_time>, <_cleanuptime> )"
|
|
"Summary: Plays a sound in space, returns an ent and cleans it up when done. "
|
|
"Module: Sound"
|
|
"CallOn: A Thread"
|
|
"MandatoryArg: <alias_name>: name of the alias"
|
|
"MandatoryArg: <org>: Vector"
|
|
"MandatoryArg: <_cleanuptime>: Time before ents are cleaned up."
|
|
"MandatoryArg: <delay_time>: Time before sound starts."
|
|
"Example: "snd_play_in_space( "playasoundhereomg" , ( 100, 1203, 10 ) )"
|
|
"SPMP: Multiplayer"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
snd_play_in_space_delayed( alias_name, org, delay_time, _cleanup_time, _fadeout_time )
|
|
{
|
|
cleanup_time = 9;
|
|
fadeout_time = 0.75;
|
|
|
|
snd_ent = spawn( "script_origin", org );
|
|
snd_ent thread sndx_play_in_space_delayed_internal( alias_name, delay_time, _cleanup_time, _fadeout_time );
|
|
return snd_ent;
|
|
}
|
|
|
|
sndx_play_in_space_delayed_internal( alias_name, delay_time, _cleanup_time, _fadeout_time )
|
|
{
|
|
wait( delay_time );
|
|
cleanup_time = 9;
|
|
fadeout_time = 0.05;
|
|
snd_ent = self;
|
|
|
|
snd_ent playsound( alias_name );
|
|
|
|
if( IsDefined( _cleanup_time ) )
|
|
cleanup_time = _cleanup_time;
|
|
|
|
if( IsDefined( _fadeout_time ) )
|
|
fadeout_time = _fadeout_time;
|
|
|
|
wait( cleanup_time );
|
|
|
|
if(IsDefined( snd_ent ) )
|
|
{
|
|
snd_ent scalevolume( 0, fadeout_time );
|
|
wait( fadeout_time + 0.05 );
|
|
|
|
if(IsDefined( snd_ent ))
|
|
snd_ent delete();
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_play_linked( <alias_name> , <ent>, <_cleanuptime>, <_fadeouttime> )"
|
|
"Summary: Plays a sound attached on an ent, returns ent and cleans it up when done. "
|
|
"Module: Sound"
|
|
"CallOn: A Thread"
|
|
"MandatoryArg: <alias_name>: name of the alias"
|
|
"MandatoryArg: <ent>: Ent you wish to attach sound to"
|
|
"OptionalArg: <_cleanuptime>: Time before ents are cleaned up."
|
|
"OptionalArg: <_fadeouttime>: Fade time before the ent is deleted (after cleanuptime is complete."
|
|
"Example: "snd_play_in_space( "play_a_sound_on_a_thing" , ent )"
|
|
"SPMP: Multiplayer"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
snd_play_linked( alias_name, ent, _cleanup_time, _fadeout_time )
|
|
{
|
|
snd_ent = spawn( "script_origin", ent.origin );
|
|
snd_ent linkto( ent );
|
|
snd_ent thread sndx_play_linked_internal( alias_name, ent, _cleanup_time, _fadeout_time );
|
|
return snd_ent;
|
|
|
|
}
|
|
|
|
sndx_play_linked_internal( alias_name, ent, _cleanup_time, _fadeout_time )
|
|
{
|
|
cleanup_time = 9;
|
|
fadeout_time = 0.05;
|
|
snd_ent = self;
|
|
|
|
snd_ent playsound( alias_name );
|
|
|
|
if( IsDefined( _cleanup_time ) )
|
|
cleanup_time = _cleanup_time;
|
|
|
|
if( IsDefined( _fadeout_time ) )
|
|
fadeout_time = _fadeout_time;
|
|
|
|
wait( cleanup_time );
|
|
|
|
if(IsDefined( snd_ent ) )
|
|
{
|
|
snd_ent scalevolume( 0, fadeout_time );
|
|
wait( fadeout_time + 0.05 );
|
|
snd_ent delete();
|
|
}
|
|
}
|
|
|
|
/*
|
|
=============
|
|
///ScriptDocBegin
|
|
"Name: snd_play_linked_loop( <alias_name> , <ent>, <_cleanuptime>, <_fadeouttime> )"
|
|
"Summary: Plays a sound attached on an ent, returns ent and cleans it up when done. "
|
|
"Module: Sound"
|
|
"CallOn: A Thread"
|
|
"MandatoryArg: <alias_name>: name of the alias"
|
|
"MandatoryArg: <ent>: Ent you wish to attach sound to"
|
|
"OptionalArg: <_fadeouttime>: Fade time before the ent is deleted."
|
|
"Example: snd_play_in_space( "play_a_sound_on_a_thing" , ent )
|
|
"SPMP: Multiplayer"
|
|
///ScriptDocEnd
|
|
=============
|
|
*/
|
|
snd_play_linked_loop( alias_name, ent, _fadeout_time )
|
|
{
|
|
snd_ent = spawn( "script_origin", ent.origin );
|
|
snd_ent linkto( ent );
|
|
snd_ent thread sndx_play_linked_loop_internal( alias_name, ent, _fadeout_time );
|
|
return snd_ent;
|
|
|
|
}
|
|
|
|
sndx_play_linked_loop_internal( alias_name, ent, _fadeout_time )
|
|
{
|
|
fadeout_time = 0.05;
|
|
snd_ent = self;
|
|
|
|
snd_ent playloopsound( alias_name );
|
|
|
|
if( IsDefined( _fadeout_time ) )
|
|
fadeout_time = _fadeout_time;
|
|
|
|
ent waittill( "death" );
|
|
|
|
if(IsDefined( snd_ent ) )
|
|
{
|
|
snd_ent scalevolume( 0, fadeout_time );
|
|
wait( fadeout_time + 0.05 );
|
|
snd_ent delete();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
///ScriptDocBegin
|
|
"Name: aud_print_3d_on_ent(<msg> , <_size>, <_text_color> )"
|
|
"Summary: Create a print msg in 3d space that follows the entity this function is called on."
|
|
"Module: Audio"
|
|
"CallOn: The entity you wish to tag your print msg to."
|
|
"MandatoryArg: <msg> : Your print msg."
|
|
"OptionalArg": <_size> : Text size.
|
|
"OptionalArg": <_text_color> : Text color.
|
|
"OptionalArg": <_msg_callback> : Function pointer that returns a string which will be concatenated to <msg>. _msg_callback is called on self.
|
|
"OptionalArg": <_msg_callback> : Duration in seconds that the 3D message should be printed on self.
|
|
"SPMP: multiplayer"
|
|
///ScriptDocEnd
|
|
*/
|
|
aud_print_3d_on_ent(msg, _size, _text_color, _msg_callback, durration_)
|
|
{
|
|
if(IsDefined(self))
|
|
{
|
|
|
|
white = (1, 1, 1); //Default color if no arg is given.
|
|
red = (1, 0, 0);
|
|
green = (0, 1, 0);
|
|
blue = (0, 1, 1);
|
|
|
|
size = 5;
|
|
text_color = white;
|
|
|
|
if(IsDefined(_size))
|
|
{
|
|
size = _size;
|
|
}
|
|
|
|
if(IsDefined( _text_color))
|
|
{
|
|
text_color = _text_color;
|
|
|
|
switch( text_color )
|
|
{
|
|
case "red":
|
|
{
|
|
text_color = red;
|
|
}
|
|
break;
|
|
case "white":
|
|
{
|
|
text_color = white;
|
|
}
|
|
break;
|
|
case "blue":
|
|
{
|
|
text_color = blue;
|
|
}
|
|
break;
|
|
case "green":
|
|
{
|
|
text_color = green;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
{
|
|
text_color = white;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(IsDefined(durration_))
|
|
{
|
|
self thread audx_print_3d_timer(durration_);
|
|
}
|
|
|
|
self endon("death");
|
|
self endon("aud_stop_3D_print");
|
|
|
|
while(IsDefined(self))
|
|
{
|
|
full_msg = msg;
|
|
if (IsDefined(_msg_callback))
|
|
{
|
|
full_msg = full_msg + self [[_msg_callback]]();
|
|
}
|
|
Print3d(self.origin, full_msg, text_color, 1, size, 1);
|
|
wait(0.05);
|
|
}
|
|
}
|
|
}
|
|
|
|
audx_print_3d_timer( durration_ )
|
|
{
|
|
self endon("death");
|
|
assert(IsDefined(durration_));
|
|
wait(durration_);
|
|
if (IsDefined(self))
|
|
{
|
|
self notify("aud_stop_3D_print");
|
|
}
|
|
}
|
|
|
|
// NOTES
|
|
// Checks to see if game mode is team based.
|
|
//level.teamBased
|
|
//self endon( "disconnect" );
|
|
//level endon( "game_ended" );
|
|
|
|
|
|
|
|
snd_vehicle_mp()
|
|
{
|
|
// vehicle = self;
|
|
//
|
|
// //Setup Default Envelopes.
|
|
// hover_env = [ [0,1],[1,0.25] ];
|
|
// move_env = [ [0,0.3],[1,1] ];
|
|
//
|
|
// if( isdefined( _hover_env ) )
|
|
// hover_env = _hover_env;
|
|
//
|
|
// if( isdefined( _move_env ) )
|
|
// move_env = _move_env;
|
|
//
|
|
// // Create Ents and link them to the vehicle.
|
|
// ent_array[ "hover_lp" ] = spawn( "script_origin", vehicle.origin );
|
|
// ent_array[ "hover_lp" ] LinkToSynchronizedParent( vehicle );
|
|
// ent_array[ "hover_lp" ] playloopsound( close_lp );
|
|
//
|
|
// ent_array[ "move_lp" ] = spawn( "script_origin", vehicle.origin );
|
|
// ent_array[ "move_lp" ] LinkToSynchronizedParent( vehicle );
|
|
// ent_array[ "move_lp" ] playloopsound( move_lp );
|
|
//
|
|
// ent_array[ "dist_lp" ] = spawn( "script_origin", vehicle.origin );
|
|
// ent_array[ "dist_lp" ] LinkToSynchronizedParent( vehicle );
|
|
// ent_array[ "dist_lp" ] playloopsound( dist_lp );
|
|
//
|
|
// velocity = 0.0;
|
|
//
|
|
// //Scale Volumes Based on Inputs
|
|
// while( Isdefined( vehicle ))
|
|
// {
|
|
//
|
|
// //if is player controlled....
|
|
// new_velocity = vehicle Vehicle_GetSpeed();
|
|
// if( new_velocity <= 0 )
|
|
// {
|
|
// player_velocity = vehicle GetEntityVelocity();
|
|
// if (isdefined(player_velocity))
|
|
// {
|
|
// new_velocity = Length2D(player_velocity);
|
|
// }
|
|
// }
|
|
// new_velocity = clamp(new_velocity, 0.0, 10.0) / 10.0;
|
|
// if ( new_velocity > velocity)
|
|
// {
|
|
// //velocity = (new_velocity + velocity) / 2.0;
|
|
// }
|
|
// else
|
|
// {
|
|
// velocity = new_velocity;
|
|
// }
|
|
//
|
|
// hover_vol = DEPRECATED_aud_map( velocity, hover_env );
|
|
// ent_array[ "hover_lp" ] scalevolume( hover_vol, 0.05 );
|
|
//
|
|
// move_vol = DEPRECATED_aud_map( velocity, move_env );
|
|
// ent_array[ "move_lp" ] scalevolume( move_vol, 0.05 );
|
|
// wait(0.05);
|
|
//
|
|
// }
|
|
//
|
|
// //vehicle waittill( "death" );
|
|
//
|
|
// foreach( ent in ent_array )
|
|
// {
|
|
// if( isDefined( ent ) )
|
|
// {
|
|
// ent setvolume(0, 1);
|
|
// wait( 1 );
|
|
// ent delete();
|
|
// }
|
|
// }
|
|
}
|
|
|
|
|
|
|
|
|