This commit is contained in:
6arelyFuture 2024-12-11 11:28:08 +01:00
commit 12ac62a956
Signed by: Future
GPG Key ID: F2000F181A4F7C85
444 changed files with 303964 additions and 0 deletions

270
codescripts/character.gsc Normal file
View File

@ -0,0 +1,270 @@
setModelFromArray( a )
{
self setModel( a[ randomint( a.size ) ] );
}
precacheModelArray( a )
{
for ( i = 0; i < a.size; i++ )
precacheModel( a[ i ] );
}
attachHead( headAlias, headArray )
{
/#
// For test map purposes only!! - IW5_Characters uses this.
if ( IsDefined( level.store_characterinfo ) )
{
if ( !IsDefined( self.characterinfo ) )
{
self.characterinfo = SpawnStruct();
self.characterinfo.headalias = headAlias;
self.characterinfo.headarray = headarray;
}
}
#/
if ( !isdefined( level.character_head_index ) )
level.character_head_index = [];
if ( !isdefined( level.character_head_index[ headAlias ] ) )
level.character_head_index[ headAlias ] = randomint( headArray.size );
assert( level.character_head_index[ headAlias ] < headArray.size );
index = ( level.character_head_index[ headAlias ] + 1 ) % headArray.size;
// the designer can overwrite the character
if ( isdefined( self.script_char_index ) )
{
index = self.script_char_index % headArray.size;
}
level.character_head_index[ headAlias ] = index;
self attach( headArray[ index ], "", true );
self.headModel = headArray[ index ];
}
attachHat( hatAlias, hatArray )
{
if ( !isdefined( level.character_hat_index ) )
level.character_hat_index = [];
if ( !isdefined( level.character_hat_index[ hatAlias ] ) )
level.character_hat_index[ hatAlias ] = randomint( hatArray.size );
assert( level.character_hat_index[ hatAlias ] < hatArray.size );
index = ( level.character_hat_index[ hatAlias ] + 1 ) % hatArray.size;
level.character_hat_index[ hatAlias ] = index;
self attach( hatArray[ index ] );
self.hatModel = hatArray[ index ];
}
new()
{
self detachAll();
oldGunHand = self.anim_gunHand;
if ( !isdefined( oldGunHand ) )
return;
self.anim_gunHand = "none";
self [[ anim.PutGunInHand ]]( oldGunHand );
}
save()
{
info[ "gunHand" ] = self.anim_gunHand;
info[ "gunInHand" ] = self.anim_gunInHand;
info[ "model" ] = self.model;
info[ "hatModel" ] = self.hatModel;
if ( isdefined( self.name ) )
{
info[ "name" ] = self.name;
println( "Save: Guy has name ", self.name );
}
else
println( "save: Guy had no name!" );
attachSize = self getAttachSize();
for ( i = 0; i < attachSize; i++ )
{
info[ "attach" ][ i ][ "model" ] = self getAttachModelName( i );
info[ "attach" ][ i ][ "tag" ] = self getAttachTagName( i );
}
return info;
}
load( info )
{
self detachAll();
self.anim_gunHand = info[ "gunHand" ];
self.anim_gunInHand = info[ "gunInHand" ];
self setModel( info[ "model" ] );
self.hatModel = info[ "hatModel" ];
if ( isdefined( info[ "name" ] ) )
{
self.name = info[ "name" ];
println( "Load: Guy has name ", self.name );
}
else
println( "Load: Guy had no name!" );
attachInfo = info[ "attach" ];
attachSize = attachInfo.size;
for ( i = 0; i < attachSize; i++ )
self attach( attachInfo[ i ][ "model" ], attachInfo[ i ][ "tag" ] );
}
precache( info )
{
if ( isdefined( info[ "name" ] ) )
println( "Precache: Guy has name ", info[ "name" ] );
else
println( "Precache: Guy had no name!" );
precacheModel( info[ "model" ] );
attachInfo = info[ "attach" ];
attachSize = attachInfo.size;
for ( i = 0; i < attachSize; i++ )
precacheModel( attachInfo[ i ][ "model" ] );
}
/*
sample save / precache / load usage( precache is only required if there are any waits in the level script before load ):
save:
info = foley codescripts\character::save();
game[ "foley" ] = info;
changelevel( "burnville", 0, true );
precache:
codescripts\character::precache( game[ "foley" ] );
load:
foley codescripts\character::load( game[ "foley" ] );
*/
get_random_character( amount )
{
self_info = strtok( self.classname, "_" );
if ( !common_scripts\utility::isSP() )
{
if ( isDefined( self.pers["modelIndex"] ) && self.pers["modelIndex"] < amount )
return self.pers["modelIndex"];
index = randomInt( amount );
self.pers["modelIndex"] = index;
return index;
}
else if ( self_info.size <= 2 )
{
// some custom guy that doesn't use standard naming convention
return randomint( amount );
}
group = "auto"; // by default the type is an auto-selected character
index = undefined;
prefix = self_info[ 2 ]; // merc, marine, etc
// the designer can overwrite the character
if ( isdefined( self.script_char_index ) )
{
index = self.script_char_index;
}
// the designer can hint that this guy is a member of a group of like - spawned guys, so he should use a different index
if ( isdefined( self.script_char_group ) )
{
type = "grouped";
group = "group_" + self.script_char_group;
}
if ( !isdefined( level.character_index_cache ) )
{
// separately store script grouped guys and auto guys so that they dont influence each other
level.character_index_cache = [];
}
if ( !isdefined( level.character_index_cache[ prefix ] ) )
{
// separately store script grouped guys and auto guys so that they dont influence each other
level.character_index_cache[ prefix ] = [];
}
if ( !isdefined( level.character_index_cache[ prefix ][ group ] ) )
{
initialize_character_group( prefix, group, amount );
}
if ( !isdefined( index ) )
{
index = get_least_used_index( prefix, group );
if ( !isdefined( index ) )
{
// fail safe
index = randomint( 5000 );
}
}
while ( index >= amount )
{
index -= amount;
}
level.character_index_cache[ prefix ][ group ][ index ]++;
return index;
}
get_least_used_index( prefix, group )
{
lowest_indices = [];
lowest_use = level.character_index_cache[ prefix ][ group ][ 0 ];
lowest_indices[ 0 ] = 0;
for ( i = 1; i < level.character_index_cache[ prefix ][ group ].size; i++ )
{
if ( level.character_index_cache[ prefix ][ group ][ i ] > lowest_use )
{
continue;
}
if ( level.character_index_cache[ prefix ][ group ][ i ] < lowest_use )
{
// if its the new lowest, start over on the array
lowest_indices = [];
lowest_use = level.character_index_cache[ prefix ][ group ][ i ];
}
// the equal amounts end up in the array
lowest_indices[ lowest_indices.size ] = i;
}
assertex( lowest_indices.size, "Tried to spawn a character but the lowest indices didn't exist" );
return random( lowest_indices );
}
initialize_character_group( prefix, group, amount )
{
for ( i = 0; i < amount; i++ )
{
level.character_index_cache[ prefix ][ group ][ i ] = 0;
}
}
get_random_weapon( amount )
{
return randomint( amount );
}
random( array )
{
return array [ randomint( array.size ) ];
}

7
codescripts/delete.gsc Normal file
View File

@ -0,0 +1,7 @@
main()
{
assert(isdefined(self));
wait 0;
if (isdefined(self))
self delete();
}

11
codescripts/struct.gsc Normal file
View File

@ -0,0 +1,11 @@
InitStructs()
{
level.struct = [];
}
CreateStruct()
{
struct = spawnstruct();
level.struct[level.struct.size] = struct;
return struct;
}

View File

@ -0,0 +1,286 @@
#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", GetDvarVector( "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", GetDvarVector( "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 ) );
// 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 );
#/
}
/#
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" ) );
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 );
}
limit( i )
{
limit = 0.001;
if ( ( i < limit ) && ( i > ( limit * -1 ) ) )
i = 0;
return i;
}
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" ) + "\"" );
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( "r_primaryLightUseTweaks_NG \"" + GetDvar( "r_primaryLightUseTweaks_NG" ) + "\"" );
fileprint_launcher( "r_primaryLightTweakDiffuseStrength_NG \"" + GetDvar( "r_primaryLightTweakDiffuseStrength_NG" ) + "\"" );
fileprint_launcher( "r_primaryLightTweakSpecularStrength_NG \"" + GetDvar( "r_primaryLightTweakSpecularStrength_NG" ) + "\"" );
fileprint_launcher( "r_charLightAmbient_NG \"" + GetDvar( "r_charLightAmbient_NG" ) + "\"" );
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( "r_viewModelPrimaryLightUseTweaks_NG \"" + GetDvar( "r_viewModelPrimaryLightUseTweaks_NG" ) + "\"" );
fileprint_launcher( "r_viewModelPrimaryLightTweakDiffuseStrength_NG \"" + GetDvar( "r_viewModelPrimaryLightTweakDiffuseStrength_NG" ) + "\"" );
fileprint_launcher( "r_viewModelPrimaryLightTweakSpecularStrength_NG \"" + GetDvar( "r_viewModelPrimaryLightTweakSpecularStrength_NG" ) + "\"" );
fileprint_launcher( "r_viewModelLightAmbient_NG \"" + GetDvar( "r_viewModelLightAmbient_NG" ) + "\"" );
fileprint_launcher( " " );
// Material Bloom
fileprint_launcher( "r_materialBloomRadius \"" + GetDvar( "r_materialBloomRadius" ) + "\"" );
fileprint_launcher( "r_materialBloomPinch \"" + GetDvar( "r_materialBloomPinch" ) + "\"" );
fileprint_launcher( "r_materialBloomIntensity \"" + GetDvar( "r_materialBloomIntensity" ) + "\"" );
fileprint_launcher( "r_materialBloomLuminanceCutoff \"" + GetDvar( "r_materialBloomLuminanceCutoff" ) + "\"" );
fileprint_launcher( "r_materialBloomDesaturation \"" + GetDvar( "r_materialBloomDesaturation" ) + "\"" );
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( " " );
// SSAO
fileprint_launcher( "r_ssaoStrength \"" + GetDvar( "r_ssaoStrength" ) + "\"" );
fileprint_launcher( "r_ssaoPower \"" + GetDvar( "r_ssaoPower" ) + "\"" );
fileprint_launcher( " " );
// Rim Light
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_rimLight0Pitch_NG \"" + GetDvar( "r_rimLight0Pitch_NG" ) + "\"" );
fileprint_launcher( "r_rimLight0Heading_NG \"" + GetDvar( "r_rimLight0Heading_NG" ) + "\"" );
fileprint_launcher( "r_rimLightDiffuseIntensity_NG \"" + GetDvar( "r_rimLightDiffuseIntensity_NG" ) + "\"" );
fileprint_launcher( "r_rimLightSpecIntensity_NG \"" + GetDvar( "r_rimLightSpecIntensity_NG" ) + "\"" );
fileprint_launcher( "r_rimLightBias_NG \"" + GetDvar( "r_rimLightBias_NG" ) + "\"" );
fileprint_launcher( "r_rimLightPower_NG \"" + GetDvar( "r_rimLightPower_NG" ) + "\"" );
fileprint_launcher( "r_rimLight0Color_NG \"" + GetDvar( "r_rimLight0Color_NG" ) + "\"" );
fileprint_launcher( " " );
// Unlit Surface
fileprint_launcher( "r_unlitSurfaceHDRScalar \"" + GetDvar( "r_unlitSurfaceHDRScalar" ) + "\"" );
fileprint_launcher( " " );
// Colorization
colorizationName = GetDvar( "r_colorizationTweakName" );
toneMappingName = GetDvar( "r_toneMappingTweakName" );
clutMaterialName = GetDvar( "r_clutMaterialTweakName" );
if ( colorizationName != "" )
fileprint_launcher( "colorizationSet \"" + colorizationName + "\"" );
if ( toneMappingName != "" )
fileprint_launcher( "toneMapping \"" + toneMappingName + "\"" );
if ( clutMaterialName != "" )
fileprint_launcher( "clutMaterial \"" + clutMaterialName + "\"" );
return fileprint_launcher_end_file( "\\share\\raw\\vision\\" + vision_set + ".vision", true );
}
print_fog_ents( forMP )
{
foreach( ent in level.vision_set_fog )
{
if( !isdefined( ent.name ) )
continue;
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 + "\" );");
fileprint_launcher( "\tent.startDist = " + ent.startDist + ";" );
fileprint_launcher( "\tent.halfwayDist = " + ent.halfwayDist + ";" );
fileprint_launcher( "\tent.red = " + ent.red + ";" );
fileprint_launcher( "\tent.green = " + ent.green + ";" );
fileprint_launcher( "\tent.blue = " + ent.blue + ";" );
fileprint_launcher( "\tent.HDRColorIntensity = " + ent.HDRColorIntensity + ";" );
fileprint_launcher( "\tent.maxOpacity = " + ent.maxOpacity + ";" );
fileprint_launcher( "\tent.transitionTime = " + ent.transitionTime + ";" );
fileprint_launcher( "\tent.sunFogEnabled = " + ent.sunFogEnabled + ";" );
fileprint_launcher( "\tent.sunRed = " + ent.sunRed + ";" );
fileprint_launcher( "\tent.sunGreen = " + ent.sunGreen + ";" );
fileprint_launcher( "\tent.sunBlue = " + ent.sunBlue + ";" );
fileprint_launcher( "\tent.HDRSunColorIntensity = " + ent.HDRSunColorIntensity + ";" );
fileprint_launcher( "\tent.sunDir = " + ent.sunDir + ";" );
fileprint_launcher( "\tent.sunBeginFadeAngle = " + ent.sunBeginFadeAngle + ";" );
fileprint_launcher( "\tent.sunEndFadeAngle = " + ent.sunEndFadeAngle + ";" );
fileprint_launcher( "\tent.normalFogScale = " + ent.normalFogScale + ";" );
fileprint_launcher( "\tent.skyFogIntensity = " + ent.skyFogIntensity + ";" );
fileprint_launcher( "\tent.skyFogMinAngle = " + ent.skyFogMinAngle + ";" );
fileprint_launcher( "\tent.skyFogMaxAngle = " + ent.skyFogMaxAngle + ";" );
if ( IsDefined( ent.HDROverride ) )
fileprint_launcher( "\tent.HDROverride = \"" + ent.HDROverride + "\";" );
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 ( " " );
}
}
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

2578
common_scripts/_createfx.gsc Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,755 @@
#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( "string", "fxid", "FX id", "nil", "fx" );
addOption( "float", "delay", "Repeat rate/start delay", 0.5, "fx" );
addOption( "string", "flag", "Flag", "nil", "exploder" );
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" );
addOption( "string", "soundalias", "Soundalias", "nil", "all" );
addOption( "string", "loopsound", "Loopsound", "nil", "exploder" );
addOption( "int", "reactive_radius", "Reactive Radius", 100, "reactive_fx", ::input_reactive_radius );
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;
// 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[ "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;
// 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_loopsound" );
ent = createLoopSound();
finish_creating_entity( ent );
return;
}
else if ( button_is_clicked( "3" ) )
{
setmenu( "create_exploder" );
ent = createNewExploder();
finish_creating_entity( ent );
return;
}
else if ( button_is_clicked( "4" ) )
{
setmenu( "create_interval_sound" );
ent = createIntervalSound();
finish_creating_entity( ent );
return;
}
else if ( button_is_clicked( "5" ) )
{
ent = createReactiveEnt();
finish_creating_entity( ent );
return;
}
}
menu_create()
{
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 )
{
display_fx_info( last_selected_ent );
level.last_displayed_ent = last_selected_ent;
}
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" );
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" );
}
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 + 3 ][ 0 ].color = ( 1, 1, 0 );
if ( IsDefined( option[ "input_func" ] ) )
{
thread [[ option[ "input_func" ] ]]( drawnCount + 3 );
}
else
{
createfx_centerprint( "To change " + option[ "description" ] + " on selected entities, type /fx newvalue" );
}
set_option_index( option[ "name" ] );
setdvar( "fx", "nil" );
}
menu_fx_option_set()
{
if ( getdvar( "fx" ) == "nil" )
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" );
apply_option_to_selected_fx( option, setting );
}
apply_option_to_selected_fx( option, setting )
{
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();
}
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, input_func )
{
option = [];
option[ "type" ] = type;
option[ "name" ] = name;
option[ "description" ] = description;
option[ "default" ] = defaultSetting;
option[ "mask" ] = mask;
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() );
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 )
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;
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() )
{
// 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 )
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;
}
}
}
//---------------------------------------------------------
// Draw Effects Section
//---------------------------------------------------------
draw_effects_list( title )
{
clear_fx_hudElements();
count = 0;
more = false;
keys = func_get_level_fx();
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()
{
keys = func_get_level_fx();
if ( level.effect_list_offset >= keys.size - level.effect_list_offset_max )
{
level.effect_list_offset = 0;
}
else
{
level.effect_list_offset += level.effect_list_offset_max;
}
}
decrement_list_offset()
{
level.effect_list_offset -= level.effect_list_offset_max;
if ( level.effect_list_offset < 0 )
{
keys = func_get_level_fx();
level.effect_list_offset = keys.size - level.effect_list_offset_max;
}
}
//---------------------------------------------------------
// 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 ];
}

1226
common_scripts/_csplines.gsc Normal file

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

1286
common_scripts/_elevator.gsc Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,987 @@
#include common_scripts\utility;
/*
Handles Old-School exploders. This is coupled with _createfx and _fx since a Radiant Created "exploder" can trigger a createfx created effect.
This Script is legacy, tried and true, It eats up entites when using script_brushmodel swapping and a lot of script_models and the damage triggers.
We should in a future game consider some entiity optimization in code. A way to Join models and brushes as one entity would be key.
*/
setup_individual_exploder( ent )
{
exploder_num = ent.script_exploder;
if ( !IsDefined( level.exploders[ exploder_num ] ) )
{
level.exploders[ exploder_num ] = [];
}
targetname = ent.targetname;
if ( !IsDefined( targetname ) )
targetname = "";
level.exploders[ exploder_num ][ level.exploders[ exploder_num ].size ] = ent;
if ( exploder_model_starts_hidden( ent ) )
{
ent Hide();
return;
}
if ( exploder_model_is_damaged_model( ent ) )
{
ent Hide();
ent NotSolid();
if ( IsDefined( ent.spawnflags ) && ( ent.spawnflags & 1 ) )
{
if ( IsDefined( ent.script_disconnectpaths ) )
{
ent ConnectPaths();
}
}
return;
}
if ( exploder_model_is_chunk( ent ) )
{
ent Hide();
ent NotSolid();
if ( IsDefined( ent.spawnflags ) && ( ent.spawnflags & 1 ) )
ent ConnectPaths();
return;
}
}
setupExploders()
{
level.exploders = [];
// Hide exploder models.
ents = GetEntArray( "script_brushmodel", "classname" );
smodels = GetEntArray( "script_model", "classname" );
for ( i = 0; i < smodels.size; i++ )
ents[ ents.size ] = smodels[ i ];
foreach ( ent in ents )
{
if ( IsDefined( ent.script_prefab_exploder ) )
ent.script_exploder = ent.script_prefab_exploder;
if ( IsDefined( ent.masked_exploder ) )
continue;
if ( IsDefined( ent.script_exploder ) )
{
setup_individual_exploder( ent );
}
}
script_exploders = [];
potentialExploders = GetEntArray( "script_brushmodel", "classname" );
for ( i = 0; i < potentialExploders.size; i++ )
{
if ( IsDefined( potentialExploders[ i ].script_prefab_exploder ) )
potentialExploders[ i ].script_exploder = potentialExploders[ i ].script_prefab_exploder;
if ( IsDefined( potentialExploders[ i ].script_exploder ) )
script_exploders[ script_exploders.size ] = potentialExploders[ i ];
}
potentialExploders = GetEntArray( "script_model", "classname" );
for ( i = 0; i < potentialExploders.size; i++ )
{
if ( IsDefined( potentialExploders[ i ].script_prefab_exploder ) )
potentialExploders[ i ].script_exploder = potentialExploders[ i ].script_prefab_exploder;
if ( IsDefined( potentialExploders[ i ].script_exploder ) )
script_exploders[ script_exploders.size ] = potentialExploders[ i ];
}
potentialExploders = GetEntArray( "item_health", "classname" );
for ( i = 0; i < potentialExploders.size; i++ )
{
if ( IsDefined( potentialExploders[ i ].script_prefab_exploder ) )
potentialExploders[ i ].script_exploder = potentialExploders[ i ].script_prefab_exploder;
if ( IsDefined( potentialExploders[ i ].script_exploder ) )
script_exploders[ script_exploders.size ] = potentialExploders[ i ];
}
potentialExploders = level.struct;
for ( i = 0; i < potentialExploders.size; i++ )
{
if ( !IsDefined( potentialExploders[ i ] ) )
continue; // these must be getting deleted somewhere else?
if ( IsDefined( potentialExploders[ i ].script_prefab_exploder ) )
potentialExploders[ i ].script_exploder = potentialExploders[ i ].script_prefab_exploder;
if ( IsDefined( potentialExploders[ i ].script_exploder ) )
{
if ( !IsDefined( potentialExploders[ i ].angles ) )
potentialExploders[ i ].angles = ( 0, 0, 0 );
script_exploders[ script_exploders.size ] = potentialExploders[ i ];
}
}
if ( !IsDefined( level.createFXent ) )
level.createFXent = [];
acceptableTargetnames = [];
acceptableTargetnames[ "exploderchunk visible" ] = true;
acceptableTargetnames[ "exploderchunk" ] = true;
acceptableTargetnames[ "exploder" ] = true;
thread setup_flag_exploders();
for ( i = 0; i < script_exploders.size; i++ )
{
exploder = script_exploders[ i ];
ent = createExploder( exploder.script_fxid );
ent.v = [];
ent.v[ "origin" ] = exploder.origin;
ent.v[ "angles" ] = exploder.angles;
ent.v[ "delay" ] = exploder.script_delay;
ent.v[ "delay_post" ] = exploder.script_delay_post;
ent.v[ "firefx" ] = exploder.script_firefx;
ent.v[ "firefxdelay" ] = exploder.script_firefxdelay;
ent.v[ "firefxsound" ] = exploder.script_firefxsound;
ent.v[ "earthquake" ] = exploder.script_earthquake;
ent.v[ "rumble" ] = exploder.script_rumble;
ent.v[ "damage" ] = exploder.script_damage;
ent.v[ "damage_radius" ] = exploder.script_radius;
ent.v[ "soundalias" ] = exploder.script_soundalias;
ent.v[ "repeat" ] = exploder.script_repeat;
ent.v[ "delay_min" ] = exploder.script_delay_min;
ent.v[ "delay_max" ] = exploder.script_delay_max;
ent.v[ "target" ] = exploder.target;
ent.v[ "ender" ] = exploder.script_ender;
ent.v[ "physics" ] = exploder.script_physics;
ent.v[ "type" ] = "exploder";
// ent.v[ "worldfx" ] = true;
if ( !IsDefined( exploder.script_fxid ) )
ent.v[ "fxid" ] = "No FX";
else
ent.v[ "fxid" ] = exploder.script_fxid;
ent.v [ "exploder" ] = exploder.script_exploder;
AssertEx( IsDefined( exploder.script_exploder ), "Exploder at origin " + exploder.origin + " has no script_exploder" );
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;
}
if ( !IsDefined( ent.v[ "delay" ] ) )
ent.v[ "delay" ] = 0;
if ( IsDefined( exploder.target ) )
{
get_ent = GetEntArray( ent.v[ "target" ], "targetname" )[ 0 ];
if ( IsDefined( get_ent ) )
{
org = get_ent.origin;
ent.v[ "angles" ] = VectorToAngles( org - ent.v[ "origin" ] );
}
else
{
get_ent = get_target_ent( ent.v[ "target" ] );
if ( IsDefined( get_ent ) )
{
org = get_ent.origin;
ent.v[ "angles" ] = VectorToAngles( org - ent.v[ "origin" ] );
}
}
}
// this basically determines if its a brush / model exploder or not
if ( !IsDefined( exploder.code_classname ) )
{
//I assume everything that doesn't have a code_classname is a struct that needs a script_modelname to make its way into the game
ent.model = exploder;
if ( IsDefined( ent.model.script_modelname ) )
{
PreCacheModel( ent.model.script_modelname );
}
}
else if ( exploder.code_classname == "script_brushmodel" || IsDefined( exploder.model ) )
{
ent.model = exploder;
ent.model.disconnect_paths = exploder.script_disconnectpaths;
}
if ( IsDefined( exploder.targetname ) && IsDefined( acceptableTargetnames[ exploder.targetname ] ) )
ent.v[ "exploder_type" ] = exploder.targetname;
else
ent.v[ "exploder_type" ] = "normal";
if ( IsDefined( exploder.masked_exploder ) )
{
ent.v[ "masked_exploder" ] = exploder.model;
ent.v[ "masked_exploder_spawnflags" ] = exploder.spawnflags;
ent.v[ "masked_exploder_script_disconnectpaths" ] = exploder.script_disconnectpaths;
exploder Delete();
}
ent common_scripts\_createfx::post_entity_creation_function();
}
}
setup_flag_exploders()
{
// createfx has to do 2 waittillframeends so we have to do 3 to make sure this comes after
// createfx is all done setting up. Who will raise the gambit to 4?
waittillframeend;
waittillframeend;
waittillframeend;
exploder_flags = [];
foreach ( ent in level.createFXent )
{
if ( ent.v[ "type" ] != "exploder" )
continue;
theFlag = ent.v[ "flag" ];
if ( !IsDefined( theFlag ) )
{
continue;
}
if ( theFlag == "nil" )
{
ent.v[ "flag" ] = undefined;
}
exploder_flags[ theFlag ] = true;
}
foreach ( msg, _ in exploder_flags )
{
thread exploder_flag_wait( msg );
}
}
exploder_flag_wait( msg )
{
if ( !flag_exist( msg ) )
flag_init( msg );
flag_wait( msg );
foreach ( ent in level.createFXent )
{
if ( ent.v[ "type" ] != "exploder" )
continue;
theFlag = ent.v[ "flag" ];
if ( !IsDefined( theFlag ) )
{
continue;
}
if ( theFlag != msg )
continue;
ent activate_individual_exploder();
}
}
exploder_model_is_damaged_model( ent )
{
return( IsDefined( ent.targetname ) ) && ( ent.targetname == "exploder" );
}
exploder_model_starts_hidden( ent )
{
return( ent.model == "fx" ) && ( ( !IsDefined( ent.targetname ) ) || ( ent.targetname != "exploderchunk" ) );
}
exploder_model_is_chunk( ent )
{
return( IsDefined( ent.targetname ) ) && ( ent.targetname == "exploderchunk" );
}
show_exploder_models_proc( num )
{
num += "";
//prof_begin( "hide_exploder" );
if ( IsDefined( level.createFXexploders ) )
{ // do optimized flavor if available
exploders = level.createFXexploders[ num ];
if ( IsDefined( exploders ) )
{
foreach ( ent in exploders )
{
//pre exploded geo. don't worry about deleted exploder geo..
if ( ! exploder_model_starts_hidden( ent.model )
&& ! exploder_model_is_damaged_model( ent.model )
&& !exploder_model_is_chunk( ent.model ) )
{
ent.model Show();
}
//exploded geo and should be shown
if ( IsDefined( ent.brush_shown ) )
ent.model Show();
}
}
}
else
{
for ( i = 0; i < level.createFXent.size; i++ )
{
ent = level.createFXent[ i ];
if ( !IsDefined( ent ) )
continue;
if ( ent.v[ "type" ] != "exploder" )
continue;
// make the exploder actually removed the array instead?
if ( !IsDefined( ent.v[ "exploder" ] ) )
continue;
if ( ent.v[ "exploder" ] + "" != num )
continue;
if ( IsDefined( ent.model ) )
{
//pre exploded geo. don't worry about deleted exploder geo..
if ( ! exploder_model_starts_hidden( ent.model ) && ! exploder_model_is_damaged_model( ent.model ) && !exploder_model_is_chunk( ent.model ) )
{
ent.model Show();
}
//exploded geo and should be shown
if ( IsDefined( ent.brush_shown ) )
ent.model Show();
}
}
}
//prof_end( "hide_exploder" );
}
stop_exploder_proc( num )
{
num += "";
if ( IsDefined( level.createFXexploders ) )
{ // do optimized flavor if available
exploders = level.createFXexploders[ num ];
if ( IsDefined( exploders ) )
{
foreach ( ent in exploders )
{
if ( !IsDefined( ent.looper ) )
continue;
ent.looper Delete();
}
}
}
else
{
for ( i = 0; i < level.createFXent.size; i++ )
{
ent = level.createFXent[ i ];
if ( !IsDefined( ent ) )
continue;
if ( ent.v[ "type" ] != "exploder" )
continue;
// make the exploder actually removed the array instead?
if ( !IsDefined( ent.v[ "exploder" ] ) )
continue;
if ( ent.v[ "exploder" ] + "" != num )
continue;
if ( !IsDefined( ent.looper ) )
continue;
ent.looper Delete();
}
}
}
get_exploder_array_proc( msg )
{
msg += "";
array = [];
if ( IsDefined( level.createFXexploders ) )
{ // do optimized flavor if available
exploders = level.createFXexploders[ msg ];
if ( IsDefined( exploders ) )
{
array = exploders;
}
}
else
{
foreach ( ent in level.createFXent )
{
if ( ent.v[ "type" ] != "exploder" )
continue;
// make the exploder actually removed the array instead?
if ( !IsDefined( ent.v[ "exploder" ] ) )
continue;