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.

114 lines
3.3 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. #define NUM_BULLET_SEED_BITS 8
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Display's a blood sprite
  18. //-----------------------------------------------------------------------------
  19. class CTEFireBullets : public CBaseTempEntity
  20. {
  21. public:
  22. DECLARE_CLASS( CTEFireBullets, CBaseTempEntity );
  23. DECLARE_SERVERCLASS();
  24. CTEFireBullets( const char *name );
  25. virtual ~CTEFireBullets( void );
  26. virtual void Create( IRecipientFilter& filter, float delay = 0.0f );
  27. public:
  28. CNetworkVar( int, m_iPlayer );
  29. CNetworkVector( m_vecOrigin );
  30. CNetworkQAngle( m_vecAngles );
  31. CNetworkVar( int, m_iWeaponID );
  32. CNetworkVar( int, m_iMode );
  33. CNetworkVar( int, m_iSeed );
  34. CNetworkVar( float, m_flSpread );
  35. };
  36. //-----------------------------------------------------------------------------
  37. // Purpose:
  38. // Input : *name -
  39. //-----------------------------------------------------------------------------
  40. CTEFireBullets::CTEFireBullets( const char *name ) :
  41. CBaseTempEntity( name )
  42. {
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. CTEFireBullets::~CTEFireBullets( void )
  48. {
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. // Input : msg_dest -
  53. // delay -
  54. // *origin -
  55. // *recipient -
  56. //-----------------------------------------------------------------------------
  57. void CTEFireBullets::Create( IRecipientFilter& filter, float delay )
  58. {
  59. engine->PlaybackTempEntity( filter, delay,
  60. (void *)this, GetServerClass()->m_pTable, GetServerClass()->m_ClassID );
  61. }
  62. IMPLEMENT_SERVERCLASS_ST_NOBASE(CTEFireBullets, DT_TEFireBullets)
  63. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD ),
  64. SendPropAngle( SENDINFO_VECTORELEM( m_vecAngles, 0 ), 13, 0 ),
  65. SendPropAngle( SENDINFO_VECTORELEM( m_vecAngles, 1 ), 13, 0 ),
  66. SendPropInt( SENDINFO( m_iWeaponID ), 5, SPROP_UNSIGNED ), // max 31 weapons
  67. SendPropInt( SENDINFO( m_iMode ), 1, SPROP_UNSIGNED ),
  68. SendPropInt( SENDINFO( m_iSeed ), NUM_BULLET_SEED_BITS, SPROP_UNSIGNED ),
  69. SendPropInt( SENDINFO( m_iPlayer ), 6, SPROP_UNSIGNED ), // max 64 players, see MAX_PLAYERS
  70. SendPropFloat( SENDINFO( m_flSpread ), 10, 0, 0, 1 ),
  71. END_SEND_TABLE()
  72. // Singleton
  73. static CTEFireBullets g_TEFireBullets( "FireBullets" );
  74. void TE_FireBullets(
  75. int iPlayerIndex,
  76. const Vector &vOrigin,
  77. const QAngle &vAngles,
  78. int iWeaponID,
  79. int iMode,
  80. int iSeed,
  81. float flSpread )
  82. {
  83. CPASFilter filter( vOrigin );
  84. filter.UsePredictionRules();
  85. g_TEFireBullets.m_iPlayer = iPlayerIndex-1;
  86. g_TEFireBullets.m_vecOrigin = vOrigin;
  87. g_TEFireBullets.m_vecAngles = vAngles;
  88. g_TEFireBullets.m_iSeed = iSeed;
  89. g_TEFireBullets.m_flSpread = flSpread;
  90. g_TEFireBullets.m_iMode = iMode;
  91. g_TEFireBullets.m_iWeaponID = iWeaponID;
  92. Assert( iSeed < (1 << NUM_BULLET_SEED_BITS) );
  93. g_TEFireBullets.Create( filter, 0 );
  94. }