From e8d1308d559e623843737e0fc6793435437a0629 Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Wed, 5 Apr 2017 20:48:21 +0200 Subject: implement the option to make evolution and equipment free when the new g_freeStuff cvar is true, alien evolution and human equipment is free, with the exception of grenades; furthermore, aliens constantly have 9 evos, as a hack to allow clients to fully use the evolution menu at all times --- src/game/g_cmds.c | 24 ++++++++++++++++-------- src/game/g_local.h | 1 + src/game/g_main.c | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 9246a644..1b67ddaf 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1875,8 +1875,10 @@ void Cmd_Class_f( gentity_t *ent ) } cost = BG_ClassCanEvolveFromTo( currentClass, newClass, - ent->client->pers.credit, + g_freeStuff.integer ? ALIEN_MAX_CREDITS : ent->client->pers.credit, g_alienStage.integer, 0 ); + if( g_freeStuff.integer && cost > 0 ) + cost = 0; if( G_RoomForClassChange( ent, newClass, infestOrigin ) ) { @@ -2212,7 +2214,7 @@ void Cmd_Buy_f( gentity_t *ent ) } //can afford this? - if( BG_Weapon( weapon )->price > (short)ent->client->pers.credit ) + if( BG_Weapon( weapon )->price > (short)ent->client->pers.credit && !g_freeStuff.integer ) { G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); return; @@ -2243,7 +2245,8 @@ void Cmd_Buy_f( gentity_t *ent ) ent->client->ps.stats[ STAT_MISC ] = 0; //subtract from funds - G_AddCreditToClient( ent->client, -(short)BG_Weapon( weapon )->price, qfalse ); + if( !g_freeStuff.integer ) + G_AddCreditToClient( ent->client, -(short)BG_Weapon( weapon )->price, qfalse ); } else if( upgrade != UP_NONE ) { @@ -2255,7 +2258,8 @@ void Cmd_Buy_f( gentity_t *ent ) } //can afford this? - if( BG_Upgrade( upgrade )->price > (short)ent->client->pers.credit ) + if( BG_Upgrade( upgrade )->price > (short)ent->client->pers.credit && + ( !g_freeStuff.integer || upgrade == UP_GRENADE ) ) { G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); return; @@ -2316,7 +2320,8 @@ void Cmd_Buy_f( gentity_t *ent ) G_GiveClientMaxAmmo( ent, qtrue ); //subtract from funds - G_AddCreditToClient( ent->client, -(short)BG_Upgrade( upgrade )->price, qfalse ); + if( !g_freeStuff.integer || upgrade == UP_GRENADE ) + G_AddCreditToClient( ent->client, -(short)BG_Upgrade( upgrade )->price, qfalse ); } else { @@ -2387,7 +2392,8 @@ void Cmd_Sell_f( gentity_t *ent ) ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; //add to funds - G_AddCreditToClient( ent->client, (short)BG_Weapon( weapon )->price, qfalse ); + if( !g_freeStuff.integer ) + G_AddCreditToClient( ent->client, (short)BG_Weapon( weapon )->price, qfalse ); } //if we have this weapon selected, force a new selection @@ -2428,7 +2434,8 @@ void Cmd_Sell_f( gentity_t *ent ) G_GiveClientMaxAmmo( ent, qtrue ); //add to funds - G_AddCreditToClient( ent->client, (short)BG_Upgrade( upgrade )->price, qfalse ); + if( !g_freeStuff.integer || upgrade == UP_GRENADE ) + G_AddCreditToClient( ent->client, (short)BG_Upgrade( upgrade )->price, qfalse ); } } else if( !Q_stricmp( s, "upgrades" ) ) @@ -2462,7 +2469,8 @@ void Cmd_Sell_f( gentity_t *ent ) G_GiveClientMaxAmmo( ent, qtrue ); //add to funds - G_AddCreditToClient( ent->client, (short)BG_Upgrade( i )->price, qfalse ); + if( !g_freeStuff.integer || i == UP_GRENADE ) + G_AddCreditToClient( ent->client, (short)BG_Upgrade( i )->price, qfalse ); } } } diff --git a/src/game/g_local.h b/src/game/g_local.h index b6d65c78..081de6cb 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1207,6 +1207,7 @@ extern vmCvar_t g_specChat; extern vmCvar_t g_publicAdminMessages; extern vmCvar_t g_allowTeamOverlay; +extern vmCvar_t g_freeStuff; extern vmCvar_t g_censorship; void trap_Print( const char *fmt ); diff --git a/src/game/g_main.c b/src/game/g_main.c index 72c144b9..4212d771 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -140,6 +140,7 @@ vmCvar_t g_specChat; vmCvar_t g_publicAdminMessages; vmCvar_t g_allowTeamOverlay; +vmCvar_t g_freeStuff; vmCvar_t g_censorship; vmCvar_t g_tag; @@ -281,6 +282,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_publicAdminMessages, "g_publicAdminMessages", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_allowTeamOverlay, "g_allowTeamOverlay", "1", CVAR_ARCHIVE, 0, qtrue }, + { &g_freeStuff, "g_freeStuff", "0", CVAR_ARCHIVE, 0, qtrue }, { &g_censorship, "g_censorship", "", CVAR_ARCHIVE, 0, qfalse }, { &g_tag, "g_tag", "gpp", CVAR_INIT, 0, qfalse } @@ -2342,6 +2344,25 @@ void G_RunFrame( int levelTime ) // now we are done spawning level.spawning = qfalse; + // give 9 evos to all aliens, to let clients evolve via the menu + if( g_freeStuff.integer ) + { + int i; + for( i = 0; i < g_maxclients.integer; ++i ) + { + gclient_t *cl = &g_clients[i]; + if( cl->pers.connected != CON_CONNECTED ) + continue; + + if( cl->pers.teamSelection == TEAM_ALIENS ) + { + cl->pers.credit = ALIEN_MAX_CREDITS; + if( cl->sess.spectatorState != SPECTATOR_FOLLOW ) + cl->ps.persistant[ PERS_CREDIT ] = cl->pers.credit; + } + } + } + // // go through all allocated objects // -- cgit