Achievements.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __ACHIEVEMENTS_H__
  21. #define __ACHIEVEMENTS_H__
  22. enum achievement_t {
  23. ACHIEVEMENT_INVALID = -1,
  24. ACHIEVEMENT_EARN_ALL_50_TROPHIES, // 0 // DONE -- (automagic?)
  25. ACHIEVEMENT_COMPLETED_DIFFICULTY_0, // 1 // DONE -- Recruit
  26. ACHIEVEMENT_COMPLETED_DIFFICULTY_1, // 2 // DONE -- Marine
  27. ACHIEVEMENT_COMPLETED_DIFFICULTY_2, // 3 // DONE -- Veteran
  28. ACHIEVEMENT_COMPLETED_DIFFICULTY_3, // 4 // DONE -- Nightmare
  29. ACHIEVEMENT_PDAS_BASE, // 5 // DONE --
  30. ACHIEVEMENT_WATCH_ALL_VIDEOS, // 6 // DONE --
  31. ACHIEVEMENT_KILL_MONSTER_WITH_1_HEALTH_LEFT, // 7 // DONE --
  32. ACHIEVEMENT_OPEN_ALL_LOCKERS, // 8 // DONE --
  33. ACHIEVEMENT_KILL_20_ENEMY_FISTS_HANDS, // 9 // DONE --- kill 20 enemies with fists & hands
  34. ACHIEVEMENT_KILL_SCI_NEXT_TO_RCR, // 10 // DONE -----> ADD TARGET TO MAP kill scientist trapped next to reactor control room
  35. ACHIEVEMENT_KILL_TWO_IMPS_ONE_SHOTGUN, // 11 // DONE --
  36. ACHIEVEMENT_SCORE_25000_TURKEY_PUNCHER, // 12 // DONE --
  37. ACHIEVEMENT_DESTROY_BARRELS, // 13 // DONE --
  38. ACHIEVEMENT_GET_BFG_FROM_SECURITY_OFFICE, // 14 // DONE -----> ADD TARGET TO MAP
  39. ACHIEVEMENT_COMPLETE_LEVEL_WITHOUT_TAKING_DMG, // 15 // DONE --
  40. ACHIEVEMENT_FIND_RAGE_LOGO, // 16 // DONE -----> ADD TARGET TO MAP (jerry)
  41. ACHIEVEMENT_SPEED_RUN, // 17 // DONE --
  42. ACHIEVEMENT_DEFEAT_VAGARY_BOSS, // 18 // DONE --
  43. ACHIEVEMENT_DEFEAT_GUARDIAN_BOSS, // 19 // DONE --
  44. ACHIEVEMENT_DEFEAT_SABAOTH_BOSS, // 20 // DONE --
  45. ACHIEVEMENT_DEFEAT_CYBERDEMON_BOSS, // 21 // DONE --
  46. ACHIEVEMENT_SENTRY_BOT_ALIVE_TO_DEST, // 22 // DONE -----> ADD TARGET TO MAP
  47. ACHIEVEMENT_KILL_20_ENEMY_WITH_CHAINSAW, // 23 // DONE --
  48. ACHIEVEMENT_ID_LOGO_SECRET_ROOM, // 24 // DONE -----> ADD TARGET TO MAP
  49. ACHIEVEMENT_BLOODY_HANDWORK_OF_BETRUGER, // 25 // DONE -----> ADD TARGET TO MAP
  50. ACHIEVEMENT_TWO_DEMONS_FIGHT_EACH_OTHER, // 26 // DONE --
  51. ACHIEVEMENT_USE_SOUL_CUBE_TO_DEFEAT_20_ENEMY, // 27 // DONE --
  52. ACHIEVEMENT_ROE_COMPLETED_DIFFICULTY_0, // 28 // DONE -- Recruit
  53. ACHIEVEMENT_ROE_COMPLETED_DIFFICULTY_1, // 29 // DONE -- Marine
  54. ACHIEVEMENT_ROE_COMPLETED_DIFFICULTY_2, // 30 // DONE -- Veteran
  55. ACHIEVEMENT_ROE_COMPLETED_DIFFICULTY_3, // 31 // DONE -- Nightmare
  56. ACHIEVEMENT_PDAS_ROE, // 32 // DONE -- read all pdas in RoE
  57. ACHIEVEMENT_KILL_5_ENEMY_HELL_TIME, // 33 // DONE --
  58. ACHIEVEMENT_DEFEAT_HELLTIME_HUNTER, // 34 // DONE --
  59. ACHIEVEMENT_DEFEAT_BERSERK_HUNTER, // 35 // DONE --
  60. ACHIEVEMENT_DEFEAT_INVULNERABILITY_HUNTER, // 36 // DONE --
  61. ACHIEVEMENT_DEFEAT_MALEDICT_BOSS, // 37 // DONE --
  62. ACHIEVEMENT_GRABBER_KILL_20_ENEMY, // 38 // DONE --
  63. ACHIEVEMENT_ARTIFACT_WITH_BERSERK_PUNCH_20, // 39 // DONE --
  64. ACHIEVEMENT_LE_COMPLETED_DIFFICULTY_0, // 40 // DONE -- Recruit
  65. ACHIEVEMENT_LE_COMPLETED_DIFFICULTY_1, // 41 // DONE -- Marine
  66. ACHIEVEMENT_LE_COMPLETED_DIFFICULTY_2, // 42 // DONE -- Veteran
  67. ACHIEVEMENT_LE_COMPLETED_DIFFICULTY_3, // 43 // DONE -- Nightmare
  68. ACHIEVEMENT_PDAS_LE, // 44 // DONE -- read all pdas in LE
  69. ACHIEVEMENT_MP_KILL_PLAYER_VIA_TELEPORT, // 45 // DONE --
  70. ACHIEVEMENT_MP_CATCH_ENEMY_IN_ROFC, // 46 // DONE -- needs to be tested -- Reactor of Frag Chamber
  71. ACHIEVEMENT_MP_KILL_5_PLAYERS_USING_INVIS, // 47 // DONE --
  72. ACHIEVEMENT_MP_COMPLETE_MATCH_WITHOUT_DYING, // 48 // DONE --
  73. ACHIEVEMENT_MP_USE_BERSERK_TO_KILL_PLAYER, // 49 // DONE --
  74. ACHIEVEMENT_MP_KILL_2_GUYS_IN_ROOM_WITH_BFG, // 50 // DONE --
  75. ACHIEVEMENT_DOOM1_NEOPHYTE_COMPLETE_ANY_LEVEL, // 51
  76. ACHIEVEMENT_DOOM1_EPISODE1_COMPLETE_MEDIUM, // 52
  77. ACHIEVEMENT_DOOM1_EPISODE2_COMPLETE_MEDIUM, // 53
  78. ACHIEVEMENT_DOOM1_EPISODE3_COMPLETE_MEDIUM, // 54
  79. ACHIEVEMENT_DOOM1_EPISODE4_COMPLETE_MEDIUM, // 55
  80. ACHIEVEMENT_DOOM1_RAMPAGE_COMPLETE_ALL_HARD, // 56
  81. ACHIEVEMENT_DOOM1_NIGHTMARE_COMPLETE_ANY_LEVEL_NIGHTMARE, // 57
  82. ACHIEVEMENT_DOOM1_BURNING_OUT_OF_CONTROL_COMPLETE_KILLS_ITEMS_SECRETS, // 58
  83. ACHIEVEMENT_DOOM2_JUST_GETTING_STARTED_COMPLETE_ANY_LEVEL, // 59
  84. ACHIEVEMENT_DOOM2_FROM_EARTH_TO_HELL_COMPLETE_HELL_ON_EARTH, // 60
  85. ACHIEVEMENT_DOOM2_AND_BACK_AGAIN_COMPLETE_NO_REST, // 61
  86. ACHIEVEMENT_DOOM2_SUPERIOR_FIREPOWER_COMPLETE_ALL_HARD, // 62
  87. ACHIEVEMENT_DOOM2_REALLY_BIG_GUN_FIND_BFG_SINGLEPLAYER, // 63
  88. ACHIEVEMENT_DOOM2_BURNING_OUT_OF_CONTROL_COMPLETE_KILLS_ITEMS_SECRETS, // 64
  89. ACHIEVEMENT_DOOM2_IMPORTANT_LOOKING_DOOR_FIND_ANY_SECRET, // 65
  90. ACHIEVEMENTS_NUM,
  91. STAT_DOOM_COMPLETED_EPISODE_1_MEDIUM,
  92. STAT_DOOM_COMPLETED_EPISODE_2_MEDIUM,
  93. STAT_DOOM_COMPLETED_EPISODE_3_MEDIUM,
  94. STAT_DOOM_COMPLETED_EPISODE_4_MEDIUM,
  95. STAT_DOOM_COMPLETED_EPISODE_1_HARD,
  96. STAT_DOOM_COMPLETED_EPISODE_2_HARD,
  97. STAT_DOOM_COMPLETED_EPISODE_3_HARD,
  98. STAT_DOOM_COMPLETED_EPISODE_4_HARD,
  99. };
  100. compile_time_assert( ACHIEVEMENTS_NUM <= idPlayerProfile::MAX_PLAYER_PROFILE_STATS );
  101. /*
  102. ================================================
  103. idAchievementManager
  104. Manages a List of Achievements associated with a particular Player.
  105. This is setup to only have one achievement manager per game.
  106. ================================================
  107. */
  108. class idAchievementManager {
  109. public:
  110. idAchievementManager();
  111. void Init( idPlayer * player );
  112. bool IsInitialized() const { return owner != NULL; }
  113. // save games
  114. void Save( idSaveGame * savefile ) const; // archives object for save game file
  115. void Restore( idRestoreGame * savefile ); // unarchives object from save game file
  116. // Debug tool to reset achievement state and counts
  117. void Reset();
  118. int GetCount( const achievement_t eventId ) const { return counts[eventId]; }
  119. // Adds a count to the tracked number of events, these events can be applied to multiple achievements
  120. void EventCompletesAchievement( const achievement_t eventId );
  121. int GetLastImpKilledTime() { return lastImpKilledTime; }
  122. void SetLastImpKilledTime( int time) { lastImpKilledTime = time; }
  123. int GetLastPlayerKilledTime() { return lastPlayerKilledTime; }
  124. void SetLastPlayerKilledTime( int time ) { lastPlayerKilledTime = time; }
  125. bool GetPlayerTookDamage() { return playerTookDamage; }
  126. void SetPlayerTookDamage( bool bl ) { playerTookDamage = bl; }
  127. void IncrementHellTimeKills();
  128. void ResetHellTimeKills() { currentHellTimeKills = 0; }
  129. void SavePersistentData( idDict & playerInfo );
  130. void RestorePersistentData( const idDict & spawnArgs );
  131. static void LocalUser_CompleteAchievement( achievement_t id );
  132. static void CheckDoomClassicsAchievements( int killcount, int itemcount, int secretcount, int skill, int mission, int map, int episode, int totalkills, int totalitems, int totalsecret );
  133. private:
  134. idEntityPtr< idPlayer > owner;
  135. idArray<int, ACHIEVEMENTS_NUM> counts; // How many times has each achievement been given
  136. int lastPlayerKilledTime;
  137. int lastImpKilledTime;
  138. bool playerTookDamage;
  139. int currentHellTimeKills;
  140. static bool cheatingDialogShown;
  141. idLocalUser * GetLocalUser();
  142. void SyncAchievments();
  143. };
  144. #endif // !__ACHIEVEMENTS_H__