Exemple #1
0
/**
 * @brief Local func to actual do skill upgrade, used by both MP skill system, and SP scripted skill system
 * @param[in,out] ent
 * @param[in] skill
 */
void G_UpgradeSkill(gentity_t *ent, skillType_t skill)
{
	int i;

#ifdef FEATURE_LUA
	// *LUA* API callbacks
	if (G_LuaHook_UpgradeSkill(g_entities - ent, skill))
	{
		return;
	}
#endif

	// See if this is the first time we've reached this skill level
	for (i = 0; i < SK_NUM_SKILLS; i++)
	{
		if (i == skill)
		{
			continue;
		}

		if (ent->client->sess.skill[skill] <= ent->client->sess.skill[i])
		{
			break;
		}
	}

	G_DebugAddSkillLevel(ent, skill);

#ifdef FEATURE_RATING
	if (g_skillRating.integer)
	{
		ent->client->sess.rank = (int)(MAX(ent->client->sess.mu - 3 * ent->client->sess.sigma, 0.f) / (2 * MU) * NUM_EXPERIENCE_LEVELS);

		if (ent->client->sess.rank > 10)
		{
			ent->client->sess.rank = 10;
		}
	}
	else
	{
#endif
	if (i == SK_NUM_SKILLS)
	{
		// increase rank
		ent->client->sess.rank++;
	}

	if (ent->client->sess.rank >= 4)
	{
		int cnt = 0;

		// count the number of maxed out skills
		for (i = 0; i < SK_NUM_SKILLS; i++)
		{
			if (ent->client->sess.skill[i] >= 4)
			{
				cnt++;
			}
		}

		ent->client->sess.rank = cnt + 3;
		if (ent->client->sess.rank > 10)
		{
			ent->client->sess.rank = 10;
		}
	}
#ifdef FEATURE_RATING
}
#endif

	ClientUserinfoChanged(ent - g_entities);

	// Give em rightaway
	if (skill == SK_BATTLE_SENSE && ent->client->sess.skill[skill] == 1)
	{
		AddWeaponToPlayer(ent->client, WP_BINOCULARS, 1, 0, qfalse);
		ent->client->ps.stats[STAT_KEYS] |= (1 << INV_BINOCS);
	}
	else if (skill == SK_FIRST_AID && ent->client->sess.playerType == PC_MEDIC && ent->client->sess.skill[skill] == 4)
	{
		AddWeaponToPlayer(ent->client, WP_MEDIC_ADRENALINE, ent->client->ps.ammo[GetWeaponTableData(WP_MEDIC_ADRENALINE)->ammoIndex], ent->client->ps.ammoclip[GetWeaponTableData(WP_MEDIC_ADRENALINE)->clipIndex], qfalse);
	}
}
Exemple #2
0
// TAT 11/6/2002
//      Local func to actual do skill upgrade, used by both MP skill system, and SP scripted skill system
static void G_UpgradeSkill( gentity_t *ent, skillType_t skill )
{
	int i, cnt = 0;

	// See if this is the first time we've reached this skill level
	for ( i = 0; i < SK_NUM_SKILLS; i++ )
	{
		if ( i == skill )
		{
			continue;
		}

		if ( ent->client->sess.skill[ skill ] <= ent->client->sess.skill[ i ] )
		{
			break;
		}
	}

#ifdef LUA_SUPPORT

	// Lua API callbacks
	if ( G_LuaHook_UpgradeSkill( g_entities - ent, skill ) )
	{
		return;
	}

#endif // LUA_SUPPORT

	G_DebugAddSkillLevel( ent, skill );

	if ( i == SK_NUM_SKILLS )
	{
		// increase rank
		ent->client->sess.rank++;
	}

	if ( ent->client->sess.rank >= 4 )
	{
		// Gordon: count the number of maxed out skills
		for ( i = 0; i < SK_NUM_SKILLS; i++ )
		{
			if ( ent->client->sess.skill[ i ] >= 4 )
			{
				cnt++;
			}
		}

		ent->client->sess.rank = cnt + 3;

		if ( ent->client->sess.rank > 10 )
		{
			ent->client->sess.rank = 10;
		}
	}

	ClientUserinfoChanged( ent - g_entities );

	// Give em rightaway
	if ( skill == SK_BATTLE_SENSE && ent->client->sess.skill[ skill ] == 1 )
	{
		if ( AddWeaponToPlayer( ent->client, WP_BINOCULARS, 1, 0, qfalse ) )
		{
			ent->client->ps.stats[ STAT_KEYS ] |= ( 1 << INV_BINOCS );
		}
	}
	else if ( skill == SK_FIRST_AID && ent->client->sess.playerType == PC_MEDIC && ent->client->sess.skill[ skill ] == 4 )
	{
		AddWeaponToPlayer( ent->client, WP_MEDIC_ADRENALINE, ent->client->ps.ammo[ BG_FindAmmoForWeapon( WP_MEDIC_ADRENALINE ) ],
		                   ent->client->ps.ammoclip[ BG_FindClipForWeapon( WP_MEDIC_ADRENALINE ) ], qfalse );
	}
}