diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/shared/tf/achievements_tf.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/shared/tf/achievements_tf.h')
| -rw-r--r-- | game/shared/tf/achievements_tf.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/game/shared/tf/achievements_tf.h b/game/shared/tf/achievements_tf.h new file mode 100644 index 0000000..0fd095d --- /dev/null +++ b/game/shared/tf/achievements_tf.h @@ -0,0 +1,97 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + + +#include "cbase.h" + +#ifdef CLIENT_DLL + +bool CheckWinNoEnemyCaps( IGameEvent *event, int iRole ); +bool IsLocalTFPlayerClass( int iClass ); +bool GameRulesAllowsAchievements( void ); + + +//---------------------------------------------------------------------------------------------------------------- +// All achievements should derive from this. It takes care of ensuring that MVM mode isn't active for +// non MVM achievements and that MVM is active for MVM achievements +class CBaseTFAchievementSimple : public CBaseAchievement +{ + DECLARE_CLASS( CBaseTFAchievementSimple, CBaseAchievement ); +public: + virtual bool LocalPlayerCanEarn( void ); + + virtual void FireGameEvent( IGameEvent *event ); +}; + +//---------------------------------------------------------------------------------------------------------------- +// All class specific achievements should derive from this. It takes care of ensuring that the class +// check is performed, and saves needless event handling for other class's achievements. +class CBaseTFAchievement : public CBaseTFAchievementSimple +{ + DECLARE_CLASS( CBaseTFAchievement, CBaseTFAchievementSimple ); +public: + virtual bool LocalPlayerCanEarn( void ); +}; + +//---------------------------------------------------------------------------------------------------------------- +// Helper class for achievements that check that the player was playing on a game team for the full round +class CTFAchievementFullRound : public CBaseTFAchievement +{ + DECLARE_CLASS( CTFAchievementFullRound, CBaseTFAchievement ); +public: + void Init() ; + virtual void ListenForEvents(); + void FireGameEvent_Internal( IGameEvent *event ); + bool PlayerWasInEntireRound( float flRoundTime ); + + virtual void Event_OnRoundComplete( float flRoundTime, IGameEvent *event ) = 0 ; +}; + +class CAchievementTopScoreboard : public CTFAchievementFullRound +{ + DECLARE_CLASS( CAchievementTopScoreboard, CTFAchievementFullRound ); + +public: + void Init(); + virtual void ListenForEvents(); + virtual void Event_OnRoundComplete( float flRoundTime, IGameEvent *event ); +}; + +//---------------------------------------------------------------------------------------------------------------- +// Helper class for achievements that involve killing players after walking through a teleporter +template < class tBaseClass > +class CTFAchievementTeleporterTimingKills : public tBaseClass +{ + DECLARE_CLASS( CTFAchievementTeleporterTimingKills, CBaseTFAchievement ); + + void Init() + { + this->SetFlags( ACH_SAVE_GLOBAL | ACH_LISTEN_KILL_ENEMY_EVENTS ); + this->SetGoal( 1 ); + } + + virtual void Event_EntityKilled( CBaseEntity *pVictim, CBaseEntity *pAttacker, CBaseEntity *pInflictor, IGameEvent *event ) + { + if ( !pVictim || !pVictim->IsPlayer() ) + return; + + C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); + if ( pAttacker == pLocalPlayer && pVictim != pLocalPlayer ) + { + C_TFPlayer *pTFAttacker = ToTFPlayer( pAttacker ); + if ( pTFAttacker && pTFAttacker->m_Shared.InCond( TF_COND_TELEPORTED ) && ( gpGlobals->curtime - pTFAttacker->m_Shared.GetTimeTeleEffectAdded() <= 5.0f ) ) + { + this->IncrementCount(); + } + } + } +}; + + + +extern CAchievementMgr g_AchievementMgrTF; // global achievement mgr for TF + +#endif // CLIENT_DLL |