From 7309ee5dd3ba0b9a40705bc6373d867aea3a6f97 Mon Sep 17 00:00:00 2001 From: IronClawTrem Date: Sat, 7 Mar 2020 20:56:38 +0000 Subject: add !practise command --- src/game/g_active.c | 17 +++++++++++++++ src/game/g_admin.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/game/g_admin.h | 1 + src/game/g_buildable.c | 4 ---- src/game/g_client.c | 4 +++- src/game/g_cmds.c | 39 +++++++++++++++++++++++++++------ src/game/g_combat.c | 3 +++ src/game/g_local.h | 1 + src/game/g_main.c | 16 +++++++++++--- 9 files changed, 128 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/game/g_active.c b/src/game/g_active.c index fc7d540..c69d421 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -1469,6 +1469,7 @@ void ClientThink_real( gentity_t *ent ) int msec; usercmd_t *ucmd; int real_pm_type; + pTeam_t team; client = ent->client; @@ -1918,6 +1919,22 @@ void ClientThink_real( gentity_t *ent ) bubble = G_TempEntity( client->ps.origin, EV_PLAYER_TELEPORT_OUT ); bubble->s.clientNum = ent->s.clientNum; } + + if( g_practise.integer ) + { + if( team = PTE_ALIENS ) + { + if( client->pers.credit < 9 ) + G_AddCreditToClient( client, 9, qtrue ); + } + if( team = PTE_HUMANS ) + { + if( client->pers.credit < 2000 ) + G_AddCreditToClient( client, 2000, qtrue ); + else if( client->pers.credit > 2000 ) + G_AddCreditToClient( client, -2000, qtrue ); + } + } } /* diff --git a/src/game/g_admin.c b/src/game/g_admin.c index ea6a896..dfccfa3 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -446,6 +446,11 @@ g_admin_cmd_t g_admin_cmds[ ] = {"range", G_admin_range, "range", "changes a player's bite/swipe/chomp range", "[^3name|slot#^7] [^5range^7]" + }, + + {"practise", G_admin_practise, "practise", + "enables practise mode", + "[^3on|off^7]" } }; @@ -8431,3 +8436,56 @@ qboolean G_admin_range( gentity_t *ent, int skiparg ) return qtrue; } + +qboolean G_admin_practise( gentity_t *ent, int skiparg ) +{ + int minargc; + char arg[ MAX_STRING_CHARS ]; + minargc = 2 + skiparg; + + if( G_SayArgc() < minargc ) + { + ADMP( "^3!practise: ^7usage: !practise [on|off]\n" ); + return qfalse; + } + + G_SayArgv( 1 + skiparg, arg, sizeof( arg ) ); + + if( !Q_stricmp( arg, "on" ) ) + { + if( g_practise.integer ) + { + ADMP( "^3!practise: ^7practise mode is already on\n" ); + return qfalse; + } + trap_Cvar_Set( "g_practise", "1" ); + trap_Cvar_Set( "g_alienStage", "2" ); + trap_Cvar_Set( "g_humanStage", "2" ); + strcpy( arg, "^2enabled^7" ); + } + else if( !Q_stricmp( arg, "off" ) ) + { + if( !g_practise.integer ) + { + ADMP( "^3!practise: ^7practise mode is already off\n" ); + return qfalse; + } + trap_Cvar_Set( "g_practise", "0" ); + strcpy( arg, "^1disabled^7" ); + } + else + { + ADMP( "^3!practise: ^7usage: !practise [on|off]\n" ); + return qfalse; + } + + if( ent ) + ent->flags ^= FL_NOTARGET; + + AP( va( "print \"^3!practise: ^7practise mode was %s by %s\n\"", + arg, + ( ent ) ? G_admin_adminPrintName( ent ) : "console" ) ); + + return qtrue; + +} diff --git a/src/game/g_admin.h b/src/game/g_admin.h index a7653d9..6438a81 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -295,6 +295,7 @@ qboolean G_admin_switch( gentity_t *ent, int skiparg ); qboolean G_admin_drug( gentity_t *ent, int skiparg ); qboolean G_admin_god( gentity_t *ent, int skiparg ); qboolean G_admin_range( gentity_t *ent, int skiparg ); +qboolean G_admin_practise( gentity_t *ent, int skiparg ); void G_admin_print( gentity_t *ent, char *m ); void G_admin_buffer_print( gentity_t *ent, char *m ); diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index b7bc386..1851ea9 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -1986,9 +1986,6 @@ void HMedistat_Think( gentity_t *self ) { player = &g_entities[ entityList[ i ] ]; - if( player->flags & FL_NOTARGET ) - continue; // notarget cancels even beneficial effects? - if( player->client && player->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { if( player->health < player->client->ps.stats[ STAT_MAX_HEALTH ] && @@ -3523,7 +3520,6 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori built->splashMethodOfDeath = BG_FindMODForBuildable( buildable ); built->nextthink = BG_FindNextThinkForBuildable( buildable ); - built->takedamage = qtrue; built->spawned = qfalse; built->buildTime = built->s.time = level.time; diff --git a/src/game/g_client.c b/src/game/g_client.c index 97c02eb..6b49f4b 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1789,7 +1789,9 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles ent->watertype = 0; ent->flags = 0; if( ent->client->pers.godMode ) - ent->flags = FL_GODMODE; + ent->flags += FL_GODMODE; + if( g_practise.integer ) + ent->flags += FL_NOTARGET; //TA: calculate each client's acceleration ent->evaluateAcceleration = qtrue; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index e4f6ad7..33771df 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -2742,14 +2742,17 @@ void Cmd_Class_f( gentity_t *ent ) if( ent->client->pers.teamSelection == PTE_ALIENS ) { - if( newClass != PCL_ALIEN_BUILDER0 && - newClass != PCL_ALIEN_BUILDER0_UPG && - newClass != PCL_ALIEN_LEVEL0 ) + if( !g_practise.integer ) { - trap_SendServerCommand( ent-g_entities, - va( "print \"You cannot spawn with class %s\n\"", s ) ); - return; - } + if( newClass != PCL_ALIEN_BUILDER0 && + newClass != PCL_ALIEN_BUILDER0_UPG && + newClass != PCL_ALIEN_LEVEL0 ) + { + trap_SendServerCommand( ent-g_entities, + va( "print \"You cannot spawn with class %s\n\"", s ) ); + return; + } + } if( !BG_ClassIsAllowed( newClass ) ) { @@ -3019,6 +3022,13 @@ void Cmd_Destroy_f( gentity_t *ent ) return; } + if( g_practise.integer ) + { + trap_SendServerCommand( ent-g_entities, + "print \"You cannot build in practise mode\n\"" ); + return; + } + trap_Argv( 0, cmd, sizeof( cmd ) ); if( Q_stricmp( cmd, "destroy" ) == 0 ) deconstruct = qfalse; @@ -3194,6 +3204,13 @@ void Cmd_Mark_f( gentity_t *ent ) return; } + if( g_practise.integer ) + { + trap_SendServerCommand( ent-g_entities, + "print \"You cannot build in practise mode\n\"" ); + return; + } + // Check the minimum level to deconstruct if ( G_admin_level( ent ) < g_minDeconLevel.integer && !ent->client->pers.designatedBuilder && g_minDeconAffectsMark.integer > 0 ) { @@ -3768,6 +3785,7 @@ void Cmd_Build_f( gentity_t *ent ) "print \"Your building rights have been revoked\n\"" ); return; } + if( ent->client->pers.paused ) { trap_SendServerCommand( ent-g_entities, @@ -3775,6 +3793,13 @@ void Cmd_Build_f( gentity_t *ent ) return; } + if( g_practise.integer ) + { + trap_SendServerCommand( ent-g_entities, + "print \"You cannot build in practise mode\n\"" ); + return; + } + trap_Argv( 1, s, sizeof( s ) ); buildable = BG_FindBuildNumForName( s ); diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 091040e..ddda818 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -1336,6 +1336,9 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, if(targ->s.eType == ET_BUILDABLE && g_cheats.integer && g_devmapNoStructDmg.integer) return; + + if( targ->s.eType == ET_BUILDABLE && g_practise.integer ) + return; } // add to the attacker's hit counter diff --git a/src/game/g_local.h b/src/game/g_local.h index 2d73b5f..48e7ab8 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1495,6 +1495,7 @@ extern vmCvar_t g_Bubbles; extern vmCvar_t g_scrimMode; extern vmCvar_t g_gradualFreeFunds; extern vmCvar_t g_bleedingSpree; +extern vmCvar_t g_practise; void trap_Printf( const char *fmt ); void trap_Error( const char *fmt ); diff --git a/src/game/g_main.c b/src/game/g_main.c index b30f8c0..3776870 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -239,6 +239,7 @@ vmCvar_t g_Bubbles; vmCvar_t g_scrimMode; vmCvar_t g_gradualFreeFunds; vmCvar_t g_bleedingSpree; +vmCvar_t g_practise; static cvarTable_t gameCvarTable[ ] = { @@ -455,7 +456,8 @@ static cvarTable_t gameCvarTable[ ] = { &g_Bubbles, "g_Bubbles", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_scrimMode, "g_scrimMode", "0", CVAR_ARCHIVE, 0, qfalse }, { &g_gradualFreeFunds, "g_gradualFreeFunds", "2", CVAR_ARCHIVE, 0, qtrue }, - { &g_bleedingSpree, "g_bleedingSpree", "0", CVAR_ARCHIVE, 0, qfalse } + { &g_bleedingSpree, "g_bleedingSpree", "0", CVAR_ARCHIVE, 0, qfalse }, + { &g_practise, "g_practise", "0", CVAR_ARCHIVE, 0, qfalse } }; static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] ); @@ -847,8 +849,16 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) G_PrintRotations( ); //reset stages - trap_Cvar_Set( "g_alienStage", va( "%d", S1 ) ); - trap_Cvar_Set( "g_humanStage", va( "%d", S1 ) ); + if( g_practise.integer ) + { + trap_Cvar_Set( "g_alienStage", "2" ); + trap_Cvar_Set( "g_humanStage", "2" ); + } + else + { + trap_Cvar_Set( "g_alienStage", va( "%d", S1 ) ); + trap_Cvar_Set( "g_humanStage", va( "%d", S1 ) ); + } trap_Cvar_Set( "g_alienKills", 0 ); trap_Cvar_Set( "g_humanKills", 0 ); trap_Cvar_Set( "g_suddenDeath", 0 ); -- cgit