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.

153 lines
4.7 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 "basetempentity.h"
  15. #include "te_basebeam.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include "tier0/memdbgon.h"
  18. extern short g_sModelIndexSmoke; // (in combatweapon.cpp) holds the index for the smoke cloud
  19. //-----------------------------------------------------------------------------
  20. // Purpose: Dispatches a beam ring between two entities
  21. //-----------------------------------------------------------------------------
  22. class CTEBeamEntPoint : public CTEBaseBeam
  23. {
  24. public:
  25. DECLARE_CLASS( CTEBeamEntPoint, CTEBaseBeam );
  26. DECLARE_SERVERCLASS();
  27. CTEBeamEntPoint( const char *name );
  28. virtual ~CTEBeamEntPoint( void );
  29. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  30. public:
  31. CNetworkVar( int, m_nStartEntity );
  32. CNetworkVector( m_vecStartPoint );
  33. CNetworkVar( int, m_nEndEntity );
  34. CNetworkVector( m_vecEndPoint );
  35. };
  36. //-----------------------------------------------------------------------------
  37. // Purpose:
  38. // Input : *name -
  39. //-----------------------------------------------------------------------------
  40. CTEBeamEntPoint::CTEBeamEntPoint( const char *name ) :
  41. CTEBaseBeam( name )
  42. {
  43. m_nStartEntity = 0;
  44. m_nEndEntity = 0;
  45. m_vecStartPoint.Init();
  46. m_vecEndPoint.Init();
  47. }
  48. //-----------------------------------------------------------------------------
  49. // Purpose:
  50. //-----------------------------------------------------------------------------
  51. CTEBeamEntPoint::~CTEBeamEntPoint( void )
  52. {
  53. }
  54. //-----------------------------------------------------------------------------
  55. // Purpose:
  56. // Input : *current_origin -
  57. // *current_angles -
  58. //-----------------------------------------------------------------------------
  59. void CTEBeamEntPoint::Test( const Vector& current_origin, const QAngle& current_angles )
  60. {
  61. m_nStartEntity = 1;
  62. m_nModelIndex = g_sModelIndexSmoke;
  63. m_nStartFrame = 0;
  64. m_nFrameRate = 10;
  65. m_fLife = 2.0;
  66. m_fWidth = 1.0;
  67. m_fAmplitude = 1.0;
  68. r = 0;
  69. g = 63;
  70. b = 127;
  71. a = 150;
  72. m_nSpeed = 1;
  73. m_vecEndPoint = current_origin;
  74. Vector forward, right;
  75. m_vecEndPoint += Vector( 0, 0, 24 );
  76. AngleVectors( current_angles, &forward, &right, 0 );
  77. forward[2] = 0.0;
  78. VectorNormalize( forward );
  79. VectorMA( m_vecEndPoint, 50.0, forward, m_vecEndPoint.GetForModify() );
  80. CBroadcastRecipientFilter filter;
  81. Create( filter, 0.0 );
  82. }
  83. IMPLEMENT_SERVERCLASS_ST(CTEBeamEntPoint, DT_TEBeamEntPoint)
  84. SendPropInt( SENDINFO(m_nStartEntity), 24, SPROP_UNSIGNED ),
  85. SendPropInt( SENDINFO(m_nEndEntity), 24, SPROP_UNSIGNED ),
  86. SendPropVector( SENDINFO(m_vecStartPoint), -1, SPROP_COORD ),
  87. SendPropVector( SENDINFO(m_vecEndPoint), -1, SPROP_COORD ),
  88. END_SEND_TABLE()
  89. // Singleton to fire TEBeamEntPoint objects
  90. static CTEBeamEntPoint g_TEBeamEntPoint( "BeamEntPoint" );
  91. //-----------------------------------------------------------------------------
  92. // Purpose:
  93. // Input : msg_dest -
  94. // delay -
  95. // *origin -
  96. // *recipient -
  97. // int start -
  98. // *end -
  99. // modelindex -
  100. // startframe -
  101. // framerate -
  102. // msg_dest -
  103. // delay -
  104. // origin -
  105. // recipient -
  106. //-----------------------------------------------------------------------------
  107. void TE_BeamEntPoint( IRecipientFilter& filter, float delay,
  108. int nStartEntity, const Vector *start, int nEndEntity, const Vector* end,
  109. int modelindex, int haloindex, int startframe, int framerate,
  110. float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed )
  111. {
  112. g_TEBeamEntPoint.m_nStartEntity = (nStartEntity > 0) ? (nStartEntity & 0x0FFF) | ((1 & 0xF)<<12) : 0;
  113. g_TEBeamEntPoint.m_nEndEntity = (nEndEntity > 0) ? (nEndEntity & 0x0FFF) | ((1 & 0xF)<<12) : 0;
  114. g_TEBeamEntPoint.m_vecStartPoint = start ? *start : vec3_origin;
  115. g_TEBeamEntPoint.m_vecEndPoint = end ? *end : vec3_origin;
  116. g_TEBeamEntPoint.m_nModelIndex = modelindex;
  117. g_TEBeamEntPoint.m_nHaloIndex = haloindex;
  118. g_TEBeamEntPoint.m_nStartFrame = startframe;
  119. g_TEBeamEntPoint.m_nFrameRate = framerate;
  120. g_TEBeamEntPoint.m_fLife = life;
  121. g_TEBeamEntPoint.m_fWidth = width;
  122. g_TEBeamEntPoint.m_fEndWidth = endWidth;
  123. g_TEBeamEntPoint.m_nFadeLength = fadeLength;
  124. g_TEBeamEntPoint.m_fAmplitude = amplitude;
  125. g_TEBeamEntPoint.m_nSpeed = speed;
  126. g_TEBeamEntPoint.r = r;
  127. g_TEBeamEntPoint.g = g;
  128. g_TEBeamEntPoint.b = b;
  129. g_TEBeamEntPoint.a = a;
  130. // Send it over the wire
  131. g_TEBeamEntPoint.Create( filter, delay );
  132. }