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.

185 lines
5.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: CTF HealthKit.
  4. //
  5. //=============================================================================//
  6. #ifndef ENTITY_HEALTHKIT_H
  7. #define ENTITY_HEALTHKIT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_powerup.h"
  12. #include "tf_gamerules.h"
  13. #define TF_MEDKIT_SMALL_BDAY "models/items/medkit_small_bday.mdl"
  14. #define TF_MEDKIT_MEDIUM_BDAY "models/items/medkit_medium_bday.mdl"
  15. #define TF_MEDKIT_LARGE_BDAY "models/items/medkit_large_bday.mdl"
  16. #define TF_MEDKIT_SMALL_HALLOWEEN "models/props_halloween/halloween_medkit_small.mdl"
  17. #define TF_MEDKIT_MEDIUM_HALLOWEEN "models/props_halloween/halloween_medkit_medium.mdl"
  18. #define TF_MEDKIT_LARGE_HALLOWEEN "models/props_halloween/halloween_medkit_large.mdl"
  19. //=============================================================================
  20. //
  21. // CTF HealthKit class.
  22. //
  23. DECLARE_AUTO_LIST( IHealthKitAutoList );
  24. class CHealthKit : public CTFPowerup, public IHealthKitAutoList
  25. {
  26. public:
  27. DECLARE_CLASS( CHealthKit, CTFPowerup );
  28. void Spawn( void );
  29. virtual void Precache( void );
  30. virtual bool MyTouch( CBasePlayer *pPlayer );
  31. virtual void UpdateModelIndexOverrides( void )
  32. {
  33. if ( modelinfo )
  34. {
  35. SetModelIndexOverride( VISION_MODE_NONE, modelinfo->GetModelIndex( GetPowerupModel() ) );
  36. SetModelIndexOverride( VISION_MODE_PYRO, modelinfo->GetModelIndex( TF_MEDKIT_LARGE_BDAY ) );
  37. SetModelIndexOverride( VISION_MODE_HALLOWEEN, modelinfo->GetModelIndex( TF_MEDKIT_LARGE_HALLOWEEN ) );
  38. }
  39. }
  40. virtual const char *GetDefaultPowerupModel( void )
  41. {
  42. if ( TFGameRules() && TFGameRules()->IsHolidayActive( kHoliday_TFBirthday ) )
  43. {
  44. return TF_MEDKIT_LARGE_BDAY;
  45. }
  46. return "models/items/medkit_large.mdl";
  47. }
  48. powerupsize_t GetPowerupSize( void ) { return POWERUP_FULL; }
  49. virtual const char *GetHealthKitName( void ) { return "medkit_large"; }
  50. virtual float GetRespawnDelay( void );
  51. };
  52. class CHealthKitSmall : public CHealthKit
  53. {
  54. public:
  55. DECLARE_CLASS( CHealthKitSmall, CHealthKit );
  56. powerupsize_t GetPowerupSize( void ) { return POWERUP_SMALL; }
  57. virtual const char *GetHealthKitName( void ) { return "medkit_small"; }
  58. virtual void Precache( void )
  59. {
  60. PrecacheModel( TF_MEDKIT_SMALL_BDAY ); // always precache this for PyroVision
  61. PrecacheModel( TF_MEDKIT_SMALL_HALLOWEEN ); // always precache this for Halloween Vision
  62. BaseClass::Precache();
  63. }
  64. virtual void UpdateModelIndexOverrides( void )
  65. {
  66. if ( modelinfo )
  67. {
  68. SetModelIndexOverride( VISION_MODE_NONE, modelinfo->GetModelIndex( GetPowerupModel() ) );
  69. SetModelIndexOverride( VISION_MODE_PYRO, modelinfo->GetModelIndex( TF_MEDKIT_SMALL_BDAY ) );
  70. SetModelIndexOverride( VISION_MODE_HALLOWEEN, modelinfo->GetModelIndex( TF_MEDKIT_SMALL_HALLOWEEN ) );
  71. }
  72. }
  73. virtual const char *GetDefaultPowerupModel( void )
  74. {
  75. if ( TFGameRules() && TFGameRules()->IsHolidayActive( kHoliday_TFBirthday ) )
  76. {
  77. return TF_MEDKIT_SMALL_BDAY;
  78. }
  79. return "models/items/medkit_small.mdl";
  80. }
  81. };
  82. class CHealthKitMedium : public CHealthKit
  83. {
  84. public:
  85. DECLARE_CLASS( CHealthKitMedium, CHealthKit );
  86. powerupsize_t GetPowerupSize( void ) { return POWERUP_MEDIUM; }
  87. virtual const char *GetHealthKitName( void ) { return "medkit_medium"; }
  88. virtual void Precache( void )
  89. {
  90. PrecacheModel( TF_MEDKIT_MEDIUM_BDAY ); // always precache this for PyroVision
  91. PrecacheModel( TF_MEDKIT_MEDIUM_HALLOWEEN ); // always precache this for Halloween Vision
  92. BaseClass::Precache();
  93. }
  94. virtual void UpdateModelIndexOverrides( void )
  95. {
  96. if ( modelinfo )
  97. {
  98. SetModelIndexOverride( VISION_MODE_NONE, modelinfo->GetModelIndex( GetPowerupModel() ) );
  99. SetModelIndexOverride( VISION_MODE_PYRO, modelinfo->GetModelIndex( TF_MEDKIT_MEDIUM_BDAY ) );
  100. SetModelIndexOverride( VISION_MODE_HALLOWEEN, modelinfo->GetModelIndex( TF_MEDKIT_MEDIUM_HALLOWEEN ) );
  101. }
  102. }
  103. virtual const char *GetDefaultPowerupModel( void )
  104. {
  105. if ( TFGameRules() && TFGameRules()->IsHolidayActive( kHoliday_TFBirthday ) )
  106. {
  107. return TF_MEDKIT_MEDIUM_BDAY;
  108. }
  109. return "models/items/medkit_medium.mdl";
  110. }
  111. };
  112. //=============================================================================
  113. //
  114. // CTF HealthAmmoKit class. Combo health and ammo kit.
  115. //
  116. // In choosing whether to derive from HealthKit, AmmoPack, or neither, it seemed
  117. // like there was more special behavior for health kits that we want to inherit (in particular
  118. // considering a Heavy's sandvich to be a health kit) than ammo kit behavior. Deriving from
  119. // health kit created the minimum code churn.
  120. //
  121. class CHealthAmmoKit : public CHealthKit
  122. {
  123. public:
  124. DECLARE_CLASS( CHealthAmmoKit, CHealthKit );
  125. powerupsize_t GetPowerupSize( void ) { return POWERUP_SMALL; }
  126. virtual const char *GetHealthKitName( void ) { return "healthammokit"; }
  127. virtual bool MyTouch( CBasePlayer *pPlayer );
  128. virtual void Precache( void )
  129. {
  130. PrecacheModel( TF_MEDKIT_MEDIUM_BDAY ); // always precache this for PyroVision
  131. PrecacheModel( TF_MEDKIT_MEDIUM_HALLOWEEN ); // always precache this for Halloween Vision
  132. BaseClass::Precache();
  133. }
  134. virtual void UpdateModelIndexOverrides( void )
  135. {
  136. if ( modelinfo )
  137. {
  138. SetModelIndexOverride( VISION_MODE_NONE, modelinfo->GetModelIndex( GetPowerupModel() ) );
  139. SetModelIndexOverride( VISION_MODE_PYRO, modelinfo->GetModelIndex( TF_MEDKIT_MEDIUM_BDAY ) );
  140. SetModelIndexOverride( VISION_MODE_HALLOWEEN, modelinfo->GetModelIndex( TF_MEDKIT_MEDIUM_HALLOWEEN ) );
  141. }
  142. }
  143. virtual const char *GetDefaultPowerupModel( void )
  144. {
  145. if ( TFGameRules() && TFGameRules()->IsHolidayActive( kHoliday_TFBirthday ) )
  146. {
  147. return TF_MEDKIT_MEDIUM_BDAY;
  148. }
  149. return "models/items/medkit_medium.mdl";
  150. }
  151. };
  152. #endif // ENTITY_HEALTHKIT_H