#include common_scripts\utility; #include maps\mp\gametypes\_hud_util; KILLSTREAK_GIMME_SLOT = 0; KILLSTREAK_SLOT_1 = 1; KILLSTREAK_SLOT_2 = 2; KILLSTREAK_SLOT_3 = 3; KILLSTREAK_ALL_PERKS_SLOT = 4; KILLSTREAK_STACKING_START_SLOT = 5; MAX_VEHICLES = 8; LIGHTWEIGHT_SCALAR = 1.07; ATTACHMAP_TABLE = "mp/attachmentmap.csv"; ATTACHMAP_COL_CLASS_OR_WEAP_NAME = 0; ATTACHMAP_ROW_ATTACH_BASE_NAME = 0; ALIENS_ATTACHMAP_TABLE = "mp/alien/alien_attachmentmap.csv"; ALIENS_ATTACHMAP_COL_CLASS_OR_WEAP_NAME = 0; ALIENS_ATTACHMAP_ROW_ATTACH_BASE_NAME = 0; MAX_CUSTOM_DEFAULT_LOADOUTS = 6; // See recipes.raw: CustomGameClass defaultClasses[ PlayerGroup ][ 6 ]; exploder_sound() { if ( isdefined( self.script_delay ) ) wait self.script_delay; self playSound( level.scr_sound[ self.script_sound ] ); } _beginLocationSelection ( streakName, selectorType, directionality , size ) { self BeginLocationSelection( selectorType, directionality, size ); self.selectingLocation = true; self setblurforplayer( 10.3, 0.3 ); self thread endSelectionOnAction( "cancel_location" ); self thread endSelectionOnAction( "death" ); self thread endSelectionOnAction( "disconnect" ); self thread endSelectionOnAction( "used" ); self thread endSelectionOnAction( "weapon_change" ); self endon( "stop_location_selection" ); self thread endSelectionOnEndGame(); self thread endSelectionOnEMP(); if ( IsDefined( streakName) && self.team != "spectator" ) { if ( IsDefined( self.streakMsg ) ) self.streakMsg destroy(); if( self IsSplitscreenPlayer() ) { self.streakMsg = self maps\mp\gametypes\_hud_util::createFontString( "default", 1.3 ); self.streakMsg maps\mp\gametypes\_hud_util::setPoint( "CENTER", "CENTER", 0 , -98 ); } else { self.streakMsg = self maps\mp\gametypes\_hud_util::createFontString( "default", 1.6 ); self.streakMsg maps\mp\gametypes\_hud_util::setPoint( "CENTER", "CENTER", 0 , -190 ); } streakString = getKillstreakName( streakName ); self.streakMsg setText( streakString ); } } stopLocationSelection( disconnected, reason ) { if ( !IsDefined( reason ) ) reason = "generic"; if ( !disconnected ) { self setblurforplayer( 0, 0.3 ); self endLocationSelection(); self.selectingLocation = undefined; if ( IsDefined( self.streakMsg ) ) self.streakMsg destroy(); } self notify( "stop_location_selection", reason ); } endSelectionOnEMP() { self endon( "stop_location_selection" ); for ( ;; ) { level waittill( "emp_update" ); if ( !self isEMPed() ) continue; self thread stopLocationSelection( false, "emp" ); return; } } endSelectionOnAction( waitfor ) { self endon( "stop_location_selection" ); self waittill( waitfor ); self thread stopLocationSelection( (waitfor == "disconnect"), waitfor ); } endSelectionOnEndGame() { self endon( "stop_location_selection" ); level waittill( "game_ended" ); self thread stopLocationSelection( false, "end_game" ); } isAttachment( attachmentName ) { if ( is_aliens() ) attachment = tableLookup( "mp/alien/alien_attachmentTable.csv", 4, attachmentName, 0 ); else attachment = tableLookup( "mp/attachmentTable.csv", 4, attachmentName, 0 ); if( IsDefined( attachment ) && attachment != "" ) return true; else return false; } getAttachmentType( attachmentName ) { if ( is_aliens() ) attachmentType = tableLookup( "mp/alien/alien_attachmentTable.csv", 4, attachmentName, 2 ); else attachmentType = tableLookup( "mp/attachmentTable.csv", 4, attachmentName, 2 ); return attachmentType; } /* 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 ); } } // JC-ToDo: This should be in common script between sp and mp but it's late in the project. array_contains_index( array, index ) { AssertEx( IsArray( array ), "array_contains_index() passed invalid array." ); AssertEx( IsDefined( index ), "array_contains_index() passed undefind index." ); foreach ( i, _ in array ) if ( i == index ) return true; return false; } getPlant() { start = self.origin + ( 0, 0, 10 ); range = 11; forward = anglesToForward( self.angles ); forward = ( 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( player isSplitscreenPlayer() && !player isSplitscreenPlayerPrimary() ) continue; 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( player isSplitscreenPlayer() && !player isSplitscreenPlayerPrimary() ) continue; 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( level.players[ i ] isSplitscreenPlayer() && !level.players[ i ] isSplitscreenPlayerPrimary() ) continue; if ( !isExcluded( level.players[ i ], excludeList ) ) level.players[ i ] playLocalSound( sound ); } } else { for ( i = 0; i < level.players.size; i++ ) { if( level.players[ i ] isSplitscreenPlayer() && !level.players[ i ] isSplitscreenPlayerPrimary() ) continue; 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, hideWhenInDemo, hideWhenInMenu ) { 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; newMessage.hideWhenInDemo = hideWhenInDemo; newMessage.hideWhenInMenu = hideWhenInMenu; sortLowerMessages(); } removeLowerMessage( name ) { if( IsDefined( self.lowerMessages ) ) { // since we're changing the array in the loop, we should iterate backwards for ( i = self.lowerMessages.size; i > 0; i-- ) { if ( self.lowerMessages[ i - 1 ].name != name ) continue; message = self.lowerMessages[ i - 1 ]; // now move every message down one to fill the empty space for( j = i; j < self.lowerMessages.size; j++ ) { if ( IsDefined( self.lowerMessages[ j ] ) ) self.lowerMessages[ j - 1 ] = self.lowerMessages[ j ]; } // make the last one undefined because we filled the space above self.lowerMessages[ self.lowerMessages.size - 1 ] = undefined; } sortLowerMessages(); } } getLowerMessage() { if ( !isdefined( self.lowerMessages ) ) return undefined; return self.lowerMessages[ 0 ]; } /* ============= ///ScriptDocBegin "Name: setLowerMessage( , ,