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.

151 lines
4.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_sModelIndexBloodDrop; // (in combatweapon.cpp) holds the sprite index for the initial blood
  18. extern int g_sModelIndexBloodSpray; // (in combatweapon.cpp) holds the sprite index for splattered blood
  19. //-----------------------------------------------------------------------------
  20. // Purpose: Display's a blood sprite
  21. //-----------------------------------------------------------------------------
  22. class CTEBloodSprite : public CBaseTempEntity
  23. {
  24. public:
  25. DECLARE_CLASS( CTEBloodSprite, CBaseTempEntity );
  26. CTEBloodSprite( const char *name );
  27. virtual ~CTEBloodSprite( void );
  28. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  29. DECLARE_SERVERCLASS();
  30. public:
  31. CNetworkVector( m_vecOrigin );
  32. CNetworkVector( m_vecDirection );
  33. CNetworkVar( int, m_nSprayModel );
  34. CNetworkVar( int, m_nDropModel );
  35. CNetworkVar( int, r );
  36. CNetworkVar( int, g );
  37. CNetworkVar( int, b );
  38. CNetworkVar( int, a );
  39. CNetworkVar( int, m_nSize );
  40. };
  41. //-----------------------------------------------------------------------------
  42. // Purpose:
  43. // Input : *name -
  44. //-----------------------------------------------------------------------------
  45. CTEBloodSprite::CTEBloodSprite( const char *name ) :
  46. CBaseTempEntity( name )
  47. {
  48. m_vecOrigin.Init();
  49. m_nSprayModel = 0;
  50. m_nDropModel = 0;
  51. r = 0;
  52. g = 0;
  53. b = 0;
  54. a = 0;
  55. m_nSize = 0;
  56. }
  57. //-----------------------------------------------------------------------------
  58. // Purpose:
  59. //-----------------------------------------------------------------------------
  60. CTEBloodSprite::~CTEBloodSprite( void )
  61. {
  62. }
  63. //-----------------------------------------------------------------------------
  64. // Purpose:
  65. // Input : *current_origin -
  66. // *current_angles -
  67. //-----------------------------------------------------------------------------
  68. void CTEBloodSprite::Test( const Vector& current_origin, const QAngle& current_angles )
  69. {
  70. // Fill in data
  71. r = 255;
  72. g = 255;
  73. b = 63;
  74. a = 255;
  75. m_nSize = 16;
  76. m_vecOrigin = current_origin;
  77. m_nSprayModel = g_sModelIndexBloodSpray;
  78. m_nDropModel = g_sModelIndexBloodDrop;
  79. Vector forward;
  80. m_vecOrigin.GetForModify()[2] += 24;
  81. AngleVectors( current_angles, &forward );
  82. forward[2] = 0.0;
  83. VectorNormalize( forward );
  84. VectorMA( m_vecOrigin, 50.0, forward, m_vecOrigin.GetForModify() );
  85. CBroadcastRecipientFilter filter;
  86. Create( filter, 0.0 );
  87. }
  88. IMPLEMENT_SERVERCLASS_ST_NOBASE(CTEBloodSprite, DT_TEBloodSprite)
  89. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  90. SendPropVector( SENDINFO(m_vecDirection), -1, SPROP_COORD),
  91. SendPropInt( SENDINFO(r), 8, SPROP_UNSIGNED ),
  92. SendPropInt( SENDINFO(g), 8, SPROP_UNSIGNED ),
  93. SendPropInt( SENDINFO(b), 8, SPROP_UNSIGNED ),
  94. SendPropInt( SENDINFO(a), 8, SPROP_UNSIGNED ),
  95. SendPropModelIndex( SENDINFO(m_nSprayModel) ),
  96. SendPropModelIndex( SENDINFO(m_nDropModel) ),
  97. SendPropInt( SENDINFO(m_nSize), 8, SPROP_UNSIGNED ),
  98. END_SEND_TABLE()
  99. // Singleton
  100. static CTEBloodSprite g_TEBloodSprite( "Blood Sprite" );
  101. //-----------------------------------------------------------------------------
  102. // Purpose: Public interface
  103. // Input : msg_dest -
  104. // delay -
  105. // *origin -
  106. // *recipient -
  107. // *org -
  108. // r -
  109. // g -
  110. // b -
  111. // a -
  112. // size -
  113. //-----------------------------------------------------------------------------
  114. void TE_BloodSprite( IRecipientFilter& filter, float delay,
  115. const Vector *org, const Vector *dir, int r, int g, int b, int a, int size )
  116. {
  117. // Set up parameters
  118. g_TEBloodSprite.m_vecOrigin = *org;
  119. g_TEBloodSprite.m_vecDirection = *dir;
  120. g_TEBloodSprite.r = r;
  121. g_TEBloodSprite.g = g;
  122. g_TEBloodSprite.b = b;
  123. g_TEBloodSprite.a = a;
  124. g_TEBloodSprite.m_nSize = size;
  125. // Implicit
  126. g_TEBloodSprite.m_nSprayModel = g_sModelIndexBloodSpray;
  127. g_TEBloodSprite.m_nDropModel = g_sModelIndexBloodDrop;
  128. // Create it
  129. g_TEBloodSprite.Create( filter, delay );
  130. }