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.

100 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "achievementmgr.h"
  8. #include "baseachievement.h"
  9. #ifdef GAME_DLL
  10. #include "basegrenade_shared.h"
  11. CAchievementMgr g_AchievementMgrEpisodic; // global achievement mgr for episodic
  12. class CAchievementEpXGetZombineGrenade : public CBaseAchievement
  13. {
  14. protected:
  15. void Init()
  16. {
  17. SetFlags( ACH_SAVE_GLOBAL );
  18. SetGoal( 1 );
  19. if ( IsPC() )
  20. {
  21. // only in Ep2 for PC. (Shared across EPX for X360.)
  22. SetGameDirFilter( "ep2" );
  23. }
  24. }
  25. virtual void ListenForEvents()
  26. {
  27. ListenForGameEvent( "physgun_pickup" );
  28. }
  29. void FireGameEvent_Internal( IGameEvent *event )
  30. {
  31. if ( 0 == Q_strcmp( event->GetName(), "physgun_pickup" ) )
  32. {
  33. // was the object picked up a frag grenade?
  34. CBaseEntity *pEntityPickedUp = UTIL_EntityByIndex( event->GetInt( "entindex" ) );
  35. if ( pEntityPickedUp && pEntityPickedUp->ClassMatches( "npc_grenade_frag" ) )
  36. {
  37. // get the grenade object
  38. CBaseGrenade *pGrenade = dynamic_cast<CBaseGrenade *>( pEntityPickedUp );
  39. if ( pGrenade )
  40. {
  41. // was the original thrower a zombine?
  42. CBaseEntity *pOriginalThrower = pGrenade->GetOriginalThrower();
  43. if ( pOriginalThrower && pOriginalThrower->ClassMatches( "npc_zombine" ) )
  44. {
  45. IncrementCount();
  46. }
  47. }
  48. }
  49. }
  50. }
  51. };
  52. DECLARE_ACHIEVEMENT( CAchievementEpXGetZombineGrenade, ACHIEVEMENT_EPX_GET_ZOMBINEGRENADE, "EPX_GET_ZOMBINEGRENADE", 5 );
  53. class CAchievementEpXKillZombiesWithFlares : public CBaseAchievement
  54. {
  55. protected:
  56. void Init()
  57. {
  58. SetFlags( ACH_SAVE_WITH_GAME );
  59. SetGoal( 15 );
  60. if ( IsPC() )
  61. {
  62. // only in Ep1 for PC. (Shared across EPX for X360.)
  63. SetGameDirFilter( "episodic" );
  64. }
  65. }
  66. virtual void ListenForEvents()
  67. {
  68. ListenForGameEvent( "flare_ignite_npc" );
  69. }
  70. void FireGameEvent_Internal( IGameEvent *event )
  71. {
  72. if ( 0 == Q_strcmp( event->GetName(), "flare_ignite_npc" ) )
  73. {
  74. CBaseEntity *pEntityIgnited = UTIL_EntityByIndex( event->GetInt( "entindex" ) );
  75. // was it a zombie that got set on fire?
  76. if ( pEntityIgnited &&
  77. ( ( pEntityIgnited->ClassMatches( "npc_zombie" ) ) || ( pEntityIgnited->ClassMatches( "npc_zombine" ) ) ||
  78. ( pEntityIgnited->ClassMatches( "npc_fastzombie" ) ) || ( pEntityIgnited->ClassMatches( "npc_poisonzombie" ) ) ) )
  79. {
  80. IncrementCount();
  81. }
  82. }
  83. }
  84. };
  85. DECLARE_ACHIEVEMENT( CAchievementEpXKillZombiesWithFlares, ACHIEVEMENT_EPX_KILL_ZOMBIES_WITHFLARES, "EPX_KILL_ZOMBIES_WITHFLARES", 5 );
  86. #endif // GAME_DLL