Team Fortress 2 Source Code as on 22/4/2020
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.

134 lines
3.6 KiB

  1. //========= Copyright 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. //-----------------------------------------------------------------------------
  18. // Purpose: Dispatches blood stream tempentity
  19. //-----------------------------------------------------------------------------
  20. class CTEBloodStream : public CTEParticleSystem
  21. {
  22. public:
  23. DECLARE_CLASS( CTEBloodStream, CTEParticleSystem );
  24. CTEBloodStream( const char *name );
  25. virtual ~CTEBloodStream( void );
  26. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  27. DECLARE_SERVERCLASS();
  28. public:
  29. CNetworkVector( m_vecDirection );
  30. CNetworkVar( int, r );
  31. CNetworkVar( int, g );
  32. CNetworkVar( int, b );
  33. CNetworkVar( int, a );
  34. CNetworkVar( int, m_nAmount );
  35. };
  36. //-----------------------------------------------------------------------------
  37. // Purpose:
  38. // Input : *name -
  39. //-----------------------------------------------------------------------------
  40. CTEBloodStream::CTEBloodStream( const char *name ) :
  41. BaseClass( name )
  42. {
  43. m_vecDirection.Init();
  44. r = 0;
  45. g = 0;
  46. b = 0;
  47. a = 0;
  48. m_nAmount = 0;
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. //-----------------------------------------------------------------------------
  53. CTEBloodStream::~CTEBloodStream( void )
  54. {
  55. }
  56. //-----------------------------------------------------------------------------
  57. // Purpose:
  58. // Input : *current_origin -
  59. // *current_angles -
  60. //-----------------------------------------------------------------------------
  61. void CTEBloodStream::Test( const Vector& current_origin, const QAngle& current_angles )
  62. {
  63. // Fill in data
  64. r = 247;
  65. g = 0;
  66. b = 0;
  67. a = 255;
  68. m_nAmount = random->RandomInt(50, 150);
  69. m_vecOrigin = current_origin;
  70. Vector forward;
  71. m_vecOrigin.GetForModify()[2] += 24;
  72. AngleVectors( current_angles, &forward );
  73. forward[2] = 0.0;
  74. VectorNormalize( forward );
  75. m_vecOrigin += forward * 50;
  76. m_vecDirection = UTIL_RandomBloodVector();
  77. CBroadcastRecipientFilter filter;
  78. Create( filter, 0.0 );
  79. }
  80. IMPLEMENT_SERVERCLASS_ST(CTEBloodStream, DT_TEBloodStream)
  81. SendPropVector( SENDINFO(m_vecDirection), 11, 0, -10.0, 10.0 ),
  82. SendPropInt( SENDINFO(r), 8, SPROP_UNSIGNED ),
  83. SendPropInt( SENDINFO(g), 8, SPROP_UNSIGNED ),
  84. SendPropInt( SENDINFO(b), 8, SPROP_UNSIGNED ),
  85. SendPropInt( SENDINFO(a), 8, SPROP_UNSIGNED ),
  86. SendPropInt( SENDINFO(m_nAmount), 8, SPROP_UNSIGNED ),
  87. END_SEND_TABLE()
  88. // Singleton to fire TEBloodStream objects
  89. static CTEBloodStream g_TEBloodStream( "Blood Stream" );
  90. //-----------------------------------------------------------------------------
  91. // Purpose: Creates a blood stream
  92. // Input : msg_dest -
  93. // delay -
  94. // *origin -
  95. // *recipient -
  96. // *org -
  97. // *dir -
  98. // r -
  99. // g -
  100. // b -
  101. // a -
  102. // amount -
  103. //-----------------------------------------------------------------------------
  104. void TE_BloodStream( IRecipientFilter& filter, float delay,
  105. const Vector* org, const Vector* dir, int r, int g, int b, int a, int amount )
  106. {
  107. g_TEBloodStream.m_vecOrigin = *org;
  108. g_TEBloodStream.m_vecDirection = *dir;
  109. g_TEBloodStream.r = r;
  110. g_TEBloodStream.g = g;
  111. g_TEBloodStream.b = b;
  112. g_TEBloodStream.a = a;
  113. g_TEBloodStream.m_nAmount = amount;
  114. // Send it over the wire
  115. g_TEBloodStream.Create( filter, delay );
  116. }