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.

112 lines
3.2 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 "basetempentity.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. extern int g_sModelIndexSmoke; // (in combatweapon.cpp) holds the index for the smoke cloud
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Dispatches smoke tempentity
  20. //-----------------------------------------------------------------------------
  21. class CTESmoke : public CBaseTempEntity
  22. {
  23. public:
  24. DECLARE_CLASS( CTESmoke, CBaseTempEntity );
  25. CTESmoke( const char *name );
  26. virtual ~CTESmoke( void );
  27. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  28. DECLARE_SERVERCLASS();
  29. public:
  30. CNetworkVector( m_vecOrigin );
  31. CNetworkVar( int, m_nModelIndex );
  32. CNetworkVar( float, m_fScale );
  33. CNetworkVar( int, m_nFrameRate );
  34. };
  35. //-----------------------------------------------------------------------------
  36. // Purpose:
  37. // Input : *name -
  38. //-----------------------------------------------------------------------------
  39. CTESmoke::CTESmoke( const char *name ) :
  40. CBaseTempEntity( name )
  41. {
  42. m_vecOrigin.Init();
  43. m_nModelIndex = 0;
  44. m_fScale = 0;
  45. m_nFrameRate = 0;
  46. }
  47. //-----------------------------------------------------------------------------
  48. // Purpose:
  49. //-----------------------------------------------------------------------------
  50. CTESmoke::~CTESmoke( void )
  51. {
  52. }
  53. //-----------------------------------------------------------------------------
  54. // Purpose:
  55. // Input : *current_origin -
  56. // *current_angles -
  57. //-----------------------------------------------------------------------------
  58. void CTESmoke::Test( const Vector& current_origin, const QAngle& current_angles )
  59. {
  60. // Fill in data
  61. m_nModelIndex = g_sModelIndexSmoke;
  62. m_fScale = 5.0;
  63. m_nFrameRate = 12;
  64. m_vecOrigin = current_origin;
  65. Vector forward, right;
  66. m_vecOrigin.GetForModify()[2] += 24;
  67. AngleVectors( current_angles, &forward, &right, NULL );
  68. forward[2] = 0.0;
  69. VectorNormalize( forward );
  70. VectorMA( m_vecOrigin, 50.0, forward, m_vecOrigin.GetForModify() );
  71. VectorMA( m_vecOrigin, 25.0, right, m_vecOrigin.GetForModify() );
  72. CBroadcastRecipientFilter filter;
  73. Create( filter, 0.0 );
  74. }
  75. IMPLEMENT_SERVERCLASS_ST(CTESmoke, DT_TESmoke)
  76. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  77. SendPropModelIndex( SENDINFO(m_nModelIndex) ),
  78. SendPropFloat( SENDINFO(m_fScale ), 8, SPROP_ROUNDDOWN, 0.0, 25.6 ),
  79. SendPropInt( SENDINFO(m_nFrameRate), 8, SPROP_UNSIGNED ),
  80. END_SEND_TABLE()
  81. // Singleton to fire TESmoke objects
  82. static CTESmoke g_TESmoke( "Smoke" );
  83. void TE_Smoke( IRecipientFilter& filter, float delay,
  84. const Vector* pos, int modelindex, float scale, int framerate )
  85. {
  86. g_TESmoke.m_vecOrigin = *pos;
  87. g_TESmoke.m_nModelIndex = modelindex;
  88. g_TESmoke.m_fScale = scale;
  89. g_TESmoke.m_nFrameRate = framerate;
  90. // Send it over the wire
  91. g_TESmoke.Create( filter, delay );
  92. }