Example #1
0
char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd)
{
	char chTextureType;
	float rgfl1[3], rgfl2[3];
	const char *pTextureName;
	char szbuffer[64];
	CBaseEntity *pEntity;

	if( ptr->pHit == NULL )
		return CHAR_TEX_FLESH;

	pEntity = CBaseEntity::Instance(ptr->pHit);

	if (pEntity && pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)
		return CHAR_TEX_FLESH;

	vecSrc.CopyToArray(rgfl1);
	vecEnd.CopyToArray(rgfl2);

	if (pEntity)
		pTextureName = TRACE_TEXTURE(ENT(pEntity->pev), rgfl1, rgfl2);
	else
		pTextureName = TRACE_TEXTURE(ENT(0), rgfl1, rgfl2);

	if (pTextureName)
	{
		if (*pTextureName == '-' || *pTextureName == '+')
			pTextureName += 2;

		if (*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ')
			pTextureName++;

		strncpy(szbuffer, pTextureName, sizeof(szbuffer));
		szbuffer[CBTEXTURENAMEMAX - 1] = 0;
		chTextureType = PM_FindTextureType(szbuffer);
	}
	else
		chTextureType = 0;

	return chTextureType;
}
Example #2
0
void CEnvironment::UpdateGrass()
{
	if( m_flGrassTime > gEngfuncs.GetClientTime() )
	{
		return;
	}

	Vector vecDist = m_vecWeatherOrigin - m_vecGrassOrigin;

	const float flDist = vecDist.Length();

	if( flDist < 100.0 )
	{
		return;
	}

	m_vecGrassOrigin = m_vecWeatherOrigin;
	m_flGrassTime = gEngfuncs.GetClientTime() + 0.3;

	Vector vecOrigin;
	Vector vecEndPos;

	Vector vecWindOrigin;

	pmtrace_t trace;

	for( size_t uiIndex = 0; static_cast<float>( uiIndex ) < 35.0 * m_flWeatherValue; ++uiIndex )
	{
		vecOrigin = m_vecGrassOrigin;

		const float flXOffset = UTIL_RandomFloat( -800.0f, 850.0f );

		vecOrigin.x += ( UTIL_RandomLong( 0, 5 ) > 2 ) ? flXOffset : -flXOffset;
		vecOrigin.y += UTIL_RandomFloat( -800.0f, 800.0f );
		vecOrigin.z += 36.0f;

		vecEndPos.x = vecOrigin.x;
		vecEndPos.y = vecOrigin.y;
		vecEndPos.z = -8000.0f;

		gEngfuncs.pEventAPI->EV_SetTraceHull( Hull::LARGE );
		gEngfuncs.pEventAPI->EV_PlayerTrace( vecOrigin, vecEndPos, PM_WORLD_ONLY, -1, &trace );
		const char* pszTexture = gEngfuncs.pEventAPI->EV_TraceTexture( trace.ent, trace.endpos, vecEndPos );

		if( pszTexture )
		{
			//Skip the +/- and number.
			if( pszTexture[ 0 ] == '+' || 
				pszTexture[ 0 ] == '-' )
				pszTexture += 2;

			if( pszTexture[ 0 ] == '!' || 
				pszTexture[ 0 ] == '{' || 
				pszTexture[ 0 ] == '~' || 
				pszTexture[ 0 ] == ' ' )
				++pszTexture;

			if( PM_FindTextureType( pszTexture ) == CHAR_TEX_GRASS )
			{
				CreateGrassPiece( trace.endpos, Vector( 0, UTIL_RandomFloat( 0, 359.0 ), 0 ) );
			}
		}
	}
}
Example #3
0
char DLLEXPORT HUD_PlayerMoveTexture( char *name )
{
	return PM_FindTextureType( name );
}
Example #4
0
char CL_DLLEXPORT HUD_PlayerMoveTexture( char *name )
{
//	RecClClientTextureType(name);

	return PM_FindTextureType( name );
}