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.

221 lines
6.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef WEAPON_C4_H
  7. #define WEAPON_C4_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "weapon_csbase.h"
  12. #include "utlvector.h"
  13. #define NUM_BEEPS 7
  14. #if defined( CLIENT_DLL )
  15. #define CC4 C_C4
  16. #else
  17. // ------------------------------------------------------------------------------------------ //
  18. // CPlantedC4 class.
  19. // ------------------------------------------------------------------------------------------ //
  20. class CPlantedC4 : public CBaseAnimating
  21. {
  22. public:
  23. DECLARE_CLASS( CPlantedC4, CBaseAnimating );
  24. DECLARE_DATADESC();
  25. DECLARE_SERVERCLASS();
  26. DECLARE_PREDICTABLE();
  27. CPlantedC4();
  28. virtual ~CPlantedC4();
  29. virtual int UpdateTransmitState();
  30. virtual void SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways );
  31. virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
  32. static CPlantedC4* ShootSatchelCharge( CCSPlayer *pevOwner, Vector vecStart, QAngle vecAngles );
  33. virtual void Precache();
  34. // Set these flags so CTs can use the C4 to disarm it.
  35. virtual int ObjectCaps() { return BaseClass::ObjectCaps() | (FCAP_CONTINUOUS_USE | FCAP_USE_IN_RADIUS); }
  36. void SetBombSiteIndex( int iIndex ){ m_iBombSiteIndex = iIndex; }
  37. inline bool IsBombActive( void ) { return m_bBombTicking; }
  38. //=============================================================================
  39. // HPE_BEGIN:
  40. // [tj] Accessors related to planting of the bomb
  41. //=============================================================================
  42. CCSPlayer* GetPlanter() { return m_pPlanter; }
  43. void SetPlanter(CCSPlayer* player) { m_pPlanter = player; }
  44. void SetPlantedAfterPickup (bool plantedAfterPickup) { m_bPlantedAfterPickup = plantedAfterPickup; }
  45. //=============================================================================
  46. // HPE_END
  47. //=============================================================================
  48. public:
  49. CNetworkVar( bool, m_bBombTicking );
  50. CNetworkVar( float, m_flC4Blow );
  51. private:
  52. void Init( CCSPlayer *pevOwner, Vector vecStart, QAngle vecAngles );
  53. void C4Think();
  54. // This becomes the think function when the timer has expired and it is about to explode.
  55. void DetonateThink();
  56. void Explode( trace_t *pTrace, int bitsDamageType );
  57. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  58. // Replicate timer length to the client for effects
  59. CNetworkVar( float, m_flTimerLength );
  60. // Info for defusing.
  61. CHandle<CCSPlayer> m_pBombDefuser;
  62. float m_flNextDefuse;
  63. bool m_bStartDefuse;
  64. int m_iBombSiteIndex;
  65. CNetworkVar( float, m_flDefuseLength ); //How long does the defuse take? Depends on if a defuser was used
  66. CNetworkVar( float, m_flDefuseCountDown ); //What time does the defuse complete?
  67. // Control panel
  68. void GetControlPanelInfo( int nPanelIndex, const char *&pPanelName );
  69. void GetControlPanelClassName( int nPanelIndex, const char *&pPanelName );
  70. void SpawnControlPanels();
  71. typedef CHandle<CVGuiScreen> ScreenHandle_t;
  72. CUtlVector<ScreenHandle_t> m_hScreens;
  73. int m_iProgressBarTime;
  74. //=============================================================================
  75. // HPE_BEGIN:
  76. //=============================================================================
  77. // [tj] We need to store who planted the bomb so we can track who deserves credits for the kills
  78. CHandle<CCSPlayer> m_pPlanter;
  79. // [tj] We need to know if this was planted by a player who recovered the bomb
  80. bool m_bPlantedAfterPickup;
  81. //=============================================================================
  82. // HPE_END
  83. //=============================================================================
  84. };
  85. extern CUtlVector< CPlantedC4* > g_PlantedC4s;
  86. #endif
  87. #define WEAPON_C4_CLASSNAME "weapon_c4"
  88. #define PLANTED_C4_CLASSNAME "planted_c4"
  89. class CC4 : public CWeaponCSBase
  90. {
  91. public:
  92. DECLARE_CLASS( CC4, CWeaponCSBase );
  93. DECLARE_NETWORKCLASS();
  94. DECLARE_PREDICTABLE();
  95. CC4();
  96. virtual ~CC4();
  97. virtual void Spawn();
  98. bool IsPistol() const;
  99. void ItemPostFrame();
  100. virtual void PrimaryAttack();
  101. virtual void WeaponIdle();
  102. virtual void UpdateShieldState( void );
  103. virtual float GetMaxSpeed() const;
  104. // virtual float GetSpread() const;
  105. virtual CSWeaponID GetWeaponID( void ) const { return WEAPON_C4; }
  106. #ifdef CLIENT_DLL
  107. virtual bool OnFireEvent( C_BaseViewModel *pViewModel, const Vector& origin, const QAngle& angles, int event, const char *options );
  108. char *GetScreenText( void );
  109. char m_szScreenText[32];
  110. #else
  111. virtual void Precache();
  112. virtual void GetControlPanelInfo( int nPanelIndex, const char *&pPanelName );
  113. virtual unsigned int PhysicsSolidMaskForEntity( void ) const;
  114. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );
  115. virtual bool ShouldRemoveOnRoundRestart();
  116. //=============================================================================
  117. // HPE_BEGIN:
  118. // [tj] Simple Setter
  119. //=============================================================================
  120. void SetDroppedFromDeath(bool droppedFromDeath) { m_bDroppedFromDeath = droppedFromDeath; }
  121. //=============================================================================
  122. // HPE_END
  123. //=============================================================================
  124. #endif
  125. void AbortBombPlant();
  126. void PlayArmingBeeps( void );
  127. virtual void OnPickedUp( CBaseCombatCharacter *pNewOwner );
  128. virtual void Drop( const Vector &vecVelocity );
  129. CNetworkVar( bool, m_bStartedArming );
  130. CNetworkVar( float, m_fArmedTime );
  131. CNetworkVar( bool, m_bBombPlacedAnimation );
  132. virtual bool IsRemoveable( void ) { return false; }
  133. private:
  134. bool m_bPlayedArmingBeeps[NUM_BEEPS];
  135. bool m_bBombPlanted;
  136. //=============================================================================
  137. // HPE_BEGIN:
  138. // [tj] we want to store if this bomb was dropped because the original owner was killed
  139. //=============================================================================
  140. bool m_bDroppedFromDeath;
  141. //=============================================================================
  142. // HPE_END
  143. //=============================================================================
  144. private:
  145. CC4( const CC4 & );
  146. };
  147. // All the currently-active C4 grenades.
  148. extern CUtlVector< CC4* > g_C4s;
  149. #endif // WEAPON_C4_H