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.

127 lines
3.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Beam used for Laser sights. Fades out when it's perpendicular to the viewpoint.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "basetempentity.h"
  9. #include "te_basebeam.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. extern int g_sModelIndexSmoke; // (in combatweapon.cpp) holds the index for the smoke cloud
  13. //-----------------------------------------------------------------------------
  14. // Purpose: Beam used for Laser sights. Fades out when it's perpendicular to the viewpoint.
  15. //-----------------------------------------------------------------------------
  16. class CTEBeamLaser : public CTEBaseBeam
  17. {
  18. DECLARE_CLASS( CTEBeamLaser, CTEBaseBeam );
  19. public:
  20. DECLARE_SERVERCLASS();
  21. CTEBeamLaser( const char *name );
  22. virtual ~CTEBeamLaser( void );
  23. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  24. public:
  25. CNetworkVar( int, m_nStartEntity );
  26. CNetworkVar( int, m_nEndEntity );
  27. };
  28. //-----------------------------------------------------------------------------
  29. // Purpose:
  30. // Input : *name -
  31. //-----------------------------------------------------------------------------
  32. CTEBeamLaser::CTEBeamLaser( const char *name ) :
  33. CTEBaseBeam( name )
  34. {
  35. m_nStartEntity = 0;
  36. m_nEndEntity = 0;
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. //-----------------------------------------------------------------------------
  41. CTEBeamLaser::~CTEBeamLaser( void )
  42. {
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. // Input : *current_origin -
  47. // *current_angles -
  48. //-----------------------------------------------------------------------------
  49. void CTEBeamLaser::Test( const Vector& current_origin, const QAngle& current_angles )
  50. {
  51. m_nStartEntity = 1;
  52. m_nEndEntity = 0;
  53. m_nModelIndex = g_sModelIndexSmoke;
  54. m_nStartFrame = 0;
  55. m_nFrameRate = 10;
  56. m_fLife = 2.0;
  57. m_fWidth = 1.0;
  58. m_fAmplitude = 1.0;
  59. r = 127;
  60. g = 63;
  61. b = 0;
  62. a = 150;
  63. m_nSpeed = 1;
  64. CBroadcastRecipientFilter filter;
  65. Create( filter, 0.0 );
  66. }
  67. IMPLEMENT_SERVERCLASS_ST( CTEBeamLaser, DT_TEBeamLaser)
  68. SendPropInt( SENDINFO(m_nStartEntity), 24, SPROP_UNSIGNED ),
  69. SendPropInt( SENDINFO(m_nEndEntity), 24, SPROP_UNSIGNED ),
  70. END_SEND_TABLE()
  71. // Singleton to fire TEBeamLaser objects
  72. static CTEBeamLaser g_TEBeamLaser( "BeamLaser" );
  73. //-----------------------------------------------------------------------------
  74. // Purpose:
  75. // Input : msg_dest -
  76. // delay -
  77. // *origin -
  78. // *recipient -
  79. // *start -
  80. // *end -
  81. // modelindex -
  82. // startframe -
  83. // framerate -
  84. // msg_dest -
  85. // delay -
  86. // origin -
  87. // recipient -
  88. //-----------------------------------------------------------------------------
  89. void TE_BeamLaser( IRecipientFilter& filter, float delay,
  90. int start, int end, int modelindex, int haloindex, int startframe, int framerate,
  91. float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed )
  92. {
  93. g_TEBeamLaser.m_nStartEntity = (start & 0x0FFF) | ((1 & 0xF)<<12);
  94. g_TEBeamLaser.m_nEndEntity = (end & 0x0FFF) | ((1 & 0xF)<<12);
  95. g_TEBeamLaser.m_nModelIndex = modelindex;
  96. g_TEBeamLaser.m_nHaloIndex = haloindex;
  97. g_TEBeamLaser.m_nStartFrame = startframe;
  98. g_TEBeamLaser.m_nFrameRate = framerate;
  99. g_TEBeamLaser.m_fLife = life;
  100. g_TEBeamLaser.m_fWidth = width;
  101. g_TEBeamLaser.m_fEndWidth = endWidth;
  102. g_TEBeamLaser.m_nFadeLength = fadeLength;
  103. g_TEBeamLaser.m_fAmplitude = amplitude;
  104. g_TEBeamLaser.m_nSpeed = speed;
  105. g_TEBeamLaser.r = r;
  106. g_TEBeamLaser.g = g;
  107. g_TEBeamLaser.b = b;
  108. g_TEBeamLaser.a = a;
  109. // Send it over the wire
  110. g_TEBeamLaser.Create( filter, delay );
  111. }