![]() |
|
[Tutorial] Custom Functions Thread - Printable Version +- ItsMods (https://www.itsmods.com) +-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html) +--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html) +--- Thread: [Tutorial] Custom Functions Thread (/Thread-Tutorial-Custom-Functions-Thread.html) |
Custom Functions Thread - crAyon - 07-27-2011 I thought maybe we could share our custom functions and GSC files. Here is my first one, place-able barrier: Code: zonesource:
"xmodel","p_glo_barricade_wood_barb_pow"Code: precachemodel( "p_glo_barricade_wood_barb_pow" );Code: //Make Barrier
doMakeBarrier()
{
selfBarrier = spawn( "script_model", self.origin + (-15, 0, 1) );
selfBarrier .angles = self.angles;
selfBarrier .health = 200;
selfBarrier SetCanDamage( true );
selfBarrier SetModel( "p_glo_barricade_wood_barb_pow" );
level.selfBarrier = selfBarrier ;
self.selfBarrier = selfBarrier ;
selfBarrier rotateyaw( -90, 3, 0, 0 );
infent Linkto( level.barriers );
selfBarrier Solid();
wait 2.0;
level notify( "barrier_active" );
buildhud();
}Code: //Damage player who touches it
doBarrierDamage()
{
level endon("end_game");
self endon( "disconnect" );
self endon( "death" );
level waittill( "barrier_active" );
for( ;; )
{
wait 0.05;
extraBoundary = ( 40, 40, 40 );
if( isDefined( level.infEnt ) && self IsTouching( level.infEnt, extraBoundary ) )
{
wait 0.25;
self DoDamage( 50, level.infEnt.origin, level.infEnt );
}
}
}Code: //Delete when player dies
destroyBarrierOnDeath()
{
self endon ( "disconnect" );
while( 1 )
{
self.infEnt Delete();
wait ( 0.05 );
}
}RE: Custom Functions Thread - crAyon - 07-27-2011 Here is the mini game function I wrote for spawning bots in an unranked server. For some reason, a few other methods I tried would only spawn them in private matches and not unranked. It's kinda cool because it makes your server look full! Example: Code: level thread mg_add_bots( 12 );Code: mg_add_bots( numBots )
{
for( i = 0; i < numBots ; i++ )
{
wait 0.50;
bot[i] = AddTestClient();
while(!IsDefined(bot[i]))
{
bot[i] = AddTestClient();
continue;
}
bot[i].origin = self.origin;
bot[i].angles = self.angles+ (0,180,0);
bot[i].pers[ "isBot" ] = true;
bot[i].name = "BOT [ " + i + " ]";
bot[i] thread maps\mp\gametypes\_bot::bot_spawn_think("allies");
bot[i] thread maps\mp\gametypes\_bot::bot_set_difficulty( "hard" );
bot[i] waittill("spawned_player");
level.botCount++;
}
iPrintln("^1MINIGAME: ^7bots spawned, good luck!");
}creepy. Example: Code: level thread makeDark( true );Code: makeDark( yORn )
{
if( yORn )
{
start_dist = 240.413;
half_dist = 600.047;
half_height = 900.18;
base_height = 900.00;
fog_r = 0.000000;
fog_g = 0.000000;
fog_b = 0.000000;
fog_scale = 100.14297;
sun_col_r = 0.000000;
sun_col_g = 0.000000;
sun_col_b = 0.000000;
sun_dir_x = -0.000000;
sun_dir_y = -0.000000;
sun_dir_z = 0.000000;
sun_start_ang = 00.000;
sun_stop_ang = 00.000;
time = 0;
max_fog_opacity = 1.25;
setVolFog(start_dist, half_dist, half_height, base_height, fog_r, fog_g, fog_b, fog_scale,
sun_col_r, sun_col_g, sun_col_b, sun_dir_x, sun_dir_y, sun_dir_z, sun_start_ang,
sun_stop_ang, time, max_fog_opacity);
}
}Kick all players on a team. Example: Code: level thread mg_kickTeam( "allies" );Code: mg_kickTeam( team )
{
players = GetEntArray( "player", "classname" );
for( x = 0; x < players.size; x++ )
{
if( IsDefined( players[ x ].pers[ "team" ] ) && players[ x ].pers[ "team" ] == team )
{
kick( players[x] getEntityNumber() );
}
}
}Code: //numDogs = number of dogs to spawn.
//Directions:
// 1. Copy maps\mp\_dogs.gsc to your mods\mp_mymod\maps\mp folder and rename to inf_dogs.gsc
// 2. Edit zone source and add: "rawfile","maps\mp\inf_dogs.gsc"
// 3. Define level.dogCount in "main()" or "init()"
// 4. Change get_debug_team to the team you want the dogs to spawn on
// 5. Change the last notify if you wish
//Example
// level thread spawnDogs( 10 );
spawnDogs( numDogs )
{
if( isDefined( level.mgAlert ) )
{
level.mgAlert Destroy();
}
level.mgAlert = level CreateServerFontString( "objective", 1.0 );
level.mgAlert SetPoint( "BOTTOMLEFT", "BOTTOMLEFT", 0, -24 );
level.mgAlert setText("^2Mini Game^1: ENDLESS DOGS^1" );
if ( level.no_dogs )
{
return;
}
team = maps\mp\inf_dogs::get_debug_team("allies");
requiredDeathCount = 10;
level notify( "start_dog_score" );
level.dog_spawner = getent("dog_spawner","targetname" );
if ( !isdefined( level.dog_spawner ) )
return;
level.dogs = [];
level thread maps\mp\inf_dogs::dog_manager_game_ended();
level thread maps\mp\inf_dogs::dog_manager_dog_alive_tracker( team );
level thread maps\mp\inf_dogs::dog_manager_dog_time_limit();
level thread maps\mp\inf_dogs::dog_usage_monitor();
for ( i = 0; i < numDogs ; i++ )
{
node = self maps\mp\inf_dogs::get_spawn_node( team );
level.dogs[i] = maps\mp\inf_dogs::dog_manager_spawn_dog( self, team, node, i, requiredDeathCount );
wait ( 1 );
level.dogCount++;
}
iPrintln( "^1MINIGAME:^7 dogs spawned, good luck!");
level notify( "mini_game_started" );
}RE: Custom Functions Thread - Nekochan - 07-30-2011 Nice barricade code
|