This commit is contained in:
2025-05-21 16:23:17 +02:00
commit 222e802504
359 changed files with 242229 additions and 0 deletions

View File

@ -0,0 +1,547 @@
#include common_scripts\utility;
setfogsliders()
{
/$
// The read-only vars are set each time a call to SetExpFog is made, so they should contain the 'fog dest' params
SetDevDvar( "scr_fog_exp_halfplane", GetDvar( "g_fogHalfDistReadOnly", 0.0 ) );
SetDevDvar( "scr_fog_nearplane", GetDvar( "g_fogStartDistReadOnly", 0.1 ) );
SetDevDvar( "scr_fog_color", GetDvar( "g_fogColorReadOnly", ( 1, 0, 0 ) ) );
SetDevDvar( "scr_fog_color_intensity", GetDvar( "g_fogColorIntensityReadOnly", 1.0 ) );
SetDevDvar( "scr_fog_max_opacity", GetDvar( "g_fogMaxOpacityReadOnly", 1.0 ) );
SetDevDvar( "scr_sunFogEnabled", GetDvar( "g_sunFogEnabledReadOnly", 0 ) );
SetDevDvar( "scr_sunFogColor", GetDvar( "g_sunFogColorReadOnly", ( 1, 0, 0 ) ) );
SetDevDvar( "scr_sunfogColorIntensity", GetDvar( "g_sunFogColorIntensityReadOnly", 1.0 ) );
SetDevDvar( "scr_sunFogDir", GetDvarVector( "g_sunFogDirReadOnly", ( 1, 0, 0 ) ) );
SetDevDvar( "scr_sunFogBeginFadeAngle", GetDvar( "g_sunFogBeginFadeAngleReadOnly", 0.0 ) );
SetDevDvar( "scr_sunFogEndFadeAngle", GetDvar( "g_sunFogEndFadeAngleReadOnly", 180.0 ) );
SetDevDvar( "scr_sunFogScale", GetDvar( "g_sunFogScaleReadOnly", 1.0 ) );
SetDevDvar( "scr_heightFogEnabled", GetDvar( "g_heightFogEnabledReadOnly", 0 ) );
SetDevDvar( "scr_heightFogBaseHeight", GetDvar( "g_heightFogBaseHeightReadOnly", 0 ) );
SetDevDvar( "scr_heightFogHalfPlaneDistance", GetDvar( "g_heightFogHalfPlaneDistanceReadOnly", 1000 ) );
// The r_sky_fog vars are only active if tweaks on them are enabled, which is a little strange...
SetDevDvar( "scr_skyFogIntensity", GetDvar( "r_sky_fog_intensity", 0.0 ) );
SetDevDvar( "scr_skyFogMinAngle", GetDvar( "r_sky_fog_min_angle", 0.0 ) );
SetDevDvar( "scr_skyFogMaxAngle", GetDvar( "r_sky_fog_max_angle", 90.0 ) );
SetDevDvar( "scr_atmosFogEnabled", GetDvar( "g_atmosFogEnabledReadOnly", 0 ) );
SetDevDvar( "scr_atmosFogSunFogColor", GetDvar( "g_atmosFogSunFogColorReadOnly", (.5, .5, .5 ) ) );
SetDevDvar( "scr_atmosFogHazeColor", GetDvar( "g_atmosFogHazeColorReadOnly", (.5, .5, .5 ) ) );
SetDevDvar( "scr_atmosFogHazeStrength", GetDvar( "g_atmosFogHazeStrengthReadOnly", .5 ) );
SetDevDvar( "scr_atmosFogHazeSpread", GetDvar( "g_atmosFogHazeSpreadReadOnly", .75 ) );
SetDevDvar( "scr_atmosFogExtinctionStrength", GetDvar( "g_atmosFogExtinctionStrengthReadOnly", 1 ) );
SetDevDvar( "scr_atmosFogInScatterStrength", GetDvar( "g_atmosFogInScatterStrengthReadOnly", 0 ) );
SetDevDvar( "scr_atmosFogHalfPlaneDistance", GetDvar( "g_atmosFogHalfPlaneDistanceReadOnly", 5000 ) );
SetDevDvar( "scr_atmosFogStartDistance", GetDvar( "g_atmosFogStartDistanceReadOnly", 0 ) );
SetDevDvar( "scr_atmosFogDistanceScale", GetDvar( "g_atmosFogDistanceScaleReadOnly", 1 ) );
SetDevDvar( "scr_atmosFogSkyDistance", int( GetDvar( "g_atmosFogSkyDistanceReadOnly", 100000 ) ) );
SetDevDvar( "scr_atmosFogSkyAngularFalloffEnabled", GetDvar( "g_atmosFogSkyAngularFalloffEnabledReadOnly", 0 ) );
SetDevDvar( "scr_atmosFogSkyFalloffStartAngle", GetDvar( "g_atmosFogSkyFalloffStartAngleReadOnly", 0 ) );
SetDevDvar( "scr_atmosFogSkyFalloffAngleRange", GetDvar( "g_atmosFogSkyFalloffAngleRangeReadOnly", 90 ) );
SetDevDvar( "scr_atmosFogSunDirection", GetDvarVector( "g_atmosFogSunDirectionReadOnly", (0, 0, 1) ) );
SetDevDvar( "scr_atmosFogHeightFogEnabled", GetDvar( "g_atmosFogHeightFogEnabledReadOnly", 0 ) );
SetDevDvar( "scr_atmosFogHeightFogBaseHeight", GetDvar( "g_atmosFogHeightFogBaseHeightReadOnly", 0 ) );
SetDevDvar( "scr_atmosFogHeightFogHalfPlaneDistance", GetDvar( "g_atmosFogHeightFogHalfPlaneDistanceReadOnly", 1000 ) );
$/
}
/$
translateFogSlidersToScript()
{
level.fogexphalfplane = limit( GetDvarFloat( "scr_fog_exp_halfplane" ) );
level.fognearplane = limit( GetDvarFloat( "scr_fog_nearplane" ) );
level.fogHDRColorIntensity = limit( GetDvarFloat( "scr_fog_color_intensity" ) );
level.fogmaxopacity = limit( GetDvarFloat( "scr_fog_max_opacity" ) );
level.sunFogEnabled = GetDvarInt( "scr_sunFogEnabled" );
level.sunFogHDRColorIntensity = limit( GetDvarFloat( "scr_sunFogColorIntensity" ) );
level.sunFogBeginFadeAngle = limit( GetDvarFloat( "scr_sunFogBeginFadeAngle" ) );
level.sunFogEndFadeAngle = limit( GetDvarFloat( "scr_sunFogEndFadeAngle" ) );
level.sunFogScale = limit( GetDvarFloat( "scr_sunFogScale" ) );
level.skyFogIntensity = limit( GetDvarFloat( "scr_skyFogIntensity" ) );
level.skyFogMinAngle = limit( GetDvarFloat( "scr_skyFogMinAngle" ) );
level.skyFogMaxAngle = limit( GetDvarFloat( "scr_skyFogMaxAngle" ) );
level.heightFogEnabled = GetDvarInt( "scr_heightFogEnabled" );
level.heightFogBaseHeight = limit( GetDvarFloat( "scr_heightFogBaseHeight" ) );
level.heightFogHalfPlaneDistance = limit( GetDvarFloat( "scr_heightFogHalfPlaneDistance" ) );
fogColor = GetDvarVector( "scr_fog_color" );
r = limit( fogColor[0] );
g = limit( fogColor[1] );
b = limit( fogColor[2] );
level.fogcolor = ( r, g , b );
sunFogColor = GetDvarVector( "scr_sunFogColor" );
r = limit( sunFogColor[0] );
g = limit( sunFogColor[1] );
b = limit( sunFogColor[2] );
level.sunFogColor =( r, g , b );
sunFogDir = GetDvarVector( "scr_sunFogDir" );
x = limit( sunFogDir[0]);
y = limit( sunFogDir[1]);
z = limit( sunFogDir[2]);
level.sunFogDir = (x,y,z);
level.atmosFogEnabled = GetDvarInt( "scr_atmosFogEnabled" );
vec3 = GetDvarVector( "scr_atmosFogSunFogColor" );
x = limit( vec3[0] );
y = limit( vec3[1] );
z = limit( vec3[2] );
level.atmosFogSunFogColor = ( x, y, z );
vec3 = GetDvarVector( "scr_atmosFogHazeColor" );
x = limit( vec3[0] );
y = limit( vec3[1] );
z = limit( vec3[2] );
level.atmosFogHazeColor = ( x, y, z );
level.atmosFogHazeStrength = limit( GetDvarFloat( "scr_atmosFogHazeStrength" ) );
level.atmosFogHazeSpread = limit( GetDvarFloat( "scr_atmosFogHazeSpread" ) );
level.atmosFogExtinctionStrength = limit( GetDvarFloat( "scr_atmosFogExtinctionStrength" ) );
level.atmosFogInScatterStrength = limit( GetDvarFloat( "scr_atmosFogInScatterStrength" ) );
level.atmosFogHalfPlaneDistance = limit( GetDvarFloat( "scr_atmosFogHalfPlaneDistance" ) );
level.atmosFogStartDistance = limit( GetDvarFloat( "scr_atmosFogStartDistance" ) );
level.atmosFogDistanceScale = limit( GetDvarFloat( "scr_atmosFogDistanceScale" ) );
level.atmosFogSkyDistance = GetDvarInt( "scr_atmosFogSkyDistance" );
level.atmosFogSkyAngularFalloffEnabled = GetDvarInt( "scr_atmosFogSkyAngularFalloffEnabled" );
level.atmosFogSkyFalloffStartAngle = limit( GetDvarFloat( "scr_atmosFogSkyFalloffStartAngle" ) );
level.atmosFogSkyFalloffAngleRange = limit( GetDvarFloat( "scr_atmosFogSkyFalloffAngleRange" ) );
vec3 = GetDvarVector( "scr_atmosFogSunDirection" );
x = limit( vec3[0] );
y = limit( vec3[1] );
z = limit( vec3[2] );
level.atmosFogSunDirection = ( x, y, z );
level.atmosFogHeightFogEnabled = GetDvarInt( "scr_atmosFogHeightFogEnabled" );
level.atmosFogHeightFogBaseHeight = limit( GetDvarFloat( "scr_atmosFogHeightFogBaseHeight" ) );
level.atmosFogHeightFogHalfPlaneDistance = limit( GetDvarFloat( "scr_atmosFogHeightFogHalfPlaneDistance" ) );
}
limit( i)
{
limit = 0.001;
if ( ( i < limit ) && ( i > ( limit * -1 ) ) )
i = 0;
return i;
}
updateFogEntFromScript()
{
if ( GetDvarInt( "scr_cmd_plr_sun" ) )
{
SetDevDvar( "scr_sunFogDir", AnglesToForward( level.player GetPlayerAngles() ) );
SetDevDvar( "scr_cmd_plr_sun", 0 );
}
if ( GetDvarInt( "scr_cmd_plr_sun_atmos_fog" ) )
{
SetDevDvar( "scr_atmosFogSunDirection", AnglesToForward( level.player GetPlayerAngles() ) );
SetDevDvar( "scr_cmd_plr_sun_atmos_fog", 0 );
}
vision_set_name = ToLower(level.vision_set_transition_ent.vision_set);
if ( level.currentgen )
{
vision_set_name_cg = vision_set_name + "_cg";
if ( IsDefined( level.vision_set_fog[ vision_set_name_cg ] ) )
vision_set_name = vision_set_name_cg;
}
ent = level.vision_set_fog[ vision_set_name ];
if ( isdefined( ent ) && isdefined( ent.HDROverride ) && isdefined( level.vision_set_fog[ ToLower(ent.HDROverride) ] ) )
{
ent = level.vision_set_fog[ ToLower(ent.HDROverride) ];
}
if( IsDefined( ent ) && isdefined( ent.name ) )
{
ent.startDist = level.fognearplane;
ent.halfwayDist = level.fogexphalfplane;
ent.red = level.fogcolor[ 0 ];
ent.green = level.fogcolor[ 1 ];
ent.blue = level.fogcolor[ 2 ];
ent.HDRColorIntensity = level.fogHDRColorIntensity;
ent.maxOpacity = level.fogmaxopacity;
ent.sunFogEnabled = level.sunFogEnabled;
ent.sunRed = level.sunFogColor[ 0 ];
ent.sunGreen = level.sunFogColor[ 1 ];
ent.sunBlue = level.sunFogColor[ 2 ];
ent.HDRSunColorIntensity = level.sunFogHDRColorIntensity;
ent.sunDir = level.sunFogDir;
ent.sunBeginFadeAngle = level.sunFogBeginFadeAngle;
ent.sunEndFadeAngle = level.sunFogEndFadeAngle;
ent.normalFogScale = level.sunFogScale;
ent.skyFogIntensity = level.skyFogIntensity;
ent.skyFogMinAngle = level.skyFogMinAngle;
ent.skyFogMaxAngle = level.skyFogMaxAngle;
if ( IsDefined( level.heightFogEnabled ) && IsDefined( level.heightFogBaseHeight ) && IsDefined( level.heightFogHalfPlaneDistance ) )
{
ent.heightFogEnabled = level.heightFogEnabled;
ent.heightFogBaseHeight = level.heightFogBaseHeight;
ent.heightFogHalfPlaneDistance = level.heightFogHalfPlaneDistance;
}
else
{
ent.heightFogEnabled = 0;
ent.heightFogBaseHeight = 0;
ent.heightFogHalfPlaneDistance = 1000;
}
if ( IsDefined( level.atmosFogEnabled ) )
{
Assert( IsDefined( level.atmosFogSunFogColor ) );
Assert( IsDefined( level.atmosFogHazeColor ) );
Assert( IsDefined( level.atmosFogHazeStrength ) );
Assert( IsDefined( level.atmosFogHazeSpread ) );
Assert( IsDefined( level.atmosFogExtinctionStrength ) );
Assert( IsDefined( level.atmosFogInScatterStrength ) );
Assert( IsDefined( level.atmosFogHalfPlaneDistance ) );
Assert( IsDefined( level.atmosFogStartDistance ) );
Assert( IsDefined( level.atmosFogDistanceScale ) );
Assert( IsDefined( level.atmosFogSkyDistance ) );
Assert( IsDefined( level.atmosFogSkyAngularFalloffEnabled ) );
Assert( IsDefined( level.atmosFogSkyFalloffStartAngle ) );
Assert( IsDefined( level.atmosFogSkyFalloffAngleRange ) );
Assert( IsDefined( level.atmosFogSunDirection ) );
Assert( IsDefined( level.atmosFogHeightFogEnabled ) );
Assert( IsDefined( level.atmosFogHeightFogBaseHeight ) );
Assert( IsDefined( level.atmosFogHeightFogHalfPlaneDistance ) );
ent.atmosFogEnabled = level.atmosFogEnabled;
ent.atmosFogSunFogColor = level.atmosFogSunFogColor;
ent.atmosFogHazeColor = level.atmosFogHazeColor;
ent.atmosFogHazeStrength = level.atmosFogHazeStrength;
ent.atmosFogHazeSpread = level.atmosFogHazeSpread;
ent.atmosFogExtinctionStrength = level.atmosFogExtinctionStrength;
ent.atmosFogInScatterStrength = level.atmosFogInScatterStrength;
ent.atmosFogHalfPlaneDistance = level.atmosFogHalfPlaneDistance;
ent.atmosFogStartDistance = level.atmosFogStartDistance;
ent.atmosFogDistanceScale = level.atmosFogDistanceScale;
ent.atmosFogSkyDistance = level.atmosFogSkyDistance;
ent.atmosFogSkyAngularFalloffEnabled = level.atmosFogSkyAngularFalloffEnabled;
ent.atmosFogSkyFalloffStartAngle = level.atmosFogSkyFalloffStartAngle;
ent.atmosFogSkyFalloffAngleRange = level.atmosFogSkyFalloffAngleRange;
ent.atmosFogSunDirection = level.atmosFogSunDirection;
ent.atmosFogHeightFogEnabled = level.atmosFogHeightFogEnabled;
ent.atmosFogHeightFogBaseHeight = level.atmosFogHeightFogBaseHeight;
ent.atmosFogHeightFogHalfPlaneDistance = level.atmosFogHeightFogHalfPlaneDistance;
}
else
{
if ( IsDefined( ent.atmosFogEnabled ) )
{
ent.atmosFogEnabled = 0;
}
}
if ( GetDvarInt( "scr_fog_disable" ) )
{
ent.startDist = 2000000000;
ent.halfwayDist = 2000000001;
ent.red = 0;
ent.green = 0;
ent.blue = 0;
ent.HDRColorIntensity = 1;
ent.HDRSunColorIntensity = 1;
ent.maxOpacity = 0;
ent.skyFogIntensity = 0;
ent.heightFogEnabled = 0;
ent.heightFogBaseHeight = 0;
ent.heightFogHalfPlaneDistance = 1000;
if ( IsDefined( ent.atmosFogEnabled ) )
{
ent.atmosFogEnabled = 0;
}
}
set_fog_to_ent_values( ent, 0 );
}
}
fogslidercheck()
{
// catch all those cases where a slider can be pushed to a place of conflict
if ( level.sunFogBeginFadeAngle >= level.sunFogEndFadeAngle )
{
level.sunFogBeginFadeAngle = level.sunFogEndFadeAngle - 1;
SetDvar( "scr_sunFogBeginFadeAngle", level.sunFogBeginFadeAngle );
}
if ( level.sunFogEndFadeAngle <= level.sunFogBeginFadeAngle )
{
level.sunFogEndFadeAngle = level.sunFogBeginFadeAngle + 1;
SetDvar( "scr_sunFogEndFadeAngle", level.sunFogEndFadeAngle );
}
}
add_vision_set_to_list( vision_set_name )
{
assert( IsDefined( level.vision_set_names ) );
found = array_find( level.vision_set_names, vision_set_name );
if ( IsDefined( found ) )
return;
level.vision_set_names = array_add( level.vision_set_names, vision_set_name );
}
print_vision( vision_set )
{
found = array_find( level.vision_set_names, vision_set );
if ( !IsDefined( found ) )
return;
fileprint_launcher_start_file();
// Glow
fileprint_launcher( "r_glow \"" + GetDvar( "r_glowTweakEnable" ) + "\"" );
fileprint_launcher( "r_glowRadius0 \"" + GetDvar( "r_glowTweakRadius0" ) + "\"" );
fileprint_launcher( "r_glowBloomPinch \"" + GetDvar( "r_glowTweakBloomPinch" ) + "\"" );
fileprint_launcher( "r_glowBloomCutoff \"" + GetDvar( "r_glowTweakBloomCutoff" ) + "\"" );
fileprint_launcher( "r_glowBloomDesaturation \"" + GetDvar( "r_glowTweakBloomDesaturation" ) + "\"" );
fileprint_launcher( "r_glowBloomIntensity0 \"" + GetDvar( "r_glowTweakBloomIntensity0" ) + "\"" );
fileprint_launcher( "r_glowUseAltCutoff \"" + GetDvar( "r_glowTweakUseAltCutoff" ) + "\"" );
fileprint_launcher( "" );
// Film
fileprint_launcher( "r_filmEnable \"" + GetDvar( "r_filmTweakEnable" ) + "\"" );
fileprint_launcher( "r_filmContrast \"" + GetDvar( "r_filmTweakContrast" ) + "\"" );
if( level.currentgen )
fileprint_launcher( "r_filmIntensity \"" + GetDvar( "r_filmTweakIntensity" ) + "\"" );
fileprint_launcher( "r_filmBrightness \"" + GetDvar( "r_filmTweakBrightness" ) + "\"" );
fileprint_launcher( "r_filmDesaturation \"" + GetDvar( "r_filmTweakDesaturation" ) + "\"" );
fileprint_launcher( "r_filmDesaturationDark \"" + GetDvar( "r_filmTweakDesaturationDark" ) + "\"" );
fileprint_launcher( "r_filmInvert \"" + GetDvar( "r_filmTweakInvert" ) + "\"" );
fileprint_launcher( "r_filmLightTint \"" + GetDvar( "r_filmTweakLightTint" ) + "\"" );
fileprint_launcher( "r_filmMediumTint \"" + GetDvar( "r_filmTweakMediumTint" ) + "\"" );
fileprint_launcher( "r_filmDarkTint \"" + GetDvar( "r_filmTweakDarkTint" ) + "\"" );
fileprint_launcher( " " );
// Character Light
fileprint_launcher( "r_primaryLightUseTweaks \"" + GetDvar( "r_primaryLightUseTweaks" ) + "\"" );
fileprint_launcher( "r_primaryLightTweakDiffuseStrength \"" + GetDvar( "r_primaryLightTweakDiffuseStrength" ) + "\"" );
fileprint_launcher( "r_primaryLightTweakSpecularStrength \"" + GetDvar( "r_primaryLightTweakSpecularStrength" ) + "\"" );
fileprint_launcher( "r_charLightAmbient \"" + GetDvar( "r_charLightAmbient" ) + "\"" );
fileprint_launcher( " " );
// Viewmodel Light
fileprint_launcher( "r_viewModelPrimaryLightUseTweaks \"" + GetDvar( "r_viewModelPrimaryLightUseTweaks" ) + "\"" );
fileprint_launcher( "r_viewModelPrimaryLightTweakDiffuseStrength \"" + GetDvar( "r_viewModelPrimaryLightTweakDiffuseStrength" ) + "\"" );
fileprint_launcher( "r_viewModelPrimaryLightTweakSpecularStrength \"" + GetDvar( "r_viewModelPrimaryLightTweakSpecularStrength" ) + "\"" );
fileprint_launcher( "r_viewModelLightAmbient \"" + GetDvar( "r_viewModelLightAmbient" ) + "\"" );
fileprint_launcher( " " );
// Volume Light Scatter
fileprint_launcher( "r_volumeLightScatter \"" + GetDvar( "r_volumeLightScatterUseTweaks" ) + "\"" );
fileprint_launcher( "r_volumeLightScatterLinearAtten \"" + GetDvar( "r_volumeLightScatterLinearAtten" ) + "\"" );
fileprint_launcher( "r_volumeLightScatterQuadraticAtten \"" + GetDvar( "r_volumeLightScatterQuadraticAtten" ) + "\"" );
fileprint_launcher( "r_volumeLightScatterAngularAtten \"" + GetDvar( "r_volumeLightScatterAngularAtten" ) + "\"" );
fileprint_launcher( "r_volumeLightScatterDepthAttenNear \"" + GetDvar( "r_volumeLightScatterDepthAttenNear" ) + "\"" );
fileprint_launcher( "r_volumeLightScatterDepthAttenFar \"" + GetDvar( "r_volumeLightScatterDepthAttenFar" ) + "\"" );
fileprint_launcher( "r_volumeLightScatterBackgroundDistance \"" + GetDvar( "r_volumeLightScatterBackgroundDistance" ) + "\"" );
fileprint_launcher( "r_volumeLightScatterColor \"" + GetDvar( "r_volumeLightScatterColor" ) + "\"" );
fileprint_launcher( "r_volumeLightScatterEv \"" + GetDvar( "r_volumeLightScatterEv" ) + "\"" );
fileprint_launcher( " " );
// Rim Light (keep in sync with #define RIM_LIGHTING in platform_defines.h)
fileprint_launcher( "r_rimLightUseTweaks \"" + GetDvar( "r_rimLightUseTweaks" ) + "\"" );
fileprint_launcher( "r_rimLight0Pitch \"" + GetDvar( "r_rimLight0Pitch" ) + "\"" );
fileprint_launcher( "r_rimLight0Heading \"" + GetDvar( "r_rimLight0Heading" ) + "\"" );
fileprint_launcher( "r_rimLightDiffuseIntensity \"" + GetDvar( "r_rimLightDiffuseIntensity" ) + "\"" );
fileprint_launcher( "r_rimLightSpecIntensity \"" + GetDvar( "r_rimLightSpecIntensity" ) + "\"" );
fileprint_launcher( "r_rimLightBias \"" + GetDvar( "r_rimLightBias" ) + "\"" );
fileprint_launcher( "r_rimLightPower \"" + GetDvar( "r_rimLightPower" ) + "\"" );
fileprint_launcher( "r_rimLight0Color \"" + GetDvar( "r_rimLight0Color" ) + "\"" );
fileprint_launcher( "r_rimLightFalloffMaxDistance \"" + GetDvar( "r_rimLightFalloffMaxDistance" ) + "\"" );
fileprint_launcher( "r_rimLightFalloffMinDistance \"" + GetDvar( "r_rimLightFalloffMinDistance" ) + "\"" );
fileprint_launcher( "r_rimLightFalloffMinIntensity \"" + GetDvar( "r_rimLightFalloffMinIntensity" ) + "\"" );
fileprint_launcher( " " );
// Unlit Surface
fileprint_launcher( "r_unlitSurfaceHDRScalar \"" + GetDvar( "r_unlitSurfaceHDRScalar" ) + "\"" );
fileprint_launcher( "" );
// Chromatic Aberration
fileprint_launcher( "r_chromaticAberrationMode \"" + GetDvar( "r_chromaticAberration" ) + "\"" );
fileprint_launcher( "r_chromaticSeparation \"" + GetDvar( "r_chromaticSeparationR" ) + " " + GetDvar( "r_chromaticSeparationG" ) + " " + GetDvar( "r_chromaticSeparationB" ) + "\"" );
fileprint_launcher( "r_chromaticAberrationAlpha \"" + GetDvar( "r_chromaticAberrationAlpha" ) + "\"" );
visionFileName = "\\share\\raw\\vision\\" + vision_set + ".vision";
return fileprint_launcher_end_file( visionFileName, true );
}
get_lightset_filename()
{
if ( level.nextgen )
{
// [nextgen-begin]
return "\\share\\raw\\maps\\createart\\" + get_template_level() + "_lightsets_hdr.csv";
// [nextgen-end]
}
else
{
return "\\share\\raw\\maps\\createart\\" + get_template_level() + "_lightsets.csv";
}
}
print_lightset( lightset_filename )
{
fileprint_launcher_start_file();
PrintLightSetSettings();
return fileprint_launcher_end_file( lightset_filename, true );
}
print_fog_ents( forMP )
{
foreach( ent in level.vision_set_fog )
{
if( !isdefined( ent.name ) )
continue;
ConvertLegacyFog( ent );
if ( forMP )
fileprint_launcher( "\tent = maps\\mp\\_art::create_vision_set_fog( \"" + ent.name + "\" );");
else
fileprint_launcher( "\tent = maps\\_utility::create_vision_set_fog( \"" + ent.name + "\" );");
if( isdefined( ent.startDist ) )
fileprint_launcher( "\tent.startDist = "+ent.startDist + ";" );
if( isdefined( ent.halfwayDist ) )
fileprint_launcher( "\tent.halfwayDist = "+ent.halfwayDist + ";" );
if( isdefined( ent.red ) )
fileprint_launcher( "\tent.red = "+ent.red + ";" );
if( isdefined( ent.green ) )
fileprint_launcher( "\tent.green = "+ent.green + ";" );
if( isdefined( ent.blue ) )
fileprint_launcher( "\tent.blue = "+ent.blue + ";" );
if( isdefined( ent.HDRColorIntensity ) )
fileprint_launcher( "\tent.HDRColorIntensity = "+ent.HDRColorIntensity + ";" );
if( isdefined( ent.maxOpacity ) )
fileprint_launcher( "\tent.maxOpacity = "+ent.maxOpacity + ";" );
if( isdefined( ent.transitionTime ) )
fileprint_launcher( "\tent.transitionTime = "+ent.transitionTime + ";" );
if( isdefined( ent.sunFogEnabled ) )
fileprint_launcher( "\tent.sunFogEnabled = "+ent.sunFogEnabled + ";" );
if( isdefined( ent.sunRed ) )
fileprint_launcher( "\tent.sunRed = "+ent.sunRed + ";" );
if( isdefined( ent.sunGreen ) )
fileprint_launcher( "\tent.sunGreen = "+ent.sunGreen + ";" );
if( isdefined( ent.sunBlue ) )
fileprint_launcher( "\tent.sunBlue = "+ent.sunBlue + ";" );
if( isdefined( ent.HDRSunColorIntensity ) )
fileprint_launcher( "\tent.HDRSunColorIntensity = "+ent.HDRSunColorIntensity + ";" );
if( isdefined( ent.sunDir ) )
fileprint_launcher( "\tent.sunDir = "+ent.sunDir + ";" );
if( isdefined( ent.sunBeginFadeAngle ) )
fileprint_launcher( "\tent.sunBeginFadeAngle = "+ent.sunBeginFadeAngle + ";" );
if( isdefined( ent.sunEndFadeAngle ) )
fileprint_launcher( "\tent.sunEndFadeAngle = "+ent.sunEndFadeAngle + ";" );
if( isdefined( ent.normalFogScale ) )
fileprint_launcher( "\tent.normalFogScale = "+ent.normalFogScale + ";" );
if( isdefined( ent.skyFogIntensity ) )
fileprint_launcher( "\tent.skyFogIntensity = "+ent.skyFogIntensity + ";" );
if( isdefined( ent.skyFogMinAngle ) )
fileprint_launcher( "\tent.skyFogMinAngle = "+ent.skyFogMinAngle + ";" );
if( isdefined( ent.skyFogMaxAngle ) )
fileprint_launcher( "\tent.skyFogMaxAngle = "+ent.skyFogMaxAngle + ";" );
if ( IsDefined( ent.HDROverride ) )
fileprint_launcher( "\tent.HDROverride = \"" + ent.HDROverride + "\";" );
if ( IsDefined( ent.heightFogEnabled ) )
fileprint_launcher( "\tent.heightFogEnabled = " + ent.heightFogEnabled + ";" );
if ( IsDefined( ent.heightFogBaseHeight ) )
fileprint_launcher( "\tent.heightFogBaseHeight = " + ent.heightFogBaseHeight + ";" );
if ( IsDefined( ent.heightFogHalfPlaneDistance ) )
fileprint_launcher( "\tent.heightFogHalfPlaneDistance = " + ent.heightFogHalfPlaneDistance + ";" );
if ( IsDefined( ent.atmosFogEnabled ) )
fileprint_launcher( "\tent.atmosFogEnabled = " + ent.atmosFogEnabled + ";" );
if ( IsDefined( ent.atmosFogSunFogColor ) )
fileprint_launcher( "\tent.atmosFogSunFogColor = " + ent.atmosFogSunFogColor + ";" );
if ( IsDefined( ent.atmosFogHazeColor ) )
fileprint_launcher( "\tent.atmosFogHazeColor = " + ent.atmosFogHazeColor + ";" );
if ( IsDefined( ent.atmosFogHazeStrength ) )
fileprint_launcher( "\tent.atmosFogHazeStrength = " + ent.atmosFogHazeStrength + ";" );
if ( IsDefined( ent.atmosFogHazeSpread ) )
fileprint_launcher( "\tent.atmosFogHazeSpread = " + ent.atmosFogHazeSpread + ";" );
if ( IsDefined( ent.atmosFogExtinctionStrength ) )
fileprint_launcher( "\tent.atmosFogExtinctionStrength = " + ent.atmosFogExtinctionStrength + ";" );
if ( IsDefined( ent.atmosFogInScatterStrength ) )
fileprint_launcher( "\tent.atmosFogInScatterStrength = " + ent.atmosFogInScatterStrength + ";" );
if ( IsDefined( ent.atmosFogHalfPlaneDistance ) )
fileprint_launcher( "\tent.atmosFogHalfPlaneDistance = " + ent.atmosFogHalfPlaneDistance + ";" );
if ( IsDefined( ent.atmosFogStartDistance ) )
fileprint_launcher( "\tent.atmosFogStartDistance = " + ent.atmosFogStartDistance + ";" );
if ( IsDefined( ent.atmosFogDistanceScale ) )
fileprint_launcher( "\tent.atmosFogDistanceScale = " + ent.atmosFogDistanceScale + ";" );
if ( IsDefined( ent.atmosFogSkyDistance ) )
fileprint_launcher( "\tent.atmosFogSkyDistance = " + int( ent.atmosFogSkyDistance ) + ";" );
if ( IsDefined( ent.atmosFogSkyAngularFalloffEnabled ) )
fileprint_launcher( "\tent.atmosFogSkyAngularFalloffEnabled = " + ent.atmosFogSkyAngularFalloffEnabled + ";" );
if ( IsDefined( ent.atmosFogSkyFalloffStartAngle ) )
fileprint_launcher( "\tent.atmosFogSkyFalloffStartAngle = " + ent.atmosFogSkyFalloffStartAngle + ";" );
if ( IsDefined( ent.atmosFogSkyFalloffAngleRange ) )
fileprint_launcher( "\tent.atmosFogSkyFalloffAngleRange = " + ent.atmosFogSkyFalloffAngleRange + ";" );
if ( IsDefined( ent.atmosFogSunDirection ) )
fileprint_launcher( "\tent.atmosFogSunDirection = " + ent.atmosFogSunDirection + ";" );
if ( IsDefined( ent.atmosFogHeightFogEnabled ) )
fileprint_launcher( "\tent.atmosFogHeightFogEnabled = " + ent.atmosFogHeightFogEnabled + ";" );
if ( IsDefined( ent.atmosFogHeightFogBaseHeight ) )
fileprint_launcher( "\tent.atmosFogHeightFogBaseHeight = " + ent.atmosFogHeightFogBaseHeight + ";" );
if ( IsDefined( ent.atmosFogHeightFogHalfPlaneDistance ) )
fileprint_launcher( "\tent.atmosFogHeightFogHalfPlaneDistance = " + ent.atmosFogHeightFogHalfPlaneDistance + ";" );
if( isDefined( ent.stagedVisionSets ) )
{
string = " ";
for( i = 0; i < ent.stagedVisionSets.size; i++ )
{
string = string + "\""+ ent.stagedVisionSets[i] + "\"";
if ( i < ent.stagedVisionSets.size - 1 )
string = string + ",";
string = string + " ";
}
fileprint_launcher( "\tent.stagedVisionSets = [" + string + "];" );
}
fileprint_launcher ( " " );
}
if ( !forMP )
{ // MP holds this script in the setup_fog() function.
// put out our dev only call to our fog file (normally code will parse it and apply it clientside)
fileprint_launcher( "\t/$" );
if ( IsUsingHDR() )
fileprint_launcher( "\tlevel._art_fog_setup = maps\\createart\\" + level.script + "_fog_hdr::main;" );
else
fileprint_launcher( "\tlevel._art_fog_setup = maps\\createart\\" + level.script + "_fog::main;" );
fileprint_launcher( "\t$/" );
}
}
print_fog_ents_csv()
{
foreach( ent in level.vision_set_fog )
{
if( !isdefined( ent.name ) )
continue;
targettedByHDROverride = false;
foreach( ent2 in level.vision_set_fog )
{
if ( isdefined(ent2.HDROverride) && ent2.HDROverride == ent.name )
{
targettedByHDROverride = true;
break;
}
}
if ( !targettedByHDROverride )
fileprint_launcher( "rawfile,vision/"+ent.name+".vision");
}
}
$/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,968 @@
#include common_scripts\utility;
#include common_scripts\_createfx;
//---------------------------------------------------------
// Menu init/loop section
//---------------------------------------------------------
init_menu()
{
level._createfx.options = [];
// each option has a type, a name its stored under, a description, a default, and a mask it uses to determine
// which types of fx can have this option
addOption( "vector", "origin", "Origin", (0,0,0), "fx", 1 );
addOption( "vector", "angles", "Angles", (0,0,0), "fx", 1 );
addOption( "string", "fxid", "FX id", "nil", "fx" );
addOption( "float", "delay", "Repeat rate/start delay", 0.5, "fx" );
addOption( "string", "flag", "Flag", "nil", "exploder" );
addOption( "string", "platform", "Platform", "all", "all" );
if ( !level.mp_createfx )
{
addOption( "string", "firefx", "2nd FX id", "nil", "exploder" );
addOption( "float", "firefxdelay", "2nd FX id repeat rate", 0.5, "exploder" );
addOption( "float", "firefxtimeout", "2nd FX timeout", 5, "exploder" );
addOption( "string", "firefxsound", "2nd FX soundalias", "nil", "exploder" );
addOption( "float", "damage", "Radius damage", 150, "exploder" );
addOption( "float", "damage_radius", "Radius of radius damage", 250, "exploder" );
addOption( "string", "earthquake", "Earthquake", "nil", "exploder" );
addOption( "string", "ender", "Level notify for ending 2nd FX", "nil", "exploder" );
}
addOption( "float", "delay_min", "Minimimum time between repeats", 1, "soundfx_interval" );
addOption( "float", "delay_max", "Maximum time between repeats", 2, "soundfx_interval" );
addOption( "int", "repeat", "Number of times to repeat", 5, "exploder" );
addOption( "string", "exploder", "Exploder", "1", "exploder" );
setup_help_keys();
addOption( "string", "soundalias", "Soundalias", "nil", "all" );
addOption( "string", "loopsound", "Loopsound", "nil", "exploder" );
addOption( "int", "reactive_radius", "Reactive Radius", 100, "reactive_fx", undefined, ::input_reactive_radius );
addOption( "string", "ambiencename", "Ambience Name", "nil", "soundfx_dynamic" );
addOption( "int", "dynamic_distance", "Dynamic Max Distance", 1000, "soundfx_dynamic" );
if( !level.mp_createfx )
{
addOption( "string", "rumble", "Rumble", "nil", "exploder" );
addOption( "int", "stoppable", "Can be stopped from script", "1", "all" );
}
level.effect_list_offset = 0;
level.effect_list_offset_max = 10;
level.effect_list_current_size = 0;
level.help_list_offset = 0;
level.help_list_offset_max = 20;
level.createfx_help_active = false;
level.createfx_menu_list_active = false;
// creates mask groups. For example if the above says its mask is "fx", then all the types under "fx" can use the option
level.createfxMasks = [];
level.createfxMasks[ "all" ] = [];
level.createfxMasks[ "all" ][ "exploder" ] = true;
level.createfxMasks[ "all" ][ "oneshotfx" ] = true;
level.createfxMasks[ "all" ][ "loopfx" ] = true;
level.createfxMasks[ "all" ][ "soundfx" ] = true;
level.createfxMasks[ "all" ][ "soundfx_interval" ] = true;
level.createfxMasks[ "all" ][ "reactive_fx" ] = true;
level.createfxMasks[ "all" ][ "soundfx_dynamic" ] = true;
level.createfxMasks[ "fx" ] = [];
level.createfxMasks[ "fx" ][ "exploder" ] = true;
level.createfxMasks[ "fx" ][ "oneshotfx" ] = true;
level.createfxMasks[ "fx" ][ "loopfx" ] = true;
level.createfxMasks[ "exploder" ] = [];
level.createfxMasks[ "exploder" ][ "exploder" ] = true;
level.createfxMasks[ "loopfx" ] = [];
level.createfxMasks[ "loopfx" ][ "loopfx" ] = true;
level.createfxMasks[ "oneshotfx" ] = [];
level.createfxMasks[ "oneshotfx" ][ "oneshotfx" ] = true;
level.createfxMasks[ "soundfx" ] = [];
level.createfxMasks[ "soundfx" ][ "soundalias" ] = true;
level.createfxMasks[ "soundfx_interval" ] = [];
level.createfxMasks[ "soundfx_interval" ][ "soundfx_interval" ] = true;
level.createfxMasks[ "reactive_fx" ] = [];
level.createfxMasks[ "reactive_fx" ][ "reactive_fx" ] = true;
level.createfxMasks[ "soundfx_dynamic" ] = [];
level.createfxMasks[ "soundfx_dynamic" ][ "soundfx_dynamic" ] = true;
// Mainly used for input of a menu
menus = [];
menus[ "creation" ] = ::menu_create_select;
menus[ "create_oneshot" ] = ::menu_create;
menus[ "create_loopfx" ] = ::menu_create;
menus[ "change_fxid" ] = ::menu_create;
menus[ "none" ] = ::menu_none;
menus[ "add_options" ] = ::menu_add_options;
menus[ "select_by_name" ] = ::menu_select_by_name;
level._createfx.menus = menus;
}
menu( name )
{
return level.create_fx_menu == name;
}
setmenu( name )
{
level.create_fx_menu = name;
}
create_fx_menu()
{
if ( button_is_clicked( "escape", "x" ) )
{
_exit_menu();
return;
}
if ( IsDefined( level._createfx.menus[ level.create_fx_menu ] ) )
{
[[ level._createfx.menus[ level.create_fx_menu ] ]]();
}
}
menu_create_select()
{
if ( button_is_clicked( "1" ) )
{
setmenu( "create_oneshot" );
draw_effects_list();
return;
}
else if ( button_is_clicked( "2" ) )
{
setmenu( "create_loopfx" );
draw_effects_list();
return;
}
else if ( button_is_clicked( "3" ) )
{
setmenu( "create_loopsound" );
ent = createLoopSound();
finish_creating_entity( ent );
return;
}
else if ( button_is_clicked( "4" ) )
{
setmenu( "create_exploder" );
ent = createNewExploder();
finish_creating_entity( ent );
return;
}
else if ( button_is_clicked( "5" ) )
{
setmenu( "create_interval_sound" );
ent = createIntervalSound();
finish_creating_entity( ent );
return;
}
else if ( button_is_clicked( "6" ) )
{
ent = createReactiveEnt();
finish_creating_entity( ent );
return;
}
else if ( button_is_clicked( "7" ) )
{
ent = createDynamicAmbience();
finish_creating_entity( ent );
return;
}
}
menu_create()
{
level.createfx_menu_list_active = true;
if ( next_button() )
{
increment_list_offset();
draw_effects_list();
}
else if ( previous_button() )
{
decrement_list_offset();
draw_effects_list();
}
menu_fx_creation();
}
menu_none()
{
if ( button_is_clicked( "m" ) )
increment_list_offset();
// change selected entities
menu_change_selected_fx();
// if there's a selected ent then display the info on the last one to be selected
if ( entities_are_selected() )
{
last_selected_ent = get_last_selected_ent();
// only update hudelems when we have new info
if ( !IsDefined( level.last_displayed_ent ) || last_selected_ent != level.last_displayed_ent || level._createfx.justConvertedOneshot == 1 )
{
display_fx_info( last_selected_ent );
level.last_displayed_ent = last_selected_ent;
level._createfx.justConvertedOneshot = 0;
}
if ( button_is_clicked( "a" ) )
{
clear_settable_fx();
setMenu( "add_options" );
}
}
else
{
level.last_displayed_ent = undefined;
}
}
menu_add_options()
{
if ( !entities_are_selected() )
{
clear_fx_hudElements();
setMenu( "none" );
return;
}
display_fx_add_options( get_last_selected_ent() );
if ( next_button() )
{
increment_list_offset();
// draw_effects_list();
}
}
menu_select_by_name()
{
if ( next_button() )
{
increment_list_offset();
draw_effects_list( "Select by name" );
}
else if ( previous_button() )
{
decrement_list_offset();
draw_effects_list( "Select by name" );
}
select_by_name();
}
next_button()
{
return button_is_clicked( "rightarrow" );
}
previous_button()
{
return button_is_clicked( "leftarrow" );
}
_exit_menu()
{
clear_fx_hudElements();
clear_entity_selection();
update_selected_entities();
setmenu( "none" );
}
//---------------------------------------------------------
// Create FX Section (button presses)
//---------------------------------------------------------
menu_fx_creation()
{
count = 0;
picked_fx = undefined;
keys = func_get_level_fx();
for ( i = level.effect_list_offset; i < keys.size; i++ )
{
count = count + 1;
button_to_check = count;
if ( button_to_check == 10 )
button_to_check = 0;
if ( button_is_clicked( button_to_check + "" ) )
{
picked_fx = keys[ i ];
break;
}
if ( count > level.effect_list_offset_max )
break;
}
if ( !isdefined( picked_fx ) )
return;
if ( menu( "change_fxid" ) )
{
apply_option_to_selected_fx( get_option( "fxid" ), picked_fx );
level.effect_list_offset = 0;
clear_fx_hudElements();
setMenu( "none" );
level.createfx_menu_list_active = false;
level.createfx_last_movement_timer = 0;
return;
}
ent = undefined;
if ( menu( "create_loopfx" ) )
ent = createLoopEffect( picked_fx );
if ( menu( "create_oneshot" ) )
ent = createOneshotEffect( picked_fx );
finish_creating_entity( ent );
}
finish_creating_entity( ent )
{
assert( isdefined( ent ) );
ent.v[ "angles" ] = vectortoangles( ( ent.v[ "origin" ] + ( 0, 0, 100 ) ) - ent.v[ "origin" ] );
ent post_entity_creation_function();// for createfx dev purposes
clear_entity_selection();
select_last_entity();
move_selection_to_cursor();
update_selected_entities();
setMenu( "none" );
level.createfx_menu_list_active = false;
}
entities_are_selected()
{
return level._createfx.selected_fx_ents.size > 0;
}
menu_change_selected_fx()
{
if ( !level._createfx.selected_fx_ents.size )
{
return;
}
count = 0;
drawnCount = 0;
ent = get_last_selected_ent();
for ( i = 0; i < level._createfx.options.size; i++ )
{
option = level._createfx.options[ i ];
if ( !isdefined( ent.v[ option[ "name" ] ] ) )
continue;
count++ ;
if ( count < level.effect_list_offset )
continue;
drawnCount++ ;
button_to_check = drawnCount;
if ( button_to_check == 10 )
button_to_check = 0;
if ( button_is_clicked( button_to_check + "" ) )
{
prepare_option_for_change( option, drawnCount );
break;
}
if ( drawnCount > level.effect_list_offset_max )
{
more = true;
break;
}
}
}
prepare_option_for_change( option, drawnCount )
{
if ( option[ "name" ] == "fxid" )
{
setMenu( "change_fxid" );
draw_effects_list();
return;
}
level.createfx_inputlocked = true;
level._createfx.hudelems[ drawnCount + 1 ][ 0 ].color = ( 1, 1, 0 );
if ( IsDefined( option[ "input_func" ] ) )
{
thread [[ option[ "input_func" ] ]]( drawnCount + 1 );
}
else
{
createfx_centerprint( "To set " + option[ "description" ] + ", type /fx newvalue. To remove "+ option[ "description" ] +", type /fx del" );
}
set_option_index( option[ "name" ] );
setdvar( "fx", "nil" );
}
menu_fx_option_set()
{
if ( getdvar( "fx" ) == "nil" )
return;
if ( getdvar( "fx" ) == "del" )
{
remove_selected_option();
return;
}
option = get_selected_option();
setting = undefined;
if ( option[ "type" ] == "string" )
setting = getdvar( "fx" );
if ( option[ "type" ] == "int" )
setting = getdvarint( "fx" );
if ( option[ "type" ] == "float" )
setting = getdvarfloat( "fx" );
if ( option[ "type" ] == "vector" )
setting = getdvarvector( "fx" );
if(isDefined(setting))
apply_option_to_selected_fx( option, setting );
else
setdvar( "fx" , "nil");
}
apply_option_to_selected_fx( option, setting )
{
save_undo_buffer();
for ( i = 0; i < level._createfx.selected_fx_ents.size; i++ )
{
ent = level._createfx.selected_fx_ents[ i ];
if ( mask( option[ "mask" ], ent.v[ "type" ] ))
ent.v[ option[ "name" ] ] = setting;
}
level.last_displayed_ent = undefined; // needed to force a redraw of the last display ent
update_selected_entities();
clear_settable_fx();
//if we moved it, restart and focus camera on new position
if( option[ "name" ] == "origin")
{
level.createfx_last_movement_timer = 0;
frame_selected();
}
//if we changed angles, restart fx
if( option[ "name" ] == "angles")
{
level.createfx_last_movement_timer = 0;
}
save_redo_buffer();
}
set_option_index( name )
{
for ( i = 0; i < level._createfx.options.size; i++ )
{
if ( level._createfx.options[ i ][ "name" ] != name )
continue;
level._createfx.selected_fx_option_index = i;
return;
}
}
get_selected_option()
{
return level._createfx.options[ level._createfx.selected_fx_option_index ];
}
mask( type, name )
{
return isdefined( level.createfxMasks[ type ][ name ] );
}
addOption( type, name, description, defaultSetting, mask, nowrite, input_func )
{
option = [];
option[ "type" ] = type;
option[ "name" ] = name;
option[ "description" ] = description;
option[ "default" ] = defaultSetting;
option[ "mask" ] = mask;
if ( isdefined(nowrite) && nowrite )
option[ "nowrite" ] = 1;
else
option[ "nowrite" ] = 0;
if ( IsDefined( input_func ) )
{
option[ "input_func" ] = input_func;
}
level._createfx.options[ level._createfx.options.size ] = option;
}
get_option( name )
{
for ( i = 0; i < level._createfx.options.size; i++ )
{
if ( level._createfx.options[ i ][ "name" ] == name )
return level._createfx.options[ i ];
}
}
//---------------------------------------------------------
// Reactive Radius
//---------------------------------------------------------
input_reactive_radius( menu_index )
{
level._createfx.hudelems[ menu_index ][ 0 ] SetDevText( "Reactive Radius, Press: + OR -" );
while ( 1 )
{
wait( 0.05 );
if ( level.player ButtonPressed( "escape" ) || level.player ButtonPressed( "x" ) )
break;
val = 0;
if ( level.player ButtonPressed( "-" ) )
val = -10;
else if ( level.player ButtonPressed( "=" ) )
val = 10;
if ( val != 0 )
{
foreach ( ent in level._createfx.selected_fx_ents )
{
if ( IsDefined( ent.v[ "reactive_radius" ] ) )
{
ent.v[ "reactive_radius" ] += val;
ent.v[ "reactive_radius" ] = Clamp( ent.v[ "reactive_radius" ], 10, 1000 );
}
}
}
}
level.last_displayed_ent = undefined; // needed to force a redraw of the last display ent
update_selected_entities();
clear_settable_fx();
}
//---------------------------------------------------------
// Display FX Add Options
//---------------------------------------------------------
display_fx_add_options( ent )
{
// are we doing the create fx menu right now?
assert( menu( "add_options" ) );
assert( entities_are_selected() );
level.createfx_menu_list_active = true;
clear_fx_hudElements();
set_fx_hudElement( "Name: " + ent.v[ "fxid" ] );
set_fx_hudElement( "Type: " + ent.v[ "type" ] );
set_fx_hudElement( "Origin: " + ent.v[ "origin" ] );
set_fx_hudElement( "Angles: " + ent.v[ "angles" ] );
// if entities are selected then we make the entity stats modifiable
count = 0;
drawnCount = 0;
more = false;
if ( level.effect_list_offset >= level._createfx.options.size )
level.effect_list_offset = 0;
for ( i = 0; i < level._createfx.options.size; i++ )
{
option = level._createfx.options[ i ];
if ( isdefined( ent.v[ option[ "name" ] ] ) )
continue;
// does this type of effect get this kind of option?
if ( !mask( option[ "mask" ], ent.v[ "type" ] ) )
continue;
count++ ;
if ( count < level.effect_list_offset )
continue;
if ( drawnCount >= level.effect_list_offset_max )
continue;
drawnCount++ ;
button_to_check = drawnCount;
if ( button_to_check == 10 )
button_to_check = 0;
if ( button_is_clicked( button_to_check + "" ) )
{
add_option_to_selected_entities( option );
// prepare_option_for_change( option, drawnCount );
menuNone();
level.last_displayed_ent = undefined; // needed to force a redraw of the last display ent
return;
}
set_fx_hudElement( button_to_check + ". " + option[ "description" ] );
}
if ( count > level.effect_list_offset_max )
{
level.effect_list_current_size = count;
set_fx_hudElement( "(->) More >" );
}
set_fx_hudElement( "(x) Exit >" );
}
add_option_to_selected_entities( option )
{
setting = undefined;
for ( i = 0; i < level._createfx.selected_fx_ents.size; i++ )
{
ent = level._createfx.selected_fx_ents[ i ];
if ( mask( option[ "mask" ], ent.v[ "type" ] ) )
ent.v[ option[ "name" ] ] = option[ "default" ];
}
}
menuNone()
{
level.effect_list_offset = 0;
clear_fx_hudElements();
setMenu( "none" );
}
//---------------------------------------------------------
// Display FX info
//---------------------------------------------------------
display_fx_info( ent )
{
// are we doing the create fx menu right now?
if ( !menu( "none" ) )
return;
if ( level.createfx_help_active )
return;
clear_fx_hudElements();
set_fx_hudElement( "Name: " + ent.v[ "fxid" ] );
set_fx_hudElement( "Type: " + ent.v[ "type" ] );
if ( entities_are_selected() )
{
// if entities are selected then we make the entity stats modifiable
count = 0;
drawnCount = 0;
more = false;
for ( i = 0; i < level._createfx.options.size; i++ )
{
option = level._createfx.options[ i ];
if ( !isdefined( ent.v[ option[ "name" ] ] ) )
continue;
count++ ;
if ( count < level.effect_list_offset )
continue;
drawnCount++ ;
set_fx_hudElement( drawnCount + ". " + option[ "description" ] + ": " + ent.v[ option[ "name" ] ] );
if ( drawnCount > level.effect_list_offset_max )
{
more = true;
break;
}
}
if ( count > level.effect_list_offset_max )
{
level.effect_list_current_size = count;
set_fx_hudElement( "(->) More >" );
}
set_fx_hudElement( "(a) Add >" );
set_fx_hudElement( "(x) Exit >" );
}
else
{
count = 0;
more = false;
for ( i = 0; i < level._createfx.options.size; i++ )
{
option = level._createfx.options[ i ];
if ( !isdefined( ent.v[ option[ "name" ] ] ) )
continue;
count++ ;
set_fx_hudElement( option[ "description" ] + ": " + ent.v[ option[ "name" ] ] );
if ( count > level._createfx.hudelem_count )
break;
}
}
}
display_current_translation()
{
ent = get_last_selected_ent();
if(isdefined(ent))
display_fx_info(ent);
}
//---------------------------------------------------------
// Draw Effects Section
//---------------------------------------------------------
draw_effects_list( title )
{
clear_fx_hudElements();
count = 0;
more = false;
keys = func_get_level_fx();
level.effect_list_current_size = keys.size;
if( !IsDefined( title ) )
{
title = "Pick an effect";
}
set_fx_hudElement( title + " [" + level.effect_list_offset + " - " + keys.size + "]:" );
// if ( level.effect_list_offset >= keys.size )
// level.effect_list_offset = 0;
for ( i = level.effect_list_offset; i < keys.size; i++ )
{
count = count + 1;
set_fx_hudElement( count + ". " + keys[ i ] );
if ( count >= level.effect_list_offset_max )
{
more = true;
break;
}
}
if ( keys.size > level.effect_list_offset_max )
{
set_fx_hudElement( "(->) More >" );
set_fx_hudElement( "(<-) Previous >" );
}
}
increment_list_offset()
{
if ( level.effect_list_offset >= level.effect_list_current_size - level.effect_list_offset_max )
{
level.effect_list_offset = 0;
}
else
{
level.effect_list_offset += level.effect_list_offset_max;
}
}
decrement_list_offset()
{
if ( level.effect_list_current_size < level.effect_list_offset_max )
{
level.effect_list_offset = 0;
}
else
{
level.effect_list_offset -= level.effect_list_offset_max;
if ( level.effect_list_offset < 0 )
{
//keys = func_get_level_fx();
level.effect_list_offset = level.effect_list_current_size - level.effect_list_offset_max;
}
}
}
//---------------------------------------------------------
// Draw Help
//---------------------------------------------------------
draw_help_list( title )
{
clear_fx_hudElements();
count = 0;
keys = level.createfx_help_keys;
if( !IsDefined( title ) )
{
title = "Help";
}
set_fx_hudElement( "[" + title + "]");// + " [" + level.help_list_offset + " - " + keys.size + "]:" );
// if ( level.effect_list_offset >= keys.size )
// level.effect_list_offset = 0;
for ( i = level.help_list_offset; i < keys.size; i++ )
{
count = count + 1;
set_fx_hudElement( keys[ i ] );
if ( count >= level.help_list_offset_max )
{
more = true;
break;
}
}
if ( keys.size > level.help_list_offset_max )
{
level.effect_list_current_size = keys.size;
set_fx_hudElement( "(->) More >" );
set_fx_hudElement( "(<-) Previous >" );
}
}
increment_help_list_offset()
{
keys = level.createfx_help_keys;
if ( level.help_list_offset >= keys.size - level.help_list_offset_max )
{
level.help_list_offset = 0;
}
else
{
level.help_list_offset += level.help_list_offset_max;
}
}
decrement_help_list_offset()
{
level.help_list_offset -= level.help_list_offset_max;
if ( level.help_list_offset < 0 )
{
keys = level.createfx_help_keys;
level.help_list_offset = keys.size - level.help_list_offset_max;
}
}
help_navigation_buttons()
{
while(level.createfx_help_active == true)
{
if ( next_button() )
{
increment_help_list_offset();
draw_help_list();
wait 0.1;
}
else if ( previous_button() )
{
decrement_help_list_offset();
draw_help_list();
wait 0.1;
}
waitframe();
}
}
setup_help_keys()
{
level.createfx_help_keys = [
"Insert Insert entity",
"F2 Toggle createfx dot and text drawing",
"F5 SAVES your work",
"Z Undo",
"Shift-Z Redo",
"F Frames currently selected entities in camera view",
"END Drop selected entities to the ground",
"A Add option to the selected entities",
"P Reset the rotation of the selected entities",
"V Copy the angles from the most recently selected fx onto all selected fx.",
"O Orient all selected fx to point at most recently selected fx.",
"S Toggle Snap2Normal mode.",
"L Toggle 90deg Snap mode.",
"G Select all effects in level of same exploder or flag as selected.",
"U Select by name list.",
"C Convert One-Shot to Exploder.",
"Delete Kill the selected entities",
"ESCAPE Cancel out of option-modify-mode, must have console open",
"SPACE or -> Turn on exploders",
"<- Turn off exploders",
"Dpad Move selected entities on X/Y or rotate pitch/yaw",
"A button Toggle the selection of the current entity",
"X button Toggle entity rotation mode",
"Y button Move selected entites up or rotate roll",
"B button Move selected entites down or rotate roll",
"R Shoulder Move selected entities to the cursor",
"L Shoulder Hold to select multiple entites",
"L JoyClick Copy",
"R JoyClick Paste",
"Ctrl-C Copy",
"Ctrl-V Paste",
"N UFO",
"T Toggle Timescale FAST",
"Y Toggle Timescale SLOW",
"[ Toggle FX Visibility",
"] Toggle ShowTris",
"F11 Toggle FX Profile"];
}
//---------------------------------------------------------
// Select by Name Section
//---------------------------------------------------------
select_by_name()
{
count = 0;
picked_fx = undefined;
keys = func_get_level_fx();
for ( i = level.effect_list_offset; i < keys.size; i++ )
{
count = count + 1;
button_to_check = count;
if ( button_to_check == 10 )
button_to_check = 0;
if ( button_is_clicked( button_to_check + "" ) )
{
picked_fx = keys[ i ];
break;
}
if ( count > level.effect_list_offset_max )
break;
}
if ( !IsDefined( picked_fx ) )
return;
index_array = [];
foreach ( i, ent in level.createFXent )
{
if ( IsSubStr( ent.v[ "fxid" ], picked_fx ) )
{
index_array[ index_array.size ] = i;
}
}
deselect_all_ents();
select_index_array( index_array );
level._createfx.select_by_name = true;
}
//---------------------------------------------------------
// Utility Section
//---------------------------------------------------------
get_last_selected_ent()
{
return level._createfx.selected_fx_ents[ level._createfx.selected_fx_ents.size - 1 ];
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

970
raw/common_scripts/_fx.gsc Normal file
View File

@ -0,0 +1,970 @@
#include common_scripts\utility;
#include common_scripts\_createfx;
//#include soundscripts\_audio;
//#include soundscripts\_audio_dynamic_ambi;
CONST_MAX_SP_CREATEFX = 1500;
CONST_MAX_SP_CREATESOUND = 384;
initFX()
{
if ( !isdefined( level.func ) )
level.func = [];
if ( !isdefined( level.func[ "create_triggerfx" ] ) )
level.func[ "create_triggerfx" ] = ::create_triggerfx;
if ( !IsDefined( level._fx ) )
level._fx = SpawnStruct();
create_lock( "createfx_looper", 20 );
level.fxfireloopmod = 1;
// wrapper for the exploder function so we dont have to use flags and do ifs/waittills on every exploder call
level._fx.exploderFunction = common_scripts\_exploder::exploder_before_load;
waittillframeend;// Wait one frame so the effects get setup by the maps fx thread
waittillframeend;// Wait another frame so effects can be loaded based on start functions. Without this FX are initialiazed before they are defined by start functions.
level._fx.exploderFunction = common_scripts\_exploder::exploder_after_load;
level._fx.server_culled_sounds = false;
if ( GetDvarInt( "serverCulledSounds" ) == 1 )
level._fx.server_culled_sounds = true;
if ( level.createFX_enabled )
level._fx.server_culled_sounds = false;
/#
SetDevDvarIfUninitialized( "scr_map_exploder_dump", 0 );
SetDevDvarIfUninitialized( "createfx_removedupes", 0 );
if ( GetDvarInt( "r_reflectionProbeGenerate" ) == 1 )
level._fx.server_culled_sounds = true;
#/
// Give createfx_common time to delete triggers to free up entity slots.
if ( level.createFX_enabled )
{
level waittill( "createfx_common_done" );
}
/#
remove_dupes();
#/
for ( i = 0; i < level.createFXent.size; i++ )
{
ent = level.createFXent[ i ];
ent set_forward_and_up_vectors();
switch ( ent.v[ "type" ] )
{
case "loopfx":
ent thread loopfxthread();
break;
case "oneshotfx":
ent thread oneshotfxthread();
break;
case "soundfx":
ent thread create_loopsound();
break;
case "soundfx_interval":
ent thread create_interval_sound();
break;
case "reactive_fx":
ent add_reactive_fx();
break;
case "soundfx_dynamic":
ent thread create_dynamicambience();
break;
}
}
check_createfx_limit();
}
remove_dupes()
{
/#
if ( GetDvarInt( "createfx_removedupes" ) == 0 )
return;
new_ents = [];
for ( i = 0; i < level.createFXent.size; i++ )
{
add_ent = true;
i_ent = level.createFXent[ i ];
for ( j = i + 1; j < level.createFXent.size; j++ )
{
j_ent = level.createFXent[ j ];
if ( j_ent.v[ "type" ] == i_ent.v[ "type" ] )
{
if ( j_ent.v[ "origin" ] == i_ent.v[ "origin" ] )
{
println( "^3--REMOVING DUPE'D " + j_ent.v[ "type" ] + " AT " + j_ent.v[ "origin" ] );
add_ent = false;
}
}
}
if ( add_ent )
new_ents[ new_ents.size ] = i_ent;
}
level.createFXent = new_ents;
#/
}
check_createfx_limit()
{
/#
if ( !isSP() )
{
return;
}
fx_count = 0;
sound_count = 0;
foreach ( ent in level.createFXent )
{
if ( is_createfx_type( ent, "fx" ) )
fx_count++;
else if ( is_createfx_type( ent, "sound" ) )
sound_count++;
}
println( "^5Total CreateFX FX Ents: " + fx_count );
println( "^5Total CreateFX SOUND Ents: " + sound_count );
check_limit_type( "fx", fx_count );
check_limit_type( "sound", sound_count );
#/
}
check_limit_type( type, count )
{
/#
limit = undefined;
if ( type == "fx" )
{
limit = CONST_MAX_SP_CREATEFX;
}
else if ( type == "sound" )
{
limit = CONST_MAX_SP_CREATESOUND;
}
if ( count > limit )
AssertMsg( "CREATEFX: You have too many " + type + " createFX ents. You need to reduce the amount.\nYou have " + count + " and the limit is " + limit );
#/
}
print_org( fxcommand, fxId, fxPos, waittime )
{
if ( GetDvar( "debug" ) == "1" )
{
println( "{" );
println( "\"origin\" \"" + fxPos[ 0 ] + " " + fxPos[ 1 ] + " " + fxPos[ 2 ] + "\"" );
println( "\"classname\" \"script_model\"" );
println( "\"model\" \"fx\"" );
println( "\"script_fxcommand\" \"" + fxcommand + "\"" );
println( "\"script_fxid\" \"" + fxId + "\"" );
println( "\"script_delay\" \"" + waittime + "\"" );
println( "}" );
}
}
PlatformMatches()
{
if ( IsDefined( self.v[ "platform" ] ) && IsDefined( level.currentgen ) )
{
platform = self.v[ "platform" ];
if (( platform == "cg" && !level.currentgen ) ||
( platform == "ng" && !level.nextgen ) ||
( platform == "xenon" && !level.xenon ) ||
( platform == "ps3" && !level.ps3 ) ||
( platform == "pc" && !level.pc ) ||
( platform == "xb3" && !level.xb3 ) ||
( platform == "ps4" && !level.ps4 ) ||
( platform == "pccg" && !level.pccg ) ||
( platform == "!cg" && level.currentgen ) ||
( platform == "!ng" && level.nextgen ) ||
( platform == "!xenon" && level.xenon ) ||
( platform == "!ps3" && level.ps3 ) ||
( platform == "!pc" && level.pc ) ||
( platform == "!xb3" && level.xb3 ) ||
( platform == "!ps4" && level.ps4 ) ||
( platform == "!pccg" && level.pccg ) )
{
return false;
}
}
return true;
}
OneShotfx( fxId, fxPos, waittime, fxPos2 )
{
// level thread print_org ("OneShotfx", fxId, fxPos, waittime);
// level thread OneShotfxthread (fxId, fxPos, waittime, fxPos2);
}
exploderfx( num, fxId, fxPos, waittime, fxPos2, fireFx, fireFxDelay, fireFxSound, fxSound, fxQuake, fxDamage, soundalias, repeat, delay_min, delay_max, damage_radius, fireFxTimeout, exploder_group )
{
if ( 1 )
{
ent = createExploder( fxId );
ent.v[ "origin" ] = fxPos;
ent.v[ "angles" ] = ( 0, 0, 0 );
if ( isdefined( fxPos2 ) )
ent.v[ "angles" ] = vectortoangles( fxPos2 - fxPos );
ent.v[ "delay" ] = waittime;
ent.v[ "exploder" ] = num;
if (isdefined(level.createFXexploders))
{ // if we're using the optimized lookup, add it in the proper place
ary = level.createFXexploders[ ent.v[ "exploder" ] ];
if (!isdefined(ary))
ary = [];
ary[ary.size] = ent;
level.createFXexploders[ ent.v[ "exploder" ] ] = ary;
}
// deprecated
return;
}
fx = spawn( "script_origin", ( 0, 0, 0 ) );
// println ("total ", getentarray ("script_origin","classname").size);
fx.origin = fxPos;
fx.angles = vectortoangles( fxPos2 - fxPos );
// fx.targetname = "exploder";
fx.script_exploder = num;
fx.script_fxid = fxId;
fx.script_delay = waittime;
fx.script_firefx = fireFx;
fx.script_firefxdelay = ( fireFxDelay );// for awhile the script exported strings for this value so we cast it to float
fx.script_firefxsound = fireFxSound;
fx.script_sound = fxSound;
fx.script_earthquake = fxQuake;
fx.script_damage = ( fxDamage );
fx.script_radius = ( damage_radius );
fx.script_soundalias = soundalias;
fx.script_firefxtimeout = ( fireFxTimeout );
fx.script_repeat = ( repeat );
fx.script_delay_min = ( delay_min );
fx.script_delay_max = ( delay_max );
fx.script_exploder_group = exploder_group;
forward = anglestoforward( fx.angles );
forward *= ( 150 );
fx.targetPos = fxPos + forward;
if ( !isdefined( level._script_exploders ) )
level._script_exploders = [];
level._script_exploders[ level._script_exploders.size ] = fx;
}
/*
loopfxRotate(fxId, fxPos, waittime, angle, fxStart, fxStop, timeout)
{
level thread print_org ("loopfx", fxId, fxPos, waittime);
level thread loopfxthread (fxId, fxPos, waittime, fxPos2, fxStart, fxStop, timeout);
}
*/
loopfx( fxId, fxPos, waittime, fxPos2, fxStart, fxStop, timeout )
{
println( "Loopfx is deprecated!" );
ent = createLoopEffect( fxId );
ent.v[ "origin" ] = fxPos;
ent.v[ "angles" ] = ( 0, 0, 0 );
if ( isdefined( fxPos2 ) )
ent.v[ "angles" ] = vectortoangles( fxPos2 - fxPos );
ent.v[ "delay" ] = waittime;
}
/*
loopfx(fxId, fxPos, waittime, fxPos2, fxStart, fxStop, timeout)
{
level thread print_org ("loopfx", fxId, fxPos, waittime);
level thread loopfxthread (fxId, fxPos, waittime, fxPos2, fxStart, fxStop, timeout);
}
*/
create_looper()
{
//assert (isdefined(self.looper));
self.looper = playLoopedFx( level._effect[ self.v[ "fxid" ] ], self.v[ "delay" ], self.v[ "origin" ], 0, self.v[ "forward" ], self.v[ "up" ] );
create_loopsound();
}
create_loopsound()
{
if ( !PlatformMatches() )
{
return;
}
self notify( "stop_loop" );
if ( !IsDefined( self.v[ "soundalias" ] ) )
return;
if ( self.v[ "soundalias" ] == "nil" )
return;
/#
if ( GetDvar( "r_reflectionProbeGenerate" ) == "1" )
return;
#/
culled = false;
end_on = undefined;
if ( isdefined( self.v[ "stopable" ] ) && self.v[ "stopable" ] )
{
if ( IsDefined( self.looper ) )
end_on = "death";
else
end_on = "stop_loop";
}
else
{
if ( level._fx.server_culled_sounds && IsDefined( self.v[ "server_culled" ] ) )
culled = self.v[ "server_culled" ];
}
ent = self;
if ( IsDefined( self.looper ) )
ent = self.looper;
createfx_ent = undefined;
if ( level.createFX_enabled )
createfx_ent = self;
ent loop_fx_sound_with_angles( self.v[ "soundalias" ], self.v[ "origin" ], self.v[ "angles" ], culled, end_on, createfx_ent );
}
create_interval_sound()
{
if ( !PlatformMatches() )
{
return;
}
self notify( "stop_loop" );
if ( !IsDefined( self.v[ "soundalias" ] ) )
return;
if ( self.v[ "soundalias" ] == "nil" )
return;
ender = undefined;
runner = self;
/#
if ( GetDvar( "r_reflectionProbeGenerate" ) == "1" )
return;
#/
if( ( IsDefined( self.v[ "stopable" ] ) && self.v[ "stopable" ] ) || level.createFX_enabled )
{
if ( IsDefined( self.looper ) )
{
runner = self.looper;
ender = "death";
}
else
ender = "stop_loop";
}
runner thread loop_fx_sound_interval_with_angles( self.v[ "soundalias" ], self.v[ "origin" ], self.v[ "angles" ], ender, undefined, self.v[ "delay_min" ], self.v[ "delay_max" ] );
}
create_dynamicambience()
{
if ( !PlatformMatches() )
{
return;
}
if ( !IsDefined( self.v[ "ambiencename" ] ) )
return;
if ( self.v[ "ambiencename" ] == "nil" )
return;
if ( isSP() )
{
// TODO - Make this work in SP
/*
if ( IsDefined( self.dambInfoStruct ) )
{
DAMB_stop_preset_at_point( self.v[ "ambiencename" ], self.dambInfoStruct.unique_id );
}
DAMB_start_preset_at_point( self.v[ "ambiencename" ], self.v[ "origin" ], undefined, self.v[ "dynamic_distance" ], self.dambInfoStruct.unique_id );
*/
}
else
{
if ( GetDvar( "createfx" ) == "on" )
{
// wait till the player spawns and createfxlogic starts before continuing.
flag_wait( "createfx_started" );
}
if ( IsDefined( self.dambInfoStruct ) )
{
level.player StopDynamicAmbience( self.dambInfoStruct.unique_id );
}
self.dambInfoStruct = SpawnStruct();
self.dambInfoStruct assign_unique_id();
level.player PlayDynamicAmbience( self.v[ "ambiencename" ], self.v[ "origin" ], self.v[ "dynamic_distance" ], self.dambInfoStruct.unique_id );
}
}
loopfxthread()
{
waitframe();
// println ( "fx testing running Id: ", fxId );
// if ((isdefined (level.scr_sound)) && (isdefined (level.scr_sound[fxId])))
// loopSound(level.scr_sound[fxId], fxPos);
if ( isdefined( self.fxStart ) )
level waittill( "start fx" + self.fxStart );
while ( 1 )
{
/*
if (isdefined (ent.org2))
{
fxAngle = vectorNormalize (ent.org2 - ent.org);
looper = playLoopedFx( level._effect[fxId], ent.delay, ent.org, 0, fxAngle );
}
else
looper = playLoopedFx( level._effect[fxId], ent.delay, ent.org, 0 );
*/
create_looper();
if ( isdefined( self.timeout ) )
thread loopfxStop( self.timeout );
if ( isdefined( self.fxStop ) )
level waittill( "stop fx" + self.fxStop );
else
return;
if ( isdefined( self.looper ) )
self.looper delete();
if ( isdefined( self.fxStart ) )
level waittill( "start fx" + self.fxStart );
else
return;
}
}
loopfxChangeID( ent )
{
self endon( "death" );
ent waittill( "effect id changed", change );
}
loopfxChangeOrg( ent )
{
self endon( "death" );
for ( ;; )
{
ent waittill( "effect org changed", change );
self.origin = change;
}
}
loopfxChangeDelay( ent )
{
self endon( "death" );
ent waittill( "effect delay changed", change );
}
loopfxDeletion( ent )
{
self endon( "death" );
ent waittill( "effect deleted" );
self delete();
}
loopfxStop( timeout )
{
self endon( "death" );
wait( timeout );
self.looper delete();
}
loopSound( sound, Pos, waittime )
{
// level thread print_org ("loopSound", sound, Pos, waittime);
level thread loopSoundthread( sound, Pos, waittime );
}
loopSoundthread( sound, pos, waittime )
{
org = spawn( "script_origin", ( pos ) );
org.origin = pos;
// println ("hello1 ", org.origin, sound);
org playLoopSound( sound );
}
gunfireloopfx( fxId, fxPos, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax )
{
thread gunfireloopfxthread( fxId, fxPos, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax );
}
gunfireloopfxthread( fxId, fxPos, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax )
{
level endon( "stop all gunfireloopfx" );
waitframe();
if ( betweenSetsMax < betweenSetsMin )
{
temp = betweenSetsMax;
betweenSetsMax = betweenSetsMin;
betweenSetsMin = temp;
}
betweenSetsBase = betweenSetsMin;
betweenSetsRange = betweenSetsMax - betweenSetsMin;
if ( shotdelayMax < shotdelayMin )
{
temp = shotdelayMax;
shotdelayMax = shotdelayMin;
shotdelayMin = temp;
}
shotdelayBase = shotdelayMin;
shotdelayRange = shotdelayMax - shotdelayMin;
if ( shotsMax < shotsMin )
{
temp = shotsMax;
shotsMax = shotsMin;
shotsMin = temp;
}
shotsBase = shotsMin;
shotsRange = shotsMax - shotsMin;
fxEnt = spawnFx( level._effect[ fxId ], fxPos );
if ( !level.createFX_enabled )
fxEnt willNeverChange();
for ( ;; )
{
shotnum = shotsBase + randomint( shotsRange );
for ( i = 0;i < shotnum;i++ )
{
triggerFx( fxEnt );
wait( shotdelayBase + randomfloat( shotdelayRange ) );
}
wait( betweenSetsBase + randomfloat( betweenSetsRange ) );
}
}
gunfireloopfxVec( fxId, fxPos, fxPos2, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax )
{
thread gunfireloopfxVecthread( fxId, fxPos, fxPos2, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax );
}
gunfireloopfxVecthread( fxId, fxPos, fxPos2, shotsMin, shotsMax, shotdelayMin, shotdelayMax, betweenSetsMin, betweenSetsMax )
{
level endon( "stop all gunfireloopfx" );
waitframe();
if ( betweenSetsMax < betweenSetsMin )
{
temp = betweenSetsMax;
betweenSetsMax = betweenSetsMin;
betweenSetsMin = temp;
}
betweenSetsBase = betweenSetsMin;
betweenSetsRange = betweenSetsMax - betweenSetsMin;
if ( shotdelayMax < shotdelayMin )
{
temp = shotdelayMax;
shotdelayMax = shotdelayMin;
shotdelayMin = temp;
}
shotdelayBase = shotdelayMin;
shotdelayRange = shotdelayMax - shotdelayMin;
if ( shotsMax < shotsMin )
{
temp = shotsMax;
shotsMax = shotsMin;
shotsMin = temp;
}
shotsBase = shotsMin;
shotsRange = shotsMax - shotsMin;
fxPos2 = vectornormalize( fxPos2 - fxPos );
fxEnt = spawnFx( level._effect[ fxId ], fxPos, fxPos2 );
if ( !level.createFX_enabled )
fxEnt willNeverChange();
for ( ;; )
{
shotnum = shotsBase + randomint( shotsRange );
for ( i = 0;i < int( shotnum / level.fxfireloopmod );i++ )
{
triggerFx( fxEnt );
delay = ( ( shotdelayBase + randomfloat( shotdelayRange ) ) * level.fxfireloopmod );
if ( delay < .05 )
delay = .05;
wait delay;
}
wait( shotdelayBase + randomfloat( shotdelayRange ) );
wait( betweenSetsBase + randomfloat( betweenSetsRange ) );
}
}
setfireloopmod( value )
{
level.fxfireloopmod = 1 / value;
}
setup_fx()
{
if ( ( !isdefined( self.script_fxid ) ) || ( !isdefined( self.script_fxcommand ) ) || ( !isdefined( self.script_delay ) ) )
{
// println (self.script_fxid);
// println (self.script_fxcommand);
// println (self.script_delay);
// println ("Effect at origin ", self.origin," doesn't have script_fxid/script_fxcommand/script_delay");
// self delete();
return;
}
// println ("^a Command:", self.script_fxcommand, " Effect:", self.script_fxID, " Delay:", self.script_delay, " ", self.origin);
if ( isdefined( self.model ) )
if ( self.model == "toilet" )
{
self thread burnville_paratrooper_hack();
return;
}
org = undefined;
if ( isdefined( self.target ) )
{
ent = getent( self.target, "targetname" );
if ( isdefined( ent ) )
org = ent.origin;
}
fxStart = undefined;
if ( isdefined( self.script_fxstart ) )
fxStart = self.script_fxstart;
fxStop = undefined;
if ( isdefined( self.script_fxstop ) )
fxStop = self.script_fxstop;
if ( self.script_fxcommand == "OneShotfx" )
OneShotfx( self.script_fxId, self.origin, self.script_delay, org );
if ( self.script_fxcommand == "loopfx" )
loopfx( self.script_fxId, self.origin, self.script_delay, org, fxStart, fxStop );
if ( self.script_fxcommand == "loopsound" )
loopsound( self.script_fxId, self.origin, self.script_delay );
self delete();
}
burnville_paratrooper_hack()
{
normal = ( 0, 0, self.angles[ 1 ] );
// println ("z: paratrooper fx hack: ", normal);
id = level._effect[ self.script_fxId ];
origin = self.origin;
// if (isdefined (self.script_delay))
// wait (self.script_delay);
wait 1;
level thread burnville_paratrooper_hack_loop( normal, origin, id );
self delete();
}
burnville_paratrooper_hack_loop( normal, origin, id )
{
while ( 1 )
{
// iprintln ("z: playing paratrooper fx", origin);
playfx( id, origin );
wait( 30 + randomfloat( 40 ) );
}
}
create_triggerfx()
{
//assert (isdefined(self.looper));
if( ! verify_effects_assignment( self.v[ "fxid" ] ) )
return;
self.looper = spawnFx( level._effect[ self.v[ "fxid" ] ], self.v[ "origin" ], self.v[ "forward" ], self.v[ "up" ] );
triggerFx( self.looper, self.v[ "delay" ] );
if ( !level.createFX_enabled )
self.looper willNeverChange();
create_loopsound();
}
verify_effects_assignment( effectID )
{
if( isdefined ( level._effect[ effectID ] ) )
return true;
if( ! isdefined( level._missing_FX ) )
level._missing_FX = [];
level._missing_FX[ self.v[ "fxid" ] ] = effectID;
verify_effects_assignment_print( effectID );
return false;
}
verify_effects_assignment_print( effectID )
{
level notify ( "verify_effects_assignment_print" );
level endon ( "verify_effects_assignment_print" );
wait .05; //allow errors on the same frame to que up before printing
println("Error:");
println("Error:**********MISSING EFFECTS IDS**********");
keys = getarraykeys( level._missing_FX );
foreach( key in keys )
{
println( "Error: Missing Effects ID assignment for: "+ key );
}
println("Error:");
assertmsg( "Missing Effects ID assignments ( see console )" );
}
OneShotfxthread()
{
wait(0.05);
if ( !PlatformMatches() )
{
return;
}
if ( self.v[ "delay" ] > 0 )
wait self.v[ "delay" ];
[[ level.func[ "create_triggerfx" ] ]]();
}
//---------------------------------------------------------
// Reactive Section
//---------------------------------------------------------
CONST_MAX_REACTIVE_SOUND_ENTS = 4;
CONST_NEXT_PLAY_TIME = 3000;
add_reactive_fx()
{
if ( !PlatformMatches() )
{
return;
}
// MP should not start this thread in release
if ( !isSP() && GetDVar( "createfx" ) == "" )
{
return;
}
if ( !IsDefined( level._fx.reactive_thread ) )
{
level._fx.reactive_thread = true;
level thread reactive_fx_thread();
}
if ( !IsDefined( level._fx.reactive_fx_ents ) )
{
level._fx.reactive_fx_ents = [];
}
level._fx.reactive_fx_ents[ level._fx.reactive_fx_ents.size ] = self;
self.next_reactive_time = 3000;
}
reactive_fx_thread()
{
if ( !isSp() )
{
if ( GetDvar( "createfx" ) == "on" )
{
// wait till the player spawns and createfxlogic starts before continuing.
flag_wait( "createfx_started" );
}
}
// TODO: Switch to using level notify instead
// HOWEVER!!! we will need the trigger_radius for when we are in CREATEFX mode for MP only!!!
// use level.mp_createfx condition
// trigger = Spawn( "trigger_radius", level.player.origin, 0, 5000, 5000 );
// trigger SetCanDamage( true );
// trigger EnableLinkTo();
// trigger LinkTo( level.player );
level._fx.reactive_sound_ents = [];
explosion_radius = 256;
while ( 1 )
{
// trigger waittill( "damage", dmg, attacker, dir_vec, point, type );
level waittill( "code_damageradius", attacker, explosion_radius, point, weapon_name );
ents = sort_reactive_ents( point, explosion_radius );
foreach ( i, ent in ents )
ent thread play_reactive_fx( i );
}
}
vector2d( vec )
{
return ( vec[ 0 ], vec[ 1 ], 0 );
}
sort_reactive_ents( point, explosion_radius )
{
closest = [];
time = GetTime();
foreach ( ent in level._fx.reactive_fx_ents )
{
if ( ent.next_reactive_time > time )
continue;
radius_squared = ent.v[ "reactive_radius" ] + explosion_radius;
radius_squared *= radius_squared;
if ( DistanceSquared( point, ent.v[ "origin" ] ) < radius_squared )
{
closest[ closest.size ] = ent;
}
}
foreach ( ent in closest )
{
playerToEnt = vector2d( ent.v[ "origin" ] - level.player.origin );
playerToPoint = vector2d( point - level.player.origin );
vec1 = VectorNormalize( playerToEnt );
vec2 = VectorNormalize( playerToPoint );
ent.dot = VectorDot( vec1, vec2 );
}
// Sort from lowest dot to greatest
for ( i = 0; i < closest.size - 1; i++ )
{
for ( j = i + 1; j < closest.size; j++ )
{
if ( closest[ i ].dot > closest[ j ].dot )
{
temp = closest[ i ];
closest[ i ] = closest[ j ];
closest[ j ] = temp;
}
}
}
// remove the .origin and .dot since we're done with sortbydistance()
foreach ( ent in closest )
{
ent.origin = undefined;
ent.dot = undefined;
}
// Make sure we only have 4
for ( i = CONST_MAX_REACTIVE_SOUND_ENTS; i < closest.size; i++ )
{
closest[ i ] = undefined;
}
return closest;
}
play_reactive_fx( num )
{
sound_ent = get_reactive_sound_ent();
if ( !IsDefined( sound_ent ) )
return;
/#
self.is_playing = true;
#/
self.next_reactive_time = GeTTime() + CONST_NEXT_PLAY_TIME;
sound_ent.origin = self.v[ "origin" ];
sound_ent.is_playing = true;
wait( num * RandomFloatRange( 0.05, 0.1 ) );
if ( isSP() )
{
sound_ent PlaySound( self.v[ "soundalias" ], "sounddone" );
sound_ent waittill( "sounddone" );
}
else
{
sound_ent PlaySound( self.v[ "soundalias" ] );
wait( 2 );
}
// wait for sounddone to be removed compeletely
// bug in prague port to iw6 where in the same frame this got called again after the sounddone notify
// odd thing, even 0.05 doesn't work. Code should fix this!
wait( 0.1 );
sound_ent.is_playing = false;
/#
self.is_playing = undefined;
#/
}
get_reactive_sound_ent()
{
foreach ( ent in level._fx.reactive_sound_ents )
{
if ( !ent.is_playing )
return ent;
}
if ( level._fx.reactive_sound_ents.size < CONST_MAX_REACTIVE_SOUND_ENTS )
{
ent = Spawn( "script_origin", ( 0, 0, 0 ) );
ent.is_playing = false;
level._fx.reactive_sound_ents[ level._fx.reactive_sound_ents.size ] = ent;
return ent;
}
return undefined;
}

File diff suppressed because it is too large Load Diff