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.

187 lines
5.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #ifdef CLIENT_DLL
  8. #include "achievementmgr.h"
  9. #include "baseachievement.h"
  10. #include "c_tf_player.h"
  11. #include "c_tf_playerresource.h"
  12. #include "tf_gamerules.h"
  13. #include "achievements_tf.h"
  14. //======================================================================================================================================
  15. // REPLAY ACHIEVEMENTS
  16. //======================================================================================================================================
  17. class CReplayAchievement : public CBaseTFAchievement
  18. {
  19. public:
  20. virtual bool AlwaysListen() { return true; }
  21. virtual bool LocalPlayerCanEarn() { return true; }
  22. virtual bool AlwaysEnabled() { return true; }
  23. };
  24. //----------------------------------------------------------------------------------------------------------------
  25. class CAchievementTFReplay_SaveReplay : public CReplayAchievement
  26. {
  27. public:
  28. void Init()
  29. {
  30. SetFlags( ACH_SAVE_GLOBAL );
  31. ListenForGameEvent( "replay_saved" );
  32. SetGoal( 1 );
  33. }
  34. virtual void FireGameEvent_Internal( IGameEvent *event )
  35. {
  36. if ( FStrEq( event->GetName(), "replay_saved" ) )
  37. {
  38. IncrementCount();
  39. }
  40. }
  41. };
  42. DECLARE_ACHIEVEMENT( CAchievementTFReplay_SaveReplay, ACHIEVEMENT_TF_REPLAY_SAVE_REPLAY, "TF_REPLAY_SAVE_REPLAY", 5 );
  43. //----------------------------------------------------------------------------------------------------------------
  44. class CAchievementTFReplay_PerformanceMode : public CReplayAchievement
  45. {
  46. void Init()
  47. {
  48. SetFlags( ACH_SAVE_GLOBAL );
  49. ListenForGameEvent( "entered_performance_mode" );
  50. SetGoal( 1 );
  51. }
  52. virtual void FireGameEvent_Internal( IGameEvent *event )
  53. {
  54. if ( FStrEq( event->GetName(), "entered_performance_mode" ) )
  55. {
  56. IncrementCount();
  57. }
  58. }
  59. };
  60. DECLARE_ACHIEVEMENT( CAchievementTFReplay_PerformanceMode, ACHIEVEMENT_TF_REPLAY_PERFORMANCE_MODE, "TF_REPLAY_PERFORMANCE_MODE", 5 );
  61. //----------------------------------------------------------------------------------------------------------------
  62. class CAchievementTFReplay_BrowseReplays : public CReplayAchievement
  63. {
  64. void Init()
  65. {
  66. SetFlags( ACH_SAVE_GLOBAL );
  67. ListenForGameEvent( "browse_replays" );
  68. SetGoal( 1 );
  69. }
  70. virtual void FireGameEvent_Internal( IGameEvent *event )
  71. {
  72. if ( FStrEq( event->GetName(), "browse_replays" ) )
  73. {
  74. IncrementCount();
  75. }
  76. }
  77. };
  78. DECLARE_ACHIEVEMENT( CAchievementTFReplay_BrowseReplays, ACHIEVEMENT_TF_REPLAY_BROWSE_REPLAYS, "TF_REPLAY_BROWSE_REPLAYS", 5 );
  79. //----------------------------------------------------------------------------------------------------------------
  80. class CAchievementTFReplay_EditTime : public CReplayAchievement
  81. {
  82. void Init()
  83. {
  84. SetFlags( ACH_SAVE_GLOBAL );
  85. SetGoal( 1 );
  86. }
  87. };
  88. DECLARE_ACHIEVEMENT( CAchievementTFReplay_EditTime, ACHIEVEMENT_TF_REPLAY_EDIT_TIME, "TF_REPLAY_EDIT_TIME", 5 );
  89. //----------------------------------------------------------------------------------------------------------------
  90. class CAchievementTFReplay_YouTube_Views_Tier : public CReplayAchievement
  91. {
  92. public:
  93. void Init()
  94. {
  95. SetFlags( ACH_SAVE_GLOBAL );
  96. ListenForGameEvent( "replay_youtube_stats" );
  97. SetStoreProgressInSteam( true );
  98. SetStat( "TF_REPLAY_YOUTUBE_VIEWS" );
  99. }
  100. virtual void FireGameEvent_Internal( IGameEvent *event )
  101. {
  102. if ( FStrEq( event->GetName(), "replay_youtube_stats" ) )
  103. {
  104. int iCurrentCount = GetCount();
  105. int iNewCount = event->GetInt( "views" );
  106. if ( iNewCount > iCurrentCount )
  107. {
  108. IncrementCount( iNewCount - iCurrentCount );
  109. }
  110. }
  111. }
  112. virtual bool ShouldShowProgressNotification() { return false; }
  113. };
  114. class CAchievementTFReplay_YouTube_Views_Tier1 : public CAchievementTFReplay_YouTube_Views_Tier
  115. {
  116. DECLARE_CLASS( CAchievementTFReplay_YouTube_Views_Tier1, CAchievementTFReplay_YouTube_Views_Tier );
  117. public:
  118. void Init()
  119. {
  120. BaseClass::Init();
  121. SetGoal( 100 );
  122. }
  123. };
  124. DECLARE_ACHIEVEMENT( CAchievementTFReplay_YouTube_Views_Tier1, ACHIEVEMENT_TF_REPLAY_YOUTUBE_VIEWS_TIER1, "TF_REPLAY_YOUTUBE_VIEWS_TIER1", 5 );
  125. class CAchievementTFReplay_YouTube_Views_Tier2 : public CAchievementTFReplay_YouTube_Views_Tier
  126. {
  127. DECLARE_CLASS( CAchievementTFReplay_YouTube_Views_Tier1, CAchievementTFReplay_YouTube_Views_Tier );
  128. public:
  129. void Init()
  130. {
  131. BaseClass::Init();
  132. SetGoal( 1000 );
  133. }
  134. };
  135. DECLARE_ACHIEVEMENT( CAchievementTFReplay_YouTube_Views_Tier2, ACHIEVEMENT_TF_REPLAY_YOUTUBE_VIEWS_TIER2, "TF_REPLAY_YOUTUBE_VIEWS_TIER2", 5 );
  136. class CAchievementTFReplay_YouTube_Views_Tier3 : public CAchievementTFReplay_YouTube_Views_Tier
  137. {
  138. DECLARE_CLASS( CAchievementTFReplay_YouTube_Views_Tier1, CAchievementTFReplay_YouTube_Views_Tier );
  139. public:
  140. void Init()
  141. {
  142. BaseClass::Init();
  143. SetGoal( 10000 );
  144. }
  145. };
  146. DECLARE_ACHIEVEMENT( CAchievementTFReplay_YouTube_Views_Tier3, ACHIEVEMENT_TF_REPLAY_YOUTUBE_VIEWS_TIER3, "TF_REPLAY_YOUTUBE_VIEWS_TIER3", 5 );
  147. class CAchievementTFReplay_YouTube_Views_Highest : public CAchievementTFReplay_YouTube_Views_Tier
  148. {
  149. DECLARE_CLASS( CAchievementTFReplay_YouTube_Views_Tier1, CAchievementTFReplay_YouTube_Views_Tier );
  150. public:
  151. void Init()
  152. {
  153. BaseClass::Init();
  154. SetGoal( 100000 );
  155. }
  156. };
  157. DECLARE_ACHIEVEMENT( CAchievementTFReplay_YouTube_Views_Highest, ACHIEVEMENT_TF_REPLAY_YOUTUBE_VIEWS_HIGHEST, "TF_REPLAY_YOUTUBE_VIEWS_HIGHEST", 5 );
  158. //----------------------------------------------------------------------------------------------------------------
  159. #endif // CLIENT_DLL