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.

210 lines
5.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: CTF Powerup Rune.
  4. //
  5. //=============================================================================//
  6. #ifndef ENTITY_RUNE_H
  7. #define ENTITY_RUNE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_powerup.h"
  12. #include "tf_gamerules.h"
  13. #define TF_RUNE_STRENGTH "models/pickups/pickup_powerup_strength.mdl"
  14. #define TF_RUNE_RESIST "models/pickups/pickup_powerup_defense.mdl"
  15. #define TF_RUNE_REGEN "models/pickups/pickup_powerup_regen.mdl"
  16. #define TF_RUNE_HASTE "models/pickups/pickup_powerup_haste.mdl"
  17. #define TF_RUNE_VAMPIRE "models/pickups/pickup_powerup_vampire.mdl"
  18. #define TF_RUNE_REFLECT "models/pickups/pickup_powerup_reflect.mdl"
  19. #define TF_RUNE_PRECISION "models/pickups/pickup_powerup_precision.mdl"
  20. #define TF_RUNE_AGILITY "models/pickups/pickup_powerup_agility.mdl"
  21. #define TF_RUNE_KNOCKOUT "models/pickups/pickup_powerup_knockout.mdl"
  22. #define TF_RUNE_KING "models/pickups/pickup_powerup_king.mdl"
  23. #define TF_RUNE_PLAGUE "models/pickups/pickup_powerup_plague.mdl"
  24. #define TF_RUNE_SUPERNOVA "models/pickups/pickup_powerup_supernova.mdl"
  25. #define TF_RUNE_TEMP_CRIT "models/pickups/pickup_powerup_crit.mdl"
  26. #define TF_RUNE_TEMP_UBER "models/pickups/pickup_powerup_uber.mdl"
  27. DECLARE_AUTO_LIST( IInfoPowerupSpawnAutoList );
  28. //=============================================================================
  29. //
  30. // CTF Rune class. Powerups which last the life of the player and drop when they die
  31. //
  32. //=============================================================================
  33. class CTFRune : public CTFPowerup
  34. {
  35. public:
  36. DECLARE_CLASS( CTFRune, CTFPowerup );
  37. CTFRune();
  38. ~CTFRune();
  39. virtual void Spawn( void ) OVERRIDE;
  40. virtual void Precache( void ) OVERRIDE;
  41. virtual bool MyTouch( CBasePlayer *pPlayer );
  42. static CTFRune* CreateRune( const Vector &vecOrigin, RuneTypes_t nType, int nTeam, bool bShouldReposition, bool bApplyForce, Vector vecSpawnDirection = vec3_origin );
  43. static bool RepositionRune( RuneTypes_t nType, int nTeamNumber );
  44. float GetRuneRepositionTime( void );
  45. virtual const char *GetDefaultPowerupModel( void )
  46. {
  47. if ( m_nRuneType == RUNE_STRENGTH )
  48. {
  49. return TF_RUNE_STRENGTH;
  50. }
  51. else if ( m_nRuneType == RUNE_RESIST )
  52. {
  53. return TF_RUNE_RESIST;
  54. }
  55. else if ( m_nRuneType == RUNE_REGEN )
  56. {
  57. return TF_RUNE_REGEN;
  58. }
  59. else if ( m_nRuneType == RUNE_HASTE )
  60. {
  61. return TF_RUNE_HASTE;
  62. }
  63. else if ( m_nRuneType == RUNE_VAMPIRE )
  64. {
  65. return TF_RUNE_VAMPIRE;
  66. }
  67. else if ( m_nRuneType == RUNE_REFLECT )
  68. {
  69. return TF_RUNE_REFLECT;
  70. }
  71. else if ( m_nRuneType == RUNE_PRECISION )
  72. {
  73. return TF_RUNE_PRECISION;
  74. }
  75. else if ( m_nRuneType == RUNE_AGILITY )
  76. {
  77. return TF_RUNE_AGILITY;
  78. }
  79. else if ( m_nRuneType == RUNE_KNOCKOUT )
  80. {
  81. return TF_RUNE_KNOCKOUT;
  82. }
  83. else if ( m_nRuneType == RUNE_KING )
  84. {
  85. return TF_RUNE_KING;
  86. }
  87. else if ( m_nRuneType == RUNE_PLAGUE )
  88. {
  89. return TF_RUNE_PLAGUE;
  90. }
  91. else if ( m_nRuneType == RUNE_SUPERNOVA )
  92. {
  93. return TF_RUNE_SUPERNOVA;
  94. }
  95. return TF_RUNE_STRENGTH;
  96. }
  97. virtual int UpdateTransmitState( void ) OVERRIDE;
  98. virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo ) OVERRIDE;
  99. protected:
  100. bool m_bApplyForce;
  101. virtual void ComeToRest( void );
  102. Vector m_vecSpawnDirection;
  103. private:
  104. void BlinkThink();
  105. RuneTypes_t m_nRuneType;
  106. int m_nBlinkCount;
  107. float m_flKillTime;
  108. float m_flCanPickupTime;
  109. int m_nTeam;
  110. bool m_bShouldReposition;
  111. };
  112. //=============================================================================
  113. //
  114. // CTF Rune Temp class - Powerups whose effect lasts a length of time, then deactivates
  115. //
  116. //=============================================================================
  117. class CTFRuneTemp : public CTFPowerup
  118. {
  119. public:
  120. DECLARE_CLASS( CTFRuneTemp, CTFPowerup );
  121. CTFRuneTemp();
  122. virtual void Spawn( void ) OVERRIDE;
  123. virtual void Precache( void ) OVERRIDE;
  124. virtual bool MyTouch( CBasePlayer *pPlayer ) OVERRIDE;
  125. virtual const char *GetDefaultPowerupModel( void ) OVERRIDE { return TF_RUNE_TEMP_CRIT; }
  126. virtual float GetRespawnDelay( void ) OVERRIDE;
  127. protected:
  128. void TempRuneRespawnThink( void );
  129. int m_nRuneTempType;
  130. };
  131. //=============================================================================
  132. //
  133. // Temporary Crit boost
  134. //
  135. //=============================================================================
  136. class CTFRuneTempCrit : public CTFRuneTemp
  137. {
  138. public:
  139. DECLARE_CLASS( CTFRuneTempCrit, CTFRuneTemp );
  140. CTFRuneTempCrit();
  141. };
  142. //=============================================================================
  143. //
  144. // Temporary Uber boost
  145. //
  146. //=============================================================================
  147. class CTFRuneTempUber : public CTFRuneTemp
  148. {
  149. public:
  150. DECLARE_CLASS( CTFRuneTempUber, CTFRuneTemp );
  151. CTFRuneTempUber();
  152. virtual const char *GetDefaultPowerupModel( void ) OVERRIDE { return TF_RUNE_TEMP_UBER; }
  153. };
  154. //=============================================================================
  155. //
  156. // Powerup Spawn point class - location to spawn a powerup at
  157. //
  158. //=============================================================================
  159. class CTFInfoPowerupSpawn : public CPointEntity, public IInfoPowerupSpawnAutoList
  160. {
  161. public:
  162. DECLARE_CLASS( CTFInfoPowerupSpawn, CPointEntity );
  163. CTFInfoPowerupSpawn();
  164. DECLARE_DATADESC();
  165. virtual void Spawn() OVERRIDE;
  166. bool IsDisabled() const { return m_bDisabled; }
  167. bool HasRune() const { return m_hRune != NULL; }
  168. void SetRune( CTFRune *pRune ) { m_hRune = pRune; }
  169. private:
  170. bool m_bDisabled;
  171. int m_nTeam;
  172. CHandle< CTFRune > m_hRune;
  173. };
  174. #endif // ENTITY_RUNE_H