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.

142 lines
3.9 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. //-----------------------------------------------------------------------------
  18. // Purpose: Dispatches sparks
  19. //-----------------------------------------------------------------------------
  20. class CTEMetalSparks : public CBaseTempEntity
  21. {
  22. DECLARE_CLASS( CTEMetalSparks, CBaseTempEntity );
  23. public:
  24. CTEMetalSparks( const char *name );
  25. virtual ~CTEMetalSparks( void );
  26. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  27. DECLARE_SERVERCLASS();
  28. public:
  29. CNetworkVector( m_vecPos );
  30. CNetworkVector( m_vecDir );
  31. };
  32. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. // Input : *name -
  35. //-----------------------------------------------------------------------------
  36. CTEMetalSparks::CTEMetalSparks( const char *name ) :
  37. CBaseTempEntity( name )
  38. {
  39. m_vecPos.Init();
  40. m_vecDir.Init();
  41. }
  42. //-----------------------------------------------------------------------------
  43. // Purpose:
  44. //-----------------------------------------------------------------------------
  45. CTEMetalSparks::~CTEMetalSparks( void )
  46. {
  47. }
  48. //-----------------------------------------------------------------------------
  49. // Purpose:
  50. // Input : *current_origin -
  51. // *current_angles -
  52. //-----------------------------------------------------------------------------
  53. void CTEMetalSparks::Test( const Vector& current_origin, const QAngle& current_angles )
  54. {
  55. // Fill in data
  56. m_vecPos = current_origin;
  57. AngleVectors( current_angles, &m_vecDir.GetForModify() );
  58. Vector forward;
  59. m_vecPos += Vector( 0, 0, 24 );
  60. AngleVectors( current_angles, &forward );
  61. forward[2] = 0.0;
  62. VectorNormalize( forward );
  63. VectorMA( m_vecPos, 100.0, forward, m_vecPos.GetForModify() );
  64. CBroadcastRecipientFilter filter;
  65. Create( filter, 0.0 );
  66. }
  67. IMPLEMENT_SERVERCLASS_ST_NOBASE( CTEMetalSparks, DT_TEMetalSparks)
  68. SendPropVector( SENDINFO(m_vecPos), -1, SPROP_COORD),
  69. SendPropVector( SENDINFO(m_vecDir), -1, SPROP_COORD),
  70. END_SEND_TABLE()
  71. // Singleton to fire TEMetalSparks objects
  72. static CTEMetalSparks g_TEMetalSparks( "Metal Sparks" );
  73. //-----------------------------------------------------------------------------
  74. // Purpose:
  75. // Input : msg_dest -
  76. // delay -
  77. // *origin -
  78. // *recipient -
  79. // *pos -
  80. // scale -
  81. //-----------------------------------------------------------------------------
  82. void TE_MetalSparks( IRecipientFilter& filter, float delay,
  83. const Vector* pos, const Vector* dir )
  84. {
  85. g_TEMetalSparks.m_vecPos = *pos;
  86. g_TEMetalSparks.m_vecDir = *dir;
  87. Assert( dir->Length() < 1.01 ); // make sure it's a normal
  88. // Send it over the wire
  89. g_TEMetalSparks.Create( filter, delay );
  90. }
  91. class CTEArmorRicochet : public CTEMetalSparks
  92. {
  93. DECLARE_CLASS( CTEArmorRicochet, CTEMetalSparks );
  94. public:
  95. CTEArmorRicochet( const char *name ) : CTEMetalSparks(name) {}
  96. DECLARE_SERVERCLASS();
  97. };
  98. IMPLEMENT_SERVERCLASS_ST( CTEArmorRicochet, DT_TEArmorRicochet)
  99. END_SEND_TABLE()
  100. static CTEArmorRicochet g_TEArmorRicochet( "Armor Ricochet" );
  101. //-----------------------------------------------------------------------------
  102. // Purpose:
  103. // Input : msg_dest -
  104. // delay -
  105. // *origin -
  106. // *recipient -
  107. // *pos -
  108. // scale -
  109. //-----------------------------------------------------------------------------
  110. void TE_ArmorRicochet( IRecipientFilter& filter, float delay,
  111. const Vector* pos, const Vector* dir )
  112. {
  113. g_TEArmorRicochet.m_vecPos = *pos;
  114. g_TEArmorRicochet.m_vecDir = *dir;
  115. // Send it over the wire
  116. g_TEArmorRicochet.Create( filter, delay );
  117. }