Пример #1
0
void rvStatManager::GetAccuracyLeaders( int accuracyLeaders[ MAX_WEAPONS ] ) {
	memset( accuracyLeaders, -1, sizeof( int ) * MAX_WEAPONS );

	for( int i = 0; i < MAX_CLIENTS; i++ ) {
		if( gameLocal.entities[ i ] == NULL ) {
			continue;
		}

		rvPlayerStat* playerStats = GetPlayerStat( i );

		for( int j = 0; j < MAX_WEAPONS; j++ ) {
			if( playerStats->weaponShots[ j ] == 0 ) {
				continue;
			}

			float playerAccuracy = (float)playerStats->weaponHits[ j ] / (float)playerStats->weaponShots[ j ];
			float leaderAccuracy = -1.0f;
			if( accuracyLeaders[ j ] != -1 ) {
				rvPlayerStat* leaderStats = GetPlayerStat( accuracyLeaders[ j ] );
				if( leaderStats->weaponShots[ j ] != 0 ) {
					leaderAccuracy = (float)leaderStats->weaponHits[ j ] / (float)leaderStats->weaponShots[ j ];
				}
			}
			if( playerAccuracy > leaderAccuracy ) {
				accuracyLeaders[ j ] = i;
			}
		}
	}
}
Пример #2
0
// Calculate weapon range using efficient stuffs
float CPlayer::GetWeaponRangeFromSlot( uint uiSlot )
{
    eWeaponType eWeapon = static_cast < eWeaponType > ( GetWeaponType ( uiSlot ) );
    float fSkill = GetPlayerStat ( CWeaponStatManager::GetSkillStatIndex ( eWeapon ) );

    if ( fSkill != m_fWeaponRangeLastSkill || eWeapon != m_eWeaponRangeLastWeapon || CWeaponStat::GetAllWeaponStatsRevision() != m_uiWeaponRangeLastStatsRevision )
    {
        m_fWeaponRangeLastSkill = fSkill;
        m_eWeaponRangeLastWeapon = eWeapon;
        m_uiWeaponRangeLastStatsRevision = CWeaponStat::GetAllWeaponStatsRevision();
        m_fWeaponRangeLast = g_pGame->GetWeaponStatManager ( )->GetWeaponRangeFromSkillLevel ( eWeapon, fSkill );       
    }
    return m_fWeaponRangeLast;
}
Пример #3
0
float CPed::GetMaxHealth ( void )
{
    // TODO: Verify this formula

    // Grab his player health stat
    float fStat = GetPlayerStat ( 24 /*MAX_HEALTH*/ );

    // Do a linear interpolation to get how much health this would allow
    // Assumes: 100 health = 569 stat, 200 health = 1000 stat.
    float fMaxHealth = 100.0f + ( 100.0f / 431.0f * ( fStat - 569.0f ) );

    // Return the max health. Make sure it can't be below 1
    if ( fMaxHealth < 1.0f ) fMaxHealth = 1.0f;
    return fMaxHealth;
}