#include common_scripts\utility; #include maps\mp\gametypes\_hud_util; exploder_sound() { if ( isdefined( self.script_delay ) ) wait self.script_delay; self playSound( level._scr_sound[ self.script_sound ] ); } /* saveModel() { info["model"] = self.model; info["viewmodel"] = self getViewModel(); attachSize = self getAttachSize(); info["attach"] = []; assert(info["viewmodel"] != ""); // No viewmodel was associated with the player's model for(i = 0; i < attachSize; i++) { info["attach"][i]["model"] = self getAttachModelName(i); info["attach"][i]["tag"] = self getAttachTagName(i); info["attach"][i]["ignoreCollision"] = self getAttachIgnoreCollision(i); } return info; } loadModel(info) { self detachAll(); self setModel(info["model"]); self setViewModel(info["viewmodel"]); attachInfo = info["attach"]; attachSize = attachInfo.size; for(i = 0; i < attachSize; i++) self attach(attachInfo[i]["model"], attachInfo[i]["tag"], attachInfo[i]["ignoreCollision"]); } */ /* ============= ///ScriptDocBegin "Name: delayThread( , , , , , )" "Summary: Delaythread is cool! It saves you from having to write extra script for once off commands. Note you don�t have to thread it off. Delaythread is that smart!" "Module: Utility" "MandatoryArg: : The delay before the function occurs" "MandatoryArg: : The function to run." "OptionalArg: : parameter 1 to pass to the process" "OptionalArg: : parameter 2 to pass to the process" "OptionalArg: : parameter 3 to pass to the process" "OptionalArg: : parameter 4 to pass to the process" "OptionalArg: : parameter 5 to pass to the process" "Example: delayThread( 3, ::flag_set, "player_can_rappel" ); "SPMP: both" ///ScriptDocEnd ============= */ delayThread( timer, func, param1, param2, param3, param4, param5 ) { // to thread it off thread delayThread_proc( func, timer, param1, param2, param3, param4, param5 ); } delayThread_proc( func, timer, param1, param2, param3, param4, param5 ) { wait( timer ); if ( !IsDefined( param1 ) ) { assertex( !isdefined( param2 ), "Delaythread does not support vars after undefined." ); assertex( !isdefined( param3 ), "Delaythread does not support vars after undefined." ); assertex( !isdefined( param4 ), "Delaythread does not support vars after undefined." ); assertex( !isdefined( param5 ), "Delaythread does not support vars after undefined." ); thread [[ func ]](); } else if ( !IsDefined( param2 ) ) { assertex( !isdefined( param3 ), "Delaythread does not support vars after undefined." ); assertex( !isdefined( param4 ), "Delaythread does not support vars after undefined." ); assertex( !isdefined( param5 ), "Delaythread does not support vars after undefined." ); thread [[ func ]]( param1 ); } else if ( !IsDefined( param3 ) ) { assertex( !isdefined( param4 ), "Delaythread does not support vars after undefined." ); assertex( !isdefined( param5 ), "Delaythread does not support vars after undefined." ); thread [[ func ]]( param1, param2 ); } else if ( !IsDefined( param4 ) ) { assertex( !isdefined( param5 ), "Delaythread does not support vars after undefined." ); thread [[ func ]]( param1, param2, param3 ); } else if ( !IsDefined( param5 ) ) { thread [[ func ]]( param1, param2, param3, param4 ); } else { thread [[ func ]]( param1, param2, param3, param4, param5 ); } } getPlant() { start = self.origin + ( 0, 0, 10 ); range = 11; forward = anglesToForward( self.angles ); forward = vector_multiply( forward, range ); traceorigins[ 0 ] = start + forward; traceorigins[ 1 ] = start; trace = bulletTrace( traceorigins[ 0 ], ( traceorigins[ 0 ] + ( 0, 0, -18 ) ), false, undefined ); if ( trace[ "fraction" ] < 1 ) { //println("^6Using traceorigins[0], tracefraction is", trace["fraction"]); temp = spawnstruct(); temp.origin = trace[ "position" ]; temp.angles = orientToNormal( trace[ "normal" ] ); return temp; } trace = bulletTrace( traceorigins[ 1 ], ( traceorigins[ 1 ] + ( 0, 0, -18 ) ), false, undefined ); if ( trace[ "fraction" ] < 1 ) { //println("^6Using traceorigins[1], tracefraction is", trace["fraction"]); temp = spawnstruct(); temp.origin = trace[ "position" ]; temp.angles = orientToNormal( trace[ "normal" ] ); return temp; } traceorigins[ 2 ] = start + ( 16, 16, 0 ); traceorigins[ 3 ] = start + ( 16, -16, 0 ); traceorigins[ 4 ] = start + ( -16, -16, 0 ); traceorigins[ 5 ] = start + ( -16, 16, 0 ); besttracefraction = undefined; besttraceposition = undefined; for ( i = 0; i < traceorigins.size; i++ ) { trace = bulletTrace( traceorigins[ i ], ( traceorigins[ i ] + ( 0, 0, -1000 ) ), false, undefined ); //ent[i] = spawn("script_model",(traceorigins[i]+(0, 0, -2))); //ent[i].angles = (0, 180, 180); //ent[i] setmodel("105"); //println("^6trace ", i ," fraction is ", trace["fraction"]); if ( !isdefined( besttracefraction ) || ( trace[ "fraction" ] < besttracefraction ) ) { besttracefraction = trace[ "fraction" ]; besttraceposition = trace[ "position" ]; //println("^6besttracefraction set to ", besttracefraction, " which is traceorigin[", i, "]"); } } if ( besttracefraction == 1 ) besttraceposition = self.origin; temp = spawnstruct(); temp.origin = besttraceposition; temp.angles = orientToNormal( trace[ "normal" ] ); return temp; } orientToNormal( normal ) { hor_normal = ( normal[ 0 ], normal[ 1 ], 0 ); hor_length = length( hor_normal ); if ( !hor_length ) return( 0, 0, 0 ); hor_dir = vectornormalize( hor_normal ); neg_height = normal[ 2 ] * - 1; tangent = ( hor_dir[ 0 ] * neg_height, hor_dir[ 1 ] * neg_height, hor_length ); plant_angle = vectortoangles( tangent ); //println("^6hor_normal is ", hor_normal); //println("^6hor_length is ", hor_length); //println("^6hor_dir is ", hor_dir); //println("^6neg_height is ", neg_height); //println("^6tangent is ", tangent); //println("^6plant_angle is ", plant_angle); return plant_angle; } deletePlacedEntity( entity ) { entities = getentarray( entity, "classname" ); for ( i = 0; i < entities.size; i++ ) { //println("DELETED: ", entities[i].classname); entities[ i ] delete(); } } playSoundOnPlayers( sound, team, excludeList ) { assert( isdefined( level._players ) ); if ( level._splitscreen ) { if ( isdefined( level._players[ 0 ] ) ) level._players[ 0 ] playLocalSound( sound ); } else { if ( isDefined( team ) ) { if ( isdefined( excludeList ) ) { for ( i = 0; i < level._players.size; i++ ) { player = level._players[ i ]; if ( isdefined( player.pers[ "team" ] ) && ( player.pers[ "team" ] == team ) && !isExcluded( player, excludeList ) ) player playLocalSound( sound ); } } else { for ( i = 0; i < level._players.size; i++ ) { player = level._players[ i ]; if ( isdefined( player.pers[ "team" ] ) && ( player.pers[ "team" ] == team ) ) player playLocalSound( sound ); } } } else { if ( isdefined( excludeList ) ) { for ( i = 0; i < level._players.size; i++ ) { if ( !isExcluded( level._players[ i ], excludeList ) ) level._players[ i ] playLocalSound( sound ); } } else { for ( i = 0; i < level._players.size; i++ ) level._players[ i ] playLocalSound( sound ); } } } } sortLowerMessages() { for ( i = 1; i < self.lowerMessages.size; i++ ) { message = self.lowerMessages[ i ]; priority = message.priority; for ( j = i - 1; j >= 0 && priority > self.lowerMessages[ j ].priority; j -- ) self.lowerMessages[ j + 1 ] = self.lowerMessages[ j ]; self.lowerMessages[ j + 1 ] = message; } } addLowerMessage( name, text, time, priority, showTimer, shouldFade, fadeToAlpha, fadeToAlphaTime ) { newMessage = undefined; foreach ( message in self.lowerMessages ) { if ( message.name == name ) { if ( message.text == text && message.priority == priority ) return; newMessage = message; break; } } if ( !isDefined( newMessage ) ) { newMessage = spawnStruct(); self.lowerMessages[ self.lowerMessages.size ] = newMessage; } newMessage.name = name; newMessage.text = text; newMessage.time = time; newMessage.addTime = getTime(); newMessage.priority = priority; newMessage.showTimer = showTimer; newMessage.shouldFade = shouldFade; newMessage.fadeToAlpha = fadeToAlpha; newMessage.fadeToAlphaTime = fadeToAlphaTime; sortLowerMessages(); } removeLowerMessage( name ) { if( IsDefined( self.lowerMessages ) ) { for ( i = 0; i < self.lowerMessages.size; i++ ) { if ( self.lowerMessages[ i ].name != name ) continue; message = self.lowerMessages[ i ]; if ( i < self.lowerMessages.size - 1 ) self.lowerMessages[ i ] = self.lowerMessages[ self.lowerMessages.size - 1 ]; self.lowerMessages[ self.lowerMessages.size - 1 ] = undefined; } sortLowerMessages(); } } getLowerMessage() { return self.lowerMessages[ 0 ]; } /* ============= ///ScriptDocBegin "Name: setLowerMessage( , ,