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.

161 lines
4.6 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 "fx_cs_shared.h"
  16. #define NUM_BULLET_SEED_BITS 8
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Display's a blood sprite
  19. //-----------------------------------------------------------------------------
  20. class CTEFireBullets : public CBaseTempEntity
  21. {
  22. public:
  23. DECLARE_CLASS( CTEFireBullets, CBaseTempEntity );
  24. DECLARE_SERVERCLASS();
  25. CTEFireBullets( const char *name );
  26. virtual ~CTEFireBullets( void );
  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_fInaccuracy );
  35. CNetworkVar( float, m_fSpread );
  36. };
  37. //-----------------------------------------------------------------------------
  38. // Purpose:
  39. // Input : *name -
  40. //-----------------------------------------------------------------------------
  41. CTEFireBullets::CTEFireBullets( const char *name ) :
  42. CBaseTempEntity( name )
  43. {
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Purpose:
  47. //-----------------------------------------------------------------------------
  48. CTEFireBullets::~CTEFireBullets( void )
  49. {
  50. }
  51. IMPLEMENT_SERVERCLASS_ST_NOBASE(CTEFireBullets, DT_TEFireBullets)
  52. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD ),
  53. SendPropAngle( SENDINFO_VECTORELEM( m_vecAngles, 0 ), 13, 0 ),
  54. SendPropAngle( SENDINFO_VECTORELEM( m_vecAngles, 1 ), 13, 0 ),
  55. SendPropInt( SENDINFO( m_iWeaponID ), 5, SPROP_UNSIGNED ), // max 31 weapons
  56. SendPropInt( SENDINFO( m_iMode ), 1, SPROP_UNSIGNED ),
  57. SendPropInt( SENDINFO( m_iSeed ), NUM_BULLET_SEED_BITS, SPROP_UNSIGNED ),
  58. SendPropInt( SENDINFO( m_iPlayer ), 6, SPROP_UNSIGNED ), // max 64 players, see MAX_PLAYERS
  59. SendPropFloat( SENDINFO( m_fInaccuracy ), 10, 0, 0, 1 ),
  60. SendPropFloat( SENDINFO( m_fSpread ), 8, 0, 0, 0.1f ),
  61. END_SEND_TABLE()
  62. // Singleton
  63. static CTEFireBullets g_TEFireBullets( "Shotgun Shot" );
  64. void TE_FireBullets(
  65. int iPlayerIndex,
  66. const Vector &vOrigin,
  67. const QAngle &vAngles,
  68. int iWeaponID,
  69. int iMode,
  70. int iSeed,
  71. float fInaccuracy,
  72. float fSpread
  73. )
  74. {
  75. CPASFilter filter( vOrigin );
  76. filter.UsePredictionRules();
  77. g_TEFireBullets.m_iPlayer = iPlayerIndex-1;
  78. g_TEFireBullets.m_vecOrigin = vOrigin;
  79. g_TEFireBullets.m_vecAngles = vAngles;
  80. g_TEFireBullets.m_iSeed = iSeed;
  81. g_TEFireBullets.m_fInaccuracy = fInaccuracy;
  82. g_TEFireBullets.m_fSpread = fSpread;
  83. g_TEFireBullets.m_iMode = iMode;
  84. g_TEFireBullets.m_iWeaponID = iWeaponID;
  85. Assert( iSeed < (1 << NUM_BULLET_SEED_BITS) );
  86. g_TEFireBullets.Create( filter, 0 );
  87. }
  88. //-----------------------------------------------------------------------------
  89. // Purpose: Displays a bomb plant animation
  90. //-----------------------------------------------------------------------------
  91. class CTEPlantBomb : public CBaseTempEntity
  92. {
  93. public:
  94. DECLARE_CLASS( CTEPlantBomb, CBaseTempEntity );
  95. DECLARE_SERVERCLASS();
  96. CTEPlantBomb( const char *name );
  97. virtual ~CTEPlantBomb( void );
  98. public:
  99. CNetworkVar( int, m_iPlayer );
  100. CNetworkVector( m_vecOrigin );
  101. CNetworkVar( PlantBombOption_t, m_option );
  102. };
  103. //-----------------------------------------------------------------------------
  104. // Purpose:
  105. // Input : *name -
  106. //-----------------------------------------------------------------------------
  107. CTEPlantBomb::CTEPlantBomb( const char *name ) :
  108. CBaseTempEntity( name )
  109. {
  110. }
  111. //-----------------------------------------------------------------------------
  112. // Purpose:
  113. //-----------------------------------------------------------------------------
  114. CTEPlantBomb::~CTEPlantBomb( void )
  115. {
  116. }
  117. IMPLEMENT_SERVERCLASS_ST_NOBASE(CTEPlantBomb, DT_TEPlantBomb)
  118. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD ),
  119. SendPropInt( SENDINFO( m_iPlayer ), 6, SPROP_UNSIGNED ), // max 64 players, see MAX_PLAYERS
  120. SendPropInt( SENDINFO( m_option ), 1, SPROP_UNSIGNED ),
  121. END_SEND_TABLE()
  122. // Singleton
  123. static CTEPlantBomb g_TEPlantBomb( "Bomb Plant" );
  124. void TE_PlantBomb( int iPlayerIndex, const Vector &vOrigin, PlantBombOption_t option )
  125. {
  126. CPASFilter filter( vOrigin );
  127. filter.UsePredictionRules();
  128. g_TEPlantBomb.m_iPlayer = iPlayerIndex-1;
  129. g_TEPlantBomb.m_option = option;
  130. g_TEPlantBomb.Create( filter, 0 );
  131. }