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.

267 lines
7.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef WEAPON_RPG_H
  8. #define WEAPON_RPG_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "weapon_hl2mpbasehlmpcombatweapon.h"
  13. #ifdef CLIENT_DLL
  14. #include "iviewrender_beams.h"
  15. #endif
  16. #ifndef CLIENT_DLL
  17. #include "Sprite.h"
  18. #include "npcevent.h"
  19. #include "beam_shared.h"
  20. class CWeaponRPG;
  21. class CLaserDot;
  22. class RocketTrail;
  23. //###########################################################################
  24. // >> CMissile (missile launcher class is below this one!)
  25. //###########################################################################
  26. class CMissile : public CBaseCombatCharacter
  27. {
  28. DECLARE_CLASS( CMissile, CBaseCombatCharacter );
  29. public:
  30. CMissile();
  31. ~CMissile();
  32. #ifdef HL1_DLL
  33. Class_T Classify( void ) { return CLASS_NONE; }
  34. #else
  35. Class_T Classify( void ) { return CLASS_MISSILE; }
  36. #endif
  37. void Spawn( void );
  38. void Precache( void );
  39. void MissileTouch( CBaseEntity *pOther );
  40. void Explode( void );
  41. void ShotDown( void );
  42. void AccelerateThink( void );
  43. void AugerThink( void );
  44. void IgniteThink( void );
  45. void SeekThink( void );
  46. void DumbFire( void );
  47. void SetGracePeriod( float flGracePeriod );
  48. int OnTakeDamage_Alive( const CTakeDamageInfo &info );
  49. void Event_Killed( const CTakeDamageInfo &info );
  50. virtual float GetDamage() { return m_flDamage; }
  51. virtual void SetDamage(float flDamage) { m_flDamage = flDamage; }
  52. unsigned int PhysicsSolidMaskForEntity( void ) const;
  53. CHandle<CWeaponRPG> m_hOwner;
  54. static CMissile *Create( const Vector &vecOrigin, const QAngle &vecAngles, edict_t *pentOwner );
  55. protected:
  56. virtual void DoExplosion();
  57. virtual void ComputeActualDotPosition( CLaserDot *pLaserDot, Vector *pActualDotPosition, float *pHomingSpeed );
  58. virtual int AugerHealth() { return m_iMaxHealth - 20; }
  59. // Creates the smoke trail
  60. void CreateSmokeTrail( void );
  61. // Gets the shooting position
  62. void GetShootPosition( CLaserDot *pLaserDot, Vector *pShootPosition );
  63. CHandle<RocketTrail> m_hRocketTrail;
  64. float m_flAugerTime; // Amount of time to auger before blowing up anyway
  65. float m_flMarkDeadTime;
  66. float m_flDamage;
  67. private:
  68. float m_flGracePeriodEndsAt;
  69. DECLARE_DATADESC();
  70. };
  71. //-----------------------------------------------------------------------------
  72. // Laser dot control
  73. //-----------------------------------------------------------------------------
  74. CBaseEntity *CreateLaserDot( const Vector &origin, CBaseEntity *pOwner, bool bVisibleDot );
  75. void SetLaserDotTarget( CBaseEntity *pLaserDot, CBaseEntity *pTarget );
  76. void EnableLaserDot( CBaseEntity *pLaserDot, bool bEnable );
  77. //-----------------------------------------------------------------------------
  78. // Specialized mizzizzile
  79. //-----------------------------------------------------------------------------
  80. class CAPCMissile : public CMissile
  81. {
  82. DECLARE_CLASS( CMissile, CMissile );
  83. DECLARE_DATADESC();
  84. public:
  85. static CAPCMissile *Create( const Vector &vecOrigin, const QAngle &vecAngles, const Vector &vecVelocity, CBaseEntity *pOwner );
  86. CAPCMissile();
  87. ~CAPCMissile();
  88. void IgniteDelay( void );
  89. void AugerDelay( float flDelayTime );
  90. void ExplodeDelay( float flDelayTime );
  91. void DisableGuiding();
  92. #if defined( HL2_DLL )
  93. virtual Class_T Classify ( void ) { return CLASS_COMBINE; }
  94. #endif
  95. void AimAtSpecificTarget( CBaseEntity *pTarget );
  96. void SetGuidanceHint( const char *pHintName );
  97. CAPCMissile *m_pNext;
  98. protected:
  99. virtual void DoExplosion();
  100. virtual void ComputeActualDotPosition( CLaserDot *pLaserDot, Vector *pActualDotPosition, float *pHomingSpeed );
  101. virtual int AugerHealth();
  102. private:
  103. void Init();
  104. void ComputeLeadingPosition( const Vector &vecShootPosition, CBaseEntity *pTarget, Vector *pLeadPosition );
  105. void BeginSeekThink();
  106. void AugerStartThink();
  107. void ExplodeThink();
  108. void APCMissileTouch( CBaseEntity *pOther );
  109. float m_flReachedTargetTime;
  110. float m_flIgnitionTime;
  111. bool m_bGuidingDisabled;
  112. float m_flLastHomingSpeed;
  113. EHANDLE m_hSpecificTarget;
  114. string_t m_strHint;
  115. };
  116. //-----------------------------------------------------------------------------
  117. // Finds apc missiles in cone
  118. //-----------------------------------------------------------------------------
  119. CAPCMissile *FindAPCMissileInCone( const Vector &vecOrigin, const Vector &vecDirection, float flAngle );
  120. #endif
  121. //-----------------------------------------------------------------------------
  122. // RPG
  123. //-----------------------------------------------------------------------------
  124. #ifdef CLIENT_DLL
  125. #define CWeaponRPG C_WeaponRPG
  126. #endif
  127. class CWeaponRPG : public CBaseHL2MPCombatWeapon
  128. {
  129. DECLARE_CLASS( CWeaponRPG, CBaseHL2MPCombatWeapon );
  130. public:
  131. CWeaponRPG();
  132. ~CWeaponRPG();
  133. DECLARE_NETWORKCLASS();
  134. DECLARE_PREDICTABLE();
  135. void Precache( void );
  136. void PrimaryAttack( void );
  137. virtual float GetFireRate( void ) { return 1; };
  138. void ItemPostFrame( void );
  139. void Activate( void );
  140. void DecrementAmmo( CBaseCombatCharacter *pOwner );
  141. bool Deploy( void );
  142. bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL );
  143. bool Reload( void );
  144. bool WeaponShouldBeLowered( void );
  145. bool Lower( void );
  146. bool CanHolster( void );
  147. virtual void Drop( const Vector &vecVelocity );
  148. int GetMinBurst() { return 1; }
  149. int GetMaxBurst() { return 1; }
  150. float GetMinRestTime() { return 4.0; }
  151. float GetMaxRestTime() { return 4.0; }
  152. void StartGuiding( void );
  153. void StopGuiding( void );
  154. void ToggleGuiding( void );
  155. bool IsGuiding( void );
  156. void NotifyRocketDied( void );
  157. bool HasAnyAmmo( void );
  158. void SuppressGuiding( bool state = true );
  159. void CreateLaserPointer( void );
  160. void UpdateLaserPosition( Vector vecMuzzlePos = vec3_origin, Vector vecEndPos = vec3_origin );
  161. Vector GetLaserPosition( void );
  162. // NPC RPG users cheat and directly set the laser pointer's origin
  163. void UpdateNPCLaserPosition( const Vector &vecTarget );
  164. void SetNPCLaserPosition( const Vector &vecTarget );
  165. const Vector &GetNPCLaserPosition( void );
  166. #ifdef CLIENT_DLL
  167. // We need to render opaque and translucent pieces
  168. virtual RenderGroup_t GetRenderGroup( void ) { return RENDER_GROUP_TWOPASS; }
  169. virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
  170. virtual int DrawModel( int flags );
  171. virtual void ViewModelDrawn( C_BaseViewModel *pBaseViewModel );
  172. virtual bool IsTranslucent( void );
  173. void InitBeam( void );
  174. void GetWeaponAttachment( int attachmentId, Vector &outVector, Vector *dir = NULL );
  175. void DrawEffects( void );
  176. // void DrawLaserDot( void );
  177. CMaterialReference m_hSpriteMaterial; // Used for the laser glint
  178. CMaterialReference m_hBeamMaterial; // Used for the laser beam
  179. Beam_t *m_pBeam; // Laser beam temp entity
  180. #endif //CLIENT_DLL
  181. CBaseEntity *GetMissile( void ) { return m_hMissile; }
  182. #ifndef CLIENT_DLL
  183. DECLARE_ACTTABLE();
  184. #endif
  185. protected:
  186. CNetworkVar( bool, m_bInitialStateUpdate );
  187. CNetworkVar( bool, m_bGuiding );
  188. CNetworkVar( bool, m_bHideGuiding );
  189. CNetworkHandle( CBaseEntity, m_hMissile );
  190. CNetworkVar( Vector, m_vecLaserDot );
  191. #ifndef CLIENT_DLL
  192. CHandle<CLaserDot> m_hLaserDot;
  193. #endif
  194. private:
  195. CWeaponRPG( const CWeaponRPG & );
  196. };
  197. #endif // WEAPON_RPG_H