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.

116 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "basetempentity.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. //-----------------------------------------------------------------------------
  11. // Purpose:
  12. //-----------------------------------------------------------------------------
  13. class CTEClientProjectile : public CBaseTempEntity
  14. {
  15. public:
  16. DECLARE_CLASS( CTEClientProjectile, CBaseTempEntity );
  17. CTEClientProjectile( const char *name );
  18. virtual ~CTEClientProjectile( void );
  19. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  20. DECLARE_SERVERCLASS();
  21. public:
  22. CNetworkVector( m_vecOrigin );
  23. CNetworkVector( m_vecVelocity );
  24. CNetworkVar( int, m_nModelIndex );
  25. CNetworkVar( int, m_nLifeTime );
  26. CNetworkHandle( CBaseEntity, m_hOwner );
  27. };
  28. //-----------------------------------------------------------------------------
  29. // Purpose:
  30. // Input : *name -
  31. //-----------------------------------------------------------------------------
  32. CTEClientProjectile::CTEClientProjectile( const char *name ) :
  33. CBaseTempEntity( name )
  34. {
  35. m_vecOrigin.Init();
  36. m_vecVelocity.Init();
  37. m_nModelIndex = 0;
  38. m_nLifeTime = 0;
  39. m_hOwner = NULL;
  40. }
  41. //-----------------------------------------------------------------------------
  42. // Purpose:
  43. //-----------------------------------------------------------------------------
  44. CTEClientProjectile::~CTEClientProjectile( void )
  45. {
  46. }
  47. //-----------------------------------------------------------------------------
  48. // Purpose:
  49. // Input : *current_origin -
  50. // *current_angles -
  51. //-----------------------------------------------------------------------------
  52. void CTEClientProjectile::Test( const Vector& current_origin, const QAngle& current_angles )
  53. {
  54. // Fill in data
  55. m_vecOrigin = current_origin;
  56. Vector forward;
  57. AngleVectors( current_angles, &forward );
  58. forward[2] = 0.0;
  59. VectorNormalize( forward );
  60. m_vecVelocity = forward * 2048;
  61. m_nLifeTime = 5;
  62. m_hOwner = NULL;
  63. CBroadcastRecipientFilter filter;
  64. Create( filter, 0.0 );
  65. }
  66. IMPLEMENT_SERVERCLASS_ST(CTEClientProjectile, DT_TEClientProjectile)
  67. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  68. SendPropVector( SENDINFO(m_vecVelocity), -1, SPROP_COORD),
  69. SendPropModelIndex( SENDINFO(m_nModelIndex) ),
  70. SendPropInt( SENDINFO(m_nLifeTime), 6, SPROP_UNSIGNED ),
  71. SendPropEHandle(SENDINFO(m_hOwner)),
  72. END_SEND_TABLE()
  73. // Singleton to fire TEClientProjectile objects
  74. static CTEClientProjectile g_TEClientProjectile( "Client Projectile" );
  75. //-----------------------------------------------------------------------------
  76. // Purpose:
  77. // Input : msg_dest -
  78. // delay -
  79. // *origin -
  80. // *recipient -
  81. // *mins -
  82. // *maxs -
  83. // height -
  84. // modelindex -
  85. // count -
  86. // speed -
  87. //-----------------------------------------------------------------------------
  88. void TE_ClientProjectile( IRecipientFilter& filter, float delay,
  89. const Vector* vecOrigin, const Vector* vecVelocity, int modelindex, int lifetime, CBaseEntity *pOwner )
  90. {
  91. g_TEClientProjectile.m_vecOrigin = *vecOrigin;
  92. g_TEClientProjectile.m_vecVelocity = *vecVelocity;
  93. g_TEClientProjectile.m_nModelIndex = modelindex;
  94. g_TEClientProjectile.m_nLifeTime = lifetime;
  95. g_TEClientProjectile.m_hOwner = pOwner;
  96. // Send it over the wire
  97. g_TEClientProjectile.Create( filter, delay );
  98. }