Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Game-specific impact effect hooks
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "fx_impact.h"
  8. #include "engine/IEngineSound.h"
  9. //-----------------------------------------------------------------------------
  10. // Purpose: Handle weapon impacts
  11. //-----------------------------------------------------------------------------
  12. void ImpactCallback( const CEffectData &data )
  13. {
  14. trace_t tr;
  15. Vector vecOrigin, vecStart, vecShotDir;
  16. int iMaterial, iDamageType, iHitbox;
  17. short nSurfaceProp;
  18. C_BaseEntity *pEntity = ParseImpactData( data, &vecOrigin, &vecStart, &vecShotDir, nSurfaceProp, iMaterial, iDamageType, iHitbox );
  19. if ( !pEntity )
  20. return;
  21. // If we hit, perform our custom effects and play the sound
  22. if ( Impact( vecOrigin, vecStart, iMaterial, iDamageType, iHitbox, pEntity, tr ) )
  23. {
  24. // Check for custom effects based on the Decal index
  25. PerformCustomEffects( vecOrigin, tr, vecShotDir, iMaterial, 1.0 );
  26. //Play a ricochet sound some of the time
  27. if( random->RandomInt(1,10) <= 3 && (iDamageType == DMG_BULLET) )
  28. {
  29. CLocalPlayerFilter filter;
  30. C_BaseEntity::EmitSound( filter, SOUND_FROM_WORLD, "Bounce.Shrapnel", &vecOrigin );
  31. }
  32. }
  33. PlayImpactSound( pEntity, tr, vecOrigin, nSurfaceProp );
  34. }
  35. DECLARE_CLIENT_EFFECT( "Impact", ImpactCallback );