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.

125 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: CTF AmmoPack.
  4. //
  5. //=============================================================================//
  6. #ifndef ENTITY_AMMOPACK_H
  7. #define ENTITY_AMMOPACK_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_powerup.h"
  12. #include "tf_gamerules.h"
  13. #define TF_AMMOPACK_SMALL_BDAY "models/items/ammopack_small_bday.mdl"
  14. #define TF_AMMOPACK_MEDIUM_BDAY "models/items/ammopack_medium_bday.mdl"
  15. #define TF_AMMOPACK_LARGE_BDAY "models/items/ammopack_large_bday.mdl"
  16. //=============================================================================
  17. //
  18. // CTF AmmoPack class.
  19. //
  20. class CAmmoPack : public CTFPowerup
  21. {
  22. public:
  23. DECLARE_CLASS( CAmmoPack, CTFPowerup );
  24. void Spawn( void );
  25. virtual void Precache( void );
  26. bool MyTouch( CBasePlayer *pPlayer );
  27. powerupsize_t GetPowerupSize( void ) { return POWERUP_FULL; }
  28. virtual const char *GetAmmoPackName( void ) { return "ammopack_large"; }
  29. virtual void UpdateModelIndexOverrides( void )
  30. {
  31. if ( modelinfo )
  32. {
  33. SetModelIndexOverride( VISION_MODE_NONE, modelinfo->GetModelIndex( GetPowerupModel() ) );
  34. SetModelIndexOverride( VISION_MODE_PYRO, modelinfo->GetModelIndex( TF_AMMOPACK_LARGE_BDAY ) );
  35. }
  36. }
  37. virtual const char *GetDefaultPowerupModel( void )
  38. {
  39. if ( TFGameRules() && TFGameRules()->IsHolidayActive( kHoliday_TFBirthday ) )
  40. {
  41. return TF_AMMOPACK_LARGE_BDAY;
  42. }
  43. return "models/items/ammopack_large.mdl";
  44. }
  45. };
  46. class CAmmoPackSmall : public CAmmoPack
  47. {
  48. public:
  49. DECLARE_CLASS( CAmmoPackSmall, CAmmoPack );
  50. powerupsize_t GetPowerupSize( void ) { return POWERUP_SMALL; }
  51. virtual const char *GetAmmoPackName( void ) { return "ammopack_small"; }
  52. virtual void Precache( void )
  53. {
  54. PrecacheModel( TF_AMMOPACK_SMALL_BDAY ); // always precache this for PyroVision
  55. BaseClass::Precache();
  56. }
  57. virtual void UpdateModelIndexOverrides( void )
  58. {
  59. if ( modelinfo )
  60. {
  61. SetModelIndexOverride( VISION_MODE_NONE, modelinfo->GetModelIndex( GetPowerupModel() ) );
  62. SetModelIndexOverride( VISION_MODE_PYRO, modelinfo->GetModelIndex( TF_AMMOPACK_SMALL_BDAY ) );
  63. }
  64. }
  65. virtual const char *GetDefaultPowerupModel( void )
  66. {
  67. if ( TFGameRules() && TFGameRules()->IsHolidayActive( kHoliday_TFBirthday ) )
  68. {
  69. return TF_AMMOPACK_SMALL_BDAY;
  70. }
  71. return "models/items/ammopack_small.mdl";
  72. }
  73. };
  74. class CAmmoPackMedium : public CAmmoPack
  75. {
  76. public:
  77. DECLARE_CLASS( CAmmoPackMedium, CAmmoPack );
  78. powerupsize_t GetPowerupSize( void ) { return POWERUP_MEDIUM; }
  79. virtual const char *GetAmmoPackName( void ) { return "ammopack_medium"; }
  80. virtual void Precache( void )
  81. {
  82. PrecacheModel( TF_AMMOPACK_MEDIUM_BDAY ); // always precache this for PyroVision
  83. BaseClass::Precache();
  84. }
  85. virtual void UpdateModelIndexOverrides( void )
  86. {
  87. if ( modelinfo )
  88. {
  89. SetModelIndexOverride( VISION_MODE_NONE, modelinfo->GetModelIndex( GetPowerupModel() ) );
  90. SetModelIndexOverride( VISION_MODE_PYRO, modelinfo->GetModelIndex( TF_AMMOPACK_MEDIUM_BDAY ) );
  91. }
  92. }
  93. virtual const char *GetDefaultPowerupModel( void )
  94. {
  95. if ( TFGameRules() && TFGameRules()->IsHolidayActive( kHoliday_TFBirthday ) )
  96. {
  97. return TF_AMMOPACK_MEDIUM_BDAY;
  98. }
  99. return "models/items/ammopack_medium.mdl";
  100. }
  101. };
  102. #endif // ENTITY_AMMOPACK_H