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.

136 lines
4.1 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 Sprite Spray tempentity
  20. //-----------------------------------------------------------------------------
  21. class CTESpriteSpray : public CBaseTempEntity
  22. {
  23. public:
  24. DECLARE_CLASS( CTESpriteSpray, CBaseTempEntity );
  25. CTESpriteSpray( const char *name );
  26. virtual ~CTESpriteSpray( void );
  27. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  28. DECLARE_SERVERCLASS();
  29. public:
  30. CNetworkVector( m_vecOrigin );
  31. CNetworkVector( m_vecDirection );
  32. CNetworkVar( int, m_nModelIndex );
  33. CNetworkVar( int, m_nSpeed );
  34. CNetworkVar( float, m_fNoise );
  35. CNetworkVar( int, m_nCount );
  36. };
  37. //-----------------------------------------------------------------------------
  38. // Purpose:
  39. // Input : *name -
  40. //-----------------------------------------------------------------------------
  41. CTESpriteSpray::CTESpriteSpray( const char *name ) :
  42. CBaseTempEntity( name )
  43. {
  44. m_vecOrigin.Init();
  45. m_vecDirection.Init();
  46. m_nModelIndex = 0;
  47. m_fNoise = 0;
  48. m_nSpeed = 0;
  49. m_nCount = 0;
  50. }
  51. //-----------------------------------------------------------------------------
  52. // Purpose:
  53. //-----------------------------------------------------------------------------
  54. CTESpriteSpray::~CTESpriteSpray( void )
  55. {
  56. }
  57. //-----------------------------------------------------------------------------
  58. // Purpose:
  59. // Input : *current_origin -
  60. // *current_angles -
  61. //-----------------------------------------------------------------------------
  62. void CTESpriteSpray::Test( const Vector& current_origin, const QAngle& current_angles )
  63. {
  64. // Fill in data
  65. m_nModelIndex = g_sModelIndexSmoke;
  66. m_fNoise = 0.8;
  67. m_nCount = 5;
  68. m_nSpeed = 30;
  69. m_vecOrigin = current_origin;
  70. Vector forward, right;
  71. m_vecOrigin.GetForModify()[2] += 24;
  72. AngleVectors( current_angles, &forward, &right, NULL );
  73. forward[2] = 0.0;
  74. VectorNormalize( forward );
  75. VectorMA( m_vecOrigin, 50.0, forward, m_vecOrigin.GetForModify() );
  76. VectorMA( m_vecOrigin, -25.0, right, m_vecOrigin.GetForModify() );
  77. m_vecDirection.Init( random->RandomInt( -100, 100 ), random->RandomInt( -100, 100 ), random->RandomInt( 0, 100 ) );
  78. CBroadcastRecipientFilter filter;
  79. Create( filter, 0.0 );
  80. }
  81. IMPLEMENT_SERVERCLASS_ST(CTESpriteSpray, DT_TESpriteSpray)
  82. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  83. SendPropVector( SENDINFO(m_vecDirection), -1, SPROP_COORD),
  84. SendPropModelIndex(SENDINFO(m_nModelIndex)),
  85. SendPropFloat( SENDINFO(m_fNoise ), 8, SPROP_ROUNDDOWN, 0.0, 2.56 ),
  86. SendPropInt( SENDINFO(m_nSpeed ), 8, SPROP_UNSIGNED ),
  87. SendPropInt( SENDINFO(m_nCount), 8, SPROP_UNSIGNED ),
  88. END_SEND_TABLE()
  89. // Singleton to fire TESpriteSpray objects
  90. static CTESpriteSpray g_TESpriteSpray( "Sprite Spray" );
  91. //-----------------------------------------------------------------------------
  92. // Purpose:
  93. // Input : msg_dest -
  94. // delay -
  95. // *origin -
  96. // *recipient -
  97. // *pos -
  98. // *dir -
  99. // modelindex -
  100. // speed -
  101. // noise -
  102. // count -
  103. //-----------------------------------------------------------------------------
  104. void TE_SpriteSpray( IRecipientFilter& filter, float delay,
  105. const Vector *pos, const Vector *dir, int modelindex, int speed, float noise, int count )
  106. {
  107. g_TESpriteSpray.m_vecOrigin = *pos;
  108. g_TESpriteSpray.m_vecDirection = *dir;
  109. g_TESpriteSpray.m_nModelIndex = modelindex;
  110. g_TESpriteSpray.m_nSpeed = speed;
  111. g_TESpriteSpray.m_fNoise = noise;
  112. g_TESpriteSpray.m_nCount = count;
  113. // Send it over the wire
  114. g_TESpriteSpray.Create( filter, delay );
  115. }