From 2ee76d11bb34641e021f69b3509da5c62e7afdb0 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Thu, 27 May 2004 21:43:24 +0000 Subject: * Added code to calculate the average number of players that are playing * Added stats on game end to aid balancing * "itemact " now selects a weapon as well as activating an upgrade * Disabled chat balloon entirely --- src/cgame/cg_players.c | 5 +++-- src/game/g_cmds.c | 11 +++++++++-- src/game/g_local.h | 5 +++++ src/game/g_main.c | 24 +++++++++++++++++++++++- 4 files changed, 40 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index 1ea8d30d..9aba27a4 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -1697,8 +1697,9 @@ static void CG_PlayerSprites( centity_t *cent ) if( cent->currentState.eFlags & EF_TALK ) { - CG_PlayerFloatSprite( cent, cgs.media.balloonShader ); - return; + //TA: the masses have decreed this to be wrong +/* CG_PlayerFloatSprite( cent, cgs.media.balloonShader ); + return;*/ } } diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 1a631389..b382c28a 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1313,16 +1313,23 @@ Activate an item void Cmd_ActivateItem_f( gentity_t *ent ) { char s[ MAX_TOKEN_CHARS ]; - int upgrade; + int upgrade, weapon; trap_Argv( 1, s, sizeof( s ) ); upgrade = BG_FindUpgradeNumForName( s ); + weapon = BG_FindWeaponNumForName( s ); if( ent->client->pers.teamSelection != PTE_HUMANS ) return; - if( BG_gotItem( upgrade, ent->client->ps.stats ) ) + if( upgrade != UP_NONE && BG_gotItem( upgrade, ent->client->ps.stats ) ) BG_activateItem( upgrade, ent->client->ps.stats ); + else if( weapon != WP_NONE ) + { + //force a weapon change + ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH; + trap_SendServerCommand( ent-g_entities, va( "weaponswitch %d", weapon ) ); + } else trap_SendServerCommand( ent-g_entities, va( "print \"You don't have the %s\n\"", s ) ); } diff --git a/src/game/g_local.h b/src/game/g_local.h index 8d891279..82681dc5 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -531,6 +531,11 @@ typedef struct int numAlienClients; int numHumanClients; + float averageNumAlienClients; + int numAlienSamples; + float averageNumHumanClients; + int numHumanSamples; + int numLiveAlienClients; int numLiveHumanClients; diff --git a/src/game/g_main.c b/src/game/g_main.c index 0fd433b7..5283ff35 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1129,6 +1129,17 @@ void CalculateRanks( void ) } } + //calculate average number of clients for stats + level.averageNumAlienClients = + ( ( level.averageNumAlienClients * level.numAlienSamples ) + + level.numAlienClients ) / + (float)( ++level.numAlienSamples ); + + level.averageNumHumanClients = + ( ( level.averageNumHumanClients * level.numHumanSamples ) + + level.numHumanClients ) / + (float)( ++level.numHumanSamples ); + qsort( level.sortedClients, level.numConnectedClients, sizeof( level.sortedClients[ 0 ] ), SortRanks ); @@ -1549,8 +1560,11 @@ can see the last frag. */ void CheckExitRules( void ) { - int i; + int i; gclient_t *cl; + char s[ MAX_STRING_CHARS ]; + + trap_Cvar_VariableStringBuffer( "mapname", s, sizeof( s ) ); // if at the intermission, wait for all non-bots to // signal ready, then go to next level @@ -1589,6 +1603,10 @@ void CheckExitRules( void ) //humans win level.lastWin = PTE_HUMANS; trap_SendServerCommand( -1, "print \"Humans win.\n\""); + G_LogPrintf( "STATS T:H A:%f H:%f M:%s D:%d\n", level.averageNumAlienClients, + level.averageNumHumanClients, + s, level.time - level.startTime ); + LogExit( "Humans win." ); return; } @@ -1599,6 +1617,10 @@ void CheckExitRules( void ) //aliens win level.lastWin = PTE_ALIENS; trap_SendServerCommand( -1, "print \"Aliens win.\n\""); + G_LogPrintf( "STATS T:A A:%f H:%f M:%s D:%d\n", level.averageNumAlienClients, + level.averageNumHumanClients, + s, level.time - level.startTime ); + LogExit( "Aliens win." ); return; } -- cgit