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.

131 lines
4.0 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //===========================================================================//
  13. #include "cbase.h"
  14. #include "te_particlesystem.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. extern int g_sModelIndexFireball; // (in combatweapon.cpp) holds the index for the smoke cloud
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Dispatches explosion tempentity
  20. //-----------------------------------------------------------------------------
  21. class CTEExplosion : public CTEParticleSystem
  22. {
  23. public:
  24. DECLARE_CLASS( CTEExplosion, CTEParticleSystem );
  25. DECLARE_SERVERCLASS();
  26. CTEExplosion( const char *name );
  27. virtual ~CTEExplosion( void );
  28. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  29. public:
  30. CNetworkVar( int, m_nModelIndex );
  31. CNetworkVar( float, m_fScale );
  32. CNetworkVar( int, m_nFrameRate );
  33. CNetworkVar( int, m_nFlags );
  34. CNetworkVector( m_vecNormal );
  35. CNetworkVar( unsigned char, m_chMaterialType );
  36. CNetworkVar( int, m_nRadius );
  37. CNetworkVar( int, m_nMagnitude );
  38. };
  39. //-----------------------------------------------------------------------------
  40. // Purpose:
  41. // Input : *name -
  42. //-----------------------------------------------------------------------------
  43. CTEExplosion::CTEExplosion( const char *name ) :
  44. BaseClass( name )
  45. {
  46. m_nModelIndex = 0;
  47. m_fScale = 0;
  48. m_nFrameRate = 0;
  49. m_nFlags = 0;
  50. m_vecNormal.Init();
  51. m_chMaterialType = 'C';
  52. m_nRadius = 0;
  53. m_nMagnitude = 0;
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. //-----------------------------------------------------------------------------
  58. CTEExplosion::~CTEExplosion( void )
  59. {
  60. }
  61. //-----------------------------------------------------------------------------
  62. // Purpose:
  63. // Input : *current_origin -
  64. // *current_angles -
  65. //-----------------------------------------------------------------------------
  66. void CTEExplosion::Test( const Vector& current_origin, const QAngle& current_angles )
  67. {
  68. // Fill in data
  69. m_nModelIndex = g_sModelIndexFireball;
  70. m_fScale = 0.5;
  71. m_nFrameRate = 15;
  72. m_nFlags = TE_EXPLFLAG_NONE;
  73. m_vecOrigin = current_origin;
  74. Vector forward;
  75. m_vecOrigin.GetForModify()[2] += 24;
  76. AngleVectors( current_angles, &forward );
  77. forward[2] = 0.0;
  78. VectorNormalize( forward );
  79. m_vecOrigin += forward * 50;
  80. CBroadcastRecipientFilter filter;
  81. Create( filter, 0.0 );
  82. }
  83. IMPLEMENT_SERVERCLASS_ST(CTEExplosion, DT_TEExplosion)
  84. SendPropModelIndex( SENDINFO(m_nModelIndex) ),
  85. SendPropFloat( SENDINFO(m_fScale ), 9, 0, 0.0, 51.2 ),
  86. SendPropInt( SENDINFO(m_nFrameRate), 8, SPROP_UNSIGNED ),
  87. SendPropInt( SENDINFO(m_nFlags), 10, SPROP_UNSIGNED ),
  88. SendPropVector( SENDINFO(m_vecNormal), -1, SPROP_COORD),
  89. SendPropInt( SENDINFO(m_chMaterialType), 8, SPROP_UNSIGNED ),
  90. SendPropInt( SENDINFO(m_nRadius), 32, SPROP_UNSIGNED ),
  91. SendPropInt( SENDINFO(m_nMagnitude), 32, SPROP_UNSIGNED ),
  92. END_SEND_TABLE()
  93. // Singleton to fire TEExplosion objects
  94. static CTEExplosion g_TEExplosion( "Explosion" );
  95. void TE_Explosion( IRecipientFilter& filter, float delay,
  96. const Vector& pos, int modelindex, float scale, int framerate, int flags, int radius, int magnitude, const Vector& normal, unsigned char materialType )
  97. {
  98. g_TEExplosion.m_vecOrigin = pos;
  99. g_TEExplosion.m_nModelIndex = modelindex;
  100. g_TEExplosion.m_fScale = scale;
  101. g_TEExplosion.m_nFrameRate = framerate;
  102. g_TEExplosion.m_nFlags = flags;
  103. g_TEExplosion.m_nRadius = radius;
  104. g_TEExplosion.m_nMagnitude = magnitude;
  105. // Make a copy here so we can re-use it below
  106. g_TEExplosion.m_vecNormal = normal; // pNormal ? ( *pNormal ) : Vector( 0, 0, 1 );
  107. g_TEExplosion.m_chMaterialType = materialType;
  108. // Send it over the wire
  109. g_TEExplosion.Create( filter, delay );
  110. }