Ejemplo n.º 1
0
// Shows best/worst accuracy for all weapons, or sorted
// accuracies for a single weapon.
void G_weaponRankings_cmd( gentity_t *ent, unsigned int dwCommand, qboolean state ) {
	gclient_t *cl;
	int c = 0, i, shots, wBestAcc;
	char z[MAX_STRING_CHARS];

	if ( trap_Argc() < 2 ) {
		G_weaponStatsLeaders_cmd( ent, state, qfalse );
		return;
	}

	wBestAcc = ( state ) ? 0 : 99999;

	// Find the weapon
	trap_Argv( 1, z, sizeof( z ) );
	if ( ( iWeap = atoi( z ) ) == 0 || iWeap < WS_KNIFE || iWeap >= WS_MAX ) {
		for ( iWeap = WS_SYRINGE; iWeap >= WS_KNIFE; iWeap-- ) {
			if ( !Q_stricmp( z, aWeaponInfo[iWeap].pszCode ) ) {
				break;
			}
		}
	}

	if ( iWeap < WS_KNIFE ) {
		G_commandHelp( ent, ( state ) ? "topshots" : "bottomshots", dwCommand );

		Q_strncpyz( z, "^3Available weapon codes:^7\n", sizeof( z ) );
		for ( i = WS_KNIFE; i < WS_MAX; i++ ) {
			Q_strcat( z, sizeof( z ), va( "  %s - %s\n", aWeaponInfo[i].pszCode, aWeaponInfo[i].pszName ) );
		}
		CP( va( "print \"%s\"", z ) );
		return;
	}

	memcpy( &level.sortedStats, &level.sortedClients, sizeof( level.sortedStats ) );
	qsort( level.sortedStats, level.numConnectedClients, sizeof( level.sortedStats[0] ), SortStats );

	z[0] = 0;
	for ( i = 0; i < level.numConnectedClients; i++ ) {
		cl = &level.clients[level.sortedStats[i]];

		if ( cl->sess.sessionTeam == TEAM_SPECTATOR ) {
			continue;
		}

		shots = cl->sess.aWeaponStats[iWeap].atts;
		if ( shots >= cQualifyingShots[iWeap] ) {
			float acc = (float)( cl->sess.aWeaponStats[iWeap].hits * 100.0 ) / (float)shots;

			c++;
			wBestAcc = ( ( ( state ) ? acc : wBestAcc ) > ( ( state ) ? wBestAcc : acc ) ) ? (int)acc : wBestAcc;
			Q_strcat( z, sizeof( z ), va( " %d %d %d %d %d", level.sortedStats[i],
										  cl->sess.aWeaponStats[iWeap].hits,
										  shots,
										  cl->sess.aWeaponStats[iWeap].kills,
										  cl->sess.aWeaponStats[iWeap].deaths ) );
		}
	}

	CP( va( "astats%s %d %d %d%s", ( ( state ) ? "" : "b" ), c, iWeap, wBestAcc, z ) );
}
Ejemplo n.º 2
0
// OSP-specific Commands 
qboolean G_commandCheck(gentity_t *ent, char *cmd, qboolean fDoAnytime)
{
	unsigned int i, cCommands = sizeof(aCommandInfo)/sizeof(aCommandInfo[0]);
	const cmd_reference_t *pCR;

	for(i=0; i<cCommands; i++) {
		pCR = &aCommandInfo[i];
		if(NULL != pCR->pCommand && pCR->fAnytime == fDoAnytime && 0 == Q_stricmp(cmd, pCR->pszCommandName)) {
			if(!G_commandHelp(ent, cmd, i)) pCR->pCommand(ent, i, pCR->fValue);
			return(qtrue);
		}
	}

	return(G_smvCommands(ent, cmd));
}