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.

97 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #ifdef CLIENT_DLL
  8. bool CheckWinNoEnemyCaps( IGameEvent *event, int iRole );
  9. bool IsLocalTFPlayerClass( int iClass );
  10. bool GameRulesAllowsAchievements( void );
  11. //----------------------------------------------------------------------------------------------------------------
  12. // All achievements should derive from this. It takes care of ensuring that MVM mode isn't active for
  13. // non MVM achievements and that MVM is active for MVM achievements
  14. class CBaseTFAchievementSimple : public CBaseAchievement
  15. {
  16. DECLARE_CLASS( CBaseTFAchievementSimple, CBaseAchievement );
  17. public:
  18. virtual bool LocalPlayerCanEarn( void );
  19. virtual void FireGameEvent( IGameEvent *event );
  20. };
  21. //----------------------------------------------------------------------------------------------------------------
  22. // All class specific achievements should derive from this. It takes care of ensuring that the class
  23. // check is performed, and saves needless event handling for other class's achievements.
  24. class CBaseTFAchievement : public CBaseTFAchievementSimple
  25. {
  26. DECLARE_CLASS( CBaseTFAchievement, CBaseTFAchievementSimple );
  27. public:
  28. virtual bool LocalPlayerCanEarn( void );
  29. };
  30. //----------------------------------------------------------------------------------------------------------------
  31. // Helper class for achievements that check that the player was playing on a game team for the full round
  32. class CTFAchievementFullRound : public CBaseTFAchievement
  33. {
  34. DECLARE_CLASS( CTFAchievementFullRound, CBaseTFAchievement );
  35. public:
  36. void Init() ;
  37. virtual void ListenForEvents();
  38. void FireGameEvent_Internal( IGameEvent *event );
  39. bool PlayerWasInEntireRound( float flRoundTime );
  40. virtual void Event_OnRoundComplete( float flRoundTime, IGameEvent *event ) = 0 ;
  41. };
  42. class CAchievementTopScoreboard : public CTFAchievementFullRound
  43. {
  44. DECLARE_CLASS( CAchievementTopScoreboard, CTFAchievementFullRound );
  45. public:
  46. void Init();
  47. virtual void ListenForEvents();
  48. virtual void Event_OnRoundComplete( float flRoundTime, IGameEvent *event );
  49. };
  50. //----------------------------------------------------------------------------------------------------------------
  51. // Helper class for achievements that involve killing players after walking through a teleporter
  52. template < class tBaseClass >
  53. class CTFAchievementTeleporterTimingKills : public tBaseClass
  54. {
  55. DECLARE_CLASS( CTFAchievementTeleporterTimingKills, CBaseTFAchievement );
  56. void Init()
  57. {
  58. this->SetFlags( ACH_SAVE_GLOBAL | ACH_LISTEN_KILL_ENEMY_EVENTS );
  59. this->SetGoal( 1 );
  60. }
  61. virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event )
  62. {
  63. if ( !pVictim || !pVictim->IsPlayer() )
  64. return;
  65. C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
  66. if ( pAttacker == pLocalPlayer && pVictim != pLocalPlayer )
  67. {
  68. C_TFPlayer *pTFAttacker = ToTFPlayer( pAttacker );
  69. if ( pTFAttacker && pTFAttacker->m_Shared.InCond( TF_COND_TELEPORTED ) && ( gpGlobals->curtime - pTFAttacker->m_Shared.GetTimeTeleEffectAdded() <= 5.0f ) )
  70. {
  71. this->IncrementCount();
  72. }
  73. }
  74. }
  75. };
  76. extern CAchievementMgr g_AchievementMgrTF; // global achievement mgr for TF
  77. #endif // CLIENT_DLL