Counter Strike : Global Offensive Source Code
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.

47 lines
1.4 KiB

  1. //========= Copyright � 1996-2005, 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. // NOTE: This has to be the last file included!
  10. #include "tier0/memdbgon.h"
  11. //-----------------------------------------------------------------------------
  12. // Purpose: Handle weapon impacts
  13. //-----------------------------------------------------------------------------
  14. void ImpactCallback( const CEffectData &data )
  15. {
  16. trace_t tr;
  17. Vector vecOrigin, vecStart, vecShotDir;
  18. int iMaterial, iDamageType, iHitbox;
  19. short nSurfaceProp;
  20. C_BaseEntity *pEntity = ParseImpactData( data, &vecOrigin, &vecStart, &vecShotDir, nSurfaceProp, iMaterial, iDamageType, iHitbox );
  21. if ( !pEntity || pEntity->IsDormant())
  22. return;
  23. int flags = 0;
  24. if ( (iDamageType & DMG_SHOCK) != 0 ) // no decals for shock damage
  25. {
  26. flags = IMPACT_NODECAL;
  27. }
  28. // If we hit, perform our custom effects and play the sound
  29. if ( Impact( vecOrigin, vecStart, iMaterial, iDamageType, iHitbox, pEntity, tr, flags ) )
  30. {
  31. // Check for custom effects based on the Decal index
  32. PerformCustomEffects( vecOrigin, tr, vecShotDir, iMaterial, 1.0 );
  33. }
  34. PlayImpactSound( pEntity, tr, vecOrigin, nSurfaceProp );
  35. }
  36. DECLARE_CLIENT_EFFECT( Impact, ImpactCallback );