Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern int gmsgCustomDecal;
- void UTIL_CustomDecal( TraceResult *pTrace, const char *name, int persistent /* =0 */ )
- {
- if (pTrace->flFraction == 1.0)
- return;
- if ( pTrace->pHit )
- {
- int idx = ENTINDEX( pTrace->pHit );
- // ALERT(at_console, "%d\n", idx);
- if (idx)
- return;
- }
- // ALERT(at_console, "sent\n");
- MESSAGE_BEGIN( MSG_BROADCAST, gmsgCustomDecal );
- WRITE_COORD( pTrace->vecEndPos.x );
- WRITE_COORD( pTrace->vecEndPos.y );
- WRITE_COORD( pTrace->vecEndPos.z );
- WRITE_COORD( pTrace->vecPlaneNormal.x );
- WRITE_COORD( pTrace->vecPlaneNormal.y );
- WRITE_COORD( pTrace->vecPlaneNormal.z );
- WRITE_BYTE( persistent );
- WRITE_STRING( name );
- MESSAGE_END();
- }
- void UTIL_BloodDecalTrace( TraceResult *pTrace, int bloodColor )
- {
- if ( UTIL_ShouldShowBlood( bloodColor ) )
- {
- if ( bloodColor == BLOOD_COLOR_RED )
- {
- UTIL_DecalTrace( pTrace, DECAL_BLOOD1 + RANDOM_LONG(0,5) );
- UTIL_CustomDecal( pTrace, "redblood" );
- }
- else
- {
- UTIL_DecalTrace( pTrace, DECAL_YBLOOD1 + RANDOM_LONG(0,5) );
- UTIL_CustomDecal( pTrace, "yellowblood" );
- }
- }
- }
- void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber )
- {
- short entityIndex;
- int index;
- int message;
- if ( decalNumber < 0 )
- return;
- index = gDecals[ decalNumber ].index;
- if ( index < 0 )
- return;
- if (pTrace->flFraction == 1.0)
- return;
- // buz: also paint custom decal
- if (decalNumber == DECAL_SCORCH1 || decalNumber == DECAL_SCORCH2)
- {
- UTIL_CustomDecal( pTrace, "scorch" );
- }
- // Only decal BSP models
- if ( pTrace->pHit )
- {
- CBaseEntity *pEntity = CBaseEntity::Instance( pTrace->pHit );
- if ( pEntity && !pEntity->IsBSPModel() )
- return;
- entityIndex = ENTINDEX( pTrace->pHit );
- }
- else
- entityIndex = 0;
- message = TE_DECAL;
- if ( entityIndex != 0 )
- {
- if ( index > 255 )
- {
- message = TE_DECALHIGH;
- index -= 256;
- }
- }
- else
- {
- message = TE_WORLDDECAL;
- if ( index > 255 )
- {
- message = TE_WORLDDECALHIGH;
- index -= 256;
- }
- }
- MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
- WRITE_BYTE( message );
- WRITE_COORD( pTrace->vecEndPos.x );
- WRITE_COORD( pTrace->vecEndPos.y );
- WRITE_COORD( pTrace->vecEndPos.z );
- WRITE_BYTE( index );
- if ( entityIndex )
- WRITE_SHORT( entityIndex );
- MESSAGE_END();
- }
- /*
- ==============
- UTIL_PlayerDecalTrace
- A player is trying to apply his custom decal for the spray can.
- Tell connected clients to display it, or use the default spray can decal
- if the custom can't be loaded.
- ==============
- */
- void UTIL_PlayerDecalTrace( TraceResult *pTrace, int playernum, int decalNumber, BOOL bIsCustom )
- {
- int index;
- if (!bIsCustom)
- {
- if ( decalNumber < 0 )
- return;
- index = gDecals[ decalNumber ].index;
- if ( index < 0 )
- return;
- }
- else
- index = decalNumber;
- if (pTrace->flFraction == 1.0)
- return;
- MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
- WRITE_BYTE( TE_PLAYERDECAL );
- WRITE_BYTE ( playernum );
- WRITE_COORD( pTrace->vecEndPos.x );
- WRITE_COORD( pTrace->vecEndPos.y );
- WRITE_COORD( pTrace->vecEndPos.z );
- WRITE_SHORT( (short)ENTINDEX(pTrace->pHit) );
- WRITE_BYTE( index );
- MESSAGE_END();
- }
- void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber )
- {
- if ( decalNumber < 0 )
- return;
- int index = gDecals[ decalNumber ].index;
- if ( index < 0 )
- return;
- if (pTrace->flFraction == 1.0)
- return;
- MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pTrace->vecEndPos );
- WRITE_BYTE( TE_GUNSHOTDECAL );
- WRITE_COORD( pTrace->vecEndPos.x );
- WRITE_COORD( pTrace->vecEndPos.y );
- WRITE_COORD( pTrace->vecEndPos.z );
- WRITE_SHORT( (short)ENTINDEX(pTrace->pHit) );
- WRITE_BYTE( index );
- MESSAGE_END();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement