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.

231 lines
6.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: CTF Halloween Pickup.
  4. //
  5. //=============================================================================//
  6. #ifndef ENTITY_HALLOWEEN_PICKUP_H
  7. #define ENTITY_HALLOWEEN_PICKUP_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #ifdef GAME_DLL
  12. #include "tf_powerup.h"
  13. #include "tf_gamerules.h"
  14. #include "tf_player.h"
  15. #endif
  16. #include "ehandle.h"
  17. #define TF_HALLOWEEN_PICKUP_MODEL "models/items/target_duck.mdl"
  18. #define TF_DUCK_PICKUP_MODEL "models/workshop/player/items/pyro/eotl_ducky/eotl_bonus_duck.mdl"
  19. #define TF_GIFT_MODEL "models/props_halloween/gargoyle_ghost.mdl"; //"models/props_halloween/halloween_gift.mdl";
  20. #define TF_HALLOWEEN_PICKUP_DEFAULT_SOUND "AmmoPack.Touch"
  21. #define BONUS_DUCK_GLOW "superrare_beams1"
  22. #define BONUS_DUCK_TRAIL_RED "duck_collect_trail_red"
  23. #define BONUS_DUCK_TRAIL_BLUE "duck_collect_trail_blue"
  24. #define BONUS_DUCK_TRAIL_SPECIAL_RED "duck_collect_trail_special_red"
  25. #define BONUS_DUCK_TRAIL_SPECIAL_BLUE "duck_collect_trail_special_blue"
  26. #define BONUS_DUCK_CREATED_SOUND "Duck.Quack"
  27. #ifdef CLIENT_DLL
  28. #define CBonusDuckPickup C_BonusDuckPickup
  29. #define CHalloweenPickup C_HalloweenPickup
  30. #define CHalloweenGiftPickup C_HalloweenGiftPickup
  31. #include "c_tf_player.h"
  32. #endif
  33. //=============================================================================
  34. //
  35. // CTF Halloween Pickup class.
  36. //
  37. class CHalloweenPickup
  38. #ifdef GAME_DLL
  39. : public CTFPowerup
  40. #else
  41. : public C_BaseAnimating
  42. #endif
  43. {
  44. public:
  45. #ifdef GAME_DLL
  46. DECLARE_CLASS( CHalloweenPickup, CTFPowerup );
  47. #else
  48. DECLARE_CLASS( CHalloweenPickup, C_BaseAnimating );
  49. #endif
  50. DECLARE_NETWORKCLASS();
  51. CHalloweenPickup();
  52. ~CHalloweenPickup();
  53. virtual void Precache( void ) OVERRIDE;
  54. #ifdef GAME_DLL
  55. virtual int UpdateTransmitState() OVERRIDE;
  56. virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo ) OVERRIDE;
  57. virtual bool ValidTouch( CBasePlayer *pPlayer ) OVERRIDE;
  58. virtual bool MyTouch( CBasePlayer *pPlayer ) OVERRIDE;
  59. virtual CBaseEntity* Respawn( void );
  60. virtual const char *GetDefaultPowerupModel( void ) OVERRIDE
  61. {
  62. return TF_HALLOWEEN_PICKUP_MODEL;
  63. }
  64. virtual float GetRespawnDelay( void ) OVERRIDE;
  65. virtual bool ItemCanBeTouchedByPlayer( CBasePlayer *pPlayer );
  66. #endif // GAME_DLL
  67. private:
  68. string_t m_iszSound;
  69. string_t m_iszParticle;
  70. #ifdef GAME_DLL
  71. COutputEvent m_OnRedPickup;
  72. COutputEvent m_OnBluePickup;
  73. #endif
  74. DECLARE_DATADESC();
  75. };
  76. class CBonusDuckPickup : public CHalloweenPickup
  77. {
  78. public:
  79. DECLARE_CLASS( CBonusDuckPickup, CHalloweenPickup );
  80. DECLARE_NETWORKCLASS();
  81. CBonusDuckPickup();
  82. ~CBonusDuckPickup();
  83. virtual void Precache( void ) OVERRIDE;
  84. #ifdef GAME_DLL
  85. virtual const char *GetDefaultPowerupModel( void ) OVERRIDE
  86. {
  87. return TF_DUCK_PICKUP_MODEL;
  88. }
  89. virtual float GetLifeTime() { if ( m_flLifeTime == 0) { m_flLifeTime = RandomFloat( 17.0f, 20.0f ); } return m_flLifeTime; }
  90. virtual bool ValidTouch( CBasePlayer *pPlayer ) OVERRIDE;
  91. void Spawn( void );
  92. virtual bool MyTouch( CBasePlayer *pPlayer ) OVERRIDE;
  93. void DropSingleInstance( Vector &vecLaunchVel, CBaseCombatCharacter *pThrower, float flThrowerTouchDelay, float flResetTime = 0.1f );
  94. void NotifyFadeOut( void );
  95. void UpdateCollisionBounds();
  96. // Make this a base class in powerup
  97. void BlinkThink();
  98. void SetCreatorId( int value ) { m_iCreatorId = value; }
  99. int GetCreatorId( void ) { return m_iCreatorId; }
  100. void SetAssisterId( int value ) { m_iAssisterId = value; }
  101. int GetAssisterId( void ) { return m_iAssisterId; }
  102. void SetVictimId( int value ) { m_iVictimId = value; }
  103. int GetVictimId( void ) { return m_iVictimId; }
  104. void SetSpecial( void ){ m_bSpecial = true; }
  105. void SetDuckFlag( int iFlag ) { m_iFlags |= iFlag; }
  106. #else
  107. virtual void OnDataChanged( DataUpdateType_t updateType ) OVERRIDE;
  108. #endif // GAME_DLL
  109. private:
  110. string_t m_iszSound;
  111. string_t m_iszParticle;
  112. #ifdef GAME_DLL
  113. float m_flLifeTime;
  114. float m_flKillTime;
  115. int m_nBlinkCount;
  116. int m_iCreatorId;
  117. int m_iAssisterId;
  118. int m_iVictimId;
  119. int m_iFlags;
  120. #else
  121. CNewParticleEffect *pGlowEffect;
  122. #endif
  123. CNetworkVar( bool, m_bSpecial );
  124. DECLARE_DATADESC();
  125. };
  126. #ifdef GAME_DLL
  127. //----------------------------------------------------------------------------
  128. DECLARE_AUTO_LIST( IHalloweenGiftSpawnAutoList );
  129. //*************************************************************************************************
  130. // Dumb entity that is placed in Hammer.
  131. // On Map load, server finds all the locations and makes note then deletes the entity
  132. class CHalloweenGiftSpawnLocation : public CBaseEntity, public IHalloweenGiftSpawnAutoList
  133. {
  134. public:
  135. DECLARE_CLASS( CHalloweenGiftSpawnLocation, CBaseEntity );
  136. CHalloweenGiftSpawnLocation();
  137. };
  138. #endif // GAME_DLL
  139. //*************************************************************************************************
  140. // Networked Entity that represents a gift. Only visible and 'touchable' by the intended target
  141. // Has a lifetime
  142. // A server can spawn multiple of these for different people or the same person but each gift has a single target
  143. class CHalloweenGiftPickup : public CHalloweenPickup
  144. {
  145. public:
  146. DECLARE_CLASS( CHalloweenGiftPickup, CHalloweenPickup );
  147. DECLARE_NETWORKCLASS();
  148. CHalloweenGiftPickup();
  149. //~CHalloweenGiftPickup();
  150. virtual void Precache( void ) OVERRIDE;
  151. void Spawn( void );
  152. #ifdef GAME_DLL
  153. void SetTargetPlayer( CTFPlayer *pTarget ); // Must be called before spawn
  154. void DespawnGift();
  155. void RemoveGift();
  156. virtual const char *GetDefaultPowerupModel( void ) OVERRIDE
  157. {
  158. return TF_GIFT_MODEL;
  159. }
  160. //virtual float GetLifeTime() { if ( m_flLifeTime == 0 ) { m_flLifeTime = RandomFloat( 17.0f, 20.0f ); } return m_flLifeTime; }
  161. virtual bool ValidTouch( CBasePlayer *pPlayer ) OVERRIDE;
  162. virtual bool MyTouch( CBasePlayer *pPlayer ) OVERRIDE;
  163. #endif
  164. #ifdef CLIENT_DLL
  165. virtual bool ShouldDraw();
  166. virtual void OnDataChanged( DataUpdateType_t updateType ) OVERRIDE;
  167. CTFPlayer *m_pPreviousTargetPlayer;
  168. #endif
  169. CNetworkVar( CHandle<CTFPlayer>, m_hTargetPlayer );
  170. DECLARE_DATADESC();
  171. };
  172. //*************************************************************************************************
  173. #endif // ENTITY_HALLOWEEN_PICKUP_H