mirror of
https://github.com/UberGames/rpgxEF.git
synced 2024-11-10 07:11:34 +00:00
Implemented FS#24
This commit is contained in:
parent
a013c95957
commit
7bd0864a2d
4 changed files with 14 additions and 760 deletions
|
@ -24,7 +24,7 @@ UpdateTournamentInfo
|
|||
|
||||
void UpdateTournamentInfo( void ) {
|
||||
int i = 0, j = 0, k = 0;
|
||||
gentity_t *player = NULL, *ent = NULL;
|
||||
gentity_t *player = NULL;
|
||||
int playerClientNum;
|
||||
int n;
|
||||
char msg[AWARDS_MSG_LENGTH], msg2[AWARDS_MSG_LENGTH];
|
||||
|
@ -37,7 +37,7 @@ void UpdateTournamentInfo( void ) {
|
|||
gclient_t *cl = NULL;
|
||||
gclient_t *cl2= NULL;
|
||||
int secondPlaceTied=0;
|
||||
|
||||
|
||||
memset(msg, 0, AWARDS_MSG_LENGTH);
|
||||
memset(msg2, 0, AWARDS_MSG_LENGTH);
|
||||
|
||||
|
@ -48,26 +48,13 @@ void UpdateTournamentInfo( void ) {
|
|||
cl2= &level.clients[level.sortedClients[2]];
|
||||
if (cl->ps.persistant[PERS_SCORE] == cl2->ps.persistant[PERS_SCORE])
|
||||
secondPlaceTied=1;
|
||||
|
||||
|
||||
winningTeam = level.clients[0].ps.persistant[PERS_RANK]+1;
|
||||
if ( winningTeam != TEAM_BLUE && winningTeam != TEAM_RED )
|
||||
{//tie or not a team game
|
||||
winningTeam = 0;
|
||||
}
|
||||
|
||||
// In team game, we want to represent the highest scored client from the WINNING team.
|
||||
for (i = 0; i < level.maxclients; i++)
|
||||
{
|
||||
ent = &g_entities[i];
|
||||
if (ent && ent->client &&
|
||||
(ent->client->sess.sessionTeam != TEAM_SPECTATOR) &&
|
||||
CalculateTeamMVPByRank(ent))
|
||||
{
|
||||
// found the winning team's MVP
|
||||
mvpNum = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mvpNum < 0)
|
||||
{//ah, crap no MVP, pick the first player on the winning team
|
||||
for (i = 0; i < level.maxclients; i++ )
|
||||
|
@ -137,10 +124,6 @@ void UpdateTournamentInfo( void ) {
|
|||
strcpy(msg2, msg);
|
||||
Com_sprintf( msg, sizeof(msg), "%s 0", msg2);
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculateAwards(player, msg);
|
||||
}
|
||||
|
||||
// now supply...
|
||||
//
|
||||
|
@ -276,8 +259,8 @@ static void CelebrateStart( gentity_t *player )
|
|||
player->nextthink = level.time + TIMER_GESTURE;
|
||||
player->think = CelebrateStop;*/
|
||||
|
||||
// We don't want the taunt sound effect because it interfears with the computer voice giving awards
|
||||
// FIXME: just get timing right?
|
||||
// We don't want the taunt sound effect because it interfears with the computer voice giving awards
|
||||
// FIXME: just get timing right?
|
||||
//FIXME: why does this get lost now?
|
||||
BG_AddPredictableEventToPlayerstate( EV_TAUNT, 0, &player->client->ps );
|
||||
}
|
||||
|
@ -386,8 +369,6 @@ SpawnModelsOnVictoryPads
|
|||
void SpawnModelsOnVictoryPads( void ) {
|
||||
gentity_t *player;
|
||||
gentity_t *podium;
|
||||
int i = 0;
|
||||
gentity_t *ent = &g_entities[0];
|
||||
|
||||
podium1 = NULL;
|
||||
podium2 = NULL;
|
||||
|
@ -396,27 +377,9 @@ void SpawnModelsOnVictoryPads( void ) {
|
|||
podium = SpawnPodium();
|
||||
|
||||
|
||||
// SPAWN PLAYER ON TOP MOST PODIUM
|
||||
if (g_gametype.integer > GT_SINGLE_PLAYER)
|
||||
{
|
||||
// In team game, we want to represent the highest scored client from the WINNING team.
|
||||
for (i = 0; i < level.maxclients; i++)
|
||||
{
|
||||
ent = &g_entities[i];
|
||||
if (ent->client && CalculateTeamMVPByRank(ent))
|
||||
{
|
||||
// found the winning team's MVP
|
||||
break;
|
||||
}
|
||||
}
|
||||
player = SpawnModelOnVictoryPad( podium, offsetFirst, ent,
|
||||
level.clients[ level.sortedClients[0] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );
|
||||
}
|
||||
else
|
||||
{
|
||||
player = SpawnModelOnVictoryPad( podium, offsetFirst, &g_entities[level.sortedClients[0]],
|
||||
level.clients[ level.sortedClients[0] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );
|
||||
}
|
||||
player = SpawnModelOnVictoryPad( podium, offsetFirst, &g_entities[level.sortedClients[0]],
|
||||
level.clients[ level.sortedClients[0] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );
|
||||
|
||||
if ( player ) {
|
||||
player->nextthink = level.time + 2000;
|
||||
player->think = CelebrateStart;
|
||||
|
@ -429,7 +392,7 @@ void SpawnModelsOnVictoryPads( void ) {
|
|||
{
|
||||
if ( level.numNonSpectatorClients > 1 ) {
|
||||
player = SpawnModelOnVictoryPad( podium, offsetSecond, &g_entities[level.sortedClients[1]],
|
||||
level.clients[ level.sortedClients[1] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );
|
||||
level.clients[ level.sortedClients[1] ].ps.persistant[PERS_RANK] &~ RANK_TIED_FLAG );
|
||||
if ( player ) {
|
||||
podium2 = player;
|
||||
}
|
||||
|
|
|
@ -53,13 +53,14 @@ void DeathmatchScoreboardMessage( gentity_t *ent ) {
|
|||
} else {
|
||||
ping = cl->ps.ping < 999 ? cl->ps.ping : 999;
|
||||
}
|
||||
// TODO ajust me some things here might not be needed anymore
|
||||
Com_sprintf (entry, sizeof(entry),
|
||||
" %i %i %i %i %i %i %i %i %i %i %i", level.sortedClients[i],
|
||||
cl->ps.persistant[PERS_SCORE], ping, (level.time - cl->pers.enterTime)/60000,
|
||||
scoreFlags, g_entities[level.sortedClients[i]].s.powerups,
|
||||
GetWorstEnemyForClient(level.sortedClients[i]),
|
||||
GetMaxDeathsForClient(level.sortedClients[i]),
|
||||
GetFavoriteWeaponForClient(level.sortedClients[i]),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
cl->ps.persistant[PERS_KILLED],
|
||||
((g_entities[cl->ps.clientNum].r.svFlags&SVF_ELIMINATED)!=0) );
|
||||
j = strlen(entry);
|
||||
|
@ -721,7 +722,7 @@ qboolean SetTeam( gentity_t *ent, char *s ) {
|
|||
if ( !Q_stricmp( s, "spectator" ) || !Q_stricmp( s, "s" ) ) {
|
||||
team = TEAM_SPECTATOR;
|
||||
specState = SPECTATOR_FREE;
|
||||
client->noclip = 1;
|
||||
client->noclip = (qboolean)1;
|
||||
} else if ( g_gametype.integer >= GT_TEAM ) {
|
||||
// if running a team game, assign player to one of the teams
|
||||
specState = SPECTATOR_NOT;
|
||||
|
|
|
@ -1250,14 +1250,6 @@ void QDECL G_LogExit( const char *string );
|
|||
*/
|
||||
void QDECL G_ClearClientLog(int client);
|
||||
|
||||
void CalculateAwards(gentity_t *ent, char *msg);
|
||||
qboolean CalculateTeamMVPByRank(gentity_t *ent);
|
||||
int GetMaxDeathsForClient(int nClient);
|
||||
int GetMaxKillsForClient(int nClient);
|
||||
int GetFavoriteTargetForClient(int nClient);
|
||||
int GetWorstEnemyForClient(int nClient);
|
||||
int GetFavoriteWeaponForClient(int nClient);
|
||||
|
||||
/*----------------------------------------------------------------------------------------*/
|
||||
|
||||
//TiM - Delayed Transport Beam
|
||||
|
|
|
@ -912,708 +912,6 @@ void G_LogWeaponOutput(void)
|
|||
#endif //LOGGING_WEAPONS
|
||||
}
|
||||
|
||||
// did this player earn the sharpshooter award?
|
||||
qboolean CalculateSharpshooter(gentity_t *ent, int *frags)
|
||||
{
|
||||
#ifdef LOGGING_WEAPONS
|
||||
int i = 0, nBestPlayer = -1, nKills = 0, nMostKills = 0,
|
||||
playTime = (level.time - ent->client->pers.enterTime)/60000;
|
||||
gentity_t *player = NULL;
|
||||
|
||||
// if this guy didn't get one kill per minute, reject him right now
|
||||
if ( ((float)(G_WeaponLogKills[ent-g_entities][MOD_CRIFLE_ALT]))/((float)(playTime)) < 1.0 )
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nKills = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse)
|
||||
continue;
|
||||
nKills = G_WeaponLogKills[i][MOD_CRIFLE_ALT];
|
||||
if (nKills > nMostKills)
|
||||
{
|
||||
nMostKills = nKills;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
*frags = nMostKills;
|
||||
return qtrue;
|
||||
}
|
||||
#endif // LOGGING_WEAPONS
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
// did this player earn the untouchable award?
|
||||
qboolean CalculateUntouchable(gentity_t *ent)
|
||||
{
|
||||
#ifdef LOGGING_WEAPONS
|
||||
int playTime;
|
||||
playTime = (level.time - ent->client->pers.enterTime)/60000;
|
||||
|
||||
//------------------------------------------------------ MUST HAVE ACHIEVED 2 KILLS PER MINUTE
|
||||
if ( ((float)ent->client->pers.teamState.frags)/((float)(playTime)) < 2.0 || playTime==0)
|
||||
return qfalse;
|
||||
//------------------------------------------------------ MUST HAVE ACHIEVED 2 KILLS PER MINUTE
|
||||
|
||||
|
||||
// if this guy was never killed... Award Away!!!
|
||||
if (ent->client->ps.persistant[PERS_KILLED]==0)
|
||||
return qtrue;
|
||||
|
||||
#endif // LOGGING_WEAPONS
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
// did this player earn the logistics award?
|
||||
qboolean CalculateLogistics(gentity_t *ent, int *stuffUsed)
|
||||
{
|
||||
#ifdef LOGGING_WEAPONS
|
||||
int i = 0, j = 0, nBestPlayer = -1, nStuffUsed = 0, nMostStuffUsed = 0,
|
||||
nDifferent = 0, nMostDifferent = 0;
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nStuffUsed = 0;
|
||||
nDifferent = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse)
|
||||
continue;
|
||||
for (j = HI_NONE+1; j < HI_NUM_HOLDABLE; j++)
|
||||
{
|
||||
if (G_WeaponLogPowerups[i][j])
|
||||
{
|
||||
nDifferent++;
|
||||
}
|
||||
nStuffUsed += G_WeaponLogPowerups[i][j];
|
||||
}
|
||||
for (j = PW_NONE+1; j < PW_NUM_POWERUPS; j++)
|
||||
{
|
||||
if (G_WeaponLogItems[i][j])
|
||||
{
|
||||
nDifferent++;
|
||||
}
|
||||
nStuffUsed += G_WeaponLogItems[i][j];
|
||||
}
|
||||
if ( (nDifferent >= 4) && (nDifferent >= nMostDifferent) )
|
||||
{
|
||||
if (nStuffUsed > nMostStuffUsed)
|
||||
{
|
||||
nMostDifferent = nDifferent;
|
||||
nMostStuffUsed = nStuffUsed;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
*stuffUsed = nMostDifferent;
|
||||
return qtrue;
|
||||
}
|
||||
#endif // LOGGING_WEAPONS
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// did this player earn the tactician award?
|
||||
qboolean CalculateTactician(gentity_t *ent, int *kills)
|
||||
{
|
||||
#ifdef LOGGING_WEAPONS
|
||||
int i = 0, nBestPlayer = -1, nKills = 0, nMostKills = 0;
|
||||
int person = 0, weapon = 0;
|
||||
gentity_t *player = NULL;
|
||||
int wasPickedUpBySomeone[WP_NUM_WEAPONS];
|
||||
int killsWithWeapon[WP_NUM_WEAPONS];
|
||||
int playTime = (level.time - ent->client->pers.enterTime)/60000;
|
||||
|
||||
//------------------------------------------------------ MUST HAVE ACHIEVED 2 KILLS PER MINUTE
|
||||
if (playTime<0.3)
|
||||
return qfalse;
|
||||
|
||||
if ( ((float)ent->client->pers.teamState.frags)/((float)(playTime)) < 2.0 )
|
||||
return qfalse;
|
||||
//------------------------------------------------------ MUST HAVE ACHIEVED 2 KILLS PER MINUTE
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------ FOR EVERY WEAPON, ADD UP TOTAL PICKUPS
|
||||
for (weapon = 0; weapon<WP_NUM_WEAPONS; weapon++)
|
||||
wasPickedUpBySomeone[weapon] = 0; // CLEAR
|
||||
|
||||
for (person=0; person<g_maxclients.integer; person++)
|
||||
{
|
||||
for (weapon = 0; weapon<WP_NUM_WEAPONS; weapon++)
|
||||
{
|
||||
if (G_WeaponLogPickups[person][weapon]>0)
|
||||
wasPickedUpBySomeone[weapon]++;
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------ FOR EVERY WEAPON, ADD UP TOTAL PICKUPS
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------ FOR EVERY PERSON, CHECK FOR CANDIDATE
|
||||
for (person=0; person<g_maxclients.integer; person++)
|
||||
{
|
||||
player = g_entities + person;
|
||||
if (!player->inuse) continue;
|
||||
|
||||
nKills = 0; // This Persons's Kills
|
||||
for (weapon=0; weapon<WP_NUM_WEAPONS; weapon++)
|
||||
killsWithWeapon[weapon] = 0; // CLEAR
|
||||
|
||||
for (i=0; i<MOD_MAX; i++)
|
||||
{
|
||||
weapon = weaponFromMOD[i]; // Select Weapon
|
||||
killsWithWeapon[weapon] += G_WeaponLogKills[person][i]; // Store Num Kills With Weapon
|
||||
}
|
||||
|
||||
weapon=WP_5; // Start At Phaser
|
||||
// keep looking through weapons if weapon is not on map, or if it is and we used it
|
||||
while( weapon<WP_NUM_WEAPONS && (!wasPickedUpBySomeone[weapon] || killsWithWeapon[weapon]>0) )
|
||||
{
|
||||
weapon++;
|
||||
if(weapon>=WP_NUM_WEAPONS) {
|
||||
break;
|
||||
}
|
||||
nKills+=killsWithWeapon[weapon]; // Update the number of kills
|
||||
}
|
||||
//
|
||||
// At this point we have either successfully gone through every weapon on the map and saw it had
|
||||
// been used, or we found one that WAS on the map and was NOT used
|
||||
//
|
||||
// so we look to see if the weapon==Max (i.e. we used every one) and then we check to see
|
||||
// if we got the most kills out of anyone else who did this.
|
||||
//
|
||||
if (weapon>=WP_NUM_WEAPONS && nKills>nMostKills)
|
||||
{
|
||||
// WE ARE A TACTICION CANDIDATE
|
||||
nMostKills = nKills;
|
||||
nBestPlayer = person;
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------ FOR EVERY PERSON, CHECK FOR CANDIDATE
|
||||
|
||||
//Now, if we are the best player, return true and the number of kills we got
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
*kills = nMostKills;
|
||||
return qtrue;
|
||||
}
|
||||
#endif // LOGGING_WEAPONS
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// did this player earn the demolitionist award?
|
||||
qboolean CalculateDemolitionist(gentity_t *ent, int *kills)
|
||||
{
|
||||
#ifdef LOGGING_WEAPONS
|
||||
int i = 0, nBestPlayer = -1, nKills = 0, nMostKills = 0,
|
||||
playTime = (level.time - ent->client->pers.enterTime)/60000;
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nKills = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse)
|
||||
continue;
|
||||
|
||||
nKills = G_WeaponLogKills[i][MOD_GRENADE];
|
||||
nKills += G_WeaponLogKills[i][MOD_GRENADE_SPLASH];
|
||||
nKills += G_WeaponLogKills[i][MOD_GRENADE_ALT_SPLASH];
|
||||
nKills += G_WeaponLogKills[i][MOD_QUANTUM];
|
||||
nKills += G_WeaponLogKills[i][MOD_QUANTUM_SPLASH];
|
||||
nKills += G_WeaponLogKills[i][MOD_QUANTUM_ALT];
|
||||
nKills += G_WeaponLogKills[i][MOD_QUANTUM_ALT_SPLASH];
|
||||
nKills += G_WeaponLogKills[i][MOD_DETPACK];
|
||||
|
||||
// if this guy didn't get two explosive kills per minute, reject him right now
|
||||
if ( ((float)nKills)/((float)(playTime)) < 2.0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nKills > nMostKills)
|
||||
{
|
||||
nMostKills = nKills;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
*kills = nMostKills;
|
||||
return qtrue;
|
||||
}
|
||||
#endif // LOGGING_WEAPONS
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean CalculateTeamMVP(gentity_t *ent)
|
||||
{
|
||||
int i = 0, nBestPlayer = -1, nScore = 0, nHighestScore = 0,
|
||||
team = ent->client->ps.persistant[PERS_TEAM];
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nScore = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse || (player->client->ps.persistant[PERS_TEAM] != team))
|
||||
continue;
|
||||
nScore = player->client->ps.persistant[PERS_SCORE];
|
||||
if (nScore > nHighestScore)
|
||||
{
|
||||
nHighestScore = nScore;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean CalculateTeamMVPByRank(gentity_t *ent)
|
||||
{
|
||||
playerState_t *ps = &ent->client->ps;
|
||||
int i = 0, nBestPlayer = -1, nScore = 0, nHighestScore = 0,
|
||||
team = ps->persistant[PERS_RANK]+1;
|
||||
qboolean bTied = (qboolean)(team == 3);
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nScore = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse)
|
||||
continue;
|
||||
if (!bTied)
|
||||
{
|
||||
if (ps->persistant[PERS_TEAM] != team)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
nScore = ps->persistant[PERS_SCORE];
|
||||
if (nScore > nHighestScore)
|
||||
{
|
||||
nHighestScore = nScore;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean CalculateTeamDefender(gentity_t *ent)
|
||||
{
|
||||
int i = 0, nBestPlayer = -1, nScore = 0, nHighestScore = 0,
|
||||
team = ent->client->ps.persistant[PERS_TEAM];
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nScore = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse || (player->client->ps.persistant[PERS_TEAM] != team))
|
||||
continue;
|
||||
nScore = player->client->pers.teamState.basedefense;
|
||||
if (nScore > nHighestScore)
|
||||
{
|
||||
nHighestScore = nScore;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean CalculateTeamWarrior(gentity_t *ent)
|
||||
{
|
||||
int i = 0, nBestPlayer = -1, nScore = 0, nHighestScore = 0,
|
||||
team = ent->client->ps.persistant[PERS_TEAM];
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nScore = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse || (player->client->ps.persistant[PERS_TEAM] != team))
|
||||
continue;
|
||||
nScore = player->client->pers.teamState.frags;
|
||||
if (nScore > nHighestScore)
|
||||
{
|
||||
nHighestScore = nScore;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean CalculateTeamCarrier(gentity_t *ent)
|
||||
{
|
||||
int i = 0, nBestPlayer = -1, nScore = 0, nHighestScore = 0,
|
||||
team = ent->client->ps.persistant[PERS_TEAM];
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nScore = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse || (player->client->ps.persistant[PERS_TEAM] != team))
|
||||
continue;
|
||||
nScore = player->client->pers.teamState.captures;
|
||||
if (nScore > nHighestScore)
|
||||
{
|
||||
nHighestScore = nScore;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean CalculateTeamInterceptor(gentity_t *ent)
|
||||
{
|
||||
int i = 0, nBestPlayer = -1, nScore = 0, nHighestScore = 0,
|
||||
team = ent->client->ps.persistant[PERS_TEAM];
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nScore = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse || (player->client->ps.persistant[PERS_TEAM] != team))
|
||||
continue;
|
||||
nScore = player->client->pers.teamState.flagrecovery;
|
||||
nScore += player->client->pers.teamState.fragcarrier;
|
||||
if (nScore > nHighestScore)
|
||||
{
|
||||
nHighestScore = nScore;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean CalculateTeamRedShirt(gentity_t *ent)
|
||||
{
|
||||
int i = 0, nBestPlayer = -1, nScore = 0, nHighestScore = 0,
|
||||
team = ent->client->ps.persistant[PERS_TEAM];
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
nScore = 0;
|
||||
player = g_entities + i;
|
||||
if (!player->inuse || (player->client->ps.persistant[PERS_TEAM] != team))
|
||||
continue;
|
||||
nScore = player->client->ps.persistant[PERS_KILLED];
|
||||
nScore -= player->client->pers.teamState.suicides; // suicides don't count, you big cheater.
|
||||
if (nScore > nHighestScore)
|
||||
{
|
||||
nHighestScore = nScore;
|
||||
nBestPlayer = i;
|
||||
}
|
||||
}
|
||||
if (-1 == nBestPlayer)
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
if (nBestPlayer == ent->s.number)
|
||||
{
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
int CalculateTeamAward(gentity_t *ent)
|
||||
{
|
||||
int teamAwards = 0;
|
||||
|
||||
if (CalculateTeamMVP(ent))
|
||||
{
|
||||
teamAwards |= (1<<TEAM_MVP);
|
||||
}
|
||||
if (GT_CTF == g_gametype.integer)
|
||||
{
|
||||
if (CalculateTeamDefender(ent))
|
||||
{
|
||||
teamAwards |= (1<<TEAM_DEFENDER);
|
||||
}
|
||||
if (CalculateTeamWarrior(ent))
|
||||
{
|
||||
teamAwards |= (1<<TEAM_WARRIOR);
|
||||
}
|
||||
if (CalculateTeamCarrier(ent))
|
||||
{
|
||||
teamAwards |= (1<<TEAM_CARRIER);
|
||||
}
|
||||
if (CalculateTeamInterceptor(ent))
|
||||
{
|
||||
teamAwards |= (1<<TEAM_INTERCEPTOR);
|
||||
}
|
||||
}
|
||||
if ( !teamAwards && CalculateTeamRedShirt(ent) )
|
||||
{//if you got nothing else and died a lot, at least get bravery
|
||||
teamAwards |= (1<<TEAM_BRAVERY);
|
||||
}
|
||||
return teamAwards;
|
||||
}
|
||||
|
||||
qboolean CalculateSection31Award(gentity_t *ent)
|
||||
{
|
||||
int i = 0;
|
||||
gentity_t *player = NULL;
|
||||
|
||||
for (i = 0; i < g_maxclients.integer; i++)
|
||||
{
|
||||
player = g_entities + i;
|
||||
if (!player->inuse)
|
||||
continue;
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
void CalculateAwards(gentity_t *ent, char *msg)
|
||||
{
|
||||
#ifdef LOGGING_WEAPONS
|
||||
char buf1[AWARDS_MSG_LENGTH], buf2[AWARDS_MSG_LENGTH];
|
||||
int awardFlags = 0, stuffUsed = 0, kills = 0, streak = 0, teamAwards = 0;
|
||||
|
||||
memset(buf1, 0, AWARDS_MSG_LENGTH);
|
||||
memset(buf2, 0, AWARDS_MSG_LENGTH);
|
||||
if (CalculateSharpshooter(ent, &kills))
|
||||
{
|
||||
awardFlags |= (1<<AWARD_SHARPSHOOTER);
|
||||
strcpy(buf2, buf1);
|
||||
Com_sprintf(buf1, AWARDS_MSG_LENGTH, "%s %d", buf2, kills);
|
||||
}
|
||||
if (CalculateUntouchable(ent))
|
||||
{
|
||||
awardFlags |= (1<<AWARD_UNTOUCHABLE);
|
||||
strcpy(buf2, buf1);
|
||||
Com_sprintf(buf1, AWARDS_MSG_LENGTH, "%s %d", buf2, 0);
|
||||
}
|
||||
if (CalculateLogistics(ent, &stuffUsed))
|
||||
{
|
||||
awardFlags |= (1<<AWARD_LOGISTICS);
|
||||
strcpy(buf2, buf1);
|
||||
Com_sprintf(buf1, AWARDS_MSG_LENGTH, "%s %d", buf2, stuffUsed);
|
||||
}
|
||||
if (CalculateTactician(ent, &kills))
|
||||
{
|
||||
awardFlags |= (1<<AWARD_TACTICIAN);
|
||||
strcpy(buf2, buf1);
|
||||
Com_sprintf(buf1, AWARDS_MSG_LENGTH, "%s %d", buf2, kills);
|
||||
}
|
||||
if (CalculateDemolitionist(ent, &kills))
|
||||
{
|
||||
awardFlags |= (1<<AWARD_DEMOLITIONIST);
|
||||
strcpy(buf2, buf1);
|
||||
Com_sprintf(buf1, AWARDS_MSG_LENGTH, "%s %d", buf2, kills);
|
||||
}
|
||||
if (g_gametype.integer >= GT_TEAM)
|
||||
{
|
||||
teamAwards = CalculateTeamAward(ent);
|
||||
if (teamAwards)
|
||||
{
|
||||
awardFlags |= (1<<AWARD_TEAM);
|
||||
strcpy(buf2, buf1);
|
||||
Com_sprintf(buf1, AWARDS_MSG_LENGTH, "%s %d", buf2, teamAwards);
|
||||
}
|
||||
}
|
||||
if (CalculateSection31Award(ent))
|
||||
{
|
||||
awardFlags |= (1<<AWARD_SECTION31);
|
||||
strcpy(buf2, buf1);
|
||||
Com_sprintf(buf1, AWARDS_MSG_LENGTH, "%s %d", buf2, 0);
|
||||
}
|
||||
Q_strncpyz(buf2, msg, sizeof(buf2));
|
||||
Com_sprintf( msg, AWARDS_MSG_LENGTH, "%s %d%s", buf2, awardFlags, buf1);
|
||||
#endif // LOGGING_WEAPONS
|
||||
}
|
||||
|
||||
int GetMaxDeathsForClient(int nClient)
|
||||
{
|
||||
int i = 0, nMostDeaths = 0;
|
||||
|
||||
if ((nClient < 0) || (nClient >= MAX_CLIENTS))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if (G_WeaponLogFrags[i][nClient] > nMostDeaths)
|
||||
{
|
||||
nMostDeaths = G_WeaponLogFrags[i][nClient];
|
||||
}
|
||||
}
|
||||
return nMostDeaths;
|
||||
}
|
||||
|
||||
int GetMaxKillsForClient(int nClient)
|
||||
{
|
||||
int i = 0, nMostKills = 0;
|
||||
|
||||
if ((nClient < 0) || (nClient >= MAX_CLIENTS))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if (G_WeaponLogFrags[nClient][i] > nMostKills)
|
||||
{
|
||||
nMostKills = G_WeaponLogFrags[nClient][i];
|
||||
}
|
||||
}
|
||||
return nMostKills;
|
||||
}
|
||||
|
||||
int GetFavoriteTargetForClient(int nClient)
|
||||
{
|
||||
int i = 0, nMostKills = 0, nFavoriteTarget = -1;
|
||||
|
||||
if ((nClient < 0) || (nClient >= MAX_CLIENTS))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if (G_WeaponLogFrags[nClient][i] > nMostKills)
|
||||
{
|
||||
nMostKills = G_WeaponLogFrags[nClient][i];
|
||||
nFavoriteTarget = i;
|
||||
}
|
||||
}
|
||||
return nFavoriteTarget;
|
||||
}
|
||||
|
||||
int GetWorstEnemyForClient(int nClient)
|
||||
{
|
||||
int i = 0, nMostDeaths = 0, nWorstEnemy = -1;
|
||||
|
||||
if ((nClient < 0) || (nClient >= MAX_CLIENTS))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
// If there is a tie for most deaths, we want to choose anybody else
|
||||
// over the client... I.E. Most deaths should not tie with yourself and
|
||||
// have yourself show up...
|
||||
|
||||
if ( G_WeaponLogFrags[i][nClient] > nMostDeaths ||
|
||||
(G_WeaponLogFrags[i][nClient]== nMostDeaths && i!=nClient && nMostDeaths!=0) )
|
||||
{
|
||||
nMostDeaths = G_WeaponLogFrags[i][nClient];
|
||||
nWorstEnemy = i;
|
||||
}
|
||||
}
|
||||
return nWorstEnemy;
|
||||
}
|
||||
|
||||
int GetFavoriteWeaponForClient(int nClient)
|
||||
{
|
||||
int i = 0, nMostKills = 0, fav=0, weapon=WP_5;
|
||||
int killsWithWeapon[WP_NUM_WEAPONS];
|
||||
|
||||
|
||||
// First thing we need to do is cycle through all the MOD types and convert
|
||||
// number of kills to a single weapon.
|
||||
//----------------------------------------------------------------
|
||||
for (weapon=0; weapon<WP_NUM_WEAPONS; weapon++)
|
||||
killsWithWeapon[weapon] = 0; // CLEAR
|
||||
|
||||
for (i=MOD_PHASER; i<=MOD_BORG_ALT; i++)
|
||||
{
|
||||
weapon = weaponFromMOD[i]; // Select Weapon
|
||||
killsWithWeapon[weapon] += G_WeaponLogKills[nClient][i]; // Store Num Kills With Weapon
|
||||
}
|
||||
|
||||
// now look through our list of kills per weapon and pick the biggest
|
||||
//----------------------------------------------------------------
|
||||
nMostKills=0;
|
||||
for (weapon=WP_5; weapon<WP_NUM_WEAPONS; weapon++)
|
||||
{
|
||||
if (killsWithWeapon[weapon]>nMostKills)
|
||||
{
|
||||
nMostKills = killsWithWeapon[weapon];
|
||||
fav = weapon;
|
||||
}
|
||||
}
|
||||
return fav;
|
||||
}
|
||||
|
||||
// kef -- if a client leaves the game, clear out all counters he may have set
|
||||
void QDECL G_ClearClientLog(int client)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue