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.

258 lines
8.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_WEAPON_JAR_H
  7. #define TF_WEAPON_JAR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_weaponbase_gun.h"
  12. #include "tf_weapon_grenade_pipebomb.h"
  13. #ifdef CLIENT_DLL
  14. #define CTFJar C_TFJar
  15. #define CTFProjectile_Jar C_TFProjectile_Jar
  16. #define CTFJarMilk C_TFJarMilk
  17. #define CTFCleaver C_TFCleaver
  18. #define CTFThrowable C_TFThrowable
  19. #define CTFProjectile_JarMilk C_TFProjectile_JarMilk
  20. #define CTFProjectile_Cleaver C_TFProjectile_Cleaver
  21. #define CTFProjectile_Throwable C_TFProjectile_Throwable
  22. #endif
  23. class CTFProjectile_Jar;
  24. enum EThrowableTypes
  25. {
  26. EThrowableBase = 0,
  27. #ifdef STAGING_ONLY
  28. EThrowableWaterBalloon,
  29. #endif
  30. };
  31. #define JAR_EXPLODE_RADIUS 200 // TF_ROCKET_RADIUS and grenade explosions is 146
  32. //=============================================================================
  33. //
  34. // Jar class.
  35. //
  36. class CTFJar : public CTFWeaponBaseGun
  37. {
  38. public:
  39. DECLARE_CLASS( CTFJar, CTFWeaponBaseGun );
  40. DECLARE_NETWORKCLASS();
  41. DECLARE_PREDICTABLE();
  42. CTFJar();
  43. virtual int GetWeaponID( void ) const { return TF_WEAPON_JAR; }
  44. virtual float GetProjectileSpeed( void );
  45. virtual void PrimaryAttack( void );
  46. float GetProgress( void ) { return GetEffectBarProgress(); }
  47. virtual CBaseEntity *FireJar( CTFPlayer *pPlayer );
  48. virtual void TossJarThink( void );
  49. virtual float InternalGetEffectBarRechargeTime( void ) { return 20.1; }
  50. virtual const char* GetEffectLabelText( void ) { return "#TF_JAR"; }
  51. virtual void GetProjectileEntityName( CAttribute_String *attrProjectileEntityName );
  52. #ifdef GAME_DLL
  53. virtual const AngularImpulse GetAngularImpulse( void ){ return AngularImpulse( 300, 0, 0 ); }
  54. virtual Vector GetVelocityVector( const Vector &vecForward, const Vector &vecRight, const Vector &vecUp );
  55. virtual bool ShouldSpeakWhenFiring( void ){ return true; }
  56. // virtual bool SendWeaponAnim( int iActivity );
  57. virtual CTFProjectile_Jar *CreateJarProjectile( const Vector &position, const QAngle &angles, const Vector &velocity,
  58. const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo );
  59. #endif
  60. virtual bool CanThrowUnderWater( void ){ return false; }
  61. private:
  62. int m_iProjectileType;
  63. CTFJar( const CTFJar & ) {}
  64. };
  65. // *************************************************************************************************************************
  66. class CTFJarMilk : public CTFJar
  67. {
  68. public:
  69. DECLARE_CLASS( CTFJarMilk, CTFJar );
  70. DECLARE_NETWORKCLASS();
  71. virtual int GetWeaponID( void ) const { return TF_WEAPON_JAR_MILK; }
  72. #ifdef GAME_DLL
  73. virtual CTFProjectile_Jar *CreateJarProjectile( const Vector &position, const QAngle &angles, const Vector &velocity,
  74. const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo );
  75. #endif
  76. #ifdef CLIENT_DLL
  77. const char* ModifyEventParticles( const char* token );
  78. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL );
  79. #endif
  80. };
  81. // *************************************************************************************************************************
  82. class CTFCleaver : public CTFJar
  83. {
  84. public:
  85. DECLARE_CLASS( CTFCleaver, CTFJar );
  86. DECLARE_NETWORKCLASS();
  87. virtual int GetWeaponID( void ) const { return TF_WEAPON_CLEAVER; }
  88. virtual float GetProjectileSpeed( void );
  89. virtual void SecondaryAttack( void );
  90. virtual const char* GetEffectLabelText( void ) { return "#TF_CLEAVER"; }
  91. virtual float InternalGetEffectBarRechargeTime( void ) { return 5.1; }
  92. #ifdef GAME_DLL
  93. virtual const AngularImpulse GetAngularImpulse( void ){ return AngularImpulse( 0, 500, 0 ); }
  94. virtual Vector GetVelocityVector( const Vector &vecForward, const Vector &vecRight, const Vector &vecUp );
  95. virtual bool ShouldSpeakWhenFiring( void ){ return false; }
  96. virtual CTFProjectile_Jar *CreateJarProjectile( const Vector &position, const QAngle &angles, const Vector &velocity,
  97. const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo );
  98. #endif
  99. #ifdef CLIENT_DLL
  100. const char* ModifyEventParticles( const char* token );
  101. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL );
  102. #endif
  103. };
  104. //=============================================================================
  105. //
  106. // JarBomb projectile class.
  107. //
  108. class CTFProjectile_Jar : public CTFGrenadePipebombProjectile
  109. {
  110. public:
  111. DECLARE_CLASS( CTFProjectile_Jar, CTFGrenadePipebombProjectile );
  112. DECLARE_NETWORKCLASS();
  113. #ifdef CLIENT_DLL
  114. virtual const char* GetTrailParticleName( void );
  115. #endif
  116. #ifdef GAME_DLL
  117. CTFProjectile_Jar();
  118. static CTFProjectile_Jar *Create( const Vector &position, const QAngle &angles, const Vector &velocity,
  119. const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo );
  120. virtual int GetProjectileType() const OVERRIDE { return m_iProjectileType; }
  121. virtual int GetWeaponID( void ) const OVERRIDE { return TF_WEAPON_GRENADE_JAR; }
  122. virtual float GetDamage() { return 0.f; }
  123. virtual bool ExplodesOnHit() { return true; }
  124. virtual void Precache() OVERRIDE;
  125. virtual void SetCustomPipebombModel() OVERRIDE;
  126. virtual float GetDamageRadius() { return JAR_EXPLODE_RADIUS ; }
  127. virtual void OnHit( CBaseEntity *pOther ) {}
  128. virtual void OnHitWorld( void ) {}
  129. virtual void Explode( trace_t *pTrace, int bitsDamageType ) OVERRIDE;
  130. virtual void PipebombTouch( CBaseEntity *pOther ) OVERRIDE;
  131. virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ) OVERRIDE;
  132. void VPhysicsCollisionThink( void );
  133. void OnBreadMonsterHit( CBaseEntity *pOther, trace_t *pTrace );
  134. bool PositionArrowOnBone( mstudiobbox_t *pBox, CBaseAnimating *pOtherAnim );
  135. void GetBoneAttachmentInfo( mstudiobbox_t *pBox, CBaseAnimating *pOtherAnim, Vector &bonePosition, QAngle &boneAngles, int &boneIndexAttached, int &physicsBoneIndex );
  136. void CreateStickyAttachmentToTarget( CTFPlayer *pOwner, CTFPlayer *pVictim, trace_t *trace );
  137. virtual const char* GetImpactEffect() { return "peejar_impact"; }
  138. virtual ETFCond GetEffectCondition( void ) { return TF_COND_URINE; }
  139. protected:
  140. Vector m_vCollisionVelocity;
  141. int m_iProjectileType;
  142. #endif
  143. };
  144. // *************************************************************************************************************************
  145. class CTFProjectile_JarMilk : public CTFProjectile_Jar
  146. {
  147. public:
  148. DECLARE_CLASS( CTFProjectile_JarMilk, CTFProjectile_Jar );
  149. DECLARE_NETWORKCLASS();
  150. #ifdef GAME_DLL
  151. static CTFProjectile_JarMilk *Create( const Vector &position, const QAngle &angles, const Vector &velocity,
  152. const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo );
  153. virtual void SetCustomPipebombModel() OVERRIDE;
  154. virtual const char* GetImpactEffect() OVERRIDE { return "peejar_impact_milk"; }
  155. virtual ETFCond GetEffectCondition( void ) OVERRIDE { return TF_COND_MAD_MILK; }
  156. #endif
  157. virtual int GetWeaponID( void ) const OVERRIDE { return TF_WEAPON_GRENADE_JAR_MILK; }
  158. virtual void Precache() OVERRIDE;
  159. };
  160. // *************************************************************************************************************************
  161. class CTFProjectile_Cleaver : public CTFProjectile_Jar
  162. {
  163. public:
  164. DECLARE_CLASS( CTFProjectile_Cleaver, CTFProjectile_Jar );
  165. DECLARE_NETWORKCLASS();
  166. #ifdef CLIENT_DLL
  167. virtual const char* GetTrailParticleName( void );
  168. #endif
  169. #ifdef GAME_DLL
  170. static CTFProjectile_Cleaver *Create( const Vector &position, const QAngle &angles, const Vector &velocity,
  171. const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo, int nSkin );
  172. #endif
  173. CTFProjectile_Cleaver();
  174. virtual int GetWeaponID( void ) const OVERRIDE { return TF_WEAPON_GRENADE_CLEAVER; }
  175. virtual void Precache() OVERRIDE;
  176. virtual void SetCustomPipebombModel() OVERRIDE;
  177. #ifdef GAME_DLL
  178. virtual float GetDamage() OVERRIDE { return 50.f; }
  179. virtual void OnHit( CBaseEntity *pOther ) OVERRIDE;
  180. virtual void Explode( trace_t *pTrace, int bitsDamageType ) OVERRIDE;
  181. virtual void Detonate() OVERRIDE;
  182. virtual const char* GetImpactEffect() OVERRIDE { return ""; }
  183. virtual ETFCond GetEffectCondition( void ) OVERRIDE { return TF_COND_BLEEDING; }
  184. private:
  185. bool m_bHitPlayer;
  186. bool m_bSoundPlayed;
  187. #endif
  188. };
  189. void JarExplode( int iEntIndex, CTFPlayer *pAttacker, CBaseEntity *pOriginalWeapon, CBaseEntity *pWeapon, const Vector& vContactPoint, int iTeam, float flRadius, ETFCond cond, float flDuration, const char *pszImpactEffect );
  190. #endif // TF_WEAPON_JAR_H