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_respawnflag.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/server/tf/func_respawnflag.cpp')
| -rw-r--r-- | game/server/tf/func_respawnflag.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/game/server/tf/func_respawnflag.cpp b/game/server/tf/func_respawnflag.cpp new file mode 100644 index 0000000..c709522 --- /dev/null +++ b/game/server/tf/func_respawnflag.cpp @@ -0,0 +1,85 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#include "cbase.h" +#include "func_respawnflag.h" +#include "entity_capture_flag.h" +#include "tf_player.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +LINK_ENTITY_TO_CLASS( func_respawnflag, CFuncRespawnFlagZone ); + +BEGIN_DATADESC( CFuncRespawnFlagZone ) + // Functions. + DEFINE_FUNCTION( Touch ), +END_DATADESC(); + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CFuncRespawnFlagZone::CFuncRespawnFlagZone() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CFuncRespawnFlagZone::Spawn( void ) +{ + AddSpawnFlags( SF_TRIGGER_ALLOW_ALL ); + + BaseClass::Spawn(); + InitTrigger(); + + SetTouch( &CFuncRespawnFlagZone::Touch ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CFuncRespawnFlagZone::Touch( CBaseEntity *pOther ) +{ + if ( !m_bDisabled ) + { + if ( pOther->IsPlayer() ) + { + CTFPlayer *pPlayer = ToTFPlayer( pOther ); + if ( pPlayer && pPlayer->HasTheFlag() ) + { + CCaptureFlag *pFlag = dynamic_cast<CCaptureFlag*>( pPlayer->GetItem() ); + + pPlayer->DropFlag(); + + if ( pFlag ) + { + pFlag->ResetFlag(); + } + } + } + } +} + + +//----------------------------------------------------------------------------- +// Purpose: Return true if the specified entity is in a RespawnFlag zone +//----------------------------------------------------------------------------- +bool PointInRespawnFlagZone( const Vector &vecPoint ) +{ + CBaseEntity *pTempEnt = NULL; + while ( ( pTempEnt = gEntList.FindEntityByClassname( pTempEnt, "func_respawnflag" ) ) != NULL ) + { + CFuncRespawnFlagZone *pZone = dynamic_cast<CFuncRespawnFlagZone *>(pTempEnt); + + if ( pZone && !pZone->m_bDisabled && pZone->PointIsWithin( vecPoint ) ) + { + return true; + } + } + + return false; +} |