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.

141 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // TF Base Projectile
  4. //
  5. //=============================================================================
  6. #ifndef TF_BASE_PROJECTILE_H
  7. #define TF_BASE_PROJECTILE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "cbase.h"
  12. #include "tf_shareddefs.h"
  13. #include "baseprojectile.h"
  14. // Client specific.
  15. #ifdef CLIENT_DLL
  16. #include "tempent.h"
  17. // Server specific.
  18. #else
  19. #include "iscorer.h"
  20. #endif
  21. #ifdef CLIENT_DLL
  22. #define CTFBaseProjectile C_TFBaseProjectile
  23. C_LocalTempEntity *ClientsideProjectileCallback( const CEffectData &data, float flGravityBase, const char *pszParticleName = NULL );
  24. #endif
  25. /*
  26. CBaseProjectile
  27. |- CTFBaseProjectile
  28. |- CTFProjectile_Nail
  29. |- CTFProjectile_Dart
  30. |- CTFProjectile_Syringe
  31. |- CTFProjectile_EnergyRing
  32. |- CTFBaseRocket
  33. |- Soldier rocket
  34. |- Pyro rocket
  35. |- CTFProjectile_Flare
  36. |- CTFProjectile_Arrow
  37. |- CBaseGrenade
  38. |- CTFWeaponBaseGrenadeProj
  39. |- CTFGrenadePipebombProjectile
  40. */
  41. //=============================================================================
  42. //
  43. // Generic projectile
  44. //
  45. class CTFBaseProjectile : public CBaseProjectile
  46. #if !defined( CLIENT_DLL )
  47. , public IScorer
  48. #endif
  49. {
  50. public:
  51. DECLARE_CLASS( CTFBaseProjectile, CBaseProjectile );
  52. DECLARE_NETWORKCLASS();
  53. CTFBaseProjectile();
  54. ~CTFBaseProjectile();
  55. void Precache( void );
  56. void Spawn( void );
  57. virtual int GetWeaponID( void ) const { return m_iWeaponID; }
  58. void SetWeaponID( int iID ) { m_iWeaponID = iID; }
  59. bool IsCritical( void ) const { return m_bCritical; }
  60. virtual void SetCritical( bool bCritical ) { m_bCritical = bCritical; }
  61. CBaseEntity *GetLauncher( void ) { return m_hLauncher; }
  62. private:
  63. int m_iWeaponID;
  64. bool m_bCritical;
  65. protected:
  66. // Networked.
  67. CNetworkVector( m_vInitialVelocity );
  68. static CTFBaseProjectile *Create( const char *pszClassname, const Vector &vecOrigin,
  69. const QAngle &vecAngles, CBaseEntity *pOwner, float flVelocity, short iProjModelIndex, const char *pszDispatchEffect = NULL, CBaseEntity *pScorer = NULL, bool bCritical = false, Vector vColor1=vec3_origin, Vector vColor2=vec3_origin );
  70. virtual const char *GetProjectileModelName( void );
  71. virtual float GetGravity( void ) { return 0.001f; }
  72. #ifdef CLIENT_DLL
  73. public:
  74. virtual int DrawModel( int flags );
  75. virtual void PostDataUpdate( DataUpdateType_t type );
  76. private:
  77. float m_flSpawnTime;
  78. #else
  79. public:
  80. DECLARE_DATADESC();
  81. // IScorer interface
  82. virtual CBasePlayer *GetScorer( void );
  83. virtual CBasePlayer *GetAssistant( void ) { return NULL; }
  84. void SetScorer( CBaseEntity *pScorer );
  85. virtual void ProjectileTouch( CBaseEntity *pOther );
  86. virtual int GetProjectileType ( void ) { return TF_PROJECTILE_NONE; } // Default unset
  87. virtual float GetDamage() { return m_flDamage; }
  88. virtual void SetDamage(float flDamage) { m_flDamage = flDamage; }
  89. virtual Vector GetDamageForce( void );
  90. virtual int GetDamageType( void );
  91. virtual unsigned int PhysicsSolidMaskForEntity( void ) const OVERRIDE;
  92. void SetupInitialTransmittedGrenadeVelocity( const Vector &velocity ) { m_vInitialVelocity = velocity; }
  93. virtual void SetLauncher( CBaseEntity *pLauncher ) OVERRIDE { m_hLauncher = pLauncher; BaseClass::SetLauncher( pLauncher ); }
  94. protected:
  95. void FlyThink( void );
  96. protected:
  97. float m_flDamage;
  98. CBaseHandle m_Scorer;
  99. #endif // ndef CLIENT_DLL
  100. protected:
  101. CNetworkHandle( CBaseEntity, m_hLauncher );
  102. };
  103. #endif //TF_BASE_PROJECTILE_H