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.

98 lines
2.9 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. public:
  27. CNetworkVar( int, m_iPlayer ); // player who fired
  28. CNetworkVector( m_vecOrigin ); // firing origin
  29. CNetworkQAngle( m_vecAngles ); // firing angle
  30. CNetworkVar( int, m_iWeaponID ); // weapon ID
  31. CNetworkVar( int, m_iMode ); // primary or secondary fire ?
  32. CNetworkVar( int, m_iSeed ); // shared random seed
  33. CNetworkVar( float, m_flSpread ); // bullets spread
  34. };
  35. //-----------------------------------------------------------------------------
  36. // Purpose:
  37. // Input : *name -
  38. //-----------------------------------------------------------------------------
  39. CTEFireBullets::CTEFireBullets( const char *name ) :
  40. CBaseTempEntity( name )
  41. {
  42. }
  43. //-----------------------------------------------------------------------------
  44. // Purpose:
  45. //-----------------------------------------------------------------------------
  46. CTEFireBullets::~CTEFireBullets( void )
  47. {
  48. }
  49. IMPLEMENT_SERVERCLASS_ST_NOBASE(CTEFireBullets, DT_TEFireBullets)
  50. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD ),
  51. SendPropAngle( SENDINFO_VECTORELEM( m_vecAngles, 0 ), 13, 0 ),
  52. SendPropAngle( SENDINFO_VECTORELEM( m_vecAngles, 1 ), 13, 0 ),
  53. SendPropInt( SENDINFO( m_iWeaponID ), 5, SPROP_UNSIGNED ), // max 31 weapons
  54. SendPropInt( SENDINFO( m_iMode ), 1, SPROP_UNSIGNED ),
  55. SendPropInt( SENDINFO( m_iSeed ), NUM_BULLET_SEED_BITS, SPROP_UNSIGNED ),
  56. SendPropInt( SENDINFO( m_iPlayer ), 6, SPROP_UNSIGNED ), // max 64 players, see MAX_PLAYERS
  57. SendPropFloat( SENDINFO( m_flSpread ), 10, 0, 0, 1 ),
  58. END_SEND_TABLE()
  59. // Singleton
  60. static CTEFireBullets g_TEFireBullets( "Shotgun Shot" );
  61. void TE_FireBullets(
  62. int iPlayerIndex,
  63. const Vector &vOrigin,
  64. const QAngle &vAngles,
  65. int iWeaponID,
  66. int iMode,
  67. int iSeed,
  68. float flSpread )
  69. {
  70. CPASFilter filter( vOrigin );
  71. filter.UsePredictionRules();
  72. g_TEFireBullets.m_iPlayer = iPlayerIndex-1;
  73. g_TEFireBullets.m_vecOrigin = vOrigin;
  74. g_TEFireBullets.m_vecAngles = vAngles;
  75. g_TEFireBullets.m_iSeed = iSeed;
  76. g_TEFireBullets.m_flSpread = flSpread;
  77. g_TEFireBullets.m_iMode = iMode;
  78. g_TEFireBullets.m_iWeaponID = iWeaponID;
  79. Assert( iSeed < (1 << NUM_BULLET_SEED_BITS) );
  80. g_TEFireBullets.Create( filter, 0 );
  81. }