mirror of
https://github.com/InfinityLoader/IL-GSC.git
synced 2025-06-27 18:07:53 -05:00
Added BO1 ZM rawfiles
This commit is contained in:
299
BO1/PC/ZM/clientscripts/_airsupport.csc
Normal file
299
BO1/PC/ZM/clientscripts/_airsupport.csc
Normal file
@ -0,0 +1,299 @@
|
||||
#include clientscripts\_utility;
|
||||
#include clientscripts\_utility_code;
|
||||
#include clientscripts\_vehicle;
|
||||
planeSounds( spawnSound, flybySound, flybySoundLoop, lengthOfFlyby )
|
||||
{
|
||||
self endon("delete");
|
||||
fake_ent_plane = spawnfakeent( 0 );
|
||||
playsound (0, spawnSound, (0,0,0));
|
||||
thread plane_position_updater (fake_ent_plane, self, flybySound, flybySoundLoop, lengthOfFlyBy);
|
||||
}
|
||||
plane_position_updater ( fake_ent, plane, flybySound, flybySoundLoop, lengthOfFlyby )
|
||||
{
|
||||
soundid = -1;
|
||||
dx = undefined;
|
||||
lastTime = undefined;
|
||||
lastPos = undefined;
|
||||
startTime = 0;
|
||||
while(IsDefined(plane))
|
||||
{
|
||||
setfakeentorg(0, fake_ent, plane.origin);
|
||||
if((soundid < 0) && isdefined(lastPos))
|
||||
{
|
||||
dx = plane.origin - lastPos;
|
||||
if(length(dx) > .01)
|
||||
{
|
||||
velocity = dx / (getrealtime()-lastTime);
|
||||
assert(isdefined(velocity));
|
||||
players = getlocalplayers();
|
||||
assert(isdefined(players));
|
||||
other_point = plane.origin + (velocity * 100000);
|
||||
point = closest_point_on_line_to_point(players[0].origin, plane.origin, other_point );
|
||||
assert(isdefined(point));
|
||||
dist = Distance( point, plane.origin );
|
||||
assert(isdefined(dist));
|
||||
time = dist / length(velocity);
|
||||
assert(isdefined(time));
|
||||
if( time < lengthOfFlyby )
|
||||
{
|
||||
if ( isdefined ( flybysoundloop ) )
|
||||
soundid = playloopsound(0, fake_ent, flybySoundLoop, 0 );
|
||||
if ( isdefined ( flybySound ) )
|
||||
plane playsound (0, flybySound);
|
||||
startTime = getRealTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
lastPos = plane.origin;
|
||||
lastTime = getrealtime();
|
||||
realwait(0.1);
|
||||
}
|
||||
wait (5);
|
||||
deletefakeent(0, fake_ent);
|
||||
}
|
||||
closest_point_on_line_to_point( Point, LineStart, LineEnd )
|
||||
{
|
||||
LineMagSqrd = lengthsquared(LineEnd - LineStart);
|
||||
t = ( ( ( Point[0] - LineStart[0] ) * ( LineEnd[0] - LineStart[0] ) ) +
|
||||
( ( Point[1] - LineStart[1] ) * ( LineEnd[1] - LineStart[1] ) ) +
|
||||
( ( Point[2] - LineStart[2] ) * ( LineEnd[2] - LineStart[2] ) ) ) /
|
||||
( LineMagSqrd );
|
||||
if( t < 0.0 )
|
||||
{
|
||||
return LineStart;
|
||||
}
|
||||
else if( t > 1.0 )
|
||||
{
|
||||
return LineEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
start_x = LineStart[0] + t * ( LineEnd[0] - LineStart[0] );
|
||||
start_y = LineStart[1] + t * ( LineEnd[1] - LineStart[1] );
|
||||
start_z = LineStart[2] + t * ( LineEnd[2] - LineStart[2] );
|
||||
return (start_x,start_y,start_z);
|
||||
}
|
||||
}
|
||||
getPlaneModel( teamFaction )
|
||||
{
|
||||
switch ( teamFaction )
|
||||
{
|
||||
case "vietcong":
|
||||
planemodel = "t5_veh_air_mig_21_nva_flying";
|
||||
break;
|
||||
case "nva":
|
||||
planemodel = "t5_veh_air_mig_21_nva_flying";
|
||||
break;
|
||||
case "japanese":
|
||||
planemodel = "t5_veh_air_mig_21_ussr_flying";
|
||||
break;
|
||||
case "russian":
|
||||
planemodel = "t5_veh_air_mig_21_ussr_flying";
|
||||
break;
|
||||
case "marines":
|
||||
planemodel = "t5_veh_jet_f4_gearup";
|
||||
break;
|
||||
case "specops":
|
||||
planemodel = "t5_veh_jet_f4_gearup";
|
||||
break;
|
||||
default:
|
||||
println( "invalid faction, defaulting to marines" );
|
||||
planemodel = "t5_veh_jet_f4_gearup";
|
||||
break;
|
||||
}
|
||||
return planeModel;
|
||||
}
|
||||
planeTurnLeft( plane, yaw, halflife )
|
||||
{
|
||||
plane endon("delete");
|
||||
yawY = getDvarFloatDefault( #"scr_planeyaw", 0.6 );
|
||||
rollZ = getDvarFloatDefault( #"scr_planeroll", -1.5 );
|
||||
maxYaw = getDvarFloatDefault( #"scr_max_planeyaw", 45.0 );
|
||||
minRoll = getDvarFloatDefault( #"scr_min_planeroll", -60.0 );
|
||||
ox = getDvarFloatDefault( #"scr_planeox", 30000.0 );
|
||||
oy = getDvarFloatDefault( #"scr_planeoy", 30000.0 );
|
||||
maxoX = getDvarFloatDefault( #"scr_maxo_planex", -1.0 );
|
||||
maxoY = getDvarFloatDefault( #"scr_maxo_planey", -1.0 );
|
||||
if (plane.angles[1] == 360)
|
||||
plane.angles = ( plane.angles[0], 0, plane.angles[2] );
|
||||
origX = plane.origin[0];
|
||||
origY = plane.origin[1];
|
||||
accumTurn = 0;
|
||||
looptime = 0.1;
|
||||
while( loopTime <= halflife )
|
||||
{
|
||||
if (plane.angles[1] == 360)
|
||||
plane.angles = ( plane.angles[0], 0, plane.angles[2] );
|
||||
if ( minRoll != -1 && plane.angles[2] <= minRoll )
|
||||
rollZ = 0.0;
|
||||
accumTurn += yawY;
|
||||
if ( accumTurn >= maxYaw )
|
||||
{
|
||||
yawY = 0.0;
|
||||
}
|
||||
plane.angles = ( plane.angles[0], plane.angles[1] + yawY, plane.angles[2] + rollZ);
|
||||
mathX = ( sin ( 45 * looptime / halflife ) ) * ox ;
|
||||
mathY = ( cos ( 45 * looptime / halflife ) ) * oy ;
|
||||
oldX = mathX;
|
||||
oldY = oy - mathY;
|
||||
rotatedX = Cos(yaw) * oldX - Sin(yaw) * oldY;
|
||||
rotatedY = Sin(yaw) * oldX + Cos(yaw) * oldY;
|
||||
endPoint = ( origX + rotatedX, origY + rotatedY, plane.origin[2]);
|
||||
plane moveTo( endPoint, 0.1, 0, 0 );
|
||||
realwait (0.1);
|
||||
loopTime += 0.1;
|
||||
}
|
||||
yawY = getDvarFloatDefault( #"scr_planeyaw2", 0.6 );
|
||||
rollZ = getDvarFloatDefault( #"scr_planeroll2", -0.9 );
|
||||
ox = getDvarFloatDefault( #"scr_planeox", 30000.0 );
|
||||
oy = getDvarFloatDefault( #"scr_planeoy", 30000.0 );
|
||||
maxoX = getDvarFloatDefault( #"scr_maxo_planex", -1.0 );
|
||||
maxoY = getDvarFloatDefault( #"scr_maxo_planey", -1.0 );
|
||||
y = getDvarFloatDefault( #"scr_planey2", 0.6 );
|
||||
z = getDvarFloatDefault( #"scr_planez2", -1.5 );
|
||||
maxy = getDvarFloatDefault( #"scr_max_planey2", 90);
|
||||
accumTurn = 0;
|
||||
while( loopTime < halflife + halflife )
|
||||
{
|
||||
if (plane.angles[1] == 360)
|
||||
plane.angles = ( plane.angles[0], 0, plane.angles[2] );
|
||||
if ( minRoll != -1 && plane.angles[2] >= 0 )
|
||||
rollZ = 0.0;
|
||||
accumTurn += yawY;
|
||||
if ( accumTurn >= maxYaw )
|
||||
{
|
||||
yawY = 0.0;
|
||||
}
|
||||
plane.angles = ( plane.angles[0], plane.angles[1] + yawY, plane.angles[2] - rollZ);
|
||||
mathX = ( sin ( 45 * looptime / halflife ) ) * ox ;
|
||||
mathY = ( cos ( 45 * looptime / halflife ) ) * oy ;
|
||||
oldX = mathX;
|
||||
oldY = oy - mathY;
|
||||
rotatedX = Cos(yaw) * oldX - Sin(yaw) * oldY;
|
||||
rotatedY = Sin(yaw) * oldX + Cos(yaw) * oldY;
|
||||
endPoint = ( origX + rotatedX, origY + rotatedY, plane.origin[2]);
|
||||
plane moveTo( endPoint, 0.1, 0, 0 );
|
||||
realwait (0.1);
|
||||
loopTime += 0.1;
|
||||
}
|
||||
}
|
||||
planeTurnRight( plane, yaw, halflife )
|
||||
{
|
||||
plane endon("delete");
|
||||
yawY = getDvarFloatDefault( #"scr_planeyaw", -0.6 );
|
||||
rollZ = getDvarFloatDefault( #"scr_planeroll", 1.5 );
|
||||
maxYaw = getDvarFloatDefault( #"scr_max_planeyaw", -45.0 );
|
||||
minRoll = getDvarFloatDefault( #"scr_min_planeroll", 60.0 );
|
||||
ox = getDvarFloatDefault( #"scr_planeox", 30000.0 );
|
||||
oy = getDvarFloatDefault( #"scr_planeoy", -30000.0 );
|
||||
maxoX = getDvarFloatDefault( #"scr_maxo_planex", -1.0 );
|
||||
maxoY = getDvarFloatDefault( #"scr_maxo_planey", -1.0 );
|
||||
if (plane.angles[1] == 360)
|
||||
plane.angles = ( plane.angles[0], 0, plane.angles[2] );
|
||||
origX = plane.origin[0];
|
||||
origY = plane.origin[1];
|
||||
accumTurn = 0;
|
||||
looptime = 0.1;
|
||||
while( loopTime <= halflife )
|
||||
{
|
||||
if (plane.angles[1] == 360)
|
||||
plane.angles = ( plane.angles[0], 0, plane.angles[2] );
|
||||
if ( minRoll != -1 && plane.angles[2] >= minRoll )
|
||||
rollZ = 0.0;
|
||||
accumTurn += yawY;
|
||||
if ( accumTurn <= maxYaw )
|
||||
{
|
||||
yawY = 0.0;
|
||||
}
|
||||
plane.angles = ( plane.angles[0], plane.angles[1] + yawY, plane.angles[2] + rollZ);
|
||||
mathX = ( sin ( 45 * looptime / halflife ) ) * ox ;
|
||||
mathY = ( cos ( 45 * looptime / halflife ) ) * oy ;
|
||||
oldX = mathX;
|
||||
oldY = oy - mathY;
|
||||
rotatedX = Cos(yaw) * oldX - Sin(yaw) * oldY;
|
||||
rotatedY = Sin(yaw) * oldX + Cos(yaw) * oldY;
|
||||
println( rotatedX + " " + rotatedY + "\n" );
|
||||
endPoint = ( origX + rotatedX, origY + rotatedY, plane.origin[2]);
|
||||
plane moveTo( endPoint, 0.1, 0, 0 );
|
||||
realwait (0.1);
|
||||
loopTime += 0.1;
|
||||
}
|
||||
yawY = getDvarFloatDefault( #"scr_planeyaw2", 0.6 );
|
||||
rollZ = getDvarFloatDefault( #"scr_planeroll2", -0.9 );
|
||||
ox = getDvarFloatDefault( #"scr_planeox", 30000.0 );
|
||||
oy = getDvarFloatDefault( #"scr_planeoy", -30000.0 );
|
||||
maxoX = getDvarFloatDefault( #"scr_maxo_planex", -1.0 );
|
||||
maxoY = getDvarFloatDefault( #"scr_maxo_planey", -1.0 );
|
||||
y = getDvarFloatDefault( #"scr_planey2", 0.6 );
|
||||
z = getDvarFloatDefault( #"scr_planez2", -1.5 );
|
||||
maxy = getDvarFloatDefault( #"scr_max_planey2", 90);
|
||||
accumTurn = 0;
|
||||
while( loopTime < halflife + halflife )
|
||||
{
|
||||
if (plane.angles[1] == 360)
|
||||
plane.angles = ( plane.angles[0], 0, plane.angles[2] );
|
||||
if ( minRoll != -1 && plane.angles[2] >= 0 )
|
||||
rollZ = 0.0;
|
||||
accumTurn += yawY;
|
||||
if ( accumTurn >= maxYaw )
|
||||
{
|
||||
yawY = 0.0;
|
||||
}
|
||||
plane.angles = ( plane.angles[0], plane.angles[1] + yawY, plane.angles[2] - rollZ);
|
||||
mathX = ( sin ( 45 * looptime / halflife ) ) * ox ;
|
||||
mathY = ( cos ( 45 * looptime / halflife ) ) * oy ;
|
||||
oldX = mathX;
|
||||
oldY = oy - mathY;
|
||||
rotatedX = Cos(yaw) * oldX - Sin(yaw) * oldY;
|
||||
rotatedY = Sin(yaw) * oldX + Cos(yaw) * oldY;
|
||||
endPoint = ( origX + rotatedX, origY + rotatedY, plane.origin[2]);
|
||||
plane moveTo( endPoint, 0.1, 0, 0 );
|
||||
realwait (0.1);
|
||||
loopTime += 0.1;
|
||||
}
|
||||
}
|
||||
doABarrelRoll( plane, endPoint, time )
|
||||
{
|
||||
plane endon("delete");
|
||||
plane moveTo( endPoint, time, 0, 0 );
|
||||
rollZ = getDvarFloatDefault( #"scr_barrelroll", 10 );
|
||||
degreesToRoll = getDvarFloatDefault( #"scr_degreesToRoll", 720 );
|
||||
degreesRolled = 0;
|
||||
while ( degreesRolled < degreesToRoll )
|
||||
{
|
||||
plane.angles = ( plane.angles[0], plane.angles[1], plane.angles[2] + rollZ);
|
||||
degreesRolled += rollZ;
|
||||
realwait (0.01);
|
||||
}
|
||||
}
|
||||
planeGoStraight( plane, endPoint, time )
|
||||
{
|
||||
plane endon("delete");
|
||||
plane moveTo( endPoint, time, 0, 0 );
|
||||
}
|
||||
debug_line( from, to, color, time )
|
||||
{
|
||||
}
|
||||
debug_star( origin, color, time )
|
||||
{
|
||||
}
|
||||
getDvarFloatDefault( dvarName, defaultValue)
|
||||
{
|
||||
returnVal = defaultValue;
|
||||
if (getDvar(dvarName) != "")
|
||||
{
|
||||
return getDvarFloat(dvarName);
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
getDvarIntDefault( dvarName, defaultValue)
|
||||
{
|
||||
returnVal = defaultValue;
|
||||
if (getDvar(dvarName) != "")
|
||||
{
|
||||
return getDvarInt(dvarName);
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
|
BIN
BO1/PC/ZM/clientscripts/_ambient.csc
Normal file
BIN
BO1/PC/ZM/clientscripts/_ambient.csc
Normal file
Binary file not shown.
644
BO1/PC/ZM/clientscripts/_ambientpackage.csc
Normal file
644
BO1/PC/ZM/clientscripts/_ambientpackage.csc
Normal file
@ -0,0 +1,644 @@
|
||||
#include clientscripts\_utility;
|
||||
deactivateAmbientPackage(client, package, priority)
|
||||
{
|
||||
if ( !isdefined( level.ambientPackages[package] ) )
|
||||
{
|
||||
assertmsg( "deactivateAmbientPackage: must declare ambient package \"" + package + "\" in level_amb main before it can be deactivated" );
|
||||
return;
|
||||
}
|
||||
for( i = 0; i < level.ambientPackages[package].priority.size; i++)
|
||||
{
|
||||
if ( level.ambientPackages[package].priority[i] == priority && level.ambientPackages[package].refcount[i] )
|
||||
{
|
||||
level.ambientPackages[package].refcount[i]--;
|
||||
level notify( "updateActiveAmbientPackage" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
deactivateAmbientRoom(client, room, priority)
|
||||
{
|
||||
if ( !isdefined( level.ambientRooms[room] ) )
|
||||
{
|
||||
assertmsg( "deactivateAmbientRoom: must declare ambient room \"" + room + "\" in level_amb main before it can be deactivated" );
|
||||
return;
|
||||
}
|
||||
for( i = 0; i < level.ambientRooms[room].priority.size; i++ )
|
||||
{
|
||||
if( level.ambientRooms[room].priority[i] == priority && level.ambientRooms[room].refcount[i] )
|
||||
{
|
||||
level.ambientRooms[room].refcount[i]--;
|
||||
level notify( "updateActiveAmbientRoom" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
trig_enter(ent)
|
||||
{
|
||||
if( self.useAmbientPackage )
|
||||
activateAmbientPackage( 0, self.script_ambientpackage, self.script_ambientpriority);
|
||||
if( self.useAmbientRoom )
|
||||
activateAmbientRoom( 0, self.script_ambientroom, self.script_ambientpriority );
|
||||
}
|
||||
trig_leave(ent)
|
||||
{
|
||||
if( self.useAmbientPackage )
|
||||
deactivateAmbientPackage( 0, self.script_ambientpackage, self.script_ambientpriority );
|
||||
if( self.useAmbientRoom )
|
||||
deactivateAmbientRoom( 0, self.script_ambientroom, self.script_ambientpriority );
|
||||
}
|
||||
AmbientPackageTrigger()
|
||||
{
|
||||
hasAmbientRoom = isdefined ( self.script_ambientroom );
|
||||
useAmbientRoom = hasAmbientRoom && isdefined( level.ambientRooms[self.script_ambientroom] );
|
||||
hasAmbientPackage = isdefined ( self.script_ambientpackage );
|
||||
useAmbientPackage = hasAmbientPackage && isdefined( level.ambientPackages[self.script_ambientpackage] );
|
||||
self.useAmbientRoom = useAmbientRoom;
|
||||
self.useAmbientPackage = useAmbientPackage;
|
||||
if (hasAmbientRoom && !useAmbientRoom)
|
||||
{
|
||||
assertmsg( "Trigger at " + self.origin + " references ambient room '" + self.script_ambientroom + "', but no such room has been declared\n" );
|
||||
return;
|
||||
}
|
||||
if (hasAmbientPackage && !useAmbientPackage)
|
||||
{
|
||||
assertmsg( "Trigger at " + self.origin + " references ambient package '" + self.script_ambientpackage + "', but no such package has been declared\n" );
|
||||
return;
|
||||
}
|
||||
if(!useAmbientPackage && !useAmbientRoom)
|
||||
{
|
||||
assertmsg( "Trigger at " + self.origin + " is an ambient trigger but has no room or package \n" );
|
||||
return;
|
||||
}
|
||||
if ( !isdefined( self.script_ambientpriority ) )
|
||||
{
|
||||
self.script_ambientpriority = 1;
|
||||
}
|
||||
self.in_volume = [];
|
||||
for (;;)
|
||||
{
|
||||
self waittill ( "trigger", trigPlayer );
|
||||
if(trigPlayer issplitscreenhost())
|
||||
{
|
||||
self thread trigger_thread(trigPlayer, ::trig_enter, ::trig_leave);
|
||||
}
|
||||
wait(0.01);
|
||||
}
|
||||
}
|
||||
init_ambient_package_triggers()
|
||||
{
|
||||
wait(0.1);
|
||||
player = GetLocalPlayers()[0];
|
||||
remove_triggers_from_ent( player );
|
||||
trigs = GetEntArray( 0, "ambient_package","targetname");
|
||||
array_thread( trigs, ::ambientPackageTrigger);
|
||||
println("Client : " + trigs.size + " ambient package triggers.");
|
||||
}
|
||||
init()
|
||||
{
|
||||
level.activeAmbientPackage = "";
|
||||
level.ambientPackages = [];
|
||||
level.ambientNumMissedSounds = 0;
|
||||
level.ambientNumSeqMissedSounds = 0;
|
||||
thread updateActiveAmbientPackage();
|
||||
thread saveRestore();
|
||||
level.ambientPackageScriptOriginPool = [];
|
||||
for ( i = 0; i < 5; i++ )
|
||||
{
|
||||
level.ambientPackageScriptOriginPool[i] = spawnStruct();
|
||||
level.ambientPackageScriptOriginPool[i].org = spawnfakeent(0);
|
||||
level.ambientPackageScriptOriginPool[i].inuse = false;
|
||||
level.ambientPackageScriptOriginPool[i] thread scriptOriginPoolThread();
|
||||
}
|
||||
level.activeAmbientRoom = "";
|
||||
level.ambientRooms = [];
|
||||
level thread updateActiveAmbientRoom();
|
||||
clientscripts\_utility::registerSystem("ambientPackageCmd", ::ambientPackageCmdHandler);
|
||||
clientscripts\_utility::registerSystem("ambientRoomCmd", ::ambientRoomCmdHandler);
|
||||
level thread init_ambient_package_triggers();
|
||||
}
|
||||
declareAmbientPackage( package )
|
||||
{
|
||||
if ( isdefined( level.ambientPackages[package] ) )
|
||||
return;
|
||||
level.ambientPackages[package] = spawnStruct();
|
||||
level.ambientPackages[package].priority = [];
|
||||
level.ambientPackages[package].refcount = [];
|
||||
level.ambientPackages[package].elements = [];
|
||||
}
|
||||
addAmbientElement( package, alias, spawnMin, spawnMax, distMin, distMax, angleMin, angleMax )
|
||||
{
|
||||
if ( !isdefined( level.ambientPackages[package] ) )
|
||||
{
|
||||
assertmsg( "addAmbientElement: must declare ambient package \"" + package + "\" in level_amb main before it can have elements added to it" );
|
||||
return;
|
||||
}
|
||||
index = level.ambientPackages[package].elements.size;
|
||||
level.ambientPackages[package].elements[index] = spawnStruct();
|
||||
level.ambientPackages[package].elements[index].alias = alias;
|
||||
if ( spawnMin < 0 )
|
||||
spawnMin = 0;
|
||||
if ( spawnMin >= spawnMax )
|
||||
spawnMax = spawnMin + 1;
|
||||
level.ambientPackages[package].elements[index].spawnMin = spawnMin;
|
||||
level.ambientPackages[package].elements[index].spawnMax = spawnMax;
|
||||
level.ambientPackages[package].elements[index].distMin = -1;
|
||||
level.ambientPackages[package].elements[index].distMax = -1;
|
||||
if ( isdefined( distMin ) && isdefined( distMax ) && distMin >= 0 && distMin < distMax )
|
||||
{
|
||||
level.ambientPackages[package].elements[index].distMin = distMin;
|
||||
level.ambientPackages[package].elements[index].distMax = distMax;
|
||||
}
|
||||
level.ambientPackages[package].elements[index].angleMin = 0;
|
||||
level.ambientPackages[package].elements[index].angleMax = 359;
|
||||
if ( isdefined( angleMin ) && isdefined( angleMax ) && angleMin >= 0 && angleMin < angleMax && angleMax <= 720 )
|
||||
{
|
||||
level.ambientPackages[package].elements[index].angleMin = angleMin;
|
||||
level.ambientPackages[package].elements[index].angleMax = angleMax;
|
||||
}
|
||||
}
|
||||
declareAmbientRoom( room )
|
||||
{
|
||||
if ( isdefined( level.ambientRooms[room] ) )
|
||||
return;
|
||||
level.ambientRooms[room] = spawnStruct();
|
||||
level.ambientRooms[room].priority = [];
|
||||
level.ambientRooms[room].refcount = [];
|
||||
level.ambientRooms[room].ent = spawnfakeent(0);
|
||||
}
|
||||
setAmbientRoomTone( room, alias, fadeIn, fadeOut )
|
||||
{
|
||||
if ( !isdefined( level.ambientRooms[room] ) )
|
||||
{
|
||||
assertmsg( "setAmbientRoomTone: must declare ambient room \"" + room + "\" in level_amb main before it can have a room tone set" );
|
||||
return;
|
||||
}
|
||||
level.ambientRooms[room].tone = alias;
|
||||
level.ambientRooms[room].fadeIn = 2;
|
||||
if ( isDefined( fadeIn ) && fadeIn >= 0 )
|
||||
{
|
||||
level.ambientRooms[room].fadeIn = fadeIn;
|
||||
}
|
||||
level.ambientRooms[room].fadeOut = 2;
|
||||
if ( isDefined( fadeOut ) && fadeOut >= 0 )
|
||||
{
|
||||
level.ambientRooms[room].fadeOut = fadeOut;
|
||||
}
|
||||
}
|
||||
setAmbientRoomSnapshot( room, snapshot)
|
||||
{
|
||||
if ( !isdefined( level.ambientRooms[room] ) )
|
||||
{
|
||||
assertmsg( "setAmbientRoomSnapshot: must declare ambient room \"" + room + "\" in level_amb main before it can have a room snapshot set" );
|
||||
return;
|
||||
}
|
||||
level.ambientRooms[room].snapshot = snapshot;
|
||||
}
|
||||
setAmbientRoomContext( room, type, value)
|
||||
{
|
||||
if ( !isdefined( level.ambientRooms[room] ) )
|
||||
{
|
||||
assertmsg( "setAmbientRoomContext: must declare ambient room \"" + room + "\" in level_amb main before it can have a room context set" );
|
||||
return;
|
||||
}
|
||||
if(!isdefined(level.ambientRooms[room].context))
|
||||
{
|
||||
level.ambientRooms[room].context = [];
|
||||
}
|
||||
level.ambientRooms[room].context[type] = value;
|
||||
if(!isdefined(level.ambientContexts))
|
||||
{
|
||||
level.ambientContexts = [];
|
||||
}
|
||||
level.ambientContexts[type] = type;
|
||||
}
|
||||
setAmbientRoomReverb( room, reverbRoomType, dry, wet, fade )
|
||||
{
|
||||
if ( !isdefined( level.ambientRooms[room] ) )
|
||||
{
|
||||
assertmsg( "setAmbientRoomReverb: must declare ambient room \"" + room + "\" in level_amb main before it can have a room reverb set" );
|
||||
return;
|
||||
}
|
||||
level.ambientRooms[room].reverb = spawnStruct();
|
||||
level.ambientRooms[room].reverb.reverbRoomType = reverbRoomType;
|
||||
level.ambientRooms[room].reverb.dry = dry;
|
||||
level.ambientRooms[room].reverb.wet = wet;
|
||||
level.ambientRooms[room].reverb.fade = 2;
|
||||
if ( isDefined( fade ) && fade >= 0 )
|
||||
{
|
||||
level.ambientRooms[room].reverb.fade = fade;
|
||||
}
|
||||
}
|
||||
activateAmbientPackage( clientNum, package, priority )
|
||||
{
|
||||
if ( !isdefined( level.ambientPackages[package] ) )
|
||||
{
|
||||
assertmsg( "activateAmbientPackage: must declare ambient package \"" + package + "\" in level_amb.csc main before it can be activated" );
|
||||
return;
|
||||
}
|
||||
for ( i = 0; i < level.ambientPackages[package].priority.size; i++ )
|
||||
{
|
||||
if ( level.ambientPackages[package].priority[i] == priority )
|
||||
{
|
||||
level.ambientPackages[package].refcount[i]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == level.ambientPackages[package].priority.size )
|
||||
{
|
||||
level.ambientPackages[package].priority[i] = priority;
|
||||
level.ambientPackages[package].refcount[i] = 1;
|
||||
}
|
||||
level notify( "updateActiveAmbientPackage" );
|
||||
}
|
||||
activateAmbientRoom( clientNum, room, priority )
|
||||
{
|
||||
if ( !isdefined( level.ambientRooms[room] ) )
|
||||
{
|
||||
assertmsg( "activateAmbientRoom: must declare ambient room \"" + room + "\" in level_amb.csc main before it can be activated" );
|
||||
return;
|
||||
}
|
||||
for ( i = 0; i < level.ambientRooms[room].priority.size; i++ )
|
||||
{
|
||||
if ( level.ambientRooms[room].priority[i] == priority )
|
||||
{
|
||||
level.ambientRooms[room].refcount[i]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == level.ambientRooms[room].priority.size )
|
||||
{
|
||||
level.ambientRooms[room].priority[i] = priority;
|
||||
level.ambientRooms[room].refcount[i] = 1;
|
||||
}
|
||||
level notify( "updateActiveAmbientRoom" );
|
||||
}
|
||||
ambientPackageCmdHandler(clientNum, state, oldState)
|
||||
{
|
||||
if(state != "")
|
||||
{
|
||||
split_state = splitargs(state);
|
||||
if(split_state.size != 3)
|
||||
{
|
||||
println("*** Client : Malformed arguements to ambient packages " + state);
|
||||
}
|
||||
else
|
||||
{
|
||||
command = split_state[0];
|
||||
package = split_state[1];
|
||||
priority = int(split_state[2]);
|
||||
println("### APC : " + command + " " + package + " " + priority);
|
||||
if(command == "A")
|
||||
{
|
||||
if ( !isdefined( level.ambientPackages[package] ) )
|
||||
{
|
||||
assertmsg( "activateAmbientPackage: must declare ambient package \"" + package + "\" in level_amb.csc main before it can be activated" );
|
||||
return;
|
||||
}
|
||||
for ( i = 0; i < level.ambientPackages[package].priority.size; i++ )
|
||||
{
|
||||
if ( level.ambientPackages[package].priority[i] == priority )
|
||||
{
|
||||
level.ambientPackages[package].refcount[i]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == level.ambientPackages[package].priority.size )
|
||||
{
|
||||
level.ambientPackages[package].priority[i] = priority;
|
||||
level.ambientPackages[package].refcount[i] = 1;
|
||||
}
|
||||
level notify( "updateActiveAmbientPackage" );
|
||||
}
|
||||
else if(command == "D")
|
||||
{
|
||||
if ( !isdefined( level.ambientPackages[package] ) )
|
||||
{
|
||||
assertmsg( "deactivateAmbientPackage: must declare ambient package \"" + package + "\" in level_amb.csc main before it can be deactivated" );
|
||||
return;
|
||||
}
|
||||
for ( i = 0; i < level.ambientPackages[package].priority.size; i++ )
|
||||
{
|
||||
if ( level.ambientPackages[package].priority[i] == priority && level.ambientPackages[package].refcount[i] )
|
||||
{
|
||||
level.ambientPackages[package].refcount[i]--;
|
||||
level notify( "updateActiveAmbientPackage" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assertmsg("Unknown command in ambientPackageCmdHandler " + state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ambientRoomCmdHandler(clientNum, state, oldState)
|
||||
{
|
||||
if(state != "")
|
||||
{
|
||||
split_state = splitargs(state);
|
||||
if(split_state.size != 3)
|
||||
{
|
||||
println("*** Client : Malformed arguements to ambient packages " + state);
|
||||
}
|
||||
else
|
||||
{
|
||||
command = split_state[0];
|
||||
room = split_state[1];
|
||||
priority = int(split_state[2]);
|
||||
if(command == "A")
|
||||
{
|
||||
if ( !isdefined( level.ambientRooms[room] ) )
|
||||
{
|
||||
assertmsg( "activateAmbientRoom: must declare ambient room \"" + room + "\" in level_amb.csc main before it can be activated" );
|
||||
return;
|
||||
}
|
||||
for ( i = 0; i < level.ambientRooms[room].priority.size; i++ )
|
||||
{
|
||||
if ( level.ambientRooms[room].priority[i] == priority )
|
||||
{
|
||||
level.ambientRooms[room].refcount[i]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == level.ambientRooms[room].priority.size )
|
||||
{
|
||||
level.ambientRooms[room].priority[i] = priority;
|
||||
level.ambientRooms[room].refcount[i] = 1;
|
||||
}
|
||||
level notify( "updateActiveAmbientRoom" );
|
||||
}
|
||||
else if(command == "D")
|
||||
{
|
||||
if ( !isdefined( level.ambientRooms[room] ) )
|
||||
{
|
||||
assertmsg( "deactivateAmbientRoom: must declare ambient room \"" + room + "\" in level_amb.csc main before it can be deactivated" );
|
||||
return;
|
||||
}
|
||||
for ( i = 0; i < level.ambientRooms[room].priority.size; i++ )
|
||||
{
|
||||
if ( level.ambientRooms[room].priority[i] == priority && level.ambientRooms[room].refcount[i] )
|
||||
{
|
||||
level.ambientRooms[room].refcount[i]--;
|
||||
level notify( "updateActiveAmbientRoom" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assertmsg("Unknown command in ambientRoomCmdHandler " + state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ambientElementThread()
|
||||
{
|
||||
level endon( "killambientElementThread" + level.activeAmbientPackage );
|
||||
timer = 0;
|
||||
if ( self.distMin < 0 )
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
timer = randomfloatrange( self.spawnMin, self.spawnMax );
|
||||
wait timer;
|
||||
if( getdvarint( #"debug_audio" ) > 0 )
|
||||
{
|
||||
}
|
||||
playsound( 0, self.alias );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dist = 0;
|
||||
angle = 0;
|
||||
offset = (0, 0, 0);
|
||||
index = -1;
|
||||
for (;;)
|
||||
{
|
||||
timer = randomfloatrange( self.spawnMin, self.spawnMax );
|
||||
wait timer;
|
||||
index = getScriptOriginPoolIndex();
|
||||
if ( index >= 0 )
|
||||
{
|
||||
dist = randomintrange( self.distMin, self.distMax );
|
||||
angle = randomintrange( self.angleMin, self.angleMax );
|
||||
player_angle = getlocalclientangles(0)[1];
|
||||
offset = anglestoforward( ( 0, angle + player_angle, 0 ) );
|
||||
offset = vector_scale( offset, dist );
|
||||
pos = getlocalclienteyepos(0) + offset;
|
||||
setfakeentorg(0, level.ambientPackageScriptOriginPool[index].org, pos);
|
||||
level.ambientPackageScriptOriginPool[index].soundId = playSound( 0, self.alias, pos );
|
||||
if( getdvarint( #"debug_audio" ) > 0 )
|
||||
{
|
||||
if(level.ambientPackageScriptOriginPool[index].soundId == -1)
|
||||
{
|
||||
col = (0.8, 0.0, 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
col = (0.0, 0.8, 0.0);
|
||||
}
|
||||
print3d (pos, "AP : " + self.alias, col, 1, 3, 30);
|
||||
}
|
||||
while(level.ambientPackageScriptOriginPool[index].soundId != -1)
|
||||
{
|
||||
wait(0.01);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
getScriptOriginPoolIndex()
|
||||
{
|
||||
for ( index = 0; index < level.ambientPackageScriptOriginPool.size; index++ )
|
||||
{
|
||||
if ( !level.ambientPackageScriptOriginPool[index].inuse )
|
||||
{
|
||||
level.ambientPackageScriptOriginPool[index].inuse = true;
|
||||
level.ambientNumSeqMissedSounds = 0;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
level.ambientNumMissedSounds++;
|
||||
level.ambientNumSeqMissedSounds++;
|
||||
if( getdvarint( #"debug_audio" ) > 0 )
|
||||
{
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
scriptOriginPoolThread()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if(self.inuse == true)
|
||||
{
|
||||
if(isdefined(self.soundId))
|
||||
{
|
||||
if(self.SoundId != -1)
|
||||
{
|
||||
if(!SoundPlaying(self.soundId))
|
||||
{
|
||||
self.inuse = false;
|
||||
self.soundId = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.inUse = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
wait(0.01);
|
||||
}
|
||||
}
|
||||
findHighestPriorityAmbientPackage()
|
||||
{
|
||||
package = "";
|
||||
priority = -1;
|
||||
packageArray = getArrayKeys( level.ambientPackages );
|
||||
for ( i = 0; i < packageArray.size; i++ )
|
||||
{
|
||||
for ( j = 0; j < level.ambientPackages[packageArray[i]].priority.size; j++ )
|
||||
{
|
||||
if ( level.ambientPackages[packageArray[i]].refcount[j] && level.ambientPackages[packageArray[i]].priority[j] > priority )
|
||||
{
|
||||
package = packageArray[i];
|
||||
priority = level.ambientPackages[packageArray[i]].priority[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
return package;
|
||||
}
|
||||
updateActiveAmbientPackage()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
level waittill( "updateActiveAmbientPackage" );
|
||||
newAmbientPackage = findHighestPriorityAmbientPackage();
|
||||
println("*** nap " + newAmbientPackage + " " + level.activeAmbientPackage);
|
||||
if ( newAmbientPackage != "" && level.activeAmbientPackage != newAmbientPackage )
|
||||
{
|
||||
level notify( "killambientElementThread" + level.activeAmbientPackage );
|
||||
level.activeAmbientPackage = newAmbientPackage;
|
||||
array_thread( level.ambientPackages[level.activeAmbientPackage].elements, ::ambientElementThread );
|
||||
}
|
||||
}
|
||||
}
|
||||
roomToneFadeOutTimerThread( fadeOut )
|
||||
{
|
||||
self endon( "killRoomToneFadeOutTimer" );
|
||||
wait fadeOut;
|
||||
self.inuse = false;
|
||||
}
|
||||
findHighestPriorityAmbientRoom()
|
||||
{
|
||||
room = "";
|
||||
priority = -1;
|
||||
roomArray = getArrayKeys( level.ambientRooms );
|
||||
if(isdefined(roomArray))
|
||||
{
|
||||
for ( i = 0; i < roomArray.size; i++ )
|
||||
{
|
||||
for ( j = 0; j < level.ambientRooms[roomArray[i]].priority.size; j++ )
|
||||
{
|
||||
if ( level.ambientRooms[roomArray[i]].refcount[j] )
|
||||
{
|
||||
}
|
||||
if ( level.ambientRooms[roomArray[i]].refcount[j] && level.ambientRooms[roomArray[i]].priority[j] > priority )
|
||||
{
|
||||
room = roomArray[i];
|
||||
priority = level.ambientRooms[roomArray[i]].priority[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return room;
|
||||
}
|
||||
saveRestore()
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
level waittill("save_restore");
|
||||
level.activeAmbientRoom = "";
|
||||
level notify( "updateActiveAmbientRoom" );
|
||||
}
|
||||
}
|
||||
updateActiveAmbientRoom()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
newAmbientRoom = findHighestPriorityAmbientRoom();
|
||||
if(newAmbientRoom == level.activeAmbientRoom)
|
||||
{
|
||||
level waittill( "updateActiveAmbientRoom" );
|
||||
}
|
||||
if(newAmbientRoom == level.activeAmbientRoom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
oldroom = level.ambientRooms[level.activeAmbientRoom];
|
||||
newroom = level.ambientRooms[newAmbientRoom];
|
||||
if(isdefined(oldroom) && isdefined(newroom)
|
||||
&& isdefined(oldroom.tone) && isdefined(newroom.tone)
|
||||
&& oldroom.tone == newroom.tone)
|
||||
{
|
||||
tmp = newroom.ent;
|
||||
newroom.ent = oldroom.ent;
|
||||
oldroom.ent = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isdefined(newroom) && isdefined(newroom.tone))
|
||||
{
|
||||
newroom.id = playloopsound( 0, newroom.ent, newroom.tone, newroom.fadeIn );
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
if(isdefined(oldroom) && isdefined(oldroom.tone))
|
||||
{
|
||||
stoploopsound(0, oldroom.ent, oldroom.fadeOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
if ( !isdefined( newroom ) || !isdefined( newroom.reverb ) )
|
||||
{
|
||||
deactivateReverb( "snd_enveffectsprio_level", 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
setReverb( "snd_enveffectsprio_level", newroom.reverb.reverbRoomType, newroom.reverb.dry, newroom.reverb.wet, newroom.reverb.fade );
|
||||
}
|
||||
snapshot = "default";
|
||||
if( isdefined( newroom ) && isdefined( newroom.snapshot ) )
|
||||
{
|
||||
snapshot = newroom.snapshot;
|
||||
}
|
||||
setAmbientSnapshot(snapshot);
|
||||
if(isdefined(newroom) && isdefined(level.ambientContexts))
|
||||
{
|
||||
contexts = getArrayKeys(level.ambientContexts);
|
||||
for(i=0; i<contexts.size; i++)
|
||||
{
|
||||
setsoundcontext( contexts[i], "");
|
||||
}
|
||||
if( isdefined( newroom.context ) )
|
||||
{
|
||||
keys = getArrayKeys(newroom.context);
|
||||
for(i=0; i<keys.size; i++)
|
||||
{
|
||||
setsoundcontext( keys[i], newroom.context[ keys[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
level.activeAmbientRoom = newAmbientRoom;
|
||||
}
|
||||
}
|
||||
|
556
BO1/PC/ZM/clientscripts/_audio.csc
Normal file
556
BO1/PC/ZM/clientscripts/_audio.csc
Normal file
@ -0,0 +1,556 @@
|
||||
|
||||
#include clientscripts\_utility;
|
||||
audio_init( localClientNum )
|
||||
{
|
||||
if( localClientNum == 0 )
|
||||
{
|
||||
snd_snapshot_init();
|
||||
thread snd_snapshot_level_fadein();
|
||||
startSoundRandoms( localClientNum );
|
||||
startSoundLoops();
|
||||
startLineEmitters();
|
||||
thread bump_trigger_start();
|
||||
thread init_audio_step_triggers();
|
||||
thread start_player_health_snapshot();
|
||||
init_after_save_restore();
|
||||
}
|
||||
}
|
||||
init_after_save_restore()
|
||||
{
|
||||
level waittill( "save_restore" );
|
||||
level thread audio_init( 0 );
|
||||
}
|
||||
snd_snapshot_init()
|
||||
{
|
||||
level._sndActiveSnapshot = "default";
|
||||
if(!isdefined(level._sndNextSnapshot))
|
||||
{
|
||||
level._sndNextSnapshot = "default";
|
||||
}
|
||||
setgroupsnapshot( level._sndActiveSnapshot );
|
||||
thread snd_snapshot_think();
|
||||
thread snd_snapshot_save();
|
||||
}
|
||||
snd_snapshot_save()
|
||||
{
|
||||
level waittill( "save_restore" );
|
||||
setgroupsnapshot( level._sndActiveSnapshot );
|
||||
}
|
||||
snd_set_snapshot( state )
|
||||
{
|
||||
level._sndNextSnapshot = state;
|
||||
println( "snd snapshot debug: set state '"+state+"'" );
|
||||
level notify( "new_bus" );
|
||||
}
|
||||
snd_snapshot_think()
|
||||
{
|
||||
level endon( "save_restore" );
|
||||
for(;;)
|
||||
{
|
||||
if( level._sndActiveSnapshot == level._sndNextSnapshot )
|
||||
{
|
||||
level waittill( "new_bus" );
|
||||
}
|
||||
if( level._sndActiveSnapshot == level._sndNextSnapshot )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
assert( IsDefined( level._sndNextSnapshot ) );
|
||||
assert( IsDefined( level._sndActiveSnapshot ) );
|
||||
setgroupsnapshot( level._sndNextSnapshot );
|
||||
level._sndActiveSnapshot = level._sndNextSnapshot;
|
||||
}
|
||||
}
|
||||
snd_snapshot_level_fadein()
|
||||
{
|
||||
level notify( "end_duplicate_fadein" );
|
||||
level endon( "end_duplicate_fadein" );
|
||||
for(;;)
|
||||
{
|
||||
SetLevelFadeSnapshot( "fadein", 1.0 );
|
||||
waitforclient( 0 );
|
||||
wait( 0.5 );
|
||||
snapshot_value = 1.0;
|
||||
while( snapshot_value > 0.0 )
|
||||
{
|
||||
snapshot_value -= 0.05;
|
||||
SetLevelFadeSnapshot( "fadein", snapshot_value );
|
||||
wait( 0.02 );
|
||||
}
|
||||
SetLevelFadeSnapshot( "fadein", 0.0 );
|
||||
if( level.zombiemode == true )
|
||||
{
|
||||
return;
|
||||
}
|
||||
player = getlocalplayer(0);
|
||||
player waittill("respawn");
|
||||
}
|
||||
}
|
||||
soundRandom_Thread( localClientNum, randSound )
|
||||
{
|
||||
level endon( "save_restore" );
|
||||
if( !IsDefined( randSound.script_wait_min ) )
|
||||
{
|
||||
randSound.script_wait_min = 1;
|
||||
}
|
||||
if( !IsDefined( randSound.script_wait_max ) )
|
||||
{
|
||||
randSound.script_wait_max = 3;
|
||||
}
|
||||
while( 1 )
|
||||
{
|
||||
wait( RandomFloatRange( randSound.script_wait_min, randSound.script_wait_max ) );
|
||||
if( !IsDefined( randSound.script_sound ) )
|
||||
{
|
||||
println( "ambient sound at "+randSound.origin+" has undefined script_sound" );
|
||||
}
|
||||
else
|
||||
{
|
||||
playsound( localClientNum, randSound.script_sound, randSound.origin );
|
||||
}
|
||||
}
|
||||
}
|
||||
startSoundRandoms( localClientNum )
|
||||
{
|
||||
randoms = GetStructArray( "random", "script_label" );
|
||||
if( IsDefined( randoms ) && randoms.size > 0 )
|
||||
{
|
||||
println( "*** Client : Initialising random sounds - " + randoms.size + " emitters." );
|
||||
for( i = 0; i < randoms.size; i++ )
|
||||
{
|
||||
thread soundRandom_Thread( localClientNum, randoms[i] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
println( "*** Client : No random sounds." );
|
||||
}
|
||||
}
|
||||
soundLoopThink()
|
||||
{
|
||||
if( !IsDefined( self.script_sound ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( !IsDefined( self.origin ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
level endon( "save_restore" );
|
||||
notifyName = "";
|
||||
assert( IsDefined( notifyName ) );
|
||||
if( IsDefined( self.script_string ) )
|
||||
{
|
||||
notifyName = self.script_string;
|
||||
}
|
||||
assert( IsDefined( notifyName ) );
|
||||
started = true;
|
||||
if( IsDefined( self.script_int) )
|
||||
{
|
||||
started = self.script_int != 0;
|
||||
}
|
||||
if( started )
|
||||
{
|
||||
soundloopemitter( self.script_sound, self.origin );
|
||||
}
|
||||
if( notifyName != "" )
|
||||
{
|
||||
println( "starting loop notify" );
|
||||
for(;;)
|
||||
{
|
||||
level waittill( notifyName );
|
||||
if(started)
|
||||
{
|
||||
soundstoploopemitter( self.script_sound, self.origin );
|
||||
}
|
||||
else
|
||||
{
|
||||
soundloopemitter( self.script_sound, self.origin );
|
||||
}
|
||||
started = !started;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
soundLineThink()
|
||||
{
|
||||
level endon("save_restore");
|
||||
if( !IsDefined( self.target) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
target = getstruct( self.target, "targetname" );
|
||||
if( !IsDefined( target) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
notifyName = "";
|
||||
if( IsDefined( self.script_string ) )
|
||||
{
|
||||
notifyName = self.script_string;
|
||||
}
|
||||
started = true;
|
||||
if( IsDefined( self.script_int) )
|
||||
{
|
||||
started = self.script_int != 0;
|
||||
}
|
||||
if( started )
|
||||
{
|
||||
soundLineEmitter( self.script_sound, self.origin, target.origin );
|
||||
}
|
||||
if( notifyName != "" )
|
||||
{
|
||||
println( "starting line notify" );
|
||||
for(;;)
|
||||
{
|
||||
level waittill( notifyName );
|
||||
if( started )
|
||||
{
|
||||
soundStopLineEmitter( self.script_sound, self.origin, target.origin );
|
||||
}
|
||||
else
|
||||
{
|
||||
soundLineEmitter( self.script_sound, self.origin, target.origin );
|
||||
}
|
||||
started = !started;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
startSoundLoops()
|
||||
{
|
||||
loopers = GetStructArray( "looper", "script_label" );
|
||||
if( IsDefined( loopers ) && loopers.size > 0 )
|
||||
{
|
||||
delay = 0;
|
||||
println( "*** Client : Initialising looper sounds - " + loopers.size + " emitters." );
|
||||
for( i = 0; i < loopers.size; i++ )
|
||||
{
|
||||
loopers[i] thread soundLoopThink();
|
||||
delay += 1;
|
||||
if( delay % 20 == 0 )
|
||||
{
|
||||
wait( 0.01 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
println( "*** Client : No looper sounds." );
|
||||
}
|
||||
}
|
||||
startLineEmitters()
|
||||
{
|
||||
lineEmitters = GetStructArray( "line_emitter", "script_label" );
|
||||
if( IsDefined( lineEmitters ) && lineEmitters.size > 0 )
|
||||
{
|
||||
delay = 0;
|
||||
println( "*** Client : Initialising line emitter sounds - " + lineEmitters.size + " emitters." );
|
||||
for( i = 0; i < lineEmitters.size; i++ )
|
||||
{
|
||||
lineEmitters[i] thread soundLineThink();
|
||||
delay += 1;
|
||||
if( delay % 20 == 0 )
|
||||
{
|
||||
wait( 0.01 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
println( "*** Client : No line emitter sounds." );
|
||||
}
|
||||
}
|
||||
init_audio_step_triggers()
|
||||
{
|
||||
waitforclient( 0 );
|
||||
trigs = GetEntArray( 0, "audio_step_trigger","targetname" );
|
||||
println( "Client : " + trigs.size + " audio_step_triggers." );
|
||||
array_thread( trigs, ::audio_step_trigger );
|
||||
}
|
||||
audio_step_trigger( trig )
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
self waittill( "trigger", trigPlayer );
|
||||
self thread trigger_thread( trigPlayer, ::trig_enter_audio_step_trigger, ::trig_leave_audio_step_trigger );
|
||||
}
|
||||
}
|
||||
trig_enter_audio_step_trigger( trigPlayer )
|
||||
{
|
||||
if( !IsDefined( trigPlayer.movementtype ) )
|
||||
{
|
||||
trigPlayer.movementtype = "null";
|
||||
}
|
||||
if( Isdefined( self.script_label) )
|
||||
{
|
||||
trigPlayer.step_sound = self.script_label;
|
||||
}
|
||||
if( Isdefined( self.script_sound ) && ( trigPlayer.movementtype == "sprint" ) )
|
||||
{
|
||||
volume = 9;
|
||||
self playsound( 0, self.script_sound, self.origin, volume );
|
||||
}
|
||||
}
|
||||
trig_leave_audio_step_trigger(trigPlayer)
|
||||
{
|
||||
if( Isdefined( self.script_noteworthy ) && ( trigPlayer.movementtype == "sprint" ) )
|
||||
{
|
||||
volume = 9;
|
||||
self playsound( 0, self.script_noteworthy, self.origin, volume );
|
||||
}
|
||||
trigPlayer.step_sound = "null";
|
||||
}
|
||||
bump_trigger_start()
|
||||
{
|
||||
bump_trigs = GetEntArray( 0, "audio_bump_trigger", "targetname" );
|
||||
for( i = 0; i < bump_trigs.size; i++)
|
||||
{
|
||||
bump_trigs[i] thread thread_bump_trigger();
|
||||
}
|
||||
}
|
||||
thread_bump_trigger()
|
||||
{
|
||||
self thread bump_trigger_listener();
|
||||
if( !IsDefined( self.script_activated ) )
|
||||
{
|
||||
self.script_activated = 1;
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
self waittill ( "trigger", trigPlayer );
|
||||
self thread trigger_thread( trigPlayer, ::trig_enter_bump, ::trig_leave_bump );
|
||||
}
|
||||
}
|
||||
trig_enter_bump( ent )
|
||||
{
|
||||
volume = get_vol_from_speed( ent );
|
||||
if( IsDefined( self.script_sound ) && self.script_activated )
|
||||
{
|
||||
if( IsDefined( self.script_noteworthy ) && IsDefined(self.script_wait) && ( self.script_wait > volume ) )
|
||||
{
|
||||
test_id = self playsound( 0, self.script_noteworthy,self.origin, volume );
|
||||
}
|
||||
if( !IsDefined( self.script_wait ) || ( self.script_wait <= volume ) )
|
||||
{
|
||||
test_id = self playsound( 0, self.script_sound, self.origin, volume );
|
||||
}
|
||||
}
|
||||
}
|
||||
trig_leave_bump( ent )
|
||||
{
|
||||
}
|
||||
bump_trigger_listener()
|
||||
{
|
||||
if( IsDefined( self.script_label ) )
|
||||
{
|
||||
level waittill( self.script_label );
|
||||
self.script_activated = 0;
|
||||
}
|
||||
}
|
||||
start_player_health_snapshot()
|
||||
{
|
||||
if( IsDefined( level.zombiemode ) && level.zombiemode == true )
|
||||
{
|
||||
return;
|
||||
}
|
||||
level endon( "save_restore" );
|
||||
wait( 1 );
|
||||
max_health = GetLocalClientMaxHealth( 0 );
|
||||
last_health = 0;
|
||||
health_snapshot = "pain_heavy_occlude";
|
||||
SetHealthSnapshot( health_snapshot, 0 );
|
||||
for( ;; )
|
||||
{
|
||||
wait ( 0.05 );
|
||||
health = GetLocalClientHealth( 0 );
|
||||
if( health > 70 )
|
||||
{
|
||||
health_scale = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
health_scale = 1 - ( health * ( 1 / 100 ) );
|
||||
}
|
||||
SetHealthSnapshot( health_snapshot, health_scale );
|
||||
}
|
||||
}
|
||||
scale_speed(x1 ,x2 ,y1 ,y2 ,z )
|
||||
{
|
||||
if ( z < x1)
|
||||
z = x1;
|
||||
if ( z > x2)
|
||||
z = x2;
|
||||
dx = x2 - x1;
|
||||
n = ( z - x1) / dx;
|
||||
dy = y2 - y1;
|
||||
w = (n*dy + y1);
|
||||
return w;
|
||||
}
|
||||
get_vol_from_speed( player )
|
||||
{
|
||||
min_speed = 21;
|
||||
max_speed = 285;
|
||||
max_vol = 1;
|
||||
min_vol = .1;
|
||||
speed = player getspeed();
|
||||
if(speed == 0 )
|
||||
{
|
||||
speed = 175;
|
||||
}
|
||||
if( IsDefined( level.footstep_vol_override ) )
|
||||
{
|
||||
min_vol = .5;
|
||||
}
|
||||
abs_speed = absolute_value( int( speed ) );
|
||||
volume = scale_speed( min_speed, max_speed, min_vol, max_vol, abs_speed );
|
||||
return volume;
|
||||
}
|
||||
absolute_value( fowd )
|
||||
{
|
||||
if( fowd < 0 )
|
||||
return (fowd*-1);
|
||||
else
|
||||
return fowd;
|
||||
}
|
||||
closest_point_on_line_to_point( Point, LineStart, LineEnd )
|
||||
{
|
||||
self endon ("end line sound");
|
||||
LineMagSqrd = lengthsquared(LineEnd - LineStart);
|
||||
t = ( ( ( Point[0] - LineStart[0] ) * ( LineEnd[0] - LineStart[0] ) ) +
|
||||
( ( Point[1] - LineStart[1] ) * ( LineEnd[1] - LineStart[1] ) ) +
|
||||
( ( Point[2] - LineStart[2] ) * ( LineEnd[2] - LineStart[2] ) ) ) /
|
||||
( LineMagSqrd );
|
||||
if( t < 0.0 )
|
||||
{
|
||||
self.origin = LineStart;
|
||||
}
|
||||
else if( t > 1.0 )
|
||||
{
|
||||
self.origin = LineEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
start_x = LineStart[0] + t * ( LineEnd[0] - LineStart[0] );
|
||||
start_y = LineStart[1] + t * ( LineEnd[1] - LineStart[1] );
|
||||
start_z = LineStart[2] + t * ( LineEnd[2] - LineStart[2] );
|
||||
self.origin = ( start_x, start_y, start_z );
|
||||
}
|
||||
}
|
||||
playloopat( localClientNum, aliasname, origin, fade )
|
||||
{
|
||||
if( !IsDefined( fade ) )
|
||||
fade = 0;
|
||||
fake_ent = spawnfakeent( localClientNum );
|
||||
setfakeentorg( localClientNum, fake_ent, origin );
|
||||
playloopsound( localClientNum, fake_ent, aliasname, fade );
|
||||
return fake_ent;
|
||||
}
|
||||
snd_play_auto_fx( fxid, alias )
|
||||
{
|
||||
for( i = 0; i < level.createFXent.size; i++ )
|
||||
{
|
||||
if( level.createFXent[i].v["fxid"] == fxid && !IsDefined( level.createFXent[i].soundEnt ) )
|
||||
{
|
||||
level.createFXent[i].soundEnt = spawnFakeEnt( 0 );
|
||||
setfakeentorg( 0, level.createFXent[i].soundEnt, level.createFXent[i].v["origin"] );
|
||||
playloopsound( 0, level.createFXent[i].soundEnt, alias, .5 );
|
||||
}
|
||||
}
|
||||
}
|
||||
snd_delete_auto_fx( fxid )
|
||||
{
|
||||
for( i = 0; i < level.createFXent.size; i++ )
|
||||
{
|
||||
if( level.createFXent[i].v["fxid"] == fxid && IsDefined( level.createFXent[i].soundEnt ) )
|
||||
{
|
||||
deletefakeent(0, level.createFXent[i].soundEnt);
|
||||
level.createFXent[i].soundEnt = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
snd_print_fx_id( fxid, type, ent )
|
||||
{
|
||||
printLn( "^5 ******* fxid; " + fxid + "^5 type; " + type );
|
||||
}
|
||||
debug_line_emitter()
|
||||
{
|
||||
while( 1 )
|
||||
{
|
||||
}
|
||||
}
|
||||
move_sound_along_line()
|
||||
{
|
||||
closest_dist = undefined;
|
||||
while( 1 )
|
||||
{
|
||||
self closest_point_on_line_to_point( getlocalclientpos( 0 ), self.start, self.end );
|
||||
if( IsDefined( self.fake_ent ) )
|
||||
{
|
||||
setfakeentorg( self.localClientNum, self.fake_ent, self.origin );
|
||||
}
|
||||
closest_dist = DistanceSquared( getlocalclientpos( 0 ), self.origin );
|
||||
if( closest_dist > 1024 * 1024 )
|
||||
{
|
||||
wait( 2 );
|
||||
}
|
||||
else if( closest_dist > 512 * 512 )
|
||||
{
|
||||
wait( 0.2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
wait( 0.05 );
|
||||
}
|
||||
}
|
||||
}
|
||||
line_sound_player()
|
||||
{
|
||||
if( IsDefined( self.script_looping ) )
|
||||
{
|
||||
self.fake_ent = spawnfakeent( self.localClientNum );
|
||||
setfakeentorg( self.localClientNum, self.fake_ent, self.origin );
|
||||
playloopsound( self.localClientNum, self.fake_ent, self.script_sound );
|
||||
}
|
||||
else
|
||||
{
|
||||
playsound( self.localClientNum, self.script_sound, self.origin );
|
||||
}
|
||||
}
|
||||
soundwait( id )
|
||||
{
|
||||
while( soundplaying( id ) )
|
||||
{
|
||||
wait( 0.1 );
|
||||
}
|
||||
}
|
||||
sound_movie_snapshot_start()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
level waittill ("pms");
|
||||
wait(0.3);
|
||||
snd_set_snapshot ("alloff_except_voice_music");
|
||||
}
|
||||
}
|
||||
sound_movie_snapshot_alloff_but_mid_start()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
level waittill ("pmsao");
|
||||
wait(0.2);
|
||||
snd_set_snapshot ("flashback_duck");
|
||||
}
|
||||
}
|
||||
sound_movie_snapshot_stop()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
level waittill ("pmo");
|
||||
snd_set_snapshot ("default");
|
||||
}
|
||||
} |