UTIL_ShouldShowBlood
UTIL_ShouldShowBlood is a UTIL provided in the Source code that returns if blood should be shown, depending on the game's violence setting.
Usage
//-----------------------------------------------------------------------------
// Purpose:
//
// Input : int - color | The color of the blood to check against.
// Output :
//-----------------------------------------------------------------------------
bool UTIL_ShouldShowBlood( int color )
{
if ( color != DONT_BLEED )
{
if ( color == BLOOD_COLOR_RED )
{
return violence_hblood.GetBool();
}
else
{
return violence_ablood.GetBool();
}
}
return false;
}
static ConVar violence_hblood( "violence_hblood","1", 0, "Draw human blood" );
static ConVar violence_ablood( "violence_ablood","1", 0, "Draw alien blood" );
Examples
//This simply checks the blood color of pHurt
//If their blood is set as DONT_BLEED, it returns false, and skips
//this function. Otherwise it will check the violence convars
//And decide if it should make the blood or not.
if ( UTIL_ShouldShowBlood(pHurt->BloodColor()) )
{
// Hit an NPC. Bleed them!
Vector vecBloodPos;
switch ( BloodOrigin )
{
case HUNTER_BLOOD_LEFT_FOOT:
{
if ( GetAttachment( "blood_left", vecBloodPos ) )
{
SpawnBlood( vecBloodPos, g_vecAttackDir, pHurt->BloodColor(), min( iDamage, 30 ) );
}
break;
}
}
}
//This example just checks the violence convar for BLOOD_COLOR_YELLOW
//which is violence_ablood.
if ( UTIL_ShouldShowBlood( BLOOD_COLOR_YELLOW ) )