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/server/tf/func_changeclass.cpp | |
| download | archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip | |
Diffstat (limited to 'game/server/tf/func_changeclass.cpp')
| -rw-r--r-- | game/server/tf/func_changeclass.cpp | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/game/server/tf/func_changeclass.cpp b/game/server/tf/func_changeclass.cpp new file mode 100644 index 0000000..2bbaa2d --- /dev/null +++ b/game/server/tf/func_changeclass.cpp @@ -0,0 +1,132 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: CTF ChangeClass Zone. +// +//=============================================================================// + +#include "cbase.h" +#include "viewport_panel_names.h" +#include "tf_player.h" +#include "tf_item.h" +#include "tf_team.h" +#include "func_changeclass.h" + +LINK_ENTITY_TO_CLASS( func_changeclass, CChangeClassZone ); + +#define TF_CHANGECLASS_SOUND "ChangeClass.Touch" +#define TF_CHANGECLASS_NEXT_USE_TIME 10.0f + +//============================================================================= +// +// CTF ChangeClass Zone functions. +// + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CChangeClassZone::CChangeClassZone() +{ + m_bDisabled = false; +} + +//----------------------------------------------------------------------------- +// Purpose: Spawn function for the entity +//----------------------------------------------------------------------------- +void CChangeClassZone::Spawn( void ) +{ + Precache(); + InitTrigger(); + SetTouch( &CChangeClassZone::Touch ); +} + +//----------------------------------------------------------------------------- +// Purpose: Precache function for the entity +//----------------------------------------------------------------------------- +void CChangeClassZone::Precache( void ) +{ + PrecacheScriptSound( TF_CHANGECLASS_SOUND ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CChangeClassZone::Touch( CBaseEntity *pOther ) +{ + if ( !IsDisabled() ) + { + CTFPlayer *pPlayer = ToTFPlayer( pOther ); + if ( pPlayer ) + { + if ( pPlayer->GetNextChangeClassTime() > gpGlobals->curtime ) + return; + + int iTeam = GetTeamNumber(); + if ( iTeam && ( pPlayer->GetTeamNumber() != iTeam ) ) + return; + + // bring up the player's changeclass menu + CCommand args; + args.Tokenize( "changeclass" ); + pPlayer->ClientCommand( args ); + pPlayer->SetNextChangeClassTime( gpGlobals->curtime + TF_CHANGECLASS_NEXT_USE_TIME ); + + CPASAttenuationFilter filter( pOther, TF_CHANGECLASS_SOUND ); + EmitSound( filter, pOther->entindex(), TF_CHANGECLASS_SOUND ); + } + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CChangeClassZone::EndTouch( CBaseEntity *pOther ) +{ + +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CChangeClassZone::InputEnable( inputdata_t &inputdata ) +{ + SetDisabled( false ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CChangeClassZone::InputDisable( inputdata_t &inputdata ) +{ + SetDisabled( true ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool CChangeClassZone::IsDisabled( void ) +{ + return m_bDisabled; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CChangeClassZone::InputToggle( inputdata_t &inputdata ) +{ + if ( m_bDisabled ) + { + SetDisabled( false ); + } + else + { + SetDisabled( true ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CChangeClassZone::SetDisabled( bool bDisabled ) +{ + m_bDisabled = bDisabled; +} |