UTIL_ImpactTrace

From Valve Developer Community
Jump to: navigation, search

UTIL_ImpactTrace is a UTIL provided in the Source code for doing decals and impact effects (such as flecks) at the end of a UTIL TraceLine trace.

Blank image.pngTodo: Find a list of CustomImpactNames, and how/where they are defined!

Usage

//------------------------------------------------------------------------------
// Purpose : Creates both an decal and any associated impact effects (such
//			 as flecks) for the given iDamageType and the trace's end position
// Input   :
// Output  :
//------------------------------------------------------------------------------
void UTIL_ImpactTrace( trace_t *pTrace, int iDamageType, char *pCustomImpactName )
{
	CBaseEntity *pEntity = pTrace->m_pEnt;

	// Is the entity valid, is the surface sky?
	if ( !pEntity || !UTIL_IsValidEntity( pEntity ) || (pTrace->surface.flags & SURF_SKY) )
		return;

	if ( pTrace->fraction == 1.0 )
		return;

	pEntity->ImpactTrace( pTrace, iDamageType, pCustomImpactName );
}

Examples

//In this example, the Custom impact type is left off.
UTIL_ImpactTrace( &tr, DMG_BULLET );
UTIL_ImpactTrace( &tr, nDamageType, "AirboatGunImpact" );
UTIL_ImpactTrace( &tr, nDamageType, "HelicopterImpact" );
if ( pEntity->GetTeamNumber() == GetTeamNumber() )
{
	if ( !friendlyfire.GetBool() )
		UTIL_ImpactTrace( &tr, iDamageType );
}