Exemple #1
0
static void CG_ChooseCgradingEffectAndFade( const playerState_t* ps, qhandle_t* effect, float* fade )
{
	int health = ps->stats[ STAT_HEALTH ];
	int team = ps->stats[ STAT_TEAM ];
	int class = ps->stats[ STAT_CLASS ];
	qboolean playing = team == TEAM_HUMANS || team == TEAM_ALIENS;
	float chargeProgress = CG_ChargeProgress();

	//the player has spawned once and is dead or in the intermission
	if ( health <= 0 || (playing && cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT) )
	{
		*effect = cgs.media.desaturatedCgrade;
		*fade = 1.0;
	}
	//not actually playing
	else if (cg.renderingThirdPerson || ! playing )
	{
		*fade = 0.0;
	}
	else if(ps->weapon == WP_ALEVEL4 && chargeProgress > 0.05)
	{
	    *effect = cgs.media.redCgrade;
	    *fade = chargeProgress * 0.5f;
	}
	else
	{
		//health effect
		float ratio = 0.0f;
		float maxHealth = BG_Class( class )->health;
		if ( team == TEAM_HUMANS )
		{
			*effect = cgs.media.redCgrade;
			ratio = 0.5f;
		}
		else if( team == TEAM_ALIENS )
		{
			*effect = cgs.media.desaturatedCgrade;
			ratio = 0.7f;
		}
		//Linear blend if the effect as a function of the health ratio
		//Find out if a quadratic effect would look better
		*fade = (1.0f - health / maxHealth) * ratio;
	}
}
Exemple #2
0
static void CG_ChooseCgradingEffectAndFade( const playerState_t* ps, qhandle_t* effect, float* fade, float* fadeRate )
{
	int health = ps->stats[ STAT_HEALTH ];
	int team = ps->persistant[ PERS_TEAM ];
	int class_ = ps->stats[ STAT_CLASS ];
	qboolean playing = team == TEAM_HUMANS || team == TEAM_ALIENS;
	float chargeProgress = CG_ChargeProgress();

	//the player has spawned once and is dead or in the intermission
	if ( health <= 0 || (playing && cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT) )
	{
		*effect = cgs.media.desaturatedCgrade;
		*fade = 1.0;
        *fadeRate = 0.004;
	}
	//no other effects for now
	else
	{
		*fade = 0.0;
	}
}