Counter Strike : Global Offensive Source Code
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.

184 lines
5.5 KiB

  1. //========= Copyright � 1996-2005, 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. CNetworkVar( uint16, m_nItemDefIndex );
  30. CNetworkVector( m_vecOrigin );
  31. CNetworkQAngle( m_vecAngles );
  32. CNetworkVar( int, m_iWeaponID );
  33. CNetworkVar( int, m_iMode );
  34. CNetworkVar( int, m_iSeed );
  35. CNetworkVar( float, m_fInaccuracy );
  36. CNetworkVar( float, m_flRecoilIndex );
  37. CNetworkVar( float, m_fSpread );
  38. #if defined( WEAPON_FIRE_BULLETS_ACCURACY_FISHTAIL_FEATURE )
  39. CNetworkVar( float, m_fAccuracyFishtail );
  40. #endif
  41. CNetworkVar( int, m_iSoundType );
  42. };
  43. //-----------------------------------------------------------------------------
  44. // Purpose:
  45. // Input : *name -
  46. //-----------------------------------------------------------------------------
  47. CTEFireBullets::CTEFireBullets( const char *name ) :
  48. CBaseTempEntity( name )
  49. {
  50. }
  51. //-----------------------------------------------------------------------------
  52. // Purpose:
  53. //-----------------------------------------------------------------------------
  54. CTEFireBullets::~CTEFireBullets( void )
  55. {
  56. }
  57. IMPLEMENT_SERVERCLASS_ST_NOBASE(CTEFireBullets, DT_TEFireBullets)
  58. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD ),
  59. SendPropAngle( SENDINFO_VECTORELEM( m_vecAngles, 0 ), 13, 0 ),
  60. SendPropAngle( SENDINFO_VECTORELEM( m_vecAngles, 1 ), 13, 0 ),
  61. SendPropInt( SENDINFO( m_iWeaponID ), 6, SPROP_UNSIGNED ), // max 63 weapons
  62. SendPropInt( SENDINFO( m_iMode ), 1, SPROP_UNSIGNED ),
  63. SendPropInt( SENDINFO( m_iSeed ), NUM_BULLET_SEED_BITS, SPROP_UNSIGNED ),
  64. SendPropInt( SENDINFO( m_iPlayer ), 6, SPROP_UNSIGNED ), // max 64 players, see MAX_PLAYERS
  65. SendPropFloat( SENDINFO( m_fInaccuracy ), 10, 0, 0, 1 ),
  66. SendPropFloat( SENDINFO( m_flRecoilIndex ), 10, 0, 0, 1000 ),
  67. SendPropFloat( SENDINFO( m_fSpread ), 8, 0, 0, 0.1f ),
  68. SendPropInt( SENDINFO( m_nItemDefIndex ), 16, SPROP_UNSIGNED ),
  69. SendPropInt( SENDINFO( m_iSoundType ), 6, SPROP_UNSIGNED ),
  70. #if defined( WEAPON_FIRE_BULLETS_ACCURACY_FISHTAIL_FEATURE )
  71. SendPropFloat( SENDINFO( m_fAccuracyFishtail ), 10, 0, -10.0f, 10.0f ),
  72. #endif
  73. END_SEND_TABLE()
  74. // Singleton
  75. static CTEFireBullets g_TEFireBullets( "Shotgun Shot" );
  76. void TE_FireBullets(
  77. int iPlayerIndex,
  78. uint16 nItemDefIndex,
  79. const Vector &vOrigin,
  80. const QAngle &vAngles,
  81. int iWeaponID,
  82. int iMode,
  83. int iSeed,
  84. float fInaccuracy,
  85. float fSpread,
  86. float fAccuracyFishtail,
  87. int iSoundType,
  88. float flRecoilIndex
  89. )
  90. {
  91. // Just always send gunshots to clients.
  92. CBroadcastRecipientFilter filter;
  93. filter.UsePredictionRules();
  94. g_TEFireBullets.m_iPlayer = iPlayerIndex-1;
  95. g_TEFireBullets.m_nItemDefIndex = nItemDefIndex;
  96. g_TEFireBullets.m_vecOrigin = vOrigin;
  97. g_TEFireBullets.m_vecAngles = vAngles;
  98. g_TEFireBullets.m_iSeed = iSeed;
  99. g_TEFireBullets.m_fInaccuracy = fInaccuracy;
  100. g_TEFireBullets.m_flRecoilIndex = flRecoilIndex;
  101. g_TEFireBullets.m_fSpread = fSpread;
  102. #if defined( WEAPON_FIRE_BULLETS_ACCURACY_FISHTAIL_FEATURE )
  103. g_TEFireBullets.m_fAccuracyFishtail = fAccuracyFishtail;
  104. #endif
  105. g_TEFireBullets.m_iMode = iMode;
  106. g_TEFireBullets.m_iWeaponID = iWeaponID;
  107. g_TEFireBullets.m_iSoundType = iSoundType;
  108. Assert( iSeed < (1 << NUM_BULLET_SEED_BITS) );
  109. g_TEFireBullets.Create( filter, 0 );
  110. }
  111. //-----------------------------------------------------------------------------
  112. // Purpose: Displays a bomb plant animation
  113. //-----------------------------------------------------------------------------
  114. class CTEPlantBomb : public CBaseTempEntity
  115. {
  116. public:
  117. DECLARE_CLASS( CTEPlantBomb, CBaseTempEntity );
  118. DECLARE_SERVERCLASS();
  119. CTEPlantBomb( const char *name );
  120. virtual ~CTEPlantBomb( void );
  121. public:
  122. CNetworkVar( int, m_iPlayer );
  123. CNetworkVector( m_vecOrigin );
  124. CNetworkVar( PlantBombOption_t, m_option );
  125. };
  126. //-----------------------------------------------------------------------------
  127. // Purpose:
  128. // Input : *name -
  129. //-----------------------------------------------------------------------------
  130. CTEPlantBomb::CTEPlantBomb( const char *name ) :
  131. CBaseTempEntity( name )
  132. {
  133. }
  134. //-----------------------------------------------------------------------------
  135. // Purpose:
  136. //-----------------------------------------------------------------------------
  137. CTEPlantBomb::~CTEPlantBomb( void )
  138. {
  139. }
  140. IMPLEMENT_SERVERCLASS_ST_NOBASE(CTEPlantBomb, DT_TEPlantBomb)
  141. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD ),
  142. SendPropInt( SENDINFO( m_iPlayer ), 6, SPROP_UNSIGNED ), // max 64 players, see MAX_PLAYERS
  143. SendPropInt( SENDINFO( m_option ), 1, SPROP_UNSIGNED ),
  144. END_SEND_TABLE()
  145. // Singleton
  146. static CTEPlantBomb g_TEPlantBomb( "Bomb Plant" );
  147. void TE_PlantBomb( int iPlayerIndex, const Vector &vOrigin, PlantBombOption_t option )
  148. {
  149. CPASFilter filter( vOrigin );
  150. filter.UsePredictionRules();
  151. g_TEPlantBomb.m_iPlayer = iPlayerIndex-1;
  152. g_TEPlantBomb.m_option = option;
  153. g_TEPlantBomb.Create( filter, 0 );
  154. }