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.

242 lines
6.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_WEAPON_BAT_H
  7. #define TF_WEAPON_BAT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_weaponbase_melee.h"
  12. #include "tf_weaponbase_grenadeproj.h"
  13. #include "tf_weapon_grenade_pipebomb.h"
  14. #include "tf_shareddefs.h"
  15. #include "tf_viewmodel.h"
  16. #ifdef CLIENT_DLL
  17. #define CTFBat C_TFBat
  18. #define CTFBat_Wood C_TFBat_Wood
  19. #define CTFBat_Fish C_TFBat_Fish
  20. #define CTFStunBall C_TFStunBall
  21. #define CTFBat_Giftwrap C_TFBat_Giftwrap
  22. #define CTFBall_Ornament C_TFBall_Ornament
  23. #endif
  24. //=============================================================================
  25. //
  26. // Bat class.
  27. //
  28. class CTFBat : public CTFWeaponBaseMelee
  29. {
  30. public:
  31. DECLARE_CLASS( CTFBat, CTFWeaponBaseMelee );
  32. DECLARE_NETWORKCLASS();
  33. DECLARE_PREDICTABLE();
  34. CTFBat();
  35. virtual int GetWeaponID( void ) const { return TF_WEAPON_BAT; }
  36. virtual bool BatDeflects() { return false; }
  37. virtual void Smack( void );
  38. virtual void PlayDeflectionSound( bool bPlayer );
  39. private:
  40. CTFBat( const CTFBat & ) {}
  41. };
  42. //=============================================================================
  43. //
  44. // CTFBat_Fish class.
  45. //
  46. class CTFBat_Fish : public CTFBat
  47. {
  48. public:
  49. DECLARE_CLASS( CTFBat_Fish, CTFBat );
  50. DECLARE_NETWORKCLASS();
  51. DECLARE_PREDICTABLE();
  52. virtual int GetWeaponID( void ) const { return TF_WEAPON_BAT_FISH; }
  53. };
  54. //=============================================================================
  55. //
  56. // CTFBat_Wood class.
  57. //
  58. class CTFBat_Wood : public CTFBat
  59. {
  60. public:
  61. DECLARE_CLASS( CTFBat_Wood, CTFBat );
  62. DECLARE_NETWORKCLASS();
  63. DECLARE_PREDICTABLE();
  64. CTFBat_Wood();
  65. virtual int GetWeaponID( void ) const { return TF_WEAPON_BAT_WOOD; }
  66. virtual bool BatDeflects() { return false; }
  67. virtual void SecondaryAttack( void );
  68. void SecondaryAttackAnim( CTFPlayer *pPlayer );
  69. virtual bool SendWeaponAnim( int iActivity );
  70. virtual bool CanCreateBall( CTFPlayer* pPlayer );
  71. virtual void LaunchBall( void );
  72. void LaunchBallThink( void );
  73. virtual float InternalGetEffectBarRechargeTime( void ) { return 15.0; }
  74. virtual int GetEffectBarAmmo( void ) { return TF_AMMO_GRENADES1; }
  75. #ifdef GAME_DLL
  76. virtual void GetBallDynamics( Vector& vecLoc, QAngle& vecAngles, Vector& vecVelocity, AngularImpulse& angImpulse, CTFPlayer* pPlayer );
  77. #endif
  78. #ifdef CLIENT_DLL
  79. virtual void SetWeaponVisible( bool visible );
  80. // Child removal:
  81. virtual void Drop( const Vector &vecVelocity );
  82. virtual void WeaponReset( void );
  83. virtual void UpdateOnRemove( void );
  84. virtual void OnDataChanged( DataUpdateType_t updateType );
  85. void AddBallChild( void );
  86. void RemoveBallChild( void );
  87. #endif
  88. virtual void PickedUpBall( void );
  89. float GetProgress( void ) { return GetEffectBarProgress(); }
  90. const char* GetEffectLabelText( void ) { return "#TF_BALL"; }
  91. virtual const char *GetBallViewModelName( void ) const { return "models/weapons/v_models/v_baseball.mdl"; }
  92. #ifdef GAME_DLL
  93. virtual CBaseEntity* CreateBall( void );
  94. #endif
  95. int m_iEnemyBallID;
  96. #ifdef CLIENT_DLL
  97. EHANDLE m_hStunBallVM; // View model ball.
  98. #endif
  99. };
  100. //=============================================================================
  101. //
  102. // StunBall class.
  103. //
  104. class CTFStunBall : public CTFGrenadePipebombProjectile
  105. {
  106. public:
  107. DECLARE_CLASS( CTFStunBall, CTFGrenadePipebombProjectile );
  108. DECLARE_NETWORKCLASS();
  109. #ifdef GAME_DLL
  110. CTFStunBall();
  111. static CTFStunBall* Create( const Vector &vecOrigin, const QAngle &vecAngles, CBaseEntity *pOwner );
  112. virtual void Precache( void );
  113. virtual void Spawn( void );
  114. void SetInitialSpeed( float flSpd ) { m_flInitialSpeed = flSpd; }
  115. virtual int GetWeaponID( void ) const { return TF_WEAPON_GRENADE_STUNBALL; }
  116. virtual const char *GetBallModelName( void ) const;
  117. virtual const char *GetBallViewModelName( void ) const;
  118. virtual bool IsAllowedToExplode( void ) OVERRIDE { return false; }
  119. virtual void Explode( trace_t *pTrace, int bitsDamageType );
  120. virtual void ApplyBallImpactEffectOnVictim( CBaseEntity *pOther );
  121. virtual void PipebombTouch( CBaseEntity *pOther );
  122. virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent );
  123. virtual float GetDamage( void );
  124. virtual int GetDamageType( void ) { return DMG_CLUB; }
  125. virtual Vector GetDamageForce( void );
  126. virtual float GetShakeAmplitude( void ) { return 0.0; }
  127. virtual float GetShakeRadius( void ) { return 0.0; }
  128. void RemoveBallTrail( void );
  129. virtual bool IsDestroyable( void ) OVERRIDE { return false; }
  130. int m_iOriginalOwnerID;
  131. private:
  132. float m_flInitialSpeed;
  133. float m_flBallTrailLife;
  134. EHANDLE m_pBallTrail;
  135. #else
  136. virtual const char *GetTrailParticleName( void );
  137. virtual void CreateTrailParticles( void );
  138. #endif
  139. };
  140. //=============================================================================
  141. //
  142. // Winter Holiday 2011 wrapping paper tube and glass ornament ball
  143. //
  144. class CTFBat_Giftwrap : public CTFBat_Wood
  145. {
  146. public:
  147. DECLARE_CLASS( CTFBat_Giftwrap, CTFBat_Wood );
  148. DECLARE_NETWORKCLASS();
  149. DECLARE_PREDICTABLE();
  150. virtual void Spawn( void );
  151. virtual int GetWeaponID( void ) const { return TF_WEAPON_BAT_GIFTWRAP; }
  152. virtual const char *GetEffectLabelText( void ) { return "#TF_BALL"; }
  153. virtual const char *GetBallViewModelName( void ) const { return "models/weapons/c_models/c_xms_festive_ornament.mdl"; }
  154. #ifdef GAME_DLL
  155. virtual CBaseEntity* CreateBall( void );
  156. #endif
  157. };
  158. //=============================================================================
  159. //
  160. // Winter Holiday 2011 wrapping paper tube and glass ornament ball
  161. //
  162. class CTFBall_Ornament : public CTFStunBall
  163. {
  164. public:
  165. DECLARE_CLASS( CTFBall_Ornament, CTFStunBall );
  166. DECLARE_NETWORKCLASS();
  167. #ifdef GAME_DLL
  168. static CTFBall_Ornament* Create( const Vector &vecOrigin, const QAngle &vecAngles, CBaseEntity *pOwner );
  169. virtual void Precache( void );
  170. virtual int GetWeaponID( void ) const { return TF_WEAPON_GRENADE_ORNAMENT_BALL; }
  171. virtual const char *GetBallModelName( void ) const;
  172. virtual const char *GetBallViewModelName( void ) const;
  173. virtual bool IsAllowedToExplode( void ) OVERRIDE { return true; }
  174. virtual void Explode( trace_t *pTrace, int bitsDamageType ) OVERRIDE;
  175. virtual void PipebombTouch( CBaseEntity *pOther ) OVERRIDE;
  176. virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ) OVERRIDE;
  177. void VPhysicsCollisionThink( void );
  178. virtual void ApplyBallImpactEffectOnVictim( CBaseEntity *pOther );
  179. protected:
  180. Vector m_vCollisionVelocity;
  181. #endif
  182. };
  183. #endif // TF_WEAPON_BAT_H