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.

247 lines
7.1 KiB

  1. //========= Copyright � 1996-2005, 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 void Spawn();
  30. virtual int UpdateTransmitState();
  31. virtual void SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways );
  32. virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
  33. static CPlantedC4* ShootSatchelCharge( CCSPlayer *pevOwner, Vector vecStart, QAngle vecAngles );
  34. virtual void Precache();
  35. // Set these flags so CTs can use the C4 to disarm it.
  36. virtual int ObjectCaps() { return BaseClass::ObjectCaps() | (FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE); }
  37. void SetBombSiteIndex( int iIndex ){ m_iBombSiteIndex = iIndex; }
  38. inline bool IsBombActive( void ) { return m_bBombTicking; }
  39. CCSPlayer* GetPlanter( void ) { return m_pPlanter; }
  40. void SetPlanter( CCSPlayer* player ) { m_pPlanter = player; }
  41. CCSPlayer* GetDefuser( void ) { return m_pBombDefuser; }
  42. void SetPlantedAfterPickup( bool plantedAfterPickup ) { m_bPlantedAfterPickup = plantedAfterPickup; }
  43. public:
  44. CNetworkVar( bool, m_bBombTicking );
  45. CNetworkVar( float, m_flC4Blow );
  46. COutputEvent m_OnBombDefused;
  47. COutputEvent m_OnBombBeginDefuse;
  48. COutputEvent m_OnBombDefuseAborted;
  49. protected:
  50. virtual void Init( CCSPlayer *pevOwner, Vector vecStart, QAngle vecAngles, bool bTrainingPlacedByPlayer );
  51. // used for the training map where the map spawns the bomb and sets the timer manually
  52. virtual void ActivateSetTimerLength( float flTimerLength );
  53. void C4Think();
  54. bool m_bTrainingPlacedByPlayer;
  55. bool m_bHasExploded;
  56. private:
  57. // This becomes the think function when the timer has expired and it is about to explode.
  58. void DetonateThink();
  59. virtual void Explode( trace_t *pTrace, int bitsDamageType );
  60. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  61. // Replicate timer length to the client for effects
  62. CNetworkVar( float, m_flTimerLength );
  63. // Info for defusing.
  64. bool m_bBeingDefused;
  65. CHandle<CCSPlayer> m_pBombDefuser;
  66. float m_fLastDefuseTime;
  67. int m_iBombSiteIndex;
  68. CNetworkVar( float, m_flDefuseLength ); //How long does the defuse take? Depends on if a defuser was used
  69. CNetworkVar( float, m_flDefuseCountDown ); //What time does the defuse complete?
  70. CNetworkVar( bool, m_bBombDefused );
  71. CNetworkVar( CHandle<CCSPlayer>, m_hBombDefuser );
  72. // Control panel
  73. void GetControlPanelInfo( int nPanelIndex, const char *&pPanelName );
  74. void GetControlPanelClassName( int nPanelIndex, const char *&pPanelName );
  75. void SpawnControlPanels( void );
  76. void RemoveControlPanels( void );
  77. typedef CHandle<CVGuiScreen> ScreenHandle_t;
  78. CUtlVector<ScreenHandle_t> m_hScreens;
  79. int m_iProgressBarTime;
  80. bool m_bVoiceAlertFired;
  81. // [tj] We need to store who planted the bomb so we can track who deserves credits for the kills
  82. CHandle<CCSPlayer> m_pPlanter;
  83. // [tj] We need to know if this was planted by a player who recovered the bomb
  84. bool m_bPlantedAfterPickup;
  85. };
  86. // ------------------------------------------------------------------------------------------ //
  87. // CPlantedC4 class.
  88. // ------------------------------------------------------------------------------------------ //
  89. class CPlantedC4Training : public CPlantedC4
  90. {
  91. public:
  92. DECLARE_CLASS( CPlantedC4Training, CPlantedC4 );
  93. DECLARE_DATADESC();
  94. //DECLARE_SERVERCLASS();
  95. DECLARE_PREDICTABLE();
  96. //CPlantedC4Training();
  97. //virtual ~CPlantedC4Training();
  98. void InputActivateSetTimerLength( inputdata_t &inputdata );
  99. COutputEvent m_OnBombExploded; //Fired when the bomb explodes
  100. protected:
  101. //virtual void Init( CCSPlayer *pevOwner, Vector vecStart, QAngle vecAngles );
  102. virtual void Explode( trace_t *pTrace, int bitsDamageType );
  103. };
  104. extern CUtlVector< CPlantedC4* > g_PlantedC4s;
  105. #endif
  106. #define WEAPON_C4_CLASSNAME "weapon_c4"
  107. #define PLANTED_C4_CLASSNAME "planted_c4"
  108. #define PLANTED_C4TRAINING_CLASSNAME "planted_c4_training"
  109. class CC4 : public CWeaponCSBase
  110. {
  111. public:
  112. DECLARE_CLASS( CC4, CWeaponCSBase );
  113. DECLARE_NETWORKCLASS();
  114. DECLARE_PREDICTABLE();
  115. CC4();
  116. virtual ~CC4();
  117. virtual void Spawn();
  118. void ItemPostFrame();
  119. virtual void WeaponReset( void );
  120. virtual void PrimaryAttack();
  121. virtual void WeaponIdle();
  122. virtual void UpdateShieldState( void );
  123. virtual float GetMaxSpeed() const;
  124. virtual CSWeaponID GetCSWeaponID( void ) const { return WEAPON_C4; }
  125. virtual bool Deploy( void ); // returns true is deploy was successful
  126. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL );
  127. #ifdef CLIENT_DLL
  128. void ClientThink( void );
  129. virtual void OnDataChanged( DataUpdateType_t type );
  130. virtual void UpdateOnRemove( void );
  131. virtual bool OnFireEvent( C_BaseViewModel *pViewModel, const Vector& origin, const QAngle& angles, int event, const char *options );
  132. char *GetScreenText( void );
  133. char m_szScreenText[32];
  134. CUtlReference<CNewParticleEffect> m_hC4LED;
  135. void CreateLEDEffect( void );
  136. void RemoveLEDEffect( void );
  137. EHANDLE m_hParticleEffectOwner;
  138. virtual Vector GetGlowColor( void ) { return Vector( (240.0f/255.0f), (225.0f/255.0f), (90.0f/255.0f) ); }
  139. #else
  140. virtual void Precache();
  141. virtual int UpdateTransmitState();
  142. virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo );
  143. virtual void GetControlPanelInfo( int nPanelIndex, const char *&pPanelName );
  144. virtual unsigned int PhysicsSolidMaskForEntity( void ) const;
  145. virtual bool ShouldRemoveOnRoundRestart();
  146. void SetDroppedFromDeath (bool droppedFromDeath) { m_bDroppedFromDeath = droppedFromDeath; }
  147. void Think( void );
  148. void ResetToLastValidPlayerHeldPosition();
  149. virtual void PhysicsTouchTriggers(const Vector *pPrevAbsOrigin = NULL);
  150. private:
  151. Vector m_vecLastValidPlayerHeldPosition;
  152. public:
  153. #endif
  154. void AbortBombPlant();
  155. void PlayArmingBeeps( void );
  156. void PlayPlantInitSound( void );
  157. virtual void OnPickedUp( CBaseCombatCharacter *pNewOwner );
  158. virtual void Drop( const Vector &vecVelocity );
  159. CNetworkVar( bool, m_bStartedArming );
  160. CNetworkVar( float, m_fArmedTime );
  161. CNetworkVar( bool, m_bBombPlacedAnimation );
  162. CNetworkVar( bool, m_bShowC4LED );
  163. CNetworkVar( bool, m_bIsPlantingViaUse );
  164. virtual bool IsRemoveable( void ) { return false; }
  165. private:
  166. bool m_bPlayedArmingBeeps[NUM_BEEPS];
  167. bool m_bBombPlanted;
  168. // [tj] we want to store if this bomb was dropped because the original owner was killed
  169. bool m_bDroppedFromDeath;
  170. private:
  171. CC4( const CC4 & );
  172. };
  173. #endif // WEAPON_C4_H