Counter Strike : Global Offensive Source Code
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.

1084 lines
45 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include <time.h>
  8. #include "achievementmgr.h"
  9. #ifdef GAME_DLL
  10. CAchievementMgr * CAchievementMgr::GetInstance()
  11. {
  12. IAchievementMgr *pMgr = engine->GetAchievementMgr();
  13. class CAchievementMgrDelegateIAchievementMgr_friend : public CAchievementMgrDelegateIAchievementMgr
  14. {
  15. public: CAchievementMgr * GetDelegate() const { return m_pDelegate; }
  16. private: CAchievementMgrDelegateIAchievementMgr_friend() : CAchievementMgrDelegateIAchievementMgr( NULL ) {}
  17. };
  18. return reinterpret_cast< CAchievementMgrDelegateIAchievementMgr_friend * >( pMgr )->GetDelegate();
  19. }
  20. IAchievementMgr * CAchievementMgr::GetInstanceInterface()
  21. {
  22. return engine->GetAchievementMgr();
  23. }
  24. #endif // GAME_DLL
  25. #ifdef CLIENT_DLL
  26. #include "baseachievement.h"
  27. #include "cs_achievement_constants.h"
  28. #include "c_cs_team.h"
  29. #include "c_cs_player.h"
  30. #include "c_cs_playerresource.h"
  31. #include "cs_gamerules.h"
  32. #include "achievements_cs.h"
  33. #include "cs_client_gamestats.h"
  34. // [dwenger] Necessary for sorting achievements by award time
  35. #include <vgui/ISystem.h>
  36. #include "../../src/public/vgui_controls/Controls.h"
  37. #endif // CLIENT_DLL
  38. // NOTE: This has to be the last file included!
  39. #include "tier0/memdbgon.h"
  40. #ifdef CLIENT_DLL
  41. ConVar achievements_easymode( "achievement_easymode", "0", FCVAR_CLIENTDLL | FCVAR_DEVELOPMENTONLY,
  42. "Enables all stat-based achievements to be earned at 10% of goals" );
  43. // global achievement mgr for CS
  44. CAchievementMgr g_AchievementMgrCS;
  45. CAchievementMgrDelegateIAchievementMgr g_IAchievementMgrImpl( &g_AchievementMgrCS );
  46. CAchievementMgr * CAchievementMgr::GetInstance()
  47. {
  48. #ifdef _DEBUG
  49. IAchievementMgr *pMgr = engine->GetAchievementMgr();
  50. Assert( !pMgr || ( pMgr == &g_IAchievementMgrImpl ) );
  51. #endif
  52. return &g_AchievementMgrCS;
  53. }
  54. IAchievementMgr * CAchievementMgr::GetInstanceInterface()
  55. {
  56. #ifdef _DEBUG
  57. IAchievementMgr *pMgr = engine->GetAchievementMgr();
  58. Assert( !pMgr || ( pMgr == &g_IAchievementMgrImpl ) );
  59. Assert( ((uintp)static_cast<IAchievementMgr*>(&g_IAchievementMgrImpl)) == ((uintp)(&g_IAchievementMgrImpl)) );
  60. #endif
  61. return &g_IAchievementMgrImpl;
  62. }
  63. CCSBaseAchievement::CCSBaseAchievement()
  64. {
  65. }
  66. //-----------------------------------------------------------------------------
  67. // Purpose: Determines the timestamp when the achievement is awarded
  68. //-----------------------------------------------------------------------------
  69. void CCSBaseAchievement::OnAchieved()
  70. {
  71. #if defined( _X360 )
  72. __time32_t unlockTime;
  73. _time32(&unlockTime);
  74. SetUnlockTime(unlockTime);
  75. #endif
  76. }
  77. //-----------------------------------------------------------------------------
  78. // Purpose: Returns the time values when the achievement was awarded.
  79. //-----------------------------------------------------------------------------
  80. bool CCSBaseAchievement::GetAwardTime( int& year, int& month, int& day, int& hour, int& minute, int& second )
  81. {
  82. if ( GetUnlockTime() )
  83. {
  84. #if defined( _PS3 ) || defined( _OSX ) || defined (LINUX)
  85. time_t timeOfDay = (time_t) GetUnlockTime( );
  86. // [dkorus] note, structuredTime is a pointer to a static structure that will last until another time structure function is called.
  87. struct tm* structuredTimePtr = localtime( &timeOfDay );
  88. #else
  89. struct tm structuredTime;
  90. __time32_t unlockTime = static_cast<__time32_t>(GetUnlockTime());
  91. _localtime32_s(&structuredTime, &unlockTime);
  92. struct tm* structuredTimePtr = &structuredTime;
  93. #endif
  94. if ( structuredTimePtr )
  95. {
  96. year = structuredTimePtr->tm_year + 1900;
  97. month = structuredTimePtr->tm_mon + 1; // 0..11
  98. day = structuredTimePtr->tm_mday;
  99. hour = structuredTimePtr->tm_hour;
  100. minute = structuredTimePtr->tm_min;
  101. second = structuredTimePtr->tm_sec;
  102. }
  103. return true;
  104. }
  105. else
  106. {
  107. return false;
  108. }
  109. }
  110. void CCSBaseAchievement::GetSettings( KeyValues* pNodeOut )
  111. {
  112. BaseClass::GetSettings(pNodeOut);
  113. pNodeOut->SetInt("unlockTime", GetUnlockTime());
  114. }
  115. void CCSBaseAchievement::ApplySettings( /* const */ KeyValues* pNodeIn )
  116. {
  117. BaseClass::ApplySettings(pNodeIn);
  118. SetUnlockTime(pNodeIn->GetInt("unlockTime"));
  119. }
  120. /**
  121. * Meta Achievement base class methods
  122. */
  123. #if (!defined NO_STEAM)
  124. CAchievement_Meta::CAchievement_Meta() :
  125. m_CallbackUserAchievement( this, &CAchievement_Meta::Steam_OnUserAchievementStored )
  126. {
  127. }
  128. #else
  129. CAchievement_Meta::CAchievement_Meta()
  130. {
  131. }
  132. #endif
  133. void CAchievement_Meta::Init()
  134. {
  135. SetFlags( ACH_SAVE_GLOBAL );
  136. SetGoal( 1 );
  137. }
  138. // $FIXME(hpe) how do we award achievements in the no steam case on X360
  139. #if (!defined NO_STEAM)
  140. void CAchievement_Meta::Steam_OnUserAchievementStored( UserAchievementStored_t *pUserAchievementStored )
  141. {
  142. if ( IsAchieved() )
  143. return;
  144. int iAchieved = 0;
  145. FOR_EACH_VEC(m_requirements, i)
  146. {
  147. IAchievement* pAchievement = (IAchievement*)m_pAchievementMgr->GetAchievementByID(m_requirements[i], m_nUserSlot);
  148. Assert ( pAchievement );
  149. if ( pAchievement->IsAchieved() )
  150. iAchieved++;
  151. else
  152. break;
  153. }
  154. if ( iAchieved == m_requirements.Count() )
  155. {
  156. AwardAchievement();
  157. }
  158. }
  159. #endif
  160. void CAchievement_StatGoal::OnPlayerStatsUpdate( int nUserSlot )
  161. {
  162. // when stats are updated by server, use most recent stat value
  163. const StatsCollection_t& roundStats = g_CSClientGameStats.GetLifetimeStats( nUserSlot );
  164. int iOldCount = GetCount();
  165. SetCount(roundStats[m_StatId]);
  166. if ( GetCount() != iOldCount )
  167. {
  168. m_pAchievementMgr->SetDirty(true, m_nUserSlot);
  169. }
  170. int iGoal = GetGoal();
  171. if (!IsAchieved() && iGoal > 0 )
  172. {
  173. if (achievements_easymode.GetBool())
  174. {
  175. iGoal /= 10;
  176. if ( iGoal == 0 )
  177. iGoal = 1;
  178. }
  179. if ( GetCount() >= iGoal )
  180. {
  181. AwardAchievement();
  182. }
  183. }
  184. }
  185. void CAchievement_Meta::AddRequirement( int nAchievementId )
  186. {
  187. m_requirements.AddToTail(nAchievementId);
  188. }
  189. #if 0
  190. bool CheckWinNoEnemyCaps( IGameEvent *event, int iRole );
  191. // Grace period that we allow a player to start after level init and still consider them to be participating for the full round. This is fairly generous
  192. // because it can in some cases take a client several minutes to connect with respect to when the server considers the game underway
  193. #define CS_FULL_ROUND_GRACE_PERIOD ( 4 * 60.0f )
  194. bool IsLocalCSPlayerClass( int iClass );
  195. //-----------------------------------------------------------------------------
  196. // Purpose:
  197. //-----------------------------------------------------------------------------
  198. void CCSBaseAchievementFullRound::Init()
  199. {
  200. m_iFlags |= ACH_FILTER_FULL_ROUND_ONLY;
  201. }
  202. //-----------------------------------------------------------------------------
  203. // Purpose:
  204. //-----------------------------------------------------------------------------
  205. void CCSBaseAchievementFullRound::ListenForEvents()
  206. {
  207. ListenForGameEvent( "teamplay_round_win" );
  208. }
  209. //-----------------------------------------------------------------------------
  210. // Purpose:
  211. //-----------------------------------------------------------------------------
  212. void CCSBaseAchievementFullRound::FireGameEvent_Internal( IGameEvent *event )
  213. {
  214. if ( 0 == Q_strcmp( event->GetName(), "teamplay_round_win" ) )
  215. {
  216. C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
  217. if ( pLocalPlayer )
  218. {
  219. // is the player currently on a game team?
  220. int iTeam = pLocalPlayer->GetTeamNumber();
  221. if ( iTeam >= FIRST_GAME_TEAM )
  222. {
  223. float flRoundTime = event->GetFloat( "round_time", 0 );
  224. if ( flRoundTime > 0 )
  225. {
  226. Event_OnRoundComplete( flRoundTime, event );
  227. }
  228. }
  229. }
  230. }
  231. }
  232. //-----------------------------------------------------------------------------
  233. // Purpose:
  234. //-----------------------------------------------------------------------------
  235. bool CCSBaseAchievementFullRound::PlayerWasInEntireRound( float flRoundTime )
  236. {
  237. float flTeamplayStartTime = m_pAchievementMgr->GetTeamplayStartTime();
  238. if ( flTeamplayStartTime > 0 )
  239. {
  240. // has the player been present and on a game team since the start of this round (minus a grace period)?
  241. if ( flTeamplayStartTime < ( gpGlobals->curtime - flRoundTime ) + CS_FULL_ROUND_GRACE_PERIOD )
  242. return true;
  243. }
  244. return false;
  245. }
  246. #endif
  247. #define DECLARE_ACHIEVEMENT_STATGOAL( achievementID, achievementName, iPointValue, iStatId, iGoal ) \
  248. static CBaseAchievement *Create_##achievementID( void ) \
  249. { \
  250. CAchievement_StatGoal *pAchievement = new CAchievement_StatGoal(); \
  251. pAchievement->SetAchievementID( achievementID ); \
  252. pAchievement->SetName( achievementName ); \
  253. pAchievement->SetPointValue( iPointValue ); \
  254. pAchievement->SetHideUntilAchieved( false ); \
  255. pAchievement->SetStatId(iStatId); \
  256. pAchievement->SetGoal( iGoal ); \
  257. return pAchievement; \
  258. }; \
  259. static CBaseAchievementHelper g_##achievementID##_Helper( Create_##achievementID );
  260. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsLow, "KILL_ENEMY_LOW", 10, CSSTAT_KILLS, 25); //25
  261. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsMed, "KILL_ENEMY_MED", 10, CSSTAT_KILLS, 500); //500
  262. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsHigh, "KILL_ENEMY_HIGH", 10, CSSTAT_KILLS, 10000); //10000
  263. DECLARE_ACHIEVEMENT_STATGOAL(CSWinRoundsLow, "WIN_ROUNDS_LOW", 10, CSSTAT_ROUNDS_WON, 10); //10
  264. DECLARE_ACHIEVEMENT_STATGOAL(CSWinRoundsMed, "WIN_ROUNDS_MED", 10, CSSTAT_ROUNDS_WON, 200); //200
  265. DECLARE_ACHIEVEMENT_STATGOAL(CSWinRoundsHigh, "WIN_ROUNDS_HIGH", 10, CSSTAT_ROUNDS_WON, 5000); //5000
  266. DECLARE_ACHIEVEMENT_STATGOAL(CSGGWinRoundsLow, "WIN_GUN_GAME_ROUNDS_LOW", 10, CSSTAT_GUN_GAME_MATCHES_WON, 1);
  267. DECLARE_ACHIEVEMENT_STATGOAL(CSGGWinRoundsMed, "WIN_GUN_GAME_ROUNDS_MED", 10, CSSTAT_GUN_GAME_MATCHES_WON, 25);
  268. DECLARE_ACHIEVEMENT_STATGOAL(CSGGWinRoundsHigh, "WIN_GUN_GAME_ROUNDS_HIGH", 10, CSSTAT_GUN_GAME_MATCHES_WON, 100);
  269. DECLARE_ACHIEVEMENT_STATGOAL(CSGGWinRoundsExtreme, "WIN_GUN_GAME_ROUNDS_EXTREME", 10, CSSTAT_GUN_GAME_MATCHES_WON, 500);
  270. DECLARE_ACHIEVEMENT_STATGOAL(CSGGWinRoundsUltimate, "WIN_GUN_GAME_ROUNDS_ULTIMATE", 10, CSSTAT_GUN_GAME_MATCHES_WON, 1000);
  271. DECLARE_ACHIEVEMENT_STATGOAL(CSGGRoundsLow, "GUN_GAME_ROUNDS_LOW", 10, CSSTAT_GUN_GAME_MATCHES_PLAYED, 100);
  272. DECLARE_ACHIEVEMENT_STATGOAL(CSGGRoundsMed, "GUN_GAME_ROUNDS_MED", 10, CSSTAT_GUN_GAME_MATCHES_PLAYED, 500);
  273. DECLARE_ACHIEVEMENT_STATGOAL(CSGGRoundsHigh, "GUN_GAME_ROUNDS_HIGH", 10, CSSTAT_GUN_GAME_MATCHES_PLAYED, 5000);
  274. DECLARE_ACHIEVEMENT_STATGOAL(CSWinPistolRoundsLow, "WIN_PISTOLROUNDS_LOW", 10, CSSTAT_PISTOLROUNDS_WON, 5); //5
  275. DECLARE_ACHIEVEMENT_STATGOAL(CSWinPistolRoundsMed, "WIN_PISTOLROUNDS_MED", 10, CSSTAT_PISTOLROUNDS_WON, 25); //25
  276. DECLARE_ACHIEVEMENT_STATGOAL(CSWinPistolRoundsHigh, "WIN_PISTOLROUNDS_HIGH", 10, CSSTAT_PISTOLROUNDS_WON, 250); //250
  277. DECLARE_ACHIEVEMENT_STATGOAL(CSMoneyEarnedLow, "EARN_MONEY_LOW", 10, CSSTAT_MONEY_EARNED, 50000); //125000
  278. DECLARE_ACHIEVEMENT_STATGOAL(CSMoneyEarnedMed, "EARN_MONEY_MED", 10, CSSTAT_MONEY_EARNED, 2500000); //2500000
  279. DECLARE_ACHIEVEMENT_STATGOAL(CSMoneyEarnedHigh, "EARN_MONEY_HIGH", 10, CSSTAT_MONEY_EARNED, 50000000); //50000000
  280. DECLARE_ACHIEVEMENT_STATGOAL(CSGiveDamageLow, "GIVE_DAMAGE_LOW", 10, CSSTAT_DAMAGE, 2500); //2500
  281. DECLARE_ACHIEVEMENT_STATGOAL(CSGiveDamageMed, "GIVE_DAMAGE_MED", 10, CSSTAT_DAMAGE, 50000); //50000
  282. DECLARE_ACHIEVEMENT_STATGOAL(CSGiveDamageHigh, "GIVE_DAMAGE_HIGH", 10, CSSTAT_DAMAGE, 1000000); //1000000
  283. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsDeagle, "KILL_ENEMY_DEAGLE", 5, CSSTAT_KILLS_DEAGLE, 200); //200
  284. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsUSP, "KILL_ENEMY_USP", 5, CSSTAT_KILLS_USP, 200); //200
  285. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsGlock, "KILL_ENEMY_GLOCK", 5, CSSTAT_KILLS_GLOCK, 100); //200
  286. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsHKP2000, "KILL_ENEMY_HKP2000", 5, CSSTAT_KILLS_HKP2000, 100);
  287. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsP228, "KILL_ENEMY_P228", 5, CSSTAT_KILLS_P228, 200); //200
  288. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsElite, "KILL_ENEMY_ELITE", 5, CSSTAT_KILLS_ELITE, 25); //100
  289. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsFiveSeven, "KILL_ENEMY_FIVESEVEN", 5, CSSTAT_KILLS_FIVESEVEN, 25); //100
  290. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsP250, "KILL_ENEMY_P250", 5, CSSTAT_KILLS_P250, 25);
  291. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsTaser, "KILL_ENEMY_TASER", 5, CSSTAT_KILLS_TASER, 10); //100
  292. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsAWP, "KILL_ENEMY_AWP", 5, CSSTAT_KILLS_AWP, 500); //1000
  293. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsAK47, "KILL_ENEMY_AK47", 5, CSSTAT_KILLS_AK47, 1000); //1000
  294. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsM4A1, "KILL_ENEMY_M4A1", 5, CSSTAT_KILLS_M4A1, 1000); //1000
  295. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsAUG, "KILL_ENEMY_AUG", 5, CSSTAT_KILLS_AUG, 250); //500
  296. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsSG552, "KILL_ENEMY_SG552", 5, CSSTAT_KILLS_SG552, 500); //500
  297. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsSG550, "KILL_ENEMY_SG550", 5, CSSTAT_KILLS_SG550, 500); //500
  298. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsGALIL, "KILL_ENEMY_GALIL", 5, CSSTAT_KILLS_GALIL, 500);
  299. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsGALILAR, "KILL_ENEMY_GALILAR", 5, CSSTAT_KILLS_GALILAR, 250);
  300. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsFAMAS, "KILL_ENEMY_FAMAS", 5, CSSTAT_KILLS_FAMAS, 100); //500
  301. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsScout, "KILL_ENEMY_SCOUT", 5, CSSTAT_KILLS_SCOUT, 1000); //1000
  302. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsG3SG1, "KILL_ENEMY_G3SG1", 5, CSSTAT_KILLS_G3SG1, 100); //500
  303. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsSCAR17, "KILL_ENEMY_SCAR17", 5, CSSTAT_KILLS_SCAR17, 1000);
  304. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsSCAR20, "KILL_ENEMY_SCAR20", 5, CSSTAT_KILLS_SCAR20, 100);
  305. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsSG556, "KILL_ENEMY_SG556", 5, CSSTAT_KILLS_SG556, 100);
  306. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsSSG08, "KILL_ENEMY_SSG08", 5, CSSTAT_KILLS_SSG08, 100);
  307. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsP90, "KILL_ENEMY_P90", 5, CSSTAT_KILLS_P90, 500); //1000
  308. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsTec9, "KILL_ENEMY_TEC9", 5, CSSTAT_KILLS_TEC9, 100); //100
  309. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsBizon, "KILL_ENEMY_BIZON", 5, CSSTAT_KILLS_BIZON, 250);
  310. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsMP5NAVY, "KILL_ENEMY_MP5NAVY", 5, CSSTAT_KILLS_MP5NAVY, 1000); //1000
  311. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsTMP, "KILL_ENEMY_TMP", 5, CSSTAT_KILLS_TMP, 500); //500
  312. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsMAC10, "KILL_ENEMY_MAC10", 5, CSSTAT_KILLS_MAC10, 100); //500
  313. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsUMP45, "KILL_ENEMY_UMP45", 5, CSSTAT_KILLS_UMP45, 250); //1000
  314. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsMP7, "KILL_ENEMY_MP7", 5, CSSTAT_KILLS_MP7, 250);
  315. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsMP9, "KILL_ENEMY_MP9", 5, CSSTAT_KILLS_MP9, 100);
  316. //DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsM3, "KILL_ENEMY_M3", 5, CSSTAT_KILLS_M3, 200); //200
  317. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsXM1014, "KILL_ENEMY_XM1014", 5, CSSTAT_KILLS_XM1014, 200); //200
  318. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsMag7, "KILL_ENEMY_MAG7", 5, CSSTAT_KILLS_MAG7, 50);
  319. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsSawedoff, "KILL_ENEMY_SAWEDOFF", 5, CSSTAT_KILLS_SAWEDOFF, 50);
  320. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsNova, "KILL_ENEMY_NOVA", 5, CSSTAT_KILLS_NOVA, 100);
  321. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsM249, "KILL_ENEMY_M249", 5, CSSTAT_KILLS_M249, 100); //500
  322. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsNegev, "KILL_ENEMY_NEGEV", 5, CSSTAT_KILLS_NEGEV, 100);
  323. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsKnife, "KILL_ENEMY_KNIFE", 5, CSSTAT_KILLS_KNIFE, 100); //100
  324. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsHEGrenade, "KILL_ENEMY_HEGRENADE", 5, CSSTAT_KILLS_HEGRENADE, 100); //500
  325. DECLARE_ACHIEVEMENT_STATGOAL(CSEnemyKillsMolotov, "KILL_ENEMY_MOLOTOV", 5, CSSTAT_KILLS_MOLOTOV, 100);
  326. DECLARE_ACHIEVEMENT_STATGOAL(CSHeadshots, "HEADSHOTS", 5, CSSTAT_KILLS_HEADSHOT, 250); //250
  327. DECLARE_ACHIEVEMENT_STATGOAL(CSKillsEnemyWeapon, "KILLS_ENEMY_WEAPON", 5, CSSTAT_KILLS_ENEMY_WEAPON, 100); //100
  328. DECLARE_ACHIEVEMENT_STATGOAL(CSKillEnemyBlinded, "KILL_ENEMY_BLINDED", 5, CSSTAT_KILLS_ENEMY_BLINDED, 25); //25
  329. DECLARE_ACHIEVEMENT_STATGOAL(CSDefuseBombsLow, "BOMB_DEFUSE_LOW", 5, CSSTAT_NUM_BOMBS_DEFUSED, 100); //100
  330. DECLARE_ACHIEVEMENT_STATGOAL(CSPlantBombsLow, "BOMB_PLANT_LOW", 5, CSSTAT_NUM_BOMBS_PLANTED, 100); //100
  331. DECLARE_ACHIEVEMENT_STATGOAL(CSDefuseBombsTRLow, "TR_BOMB_DEFUSE_LOW", 5, CSSTAT_TR_NUM_BOMBS_DEFUSED, 5);
  332. DECLARE_ACHIEVEMENT_STATGOAL(CSPlantBombsTRLow, "TR_BOMB_PLANT_LOW", 5, CSSTAT_TR_NUM_BOMBS_PLANTED, 5);
  333. DECLARE_ACHIEVEMENT_STATGOAL(CSRescueHostagesLow, "RESCUE_HOSTAGES_LOW", 5, CSSTAT_NUM_HOSTAGES_RESCUED, 100); //100
  334. DECLARE_ACHIEVEMENT_STATGOAL(CSRescueHostagesMid, "RESCUE_HOSTAGES_MED", 5, CSSTAT_NUM_HOSTAGES_RESCUED, 500); //500
  335. DECLARE_ACHIEVEMENT_STATGOAL(CSWinKnifeFightsLow, "WIN_KNIFE_FIGHTS_LOW", 5, CSSTAT_KILLS_KNIFE_FIGHT, 1); //1
  336. DECLARE_ACHIEVEMENT_STATGOAL(CSWinKnifeFightsHigh, "WIN_KNIFE_FIGHTS_HIGH", 5, CSSTAT_KILLS_KNIFE_FIGHT, 100); //100
  337. //DECLARE_ACHIEVEMENT_STATGOAL(CSDecalSprays, "DECAL_SPRAYS", 5, CSSTAT_DECAL_SPRAYS, 100); //100
  338. DECLARE_ACHIEVEMENT_STATGOAL(CSKillSnipers, "KILL_SNIPERS", 5, CSSTAT_KILLS_AGAINST_ZOOMED_SNIPER, 100); //100
  339. //DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapCS_ASSAULT, "WIN_MAP_CS_ASSAULT", 5, CSSTAT_MAP_WINS_CS_ASSAULT, 100); //100
  340. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapCS_ITALY, "WIN_MAP_CS_ITALY", 5, CSSTAT_MAP_WINS_CS_ITALY, 100); //100
  341. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapCS_OFFICE, "WIN_MAP_CS_OFFICE", 5, CSSTAT_MAP_WINS_CS_OFFICE, 100); //100
  342. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_AZTEC, "WIN_MAP_DE_AZTEC", 5, CSSTAT_MAP_WINS_DE_AZTEC, 100); //100
  343. //DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_CBBLE, "WIN_MAP_DE_CBBLE", 5, CSSTAT_MAP_WINS_DE_CBBLE, 100); //100
  344. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_DUST2, "WIN_MAP_DE_DUST2", 5, CSSTAT_MAP_WINS_DE_DUST2, 100); //100
  345. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_DUST, "WIN_MAP_DE_DUST", 5, CSSTAT_MAP_WINS_DE_DUST, 100); //100
  346. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_INFERNO, "WIN_MAP_DE_INFERNO", 5, CSSTAT_MAP_WINS_DE_INFERNO, 100); //100
  347. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_NUKE, "WIN_MAP_DE_NUKE", 5, CSSTAT_MAP_WINS_DE_NUKE, 100); //100
  348. //DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_PIRANESI, "WIN_MAP_DE_PIRANESI", 5, CSSTAT_MAP_WINS_DE_PIRANESI, 100); //100
  349. //DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_PRODIGY, "WIN_MAP_DE_PRODIGY", 5, CSSTAT_MAP_WINS_DE_PRODIGY, 100); //100
  350. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_TRAIN, "WIN_MAP_DE_TRAIN", 5, CSSTAT_MAP_WINS_DE_TRAIN, 100); //100
  351. // anticipating medals for these. Just uncomment and add strings to cstrike15_english to enable
  352. //DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_VERTIGO, "WIN_MAP_DE_VERTIGO", 5, CSSTAT_MAP_WINS_DE_VERTIGO, 100); //100
  353. //DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapDE_BALKAN, "WIN_MAP_DE_BALKAN", 5, CSSTAT_MAP_WINS_DE_BALKAN, 100); //100
  354. //DECLARE_ACHIEVEMENT_STATGOAL(CSWinMapAR_MONASTERY, "WIN_MAP_AR_MONASTERY", 5, CSSTAT_MAP_WINS_AR_MONASTERY, 5); //100
  355. // gungame maps
  356. //DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchDE_EMBASSY, "WIN_MAP_DE_EMBASSY", 5, CSSTAT_MAP_MATCHES_WON_EMBASSY, 5); //100
  357. //DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchDE_DEPOT, "WIN_MAP_DE_DEPOT", 5, CSSTAT_MAP_MATCHES_WON_DEPOT, 5); //100
  358. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchDE_BANK, "WIN_MAP_DE_BANK", 5, CSSTAT_MAP_MATCHES_WON_BANK, 5); //100
  359. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchAR_SHOOTS, "WIN_MAP_AR_SHOOTS", 5, CSSTAT_MAP_MATCHES_WON_SHOOTS, 5); //100
  360. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchDE_STMARC, "WIN_MAP_DE_STMARC", 5, CSSTAT_MAP_MATCHES_WON_STMARC, 5); //100
  361. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchDE_SUGARCANE, "WIN_MAP_DE_SUGARCANE", 5, CSSTAT_MAP_MATCHES_WON_SUGARCANE, 5); //100
  362. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchDE_SAFEHOUSE, "WIN_MAP_DE_SAFEHOUSE", 5, CSSTAT_MAP_MATCHES_WON_SAFEHOUSE, 5); //100
  363. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchDE_LAKE, "WIN_MAP_DE_LAKE", 5, CSSTAT_MAP_MATCHES_WON_LAKE, 5); //100
  364. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchAR_BAGGAGE, "WIN_MAP_AR_BAGGAGE", 5, CSSTAT_MAP_MATCHES_WON_BAGGAGE, 5); //100
  365. DECLARE_ACHIEVEMENT_STATGOAL(CSWinMatchDE_SHORTTRAIN, "WIN_MAP_DE_SHORTTRAIN", 5, CSSTAT_MAP_MATCHES_WON_SHORTTRAIN, 5); //100
  366. DECLARE_ACHIEVEMENT_STATGOAL(CSDonateWeapons, "DONATE_WEAPONS", 5, CSSTAT_WEAPONS_DONATED, 100); //100
  367. DECLARE_ACHIEVEMENT_STATGOAL(CSDominationsLow, "DOMINATIONS_LOW", 5, CSSTAT_DOMINATIONS, 1); //1
  368. DECLARE_ACHIEVEMENT_STATGOAL(CSDominationsHigh, "DOMINATIONS_HIGH", 5, CSSTAT_DOMINATIONS, 10); //10
  369. DECLARE_ACHIEVEMENT_STATGOAL(CSDominationOverkillsLow, "DOMINATION_OVERKILLS_LOW", 5, CSSTAT_DOMINATION_OVERKILLS, 1); //1
  370. DECLARE_ACHIEVEMENT_STATGOAL(CSDominationOverkillsHigh, "DOMINATION_OVERKILLS_HIGH",5, CSSTAT_DOMINATION_OVERKILLS, 100); //100
  371. DECLARE_ACHIEVEMENT_STATGOAL(CSRevengesLow, "REVENGES_LOW", 5, CSSTAT_REVENGES, 1); //1
  372. DECLARE_ACHIEVEMENT_STATGOAL(CSRevengesHigh, "REVENGES_HIGH", 5, CSSTAT_REVENGES, 20); //20
  373. //-----------------------------------------------------------------------------
  374. // Purpose: Generic server awarded achievement
  375. //-----------------------------------------------------------------------------
  376. class CAchievementCS_ServerAwarded : public CCSBaseAchievement
  377. {
  378. virtual void Init()
  379. {
  380. SetGoal(1);
  381. SetFlags( ACH_SAVE_GLOBAL );
  382. }
  383. // server fires an event for this achievement, no other code within achievement necessary
  384. };
  385. #define DECLARE_ACHIEVEMENT_SERVERAWARDED(achievementID, achievementName, iPointValue) \
  386. static CBaseAchievement *Create_##achievementID( void ) \
  387. { \
  388. CAchievementCS_ServerAwarded *pAchievement = new CAchievementCS_ServerAwarded( ); \
  389. pAchievement->SetAchievementID( achievementID ); \
  390. pAchievement->SetName( achievementName ); \
  391. pAchievement->SetPointValue( iPointValue ); \
  392. return pAchievement; \
  393. }; \
  394. static CBaseAchievementHelper g_##achievementID##_Helper( Create_##achievementID );
  395. // server triggered achievements
  396. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSBombDefuseCloseCall, "BOMB_DEFUSE_CLOSE_CALL", 5);
  397. //DECLARE_ACHIEVEMENT_SERVERAWARDED(CSDefuseAndNeededKit, "BOMB_DEFUSE_NEEDED_KIT", 5);
  398. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKilledDefuser, "KILL_BOMB_DEFUSER", 5);
  399. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSWinBombPlant, "WIN_BOMB_PLANT", 5);
  400. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSWinBombDefuse, "WIN_BOMB_DEFUSE", 5);
  401. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSPlantBombWithin25Seconds, "BOMB_PLANT_IN_25_SECONDS", 5);
  402. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSRescueAllHostagesInARound, "RESCUE_ALL_HOSTAGES", 5);
  403. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillEnemyWithFormerGun, "KILL_WITH_OWN_GUN", 5);
  404. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillingSpree, "KILLING_SPREE", 5);
  405. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillTwoWithOneShot, "KILL_TWO_WITH_ONE_SHOT", 5);
  406. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillEnemyReloading, "KILL_ENEMY_RELOADING", 5);
  407. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillsWithMultipleGuns, "KILLS_WITH_MULTIPLE_GUNS", 5);
  408. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSPosthumousGrenadeKill, "DEAD_GRENADE_KILL", 5);
  409. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillEnemyTeam, "KILL_ENEMY_TEAM", 5);
  410. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSLastPlayerAlive, "LAST_PLAYER_ALIVE", 5);
  411. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillEnemyLastBullet, "KILL_ENEMY_LAST_BULLET", 5);
  412. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillingSpreeEnder, "KILLING_SPREE_ENDER", 5);
  413. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillEnemiesWhileBlind, "KILL_ENEMIES_WHILE_BLIND", 5);
  414. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillEnemiesWhileBlindHard, "KILL_ENEMIES_WHILE_BLIND_HARD", 5);
  415. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSDamageNoKill, "DAMAGE_NO_KILL", 5);
  416. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillLowDamage, "KILL_LOW_DAMAGE", 5);
  417. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKilledRescuer, "KILL_HOSTAGE_RESCUER", 5);
  418. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSSurviveGrenade, "SURVIVE_GRENADE", 5);
  419. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKilledDefuserWithGrenade, "KILLED_DEFUSER_WITH_GRENADE", 5);
  420. //DECLARE_ACHIEVEMENT_SERVERAWARDED(CSSurvivedHeadshotDueToHelmet, "SURVIVED_HEADSHOT_DUE_TO_HELMET", 5);
  421. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillSniperWithSniper, "KILL_SNIPER_WITH_SNIPER", 5);
  422. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillSniperWithKnife, "KILL_SNIPER_WITH_KNIFE", 5);
  423. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSHipShot, "HIP_SHOT", 5);
  424. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillWhenAtLowHealth, "KILL_WHEN_AT_LOW_HEALTH", 5);
  425. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSGrenadeMultikill, "GRENADE_MULTIKILL", 5);
  426. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSBombMultikill, "BOMB_MULTIKILL", 5);
  427. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSPistolRoundKnifeKill, "PISTOL_ROUND_KNIFE_KILL", 5);
  428. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSFastRoundWin, "FAST_ROUND_WIN", 5);
  429. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSSurviveManyAttacks, "SURVIVE_MANY_ATTACKS", 5);
  430. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSGooseChase, "GOOSE_CHASE", 5);
  431. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSWinBombPlantAfterRecovery, "WIN_BOMB_PLANT_AFTER_RECOVERY", 5);
  432. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSLosslessExtermination, "LOSSLESS_EXTERMINATION", 5);
  433. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSFlawlessVictory, "FLAWLESS_VICTORY", 5);
  434. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSWinDualDuel, "WIN_DUAL_DUEL", 5);
  435. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSFastHostageRescue, "FAST_HOSTAGE_RESCUE", 5);
  436. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSBreakWindows, "BREAK_WINDOWS", 5);
  437. //DECLARE_ACHIEVEMENT_SERVERAWARDED(CSBreakProps, "BREAK_PROPS", 5);
  438. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSUnstoppableForce, "UNSTOPPABLE_FORCE", 5);
  439. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSImmovableObject, "IMMOVABLE_OBJECT", 5);
  440. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSHeadshotsInRound, "HEADSHOTS_IN_ROUND", 5);
  441. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillWhileInAir, "KILL_WHILE_IN_AIR", 5);
  442. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillEnemyInAir, "KILL_ENEMY_IN_AIR", 5);
  443. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillerAndEnemyInAir, "KILLER_AND_ENEMY_IN_AIR", 5);
  444. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSSilentWin, "SILENT_WIN", 5);
  445. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSBloodlessVictory, "BLOODLESS_VICTORY", 5);
  446. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSWinRoundsWithoutBuying, "WIN_ROUNDS_WITHOUT_BUYING", 5)
  447. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSDefuseDefense, "DEFUSE_DEFENSE", 5)
  448. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillBombPickup, "KILL_BOMB_PICKUP", 5)
  449. #if(ALL_WEARING_SAME_UNIFORM_ACHIEVEMENT)
  450. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSSameUniform, "SAME_UNIFORM", 5)
  451. #endif
  452. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSConcurrentDominations, "CONCURRENT_DOMINATIONS", 5)
  453. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSDominationOverkillsMatch, "DOMINATION_OVERKILLS_MATCH", 5)
  454. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSExtendedDomination, "EXTENDED_DOMINATION", 5)
  455. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSCauseFriendlyFireWithFlashbang, "CAUSE_FRIENDLY_FIRE_WITH_FLASHBANG", 5)
  456. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSGunGameKillKnifer, "GUN_GAME_KILL_KNIFER", 5);
  457. //DECLARE_ACHIEVEMENT_SERVERAWARDED(CSGunGameKnifeSuicide, "GUN_GAME_SELECT_SUICIDE_WITH_KNIFE", 5);
  458. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSGunGameKnifeKillKnifer, "GUN_GAME_KNIFE_KILL_KNIFER", 5);
  459. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSGunGameSMGKillKnifer, "GUN_GAME_SMG_KILL_KNIFER", 5);
  460. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSGunGameProgressiveRampage, "GUN_GAME_RAMPAGE", 5);
  461. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSGunGameFirstKill, "GUN_GAME_FIRST_KILL", 5);
  462. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillEnemyTerrTeamBeforeBombPlant, "GUN_GAME_FIRST_THING_FIRST", 5);
  463. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSKillEnemyCTTeamBeforeBombPlant, "GUN_GAME_TARGET_SECURED", 5);
  464. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSFirstBulletKills, "ONE_SHOT_ONE_KILL", 5);
  465. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSGunGameConservationist, "GUN_GAME_CONSERVATIONIST", 5);
  466. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSSpawnCamper, "BASE_SCAMPER", 5);
  467. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSBornReady, "BORN_READY", 5);
  468. DECLARE_ACHIEVEMENT_SERVERAWARDED(CSStillAlive, "STILL_ALIVE", 5);
  469. //-----------------------------------------------------------------------------
  470. // Meta Achievements
  471. //-----------------------------------------------------------------------------
  472. //-----------------------------------------------------------------------------
  473. // Purpose: Get all the pistol achievements
  474. //-----------------------------------------------------------------------------
  475. class CAchievementCS_PistolMaster : public CAchievement_Meta
  476. {
  477. DECLARE_CLASS( CAchievementCS_PistolMaster, CAchievement_Meta );
  478. virtual void Init()
  479. {
  480. BaseClass::Init();
  481. AddRequirement(CSEnemyKillsDeagle);
  482. AddRequirement(CSEnemyKillsGlock);
  483. AddRequirement(CSEnemyKillsElite);
  484. AddRequirement(CSEnemyKillsFiveSeven);
  485. AddRequirement(CSEnemyKillsTec9);
  486. AddRequirement(CSEnemyKillsHKP2000);
  487. AddRequirement(CSEnemyKillsP250);
  488. }
  489. };
  490. DECLARE_ACHIEVEMENT(CAchievementCS_PistolMaster, CSMetaPistol, "META_PISTOL", 10);
  491. //-----------------------------------------------------------------------------
  492. // Purpose: Get all the rifle achievements
  493. //-----------------------------------------------------------------------------
  494. class CAchievementCS_RifleMaster : public CAchievement_Meta
  495. {
  496. DECLARE_CLASS( CAchievementCS_RifleMaster, CAchievement_Meta );
  497. virtual void Init()
  498. {
  499. BaseClass::Init();
  500. AddRequirement(CSEnemyKillsAWP);
  501. AddRequirement(CSEnemyKillsAK47);
  502. AddRequirement(CSEnemyKillsM4A1);
  503. AddRequirement(CSEnemyKillsAUG);
  504. AddRequirement(CSEnemyKillsGALILAR);
  505. AddRequirement(CSEnemyKillsFAMAS);
  506. AddRequirement(CSEnemyKillsG3SG1);
  507. AddRequirement(CSEnemyKillsSCAR20);
  508. AddRequirement(CSEnemyKillsSG556);
  509. AddRequirement(CSEnemyKillsSSG08);
  510. }
  511. };
  512. DECLARE_ACHIEVEMENT(CAchievementCS_RifleMaster, CSMetaRifle, "META_RIFLE", 10);
  513. //-----------------------------------------------------------------------------
  514. // Purpose: Get all the SMG achievements
  515. //-----------------------------------------------------------------------------
  516. class CAchievementCS_SubMachineGunMaster : public CAchievement_Meta
  517. {
  518. DECLARE_CLASS( CAchievementCS_SubMachineGunMaster, CAchievement_Meta );
  519. virtual void Init()
  520. {
  521. BaseClass::Init();
  522. AddRequirement(CSEnemyKillsP90);
  523. AddRequirement(CSEnemyKillsMAC10);
  524. AddRequirement(CSEnemyKillsUMP45);
  525. AddRequirement(CSEnemyKillsMP7);
  526. AddRequirement(CSEnemyKillsMP9);
  527. AddRequirement(CSEnemyKillsBizon);
  528. }
  529. };
  530. DECLARE_ACHIEVEMENT(CAchievementCS_SubMachineGunMaster, CSMetaSMG, "META_SMG", 10);
  531. //-----------------------------------------------------------------------------
  532. // Purpose: Get all the Shotgun achievements
  533. //-----------------------------------------------------------------------------
  534. class CAchievementCS_ShotgunMaster : public CAchievement_Meta
  535. {
  536. DECLARE_CLASS( CAchievementCS_ShotgunMaster, CAchievement_Meta );
  537. virtual void Init()
  538. {
  539. BaseClass::Init();
  540. AddRequirement(CSEnemyKillsXM1014);
  541. AddRequirement(CSEnemyKillsMag7);
  542. AddRequirement(CSEnemyKillsSawedoff);
  543. AddRequirement(CSEnemyKillsNova);
  544. }
  545. };
  546. DECLARE_ACHIEVEMENT(CAchievementCS_ShotgunMaster, CSMetaShotgun, "META_SHOTGUN", 10);
  547. //-----------------------------------------------------------------------------
  548. // Purpose: Get every weapon achievement
  549. //-----------------------------------------------------------------------------
  550. class CAchievementCS_WeaponMaster : public CAchievement_Meta
  551. {
  552. DECLARE_CLASS( CAchievementCS_WeaponMaster, CAchievement_Meta );
  553. virtual void Init()
  554. {
  555. BaseClass::Init();
  556. AddRequirement(CSMetaPistol);
  557. AddRequirement(CSMetaRifle);
  558. AddRequirement(CSMetaSMG);
  559. AddRequirement(CSMetaShotgun);
  560. AddRequirement(CSEnemyKillsM249);
  561. AddRequirement(CSEnemyKillsNegev);
  562. AddRequirement(CSEnemyKillsKnife);
  563. AddRequirement(CSEnemyKillsHEGrenade);
  564. AddRequirement(CSEnemyKillsMolotov);
  565. AddRequirement(CSEnemyKillsTaser);
  566. }
  567. };
  568. DECLARE_ACHIEVEMENT(CAchievementCS_WeaponMaster, CSMetaWeaponMaster, "META_WEAPONMASTER", 50);
  569. class CAchievementCS_KillWithAllWeapons : public CCSBaseAchievement
  570. {
  571. void Init()
  572. {
  573. SetFlags( ACH_SAVE_GLOBAL );
  574. SetGoal( 1 );
  575. }
  576. void OnPlayerStatsUpdate( int nUserSlot )
  577. {
  578. const StatsCollection_t& stats = g_CSClientGameStats.GetLifetimeStats( nUserSlot );
  579. static CSStatType_t weaponKillStats[] = {
  580. CSSTAT_KILLS_DEAGLE,
  581. //CSSTAT_KILLS_USP,
  582. CSSTAT_KILLS_GLOCK,
  583. //CSSTAT_KILLS_P228,
  584. CSSTAT_KILLS_ELITE,
  585. CSSTAT_KILLS_FIVESEVEN,
  586. CSSTAT_KILLS_AWP,
  587. CSSTAT_KILLS_AK47,
  588. CSSTAT_KILLS_M4A1,
  589. CSSTAT_KILLS_AUG,
  590. //CSSTAT_KILLS_SG552,
  591. //CSSTAT_KILLS_SG550,
  592. CSSTAT_KILLS_GALILAR,
  593. CSSTAT_KILLS_FAMAS,
  594. //CSSTAT_KILLS_SCOUT,
  595. CSSTAT_KILLS_G3SG1,
  596. CSSTAT_KILLS_P90,
  597. //CSSTAT_KILLS_MP5NAVY,
  598. //CSSTAT_KILLS_TMP,
  599. CSSTAT_KILLS_MAC10,
  600. CSSTAT_KILLS_UMP45,
  601. //CSSTAT_KILLS_M3,
  602. CSSTAT_KILLS_XM1014,
  603. CSSTAT_KILLS_M249,
  604. //CSSTAT_KILLS_KNIFE,
  605. //CSSTAT_KILLS_HEGRENADE,
  606. //CSSTAT_KILLS_MOLOTOV,
  607. //CSSTAT_KILLS_DECOY,
  608. CSSTAT_KILLS_BIZON,
  609. CSSTAT_KILLS_MAG7,
  610. CSSTAT_KILLS_NEGEV,
  611. CSSTAT_KILLS_SAWEDOFF,
  612. CSSTAT_KILLS_TEC9,
  613. CSSTAT_KILLS_TASER,
  614. CSSTAT_KILLS_HKP2000,
  615. CSSTAT_KILLS_MP7,
  616. CSSTAT_KILLS_MP9,
  617. CSSTAT_KILLS_NOVA,
  618. CSSTAT_KILLS_P250,
  619. //CSSTAT_KILLS_SCAR17,
  620. CSSTAT_KILLS_SCAR20,
  621. CSSTAT_KILLS_SG556,
  622. CSSTAT_KILLS_SSG08,
  623. };
  624. const int numKillStats = ARRAYSIZE( weaponKillStats );
  625. //Loop through all weapons we care about and make sure we got a kill with each.
  626. for (int i = 0; i < numKillStats; ++i)
  627. {
  628. CSStatType_t statId = weaponKillStats[i];
  629. if ( stats[statId] == 0)
  630. {
  631. return;
  632. }
  633. }
  634. //If we haven't bailed yet, award the achievement.
  635. IncrementCount();
  636. }
  637. };
  638. DECLARE_ACHIEVEMENT( CAchievementCS_KillWithAllWeapons, CSKillWithEveryWeapon, "KILL_WITH_EVERY_WEAPON", 5 );
  639. class CAchievementCS_WinEveryGGMap : public CCSBaseAchievement
  640. {
  641. void Init()
  642. {
  643. SetFlags( ACH_SAVE_GLOBAL );
  644. SetGoal( 1 );
  645. }
  646. void OnPlayerStatsUpdate( int nUserSlot )
  647. {
  648. CSStatType_t mapStatsID[] = {
  649. CSSTAT_MAP_MATCHES_WON_BAGGAGE,
  650. CSSTAT_MAP_MATCHES_WON_LAKE,
  651. CSSTAT_MAP_MATCHES_WON_BANK,
  652. CSSTAT_MAP_MATCHES_WON_SAFEHOUSE,
  653. CSSTAT_MAP_MATCHES_WON_SUGARCANE,
  654. CSSTAT_MAP_MATCHES_WON_STMARC,
  655. CSSTAT_MAP_MATCHES_WON_SHOOTS,
  656. CSSTAT_MAP_MATCHES_WON_SHORTTRAIN,
  657. // DLC
  658. // CSSTAT_MAP_MATCHES_WON_EMBASSY,
  659. // CSSTAT_MAP_MATCHES_WON_DEPOT,
  660. // CSSTAT_MAP_MATCHES_WON_MONASTERY,
  661. // CSSTAT_MAP_MATCHES_WON_VERTIGO,
  662. // CSSTAT_MAP_MATCHES_WON_BALKAN,
  663. CSSTAT_MAX}; // just a stat type to indicate our end of list
  664. const StatsCollection_t& stats = g_CSClientGameStats.GetLifetimeStats( nUserSlot );
  665. //Loop through all maps we care about and make sure we got a round win
  666. for (int ii = 0; mapStatsID[ii] != CSSTAT_MAX; ++ii)
  667. {
  668. CSStatType_t statId = mapStatsID[ii];
  669. if ( stats[statId] == 0)
  670. {
  671. return;
  672. }
  673. }
  674. //If we haven't bailed yet, award the achievement. We've won a round in all these levels!
  675. IncrementCount();
  676. }
  677. };
  678. DECLARE_ACHIEVEMENT( CAchievementCS_WinEveryGGMap, CSWinEveryGGMap, "WIN_EVERY_GUNGAME_MAP", 5 );
  679. class CAchievementCS_PlayEveryGGMap : public CCSBaseAchievement
  680. {
  681. void Init()
  682. {
  683. SetFlags( ACH_SAVE_GLOBAL );
  684. SetGoal( 1 );
  685. }
  686. void OnPlayerStatsUpdate( int nUserSlot )
  687. {
  688. CSStatType_t mapStatsID[] = {CSSTAT_MAP_ROUNDS_AR_BAGGAGE,
  689. CSSTAT_MAP_ROUNDS_DE_LAKE,
  690. CSSTAT_MAP_ROUNDS_DE_BANK,
  691. CSSTAT_MAP_ROUNDS_AR_SHOOTS,
  692. CSSTAT_MAP_ROUNDS_DE_SAFEHOUSE,
  693. CSSTAT_MAP_ROUNDS_DE_SHORTTRAIN,
  694. CSSTAT_MAP_ROUNDS_DE_SUGARCANE,
  695. CSSTAT_MAP_ROUNDS_DE_STMARC,
  696. // CSSTAT_MAP_ROUNDS_DE_DEPOT,
  697. // CSSTAT_MAP_ROUNDS_DE_EMBASSY,
  698. // CSSTAT_MAP_ROUNDS_DE_MONASTERY,
  699. CSSTAT_MAX}; // just a stat type to indicate our end of list
  700. const StatsCollection_t& stats = g_CSClientGameStats.GetLifetimeStats( nUserSlot );
  701. //Loop through all maps we care about and make sure we got a round win
  702. for (int ii = 0; mapStatsID[ii] != CSSTAT_MAX; ++ii)
  703. {
  704. CSStatType_t statId = mapStatsID[ii];
  705. if ( stats[statId] == 0)
  706. {
  707. return;
  708. }
  709. }
  710. //If we haven't bailed yet, award the achievement. We've won a round in all these levels!
  711. IncrementCount();
  712. }
  713. };
  714. DECLARE_ACHIEVEMENT( CAchievementCS_PlayEveryGGMap, CSPlayEveryGGMap, "PLAY_EVERY_GUNGAME_MAP", 5 );
  715. #if(ALL_WEARING_SAME_UNIFORM_ACHIEVEMENT)
  716. class CAchievementCS_FriendsSameUniform : public CCSBaseAchievement
  717. {
  718. void Init()
  719. {
  720. SetFlags(ACH_SAVE_GLOBAL);
  721. SetGoal(1);
  722. }
  723. virtual void ListenForEvents()
  724. {
  725. ListenForGameEvent( "round_start" );
  726. }
  727. void FireGameEvent_Internal( IGameEvent *event )
  728. {
  729. if ( Q_strcmp( event->GetName(), "round_start" ) == 0 )
  730. {
  731. int localPlayerIndex = GetLocalPlayerIndex();
  732. C_CSPlayer* pLocalPlayer = ToCSPlayer(UTIL_PlayerByIndex(localPlayerIndex));
  733. // Initialize all to 1, since the local player doesn't get counted as we loop.
  734. int numPlayersOnTeam = 1;
  735. int numFriendsOnTeam = 1;
  736. int numMatchingFriendsOnTeam = 1;
  737. if (pLocalPlayer)
  738. {
  739. int localPlayerClass = pLocalPlayer->PlayerClass();
  740. int localPlayerTeam = pLocalPlayer->GetTeamNumber();
  741. for ( int i = 1; i <= gpGlobals->maxClients; i++ )
  742. {
  743. if ( i != localPlayerIndex)
  744. {
  745. CCSPlayer *pPlayer = (CCSPlayer*) UTIL_PlayerByIndex( i );
  746. if (pPlayer)
  747. {
  748. if (pPlayer->GetTeamNumber() == localPlayerTeam)
  749. {
  750. ++numPlayersOnTeam;
  751. #if defined (_X360)
  752. ACTIVE_SPLITSCREEN_PLAYER_GUARD( pLocalPlayer->GetSplitScreenPlayerSlot() );
  753. if ( IsXboxFriends( XBX_GetActiveUserId(), pPlayer->entindex() ) )
  754. #else
  755. if ( pLocalPlayer->HasPlayerAsFriend( pPlayer ) )
  756. #endif
  757. {
  758. ++numFriendsOnTeam;
  759. if ( pPlayer->PlayerClass() == localPlayerClass )
  760. ++numMatchingFriendsOnTeam;
  761. }
  762. }
  763. }
  764. }
  765. }
  766. if (numMatchingFriendsOnTeam >= AchievementConsts::FriendsSameUniform_MinPlayers )
  767. {
  768. AwardAchievement();
  769. }
  770. }
  771. }
  772. }
  773. };
  774. DECLARE_ACHIEVEMENT( CAchievementCS_FriendsSameUniform, CSFriendsSameUniform, "FRIENDS_SAME_UNIFORM", 5 );
  775. #endif // #if(ALL_WEARING_SAME_UNIFORM_ACHIEVEMENT)
  776. class CAchievementCS_AvengeFriend : public CCSBaseAchievement
  777. {
  778. void Init()
  779. {
  780. SetFlags(ACH_SAVE_GLOBAL);
  781. SetGoal(1);
  782. }
  783. void ListenForEvents()
  784. {
  785. ListenForGameEvent( "player_avenged_teammate" );
  786. }
  787. void FireGameEvent_Internal( IGameEvent *event )
  788. {
  789. if ( Q_strcmp( event->GetName(), "player_avenged_teammate" ) == 0 )
  790. {
  791. int localPlayerIndex = GetLocalPlayerIndex();
  792. C_CSPlayer* pLocalPlayer = ToCSPlayer(UTIL_PlayerByIndex(localPlayerIndex));
  793. //for debugging
  794. //int eventId = event->GetInt( "avenger_id" );
  795. //int localUserId = pLocalPlayer->GetUserID();
  796. if (pLocalPlayer && pLocalPlayer->GetUserID() == event->GetInt( "avenger_id" ))
  797. {
  798. int avengedPlayerIndex = engine->GetPlayerForUserID( event->GetInt( "avenged_player_id" ) );
  799. if ( avengedPlayerIndex > 0 )
  800. {
  801. C_CSPlayer* pAvengedPlayer = ToCSPlayer( UTIL_PlayerByIndex( avengedPlayerIndex ) );
  802. C_CS_PlayerResource *cs_PR = dynamic_cast<C_CS_PlayerResource *>( g_PR );
  803. if ( cs_PR && pAvengedPlayer )
  804. {
  805. XUID nOtherXUID = cs_PR->GetXuid( pAvengedPlayer->entindex() );
  806. if ( g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetFriendByXUID( nOtherXUID ) )
  807. {
  808. AwardAchievement();
  809. }
  810. }
  811. }
  812. }
  813. }
  814. }
  815. };
  816. DECLARE_ACHIEVEMENT( CAchievementCS_AvengeFriend, CSAvengeFriend, "AVENGE_FRIEND", 5 );
  817. class CAchievementCS_Medalist : public CCSBaseAchievement
  818. {
  819. void Init()
  820. {
  821. SetFlags(ACH_SAVE_GLOBAL);
  822. SetGoal(1);
  823. }
  824. void ListenForEvents()
  825. {
  826. ListenForGameEvent( "achievement_earned_local" );
  827. }
  828. void FireGameEvent_Internal( IGameEvent *event )
  829. {
  830. if ( Q_strcmp( event->GetName(), "achievement_earned_local" ) == 0 )
  831. {
  832. int splitScreenPlayer = event->GetInt( "splitscreenplayer" );
  833. int totalEarnedAchievements = 0;
  834. FOR_EACH_MAP( g_AchievementMgrCS.GetAchievements(splitScreenPlayer), i )
  835. {
  836. CBaseAchievement *pAchievement = g_AchievementMgrCS.GetAchievements( splitScreenPlayer )[i];
  837. if ( pAchievement && pAchievement->IsAchieved() )
  838. totalEarnedAchievements++;
  839. }
  840. if ( totalEarnedAchievements >= AchievementConsts::Num_Medalist_Required_Medals)
  841. {
  842. AwardAchievement();
  843. }
  844. }
  845. }
  846. };
  847. DECLARE_ACHIEVEMENT( CAchievementCS_Medalist, CSMedalist, "MEDALIST", 5 );
  848. #if defined ( _X360 )
  849. static CAchievementListener g_AchievementListener;
  850. //-----------------------------------------------------------------------------
  851. // Purpose: Constructor
  852. //-----------------------------------------------------------------------------
  853. CAchievementListener::CAchievementListener() :
  854. CAutoGameSystem( "CAchievementListener" )
  855. {
  856. }
  857. //-----------------------------------------------------------------------------
  858. // Purpose: Listen for earned achievements
  859. //-----------------------------------------------------------------------------
  860. bool CAchievementListener::Init()
  861. {
  862. ListenForGameEvent( "achievement_earned_local" );
  863. ListenForGameEvent( "repost_xbox_achievements" );
  864. return true;
  865. }
  866. //-----------------------------------------------------------------------------
  867. // Purpose: Listens for game events. Send off XBLA achievements for CS
  868. //-----------------------------------------------------------------------------
  869. void CAchievementListener::FireGameEvent( IGameEvent *event )
  870. {
  871. const char *eventname = event->GetName();
  872. XNotifyPositionUI( XNOTIFYUI_POS_TOPCENTER );
  873. if ( Q_strcmp( "achievement_earned_local", eventname ) == 0 )
  874. {
  875. // is this one of our XBox achievements?
  876. int achievementID = event->GetInt( "achievement" );
  877. int splitScreenPlayer = event->GetInt( "splitscreenplayer" );
  878. for ( int i=0; i<NumXboxMappedAchievements; ++i )
  879. {
  880. if ( MedalToXBox[i][0] == achievementID )
  881. {
  882. // award the Xbox achievement; pass CSInvalidAchievement in case the overlappedresult from the xbox achievement award is invalid we don't
  883. // unaward a medal in achievementmgr::Update loop where the overlapped results are processed
  884. g_AchievementMgrCS.AwardXBoxAchievement( CSInvalidAchievement, MedalToXBox[i][1], splitScreenPlayer );
  885. }
  886. }
  887. // have we earned the required # of Medals to trigger the MEDALIST xBox achievement?
  888. int totalEarnedAchievements = 0;
  889. FOR_EACH_MAP( g_AchievementMgrCS.GetAchievements(splitScreenPlayer), i )
  890. {
  891. CBaseAchievement *pAchievement = g_AchievementMgrCS.GetAchievements( splitScreenPlayer )[i];
  892. if ( pAchievement && pAchievement->IsAchieved() )
  893. totalEarnedAchievements++;
  894. }
  895. if ( totalEarnedAchievements >= AchievementConsts::Num_Medalist_Required_Medals )
  896. {
  897. // award the Xbox achievement; pass CSInvalidAchievement in case the overlappedresult from the xbox achievement award is invalid we don't
  898. // unaward a medal in achievementmgr::Update loop where the overlapped results are processed
  899. g_AchievementMgrCS.AwardXBoxAchievement( CSInvalidAchievement, ACHIEVEMENT_MEDALIST, splitScreenPlayer );
  900. }
  901. }
  902. else if ( Q_strcmp( "repost_xbox_achievements", eventname ) == 0 )
  903. {
  904. // check to see if any medals have already been earned that would award an xBox achievement; it is ok to try to award an already awarded xbox achievement
  905. // and this makes sure we award during a profile read any achievements the player earned that did not properly get awarded for some reason
  906. int splitScreenPlayer = event->GetInt( "splitscreenplayer" );
  907. for ( int i=0; i<NumXboxMappedAchievements; ++i)
  908. {
  909. CBaseAchievement *pAchievement = g_AchievementMgrCS.GetAchievementByID( MedalToXBox[i][0], splitScreenPlayer );
  910. if ( pAchievement && pAchievement->IsAchieved() )
  911. {
  912. // award the Xbox achievement; pass CSInvalidAchievement in case the overlappedresult from the xbox achievement award is invalid we don't
  913. // unaward a medal in achievementmgr::Update loop where the overlapped results are processed
  914. g_AchievementMgrCS.AwardXBoxAchievement( CSInvalidAchievement, MedalToXBox[i][1], splitScreenPlayer );
  915. }
  916. }
  917. // have we earned the required # of Medals to trigger the MEDALIST xBox achievement?
  918. int totalEarnedAchievements = 0;
  919. FOR_EACH_MAP( g_AchievementMgrCS.GetAchievements(splitScreenPlayer), i )
  920. {
  921. CBaseAchievement *pAchievement = g_AchievementMgrCS.GetAchievements( splitScreenPlayer )[i];
  922. if ( pAchievement && pAchievement->IsAchieved() )
  923. totalEarnedAchievements++;
  924. }
  925. if ( totalEarnedAchievements >= AchievementConsts::Num_Medalist_Required_Medals )
  926. {
  927. // award the Xbox achievement; pass CSInvalidAchievement in case the overlappedresult from the xbox achievement award is invalid we don't
  928. // unaward a medal in achievementmgr::Update loop where the overlapped results are processed
  929. g_AchievementMgrCS.AwardXBoxAchievement( CSInvalidAchievement, ACHIEVEMENT_MEDALIST, splitScreenPlayer );
  930. }
  931. }
  932. }
  933. #endif // (_X360)
  934. #endif // CLIENT_DLL