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.

470 lines
17 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_WEAPON_THROWABLE_H
  7. #define TF_WEAPON_THROWABLE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_weapon_jar.h"
  12. #include "tf_shareddefs.h"
  13. #include "tf_weaponbase_gun.h"
  14. #ifdef CLIENT_DLL
  15. #define CTFThrowable C_TFThrowable
  16. #define CTFThrowablePrimary C_TFThrowablePrimary
  17. #define CTFThrowableSecondary C_TFThrowableSecondary
  18. #define CTFThrowableMelee C_TFThrowableMelee
  19. #define CTFThrowableUtility C_TFThrowableUtility
  20. #define CTFProjectile_Throwable C_TFProjectile_Throwable
  21. #define CTFProjectile_ThrowableRepel C_TFProjectile_ThrowableRepel
  22. #define CTFProjectile_ThrowableBrick C_TFProjectile_ThrowableBrick
  23. #define CTFProjectile_ThrowableBreadMonster C_TFProjectile_ThrowableBreadMonster
  24. #define CTFProjectile_BreadMonster_Jarate C_TFProjectile_BreadMonster_Jarate
  25. #ifdef STAGING_ONLY
  26. #define CTFProjectile_ThrowableTargetDummy C_TFProjectile_ThrowableTargetDummy
  27. #define CTFProjectile_ConcGrenade C_TFProjectile_ConcGrenade
  28. #define CTFProjectile_TeleportGrenade C_TFProjectile_TeleportGrenade
  29. #define CTFProjectile_GravityGrenade C_TFProjectile_GravityGrenade
  30. #define CTFProjectile_ThrowingKnife C_TFProjectile_ThrowingKnife
  31. #define CTFProjectile_SmokeGrenade C_TFProjectile_SmokeGrenade
  32. #endif // STAGING_ONLY
  33. #endif
  34. class CTFProjectile_Throwable;
  35. // *************************************************************************************************************************
  36. class CTFThrowable : public CTFJar, public ITFChargeUpWeapon
  37. {
  38. public:
  39. DECLARE_CLASS( CTFThrowable, CTFJar );
  40. DECLARE_NETWORKCLASS();
  41. DECLARE_PREDICTABLE();
  42. CTFThrowable();
  43. virtual void Precache();
  44. virtual void PrimaryAttack( void );
  45. virtual void ItemPostFrame( void );
  46. virtual CBaseEntity *FireJar( CTFPlayer *pPlayer ) OVERRIDE;
  47. virtual int GetWeaponID( void ) const { return TF_WEAPON_THROWABLE; }
  48. virtual const char* GetEffectLabelText( void ) { return "#TF_Throwable"; }
  49. virtual bool ShowHudElement( void ) { return true; }
  50. virtual const char* ModifyEventParticles( const char* token ) { return NULL; }
  51. virtual float InternalGetEffectBarRechargeTime( void );
  52. virtual float GetDetonationTime( void );
  53. // ITFChargeUpWeapon
  54. virtual bool CanCharge( void );
  55. virtual float GetChargeBeginTime( void );
  56. virtual float GetChargeMaxTime( void ); // Same as Det time
  57. #ifdef GAME_DLL
  58. //virtual bool ShouldSpeakWhenFiring( void ) { return false; }
  59. //virtual const AngularImpulse GetAngularImpulse( void ){ return AngularImpulse( 300, 0, 0 ); }
  60. //virtual Vector GetVelocityVector( const Vector &vecForward, const Vector &vecRight, const Vector &vecUp );
  61. virtual void TossJarThink( void );
  62. virtual CTFProjectile_Throwable *FireProjectileInternal( void );
  63. #endif
  64. CNetworkVar( float, m_flChargeBeginTime );
  65. };
  66. // *************************************************************************************************************************
  67. class CTFThrowablePrimary : public CTFThrowable
  68. {
  69. public:
  70. DECLARE_CLASS( CTFThrowablePrimary, CTFThrowable );
  71. DECLARE_NETWORKCLASS();
  72. DECLARE_PREDICTABLE();
  73. };
  74. class CTFThrowableSecondary : public CTFThrowable
  75. {
  76. public:
  77. DECLARE_CLASS( CTFThrowableSecondary, CTFThrowable );
  78. DECLARE_NETWORKCLASS();
  79. DECLARE_PREDICTABLE();
  80. };
  81. class CTFThrowableMelee : public CTFThrowable
  82. {
  83. public:
  84. DECLARE_CLASS( CTFThrowableMelee, CTFThrowable );
  85. DECLARE_NETWORKCLASS();
  86. DECLARE_PREDICTABLE();
  87. };
  88. class CTFThrowableUtility : public CTFThrowable
  89. {
  90. public:
  91. DECLARE_CLASS( CTFThrowableUtility, CTFThrowable );
  92. DECLARE_NETWORKCLASS();
  93. DECLARE_PREDICTABLE();
  94. };
  95. // *************************************************************************************************************************
  96. class CTFProjectile_Throwable : public CTFProjectile_Jar
  97. {
  98. public:
  99. DECLARE_CLASS( CTFProjectile_Throwable, CTFProjectile_Jar );
  100. DECLARE_NETWORKCLASS();
  101. virtual int GetWeaponID( void ) const { return TF_WEAPON_GRENADE_THROWABLE; }
  102. virtual float GetModelScale() const { return 1.0f; }
  103. virtual int GetCustomDamageType() const OVERRIDE{ return TF_DMG_CUSTOM_THROWABLE; }
  104. virtual bool IsDeflectable() OVERRIDE { return true; }
  105. virtual bool ExplodesOnHit() { return true; }
  106. virtual void SetCustomPipebombModel() { return; }
  107. virtual float GetShakeAmplitude() { return 0.0; }
  108. virtual float GetProjectileSpeed() { return 1000.0f; }
  109. virtual float GetProjectileMaxSpeed() { return 2500.0f; }
  110. virtual const char *GetThrowSoundEffect() const { return NULL; }
  111. #ifdef GAME_DLL
  112. CTFProjectile_Throwable();
  113. virtual void Spawn( void )
  114. {
  115. SetModelScale( GetModelScale() );
  116. BaseClass::Spawn();
  117. }
  118. virtual void InitThrowable( float flChargePercent ) { m_flChargePercent = flChargePercent; }
  119. virtual int GetProjectileType( void ) const OVERRIDE { return TF_PROJECTILE_THROWABLE; }
  120. virtual void OnHit( CBaseEntity *pOther );
  121. //virtual void Detonate(); // Timer based Explode
  122. virtual void Misfire() { }
  123. virtual void Explode(); // Explode Helper
  124. virtual void Explode( trace_t *pTrace, int bitsDamageType ) OVERRIDE;
  125. virtual void ApplyBlastDamage( CTFPlayer *pThrower, Vector vecOrigin ) { }
  126. virtual bool InitialExplodeEffects( CTFPlayer *pThrower, const trace_t *pTrace ) { return false; }
  127. virtual void ExplodeEffectOnTarget( CTFPlayer *pThrower, CTFPlayer *pTarget, CBaseCombatCharacter *pBaseTarget ) { }
  128. virtual float GetDamage() { return 0.0f; }
  129. virtual float GetDamageRadius() const { return 250.0f; }
  130. virtual const char *GetExplodeEffectParticle() const { return GetTeamNumber() == TF_TEAM_RED ? "" : ""; }
  131. virtual const char *GetExplodeEffectSound() const { return ""; }
  132. virtual const AngularImpulse GetAngularImpulse( void ) { return AngularImpulse( 300, 0, 0 ); }
  133. virtual Vector GetVelocityVector( const Vector &vecForward, const Vector &vecRight, const Vector &vecUp, float flCharge );
  134. #endif // GAME_DLL
  135. #ifdef CLIENT_DLL
  136. virtual const char* GetTrailParticleName( void ) { return GetTeamNumber() == TF_TEAM_RED ? "trail_basic_red" : "trail_basic_blue"; }
  137. #endif
  138. protected:
  139. #ifdef GAME_DLL
  140. float m_flChargePercent;
  141. bool m_bHit;
  142. #endif // GAME_DLL
  143. private:
  144. };
  145. // *************************************************************************************************************************
  146. class CTFProjectile_ThrowableRepel : public CTFProjectile_Throwable
  147. {
  148. public:
  149. DECLARE_CLASS( CTFProjectile_ThrowableRepel, CTFProjectile_Throwable );
  150. DECLARE_NETWORKCLASS();
  151. virtual void SetCustomPipebombModel() { SetModel( "models/weapons/c_models/c_balloon_default.mdl" ); }
  152. virtual bool ExplodesOnHit() { return true; }
  153. #ifdef GAME_DLL
  154. virtual void OnHit( CBaseEntity *pOther );
  155. virtual float GetDamage() { return RemapVal( m_flChargePercent, 0, 1, 20.0f, 50.0f ); }
  156. virtual float GetDamageRadius() const { return 0.0f; }
  157. virtual const char *GetExplodeEffectParticle() const { return "Explosion_bubbles"; }
  158. virtual const char *GetExplodeEffectSound() const { return ""; }
  159. #endif // GAME_DLL
  160. };
  161. // *************************************************************************************************************************
  162. class CTFProjectile_ThrowableBrick : public CTFProjectile_Throwable
  163. {
  164. public:
  165. DECLARE_CLASS( CTFProjectile_ThrowableBrick, CTFProjectile_Throwable );
  166. DECLARE_NETWORKCLASS();
  167. virtual void SetCustomPipebombModel() { SetModel( "models/weapons/c_models/c_bread/c_bread_plainloaf.mdl" ); }
  168. virtual bool ExplodesOnHit() { return false; }
  169. #ifdef GAME_DLL
  170. virtual void OnHit( CBaseEntity *pOther );
  171. virtual float GetDamage() { return RemapVal( m_flChargePercent, 0, 1, 40.0f, 70.0f ); }
  172. virtual float GetDamageRadius() const { return 0.0f; }
  173. virtual const char *GetExplodeEffectParticle() const { return ""; }
  174. virtual const char *GetExplodeEffectSound() const { return ""; }
  175. #endif // GAME_DLL
  176. };
  177. // *************************************************************************************************************************
  178. class CTFProjectile_ThrowableBreadMonster : public CTFProjectile_Throwable
  179. {
  180. public:
  181. DECLARE_CLASS( CTFProjectile_ThrowableBreadMonster, CTFProjectile_Throwable );
  182. DECLARE_NETWORKCLASS();
  183. virtual void SetCustomPipebombModel() { SetModel( "models/weapons/c_models/c_breadmonster/c_breadmonster.mdl" ); }
  184. virtual bool ExplodesOnHit() { return true; }
  185. #ifdef GAME_DLL
  186. virtual int GetProjectileType( void ) const OVERRIDE { return TF_PROJECTILE_BREAD_MONSTER; }
  187. virtual void OnHit( CBaseEntity *pOther );
  188. virtual void Detonate(); // Timer based 'Explode' Just Remove
  189. virtual void Explode( trace_t *pTrace, int bitsDamageType );
  190. virtual float GetDamage() { return RemapVal( m_flChargePercent, 0, 1, 40.0f, 85.0f ); }
  191. virtual float GetDamageRadius() const { return 0.0f; }
  192. virtual const char *GetExplodeEffectParticle() const { return "breadjar_impact"; }
  193. virtual const char *GetThrowSoundEffect() const { return "Weapon_bm_throwable.throw"; }
  194. virtual const char *GetExplodeEffectSound() const { return "Weapon_bm_throwable.smash"; }
  195. #endif // GAME_DLL
  196. };
  197. // *************************************************************************************************************************
  198. //class CTFProjectile_BreadMonster_Jarate : public CTFProjectile_Throwable
  199. //{
  200. //public:
  201. // DECLARE_CLASS( CTFProjectile_BreadMonster_Jarate, CTFProjectile_Throwable );
  202. // DECLARE_NETWORKCLASS();
  203. //
  204. // virtual int GetProjectileType( void ) { return TF_PROJECTILE_BREAD_MONSTER; }
  205. // virtual void SetCustomPipebombModel() { SetModel( "models/weapons/c_models/c_breadmonster/c_breadmonster.mdl" ); }
  206. // virtual bool ExplodesOnHit() { return true; }
  207. ////
  208. ////#ifdef GAME_DLL
  209. // virtual void OnHit( CBaseEntity *pOther );
  210. // virtual void Detonate(); // Timer based 'Explode' Just Remove
  211. // virtual void Explode( trace_t *pTrace, int bitsDamageType );
  212. ////
  213. // virtual float GetDamage() { return 0.0f; }
  214. // virtual float GetDamageRadius() const { return 0.0f; }
  215. //
  216. // virtual const char *GetExplodeEffectParticle() const { return "breadjar_impact"; }
  217. // virtual const char *GetThrowSoundEffect() const { return "Weapon_bm_throwable.throw"; }
  218. // virtual const char *GetExplodeEffectSound() const { return "Weapon_bm_throwable.smash"; }
  219. //#endif // GAME_DLL
  220. //};
  221. #ifdef STAGING_ONLY
  222. // *************************************************************************************************************************
  223. class CTFProjectile_ThrowableTargetDummy : public CTFProjectile_Throwable
  224. {
  225. public:
  226. DECLARE_CLASS( CTFProjectile_ThrowableTargetDummy, CTFProjectile_Throwable );
  227. DECLARE_NETWORKCLASS();
  228. virtual void SetCustomPipebombModel() { SetModel( "models/props_gameplay/small_loaf.mdl" ); }
  229. virtual bool ExplodesOnHit() { return false; }
  230. #ifdef GAME_DLL
  231. virtual int GetProjectileType( void ) const OVERRIDE{ return TF_PROJECTILE_BREAD_MONSTER; }
  232. //virtual void OnHit( CBaseEntity *pOther );
  233. virtual void Detonate() { Explode(); } // Timer based 'Explode' Just Remove
  234. virtual void Explode();
  235. virtual float GetDamage() { return 0.0f; }
  236. virtual float GetDamageRadius() const { return 0.0f; }
  237. virtual const char *GetExplodeEffectParticle() const { return "breadjar_impact"; }
  238. virtual const char *GetThrowSoundEffect() const { return "Weapon_bm_throwable.throw"; }
  239. virtual const char *GetExplodeEffectSound() const { return "Weapon_bm_throwable.smash"; }
  240. #endif // GAME_DLL
  241. };
  242. // *************************************************************************************************************************
  243. class CTFProjectile_ConcGrenade : public CTFProjectile_Throwable
  244. {
  245. public:
  246. DECLARE_CLASS( CTFProjectile_ConcGrenade, CTFProjectile_Throwable );
  247. DECLARE_NETWORKCLASS();
  248. virtual void SetCustomPipebombModel( void ) OVERRIDE { return; }
  249. virtual float GetShakeAmplitude( void ) OVERRIDE { return 10.f; }
  250. virtual bool ExplodesOnHit() { return false; }
  251. #ifdef GAME_DLL
  252. virtual void Misfire();
  253. virtual void Detonate(); // Timer based Explode
  254. virtual void Explode(); // Explode Helper
  255. virtual float GetDamageRadius( void ) const OVERRIDE { return 200.f; }
  256. virtual const char *GetExplodeEffectParticle( void ) const OVERRIDE { return "mvm_soldier_shockwave"; }
  257. virtual const char *GetExplodeEffectSound(void ) const OVERRIDE { return "Weapon_Grenade_Concussion.Explode"; }
  258. #endif // GAME_DLL
  259. };
  260. // *************************************************************************************************************************
  261. class CTFProjectile_TeleportGrenade : public CTFProjectile_Throwable
  262. {
  263. public:
  264. DECLARE_CLASS( CTFProjectile_TeleportGrenade, CTFProjectile_Throwable );
  265. DECLARE_NETWORKCLASS();
  266. #ifdef GAME_DLL
  267. virtual void Spawn( void ) OVERRIDE;
  268. #endif // GAME_DLL
  269. virtual void SetCustomPipebombModel( void ) OVERRIDE { return; }
  270. virtual float GetShakeAmplitude( void ) OVERRIDE { return 10.f; }
  271. virtual bool ExplodesOnHit() OVERRIDE { return true; }
  272. #ifdef GAME_DLL
  273. virtual void Explode( trace_t *pTrace, int bitsDamageType ) OVERRIDE;
  274. virtual float GetDamageRadius( void ) const OVERRIDE { return 5.f; }
  275. virtual const char *GetExplodeEffectParticle( void ) const OVERRIDE { return "mvm_soldier_shockwave"; }
  276. virtual const char *GetExplodeEffectSound(void ) const OVERRIDE { return "Weapon_Grenade_Teleport.Explode"; }
  277. void RecordPosThink( void );
  278. #endif // GAME_DLL
  279. private:
  280. #ifdef GAME_DLL
  281. CUtlVector< Vector > m_vecTrailingPos;
  282. #endif
  283. };
  284. // *************************************************************************************************************************
  285. class CTFProjectile_GravityGrenade : public CTFProjectile_Throwable
  286. {
  287. public:
  288. DECLARE_CLASS( CTFProjectile_GravityGrenade, CTFProjectile_Throwable );
  289. DECLARE_NETWORKCLASS();
  290. #ifdef GAME_DLL
  291. virtual void Spawn( void ) OVERRIDE;
  292. #endif // GAME_DLL
  293. virtual void SetCustomPipebombModel( void ) OVERRIDE { return; }
  294. virtual float GetShakeAmplitude( void ) OVERRIDE { return 10.f; }
  295. virtual bool ExplodesOnHit() OVERRIDE { return false; }
  296. #ifdef GAME_DLL
  297. virtual void OnHitWorld( void ) OVERRIDE;
  298. virtual float GetDamageRadius( void ) const OVERRIDE { return 200.f; }
  299. virtual const char *GetExplodeEffectParticle( void ) const OVERRIDE { return "mvm_soldier_shockwave"; }
  300. virtual const char *GetExplodeEffectSound(void ) const OVERRIDE { return "Weapon_Grenade_Concussion.Explode"; }
  301. private:
  302. void TrapThink( void );
  303. void PulseTrap( void );
  304. void PulseEffects( void );
  305. float m_flStartTime;
  306. float m_flNextPulseEffectTime;
  307. bool m_bHitWorld;
  308. #endif // GAME_DLL
  309. };
  310. // *************************************************************************************************************************
  311. class CTFProjectile_ThrowingKnife : public CTFProjectile_Throwable
  312. {
  313. public:
  314. DECLARE_CLASS( CTFProjectile_ThrowingKnife, CTFProjectile_Throwable );
  315. DECLARE_NETWORKCLASS();
  316. #ifdef STAGING_ONLY
  317. virtual void SetCustomPipebombModel() { SetModel( "models/workshop_partner/weapons/c_models/c_sd_cleaver/c_sd_cleaver.mdl" ); }
  318. #else
  319. virtual void SetCustomPipebombModel() { SetModel( "models/weapons/c_models/c_sd_cleaver/c_sd_cleaver.mdl" ); }
  320. #endif
  321. virtual bool ExplodesOnHit() { return false; }
  322. virtual float GetProjectileSpeed() { return 800.0f; }
  323. virtual float GetProjectileMaxSpeed() { return 2700.0f; }
  324. #ifdef GAME_DLL
  325. virtual int GetProjectileType( void ) const OVERRIDE { return TF_PROJECTILE_THROWING_KNIFE; }
  326. virtual void OnHit( CBaseEntity *pOther );
  327. virtual void Detonate(); // Timer based 'Explode' Just Remove
  328. virtual const AngularImpulse GetAngularImpulse( void ) { return AngularImpulse( 0, 500, 0 ); }
  329. virtual Vector GetVelocityVector( const Vector &vecForward, const Vector &vecRight, const Vector &vecUp, float flCharge );
  330. virtual float GetDamage() { return 10.0f; }
  331. virtual float GetBackHitDamage() { return RemapVal( m_flChargePercent, 0, 1, 35.0f, 60.0f ); } // x3 for crit
  332. virtual float GetDamageRadius() const { return 0.0f; }
  333. virtual const char *GetExplodeEffectParticle() const { return ""; }
  334. virtual const char *GetExplodeEffectSound() const { return ""; }
  335. #endif // GAME_DLL
  336. };
  337. // *************************************************************************************************************************
  338. class CTFProjectile_SmokeGrenade : public CTFProjectile_Throwable
  339. {
  340. public:
  341. DECLARE_CLASS( CTFProjectile_GravityGrenade, CTFProjectile_Throwable );
  342. DECLARE_NETWORKCLASS();
  343. #ifdef GAME_DLL
  344. virtual void Spawn( void ) OVERRIDE;
  345. #endif // GAME_DLL
  346. virtual void SetCustomPipebombModel( void ) OVERRIDE { return; }
  347. virtual bool ExplodesOnHit() OVERRIDE { return false; }
  348. #ifdef GAME_DLL
  349. virtual void OnHitWorld( void ) OVERRIDE;
  350. virtual float GetDamageRadius( void ) const OVERRIDE { return 220.f; }
  351. virtual const char *GetExplodeEffectSound(void ) const OVERRIDE { return "Weapon_Grenade_Concussion.Explode"; }
  352. private:
  353. void SmokeThink( void );
  354. float m_flStartTime;
  355. bool m_bHitWorld;
  356. #endif // GAME_DLL
  357. };
  358. #endif // STAGING_ONLY
  359. #endif // TF_WEAPON_THROWABLE_H