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.

77 lines
2.1 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 "decals.h"
  8. #include "iefx.h"
  9. #include "fx_impact.h"
  10. #include "tempent.h"
  11. #include "c_te_effect_dispatch.h"
  12. #include "c_te_legacytempents.h"
  13. // NOTE: This has to be the last file included!
  14. #include "tier0/memdbgon.h"
  15. void KnifeSlash( const CEffectData &data )
  16. {
  17. trace_t tr;
  18. Vector vecOrigin, vecStart, vecShotDir;
  19. int iMaterial, iDamageType, iHitbox;
  20. short nSurfaceProp;
  21. C_BaseEntity *pEntity = ParseImpactData( data, &vecOrigin, &vecStart, &vecShotDir, nSurfaceProp, iMaterial, iDamageType, iHitbox );
  22. if( pEntity == NULL )
  23. return;
  24. int decalNumber = decalsystem->GetDecalIndexForName( GetImpactDecal( pEntity, iMaterial, iDamageType ) );
  25. if ( decalNumber == -1 )
  26. return;
  27. // vector perpendicular to the slash direction
  28. // so we can align the slash decal to that
  29. Vector vecPerp;
  30. AngleVectors( data.m_vAngles, NULL, &vecPerp, NULL );
  31. const ConVar *decals =cvar->FindVar( "r_decals" );
  32. if ( decals && decals->GetInt() )
  33. {
  34. if ( (pEntity->entindex() == 0) && (iHitbox != 0) )
  35. {
  36. // Setup our shot information
  37. Vector shotDir = vecOrigin - vecStart;
  38. float flLength = VectorNormalize( shotDir );
  39. Vector traceExt;
  40. VectorMA( vecStart, flLength + 8.0f, shotDir, traceExt );
  41. // Special case for world entity with hitbox (that's a static prop):
  42. // In this case, we've hit a static prop. Decal it!
  43. staticpropmgr->AddDecalToStaticProp( vecStart, traceExt, iHitbox - 1, decalNumber, true, tr );
  44. }
  45. else
  46. {
  47. effects->DecalShoot( decalNumber,
  48. pEntity->entindex(),
  49. pEntity->GetModel(),
  50. pEntity->GetAbsOrigin(),
  51. pEntity->GetAbsAngles(),
  52. vecOrigin,
  53. &vecPerp,
  54. 0 );
  55. }
  56. }
  57. if( Impact( vecOrigin, vecStart, iMaterial, iDamageType, iHitbox, pEntity, tr, data.m_fFlags ) )
  58. {
  59. // Check for custom effects based on the Decal index
  60. PerformCustomEffects( vecOrigin, tr, vecShotDir, iMaterial, 1.0 );
  61. }
  62. }
  63. DECLARE_CLIENT_EFFECT( KnifeSlash, KnifeSlash );