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.

285 lines
7.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Entities for use in the Robot Destruction TF2 game mode.
  4. //
  5. //=========================================================================//
  6. #ifndef TF_LOGIC_HALLOWEEN_2014_H
  7. #define TF_LOGIC_HALLOWEEN_2014_H
  8. #include "cbase.h"
  9. #include "tf_shareddefs.h"
  10. #ifdef GAME_DLL
  11. #include "tf_player.h"
  12. #else
  13. #include "c_tf_player.h"
  14. #endif
  15. #ifdef CLIENT_DLL
  16. #define CTFMinigameLogic C_TFMinigameLogic
  17. #define CTFMiniGame C_TFMiniGame
  18. #define CTFHalloweenMinigame C_TFHalloweenMinigame
  19. #define CTFHalloweenMinigame_FallingPlatforms C_TFHalloweenMinigame_FallingPlatforms
  20. #endif
  21. #define MINIGAME_INVALID -1
  22. DECLARE_AUTO_LIST( IMinigameAutoList );
  23. class CTFMiniGame : public CBaseEntity
  24. #ifdef GAME_DLL
  25. , public CGameEventListener
  26. #endif
  27. , public IMinigameAutoList
  28. {
  29. public:
  30. enum EScoringType
  31. {
  32. SCORING_TYPE_POINTS = 0,
  33. SCORING_TYPE_PLAYERS_ALIVE,
  34. NUM_SCORING_TYPES
  35. };
  36. enum EMinigameType
  37. {
  38. MINIGAME_GENERIC = 0,
  39. MINIGAME_HALLOWEEN2014_COLLECTION,
  40. MINIGAME_HALLOWEEN2014_PLATFORMS,
  41. MINIGAME_HALLOWEEN2014_SOCCER,
  42. // don't change the order of these first three types because the TF_HALLOWEEN_DOOMSDAY_WIN_MINIROUNDS achievement depends on it
  43. NUM_MINIGAME_TYPES
  44. };
  45. DECLARE_CLASS( CTFMiniGame, CBaseEntity )
  46. DECLARE_NETWORKCLASS();
  47. #ifdef GAME_DLL
  48. DECLARE_DATADESC();
  49. #endif
  50. CTFMiniGame();
  51. #ifdef GAME_DLL
  52. virtual void Spawn() OVERRIDE;
  53. virtual void Precache() OVERRIDE;
  54. virtual void FireGameEvent( IGameEvent * event ) OVERRIDE;
  55. virtual int UpdateTransmitState() OVERRIDE { return SetTransmitState( FL_EDICT_ALWAYS ); }
  56. void InputScoreTeamRed( inputdata_t &inputdata );
  57. void InputScoreTeamBlue( inputdata_t &inputdata );
  58. void InputChangeHudResFile( inputdata_t &inputdata );
  59. virtual void ScorePointsForTeam( int nTeamNum, int nPoints );
  60. virtual void TeleportAllPlayers();
  61. virtual void OnTeleportPlayerToMinigame( CTFPlayer *pPlayer );
  62. virtual void ReturnAllPlayers();
  63. const char *GetTeamSpawnPointName( int nTeamNum ) const;
  64. const bool AllowedInRandom() const { return m_bMinigameAllowedInRamdomPool; }
  65. virtual void UpdateDeadPlayers( int nTeam, COutputEvent& eventWin, COutputEvent& eventAllDead, bool& bCanWin );
  66. EMinigameType GetMinigameType() const { return m_eMinigameType; }
  67. void SetAdvantagedTeam ( int iAdvantageTeam ) { m_iAdvantagedTeam = iAdvantageTeam; }
  68. #else
  69. const char *GetResFile() const { return m_pszHudResFile; }
  70. int GetMaxScore( void ) const { return m_nMaxScoreForMiniGame; }
  71. int GetScoreForTeam( int nTeamNum ) const;
  72. #endif
  73. protected:
  74. #ifdef GAME_DLL
  75. virtual void InternalHandleInputScore( inputdata_t &inputdata ){}
  76. virtual void SuddenDeathTimeStartThink();
  77. COutputEvent m_OnRedHitMaxScore;
  78. COutputEvent m_OnBlueHitMaxScore;
  79. COutputEvent m_OnTeleportToMinigame;
  80. COutputEvent m_OnReturnFromMinigame;
  81. COutputEvent m_OnAllRedDead;
  82. COutputEvent m_OnAllBlueDead;
  83. COutputEvent m_OnSuddenDeathStart;
  84. const char *m_pszTeamSpawnPoint[ TF_TEAM_COUNT ];
  85. bool m_bMinigameAllowedInRamdomPool;
  86. bool m_bIsActive;
  87. string_t m_iszHudResFile;
  88. EMinigameType m_eMinigameType;
  89. string_t m_iszYourTeamScoreSound;
  90. string_t m_iszEnemyTeamScoreSound;
  91. float m_flSuddenDeathTime; // -1: No sudden death, 0: In sudden death, >0: Sudden death time.
  92. int m_iAdvantagedTeam;
  93. #endif
  94. CNetworkString( m_pszHudResFile, MAX_PATH );
  95. CNetworkVar( int, m_nMaxScoreForMiniGame );
  96. CNetworkArray( int, m_nMinigameTeamScore, TF_TEAM_COUNT );
  97. CNetworkVar( EScoringType, m_eScoringType );
  98. };
  99. class CTFHalloweenMinigame : public CTFMiniGame
  100. {
  101. DECLARE_CLASS( CTFHalloweenMinigame, CTFMiniGame )
  102. DECLARE_NETWORKCLASS();
  103. public:
  104. #ifdef GAME_DLL
  105. CTFHalloweenMinigame();
  106. DECLARE_DATADESC();
  107. virtual void Spawn() OVERRIDE;
  108. virtual void FireGameEvent( IGameEvent * event ) OVERRIDE;
  109. virtual void TeleportAllPlayers() OVERRIDE;
  110. virtual void OnTeleportPlayerToMinigame( CTFPlayer *pPlayer ) OVERRIDE;
  111. virtual void ReturnAllPlayers() OVERRIDE;
  112. void InputKartWinAnimationRed( inputdata_t &inputdata );
  113. void InputKartWinAnimationBlue( inputdata_t &inputdata );
  114. void InputKartLoseAnimationRed( inputdata_t &inputdata );
  115. void InputKartLoseAnimationBlue( inputdata_t &inputdata );
  116. void InputEnableSpawnBoss( inputdata_t &inputdata );
  117. void InputDisableSpawnBoss( inputdata_t &inputdata );
  118. protected:
  119. virtual void InternalHandleInputScore( inputdata_t &inputdata ) OVERRIDE;
  120. private:
  121. void TeleportAllPlayersThink();
  122. EHANDLE m_hBossSpawnPoint;
  123. EHANDLE m_hHalloweenBoss;
  124. #endif // GAME_DLL
  125. };
  126. class CTFHalloweenMinigame_FallingPlatforms : public CTFHalloweenMinigame
  127. {
  128. DECLARE_CLASS( CTFHalloweenMinigame_FallingPlatforms, CTFHalloweenMinigame )
  129. DECLARE_NETWORKCLASS();
  130. public:
  131. #ifdef GAME_DLL
  132. CTFHalloweenMinigame_FallingPlatforms();
  133. DECLARE_DATADESC();
  134. void InputChoosePlatform( inputdata_t &inputdata );
  135. virtual void FireGameEvent( IGameEvent * event ) OVERRIDE;
  136. COutputInt m_OutputSafePlatform;
  137. COutputInt m_OutputRemovePlatform;
  138. private:
  139. CCopyableUtlVector< int > m_vecRemainingPlatforms;
  140. #endif
  141. };
  142. class CTFMinigameLogic : public CBaseEntity
  143. {
  144. DECLARE_CLASS( CTFMinigameLogic, CBaseEntity )
  145. DECLARE_NETWORKCLASS();
  146. public:
  147. CTFMinigameLogic();
  148. virtual ~CTFMinigameLogic();
  149. static CTFMinigameLogic* GetMinigameLogic() { return m_sMinigameLogic; }
  150. CTFMiniGame *GetActiveMinigame() const { return m_hActiveMinigame; }
  151. #ifdef GAME_DLL
  152. DECLARE_DATADESC();
  153. virtual int UpdateTransmitState() OVERRIDE { return SetTransmitState( FL_EDICT_ALWAYS ); }
  154. void InputReturnFromMinigame( inputdata_t &inputdata );
  155. void InputTeleportToMinigame( inputdata_t &inputdata );
  156. void InputSetAdvantageTeam( inputdata_t &inputdata );
  157. void InputTeleportToRandomMinigame( inputdata_t &inputdata );
  158. #endif
  159. protected:
  160. static CTFMinigameLogic* m_sMinigameLogic;
  161. #ifdef GAME_DLL
  162. virtual void TeleportToMinigame( int nMiniGameIndex );
  163. virtual void ReturnFromMinigame();
  164. int m_iAdvantagedTeam;
  165. #endif
  166. CNetworkHandle( CTFMiniGame, m_hActiveMinigame );
  167. };
  168. //-----------------------------------------------------------------------------
  169. // Purpose:
  170. //-----------------------------------------------------------------------------
  171. class CTFHalloweenFortuneTeller : public CBaseAnimating
  172. #ifdef GAME_DLL
  173. , public CGameEventListener
  174. #endif
  175. {
  176. DECLARE_CLASS( CTFHalloweenFortuneTeller, CBaseAnimating );
  177. DECLARE_DATADESC();
  178. enum ETellerType
  179. {
  180. TELLER_TYPE_EVERYBODY = 0,
  181. TELLER_TYPE_PERSONAL,
  182. NUM_TELLER_TYPES
  183. };
  184. public:
  185. CTFHalloweenFortuneTeller();
  186. ~CTFHalloweenFortuneTeller();
  187. virtual void Spawn() OVERRIDE;
  188. virtual void UpdateOnRemove() OVERRIDE;
  189. #ifdef GAME_DLL
  190. void InputEnableFortuneTelling( inputdata_t & );
  191. void InputDisableFortuneTelling( inputdata_t & );
  192. void InputStartFortuneTelling( inputdata_t & );
  193. void InputEndFortuneTelling( inputdata_t & );
  194. #endif // GAME_DLL
  195. protected:
  196. virtual void Precache() OVERRIDE;
  197. #ifdef GAME_DLL
  198. void FireGameEvent( IGameEvent* pEvent );
  199. void UpdateFortuneTellerTime();
  200. void PauseTimer();
  201. void ResetTimer();
  202. void StartFortuneWarning();
  203. void StartFortuneTell();
  204. void EndFortuneTell();
  205. void TellFortune();
  206. void ApplyFortuneEffect();
  207. void StopTalkingAnim();
  208. void DanceThink();
  209. void SpeakThink();
  210. #endif // GAME_DLL
  211. private:
  212. #ifdef GAME_DLL
  213. COutputEvent m_OnFortuneWarning;
  214. COutputEvent m_OnFortuneTold;
  215. COutputEvent m_OnFortuneCurse;
  216. COutputEvent m_OnFortuneEnd;
  217. class CConditionFortuneTellerEffect* m_pActiveFortune;
  218. string_t m_iszRedTeleport;
  219. string_t m_iszBlueTeleport;
  220. bool m_bUseTimer;
  221. bool m_bWasUsingTimer;
  222. float m_flStartTime;
  223. float m_flPauseTime;
  224. #endif // GAME_DLL
  225. };
  226. #endif // TF_LOGIC_HALLOWEEN_2014