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/tf2/tf_obj_bunker.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/server/tf2/tf_obj_bunker.cpp')
| -rw-r--r-- | game/server/tf2/tf_obj_bunker.cpp | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/game/server/tf2/tf_obj_bunker.cpp b/game/server/tf2/tf_obj_bunker.cpp new file mode 100644 index 0000000..9382aa6 --- /dev/null +++ b/game/server/tf2/tf_obj_bunker.cpp @@ -0,0 +1,174 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: A stationary bunker that players can take cover in. +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "tf_obj.h" +#include "tf_team.h" +#include "tf_obj_bunker.h" +#include "engine/IEngineSound.h" + +#define BUNKER_MINS Vector(-170, -170, 0) +#define BUNKER_MAXS Vector( 170, 170, 150) +#define BUNKER_MODEL "models/objects/obj_bunker.mdl" +#define BUNKER_LADDER_MODEL "models/objects/obj_bunker_ladder.mdl" + +IMPLEMENT_SERVERCLASS_ST(CObjectBunker, DT_ObjectBunker) +END_SEND_TABLE(); + +LINK_ENTITY_TO_CLASS(obj_bunker, CObjectBunker); +PRECACHE_REGISTER(obj_bunker); + +IMPLEMENT_SERVERCLASS_ST( CObjectBunkerLadder, DT_ObjectBunkerLadder ) +END_SEND_TABLE(); + +LINK_ENTITY_TO_CLASS( obj_bunker_ladder, CObjectBunkerLadder ); +PRECACHE_REGISTER( obj_bunker_ladder ); + +// CVars +ConVar obj_bunker_health( "obj_bunker_health","100", FCVAR_NONE, "Bunker health" ); + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CObjectBunker::CObjectBunker( void ) +{ + m_hLadder = NULL; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CObjectBunker::Spawn( void ) +{ + Precache(); + SetModel( BUNKER_MODEL ); + + UTIL_SetSize(this, BUNKER_MINS, BUNKER_MAXS); + m_takedamage = DAMAGE_YES; + m_iHealth = obj_bunker_health.GetInt(); + + m_fObjectFlags |= OF_DOESNT_NEED_POWER; + SetType( OBJ_BUNKER ); + + SetSolid( SOLID_VPHYSICS ); + VPhysicsInitStatic(); + + BaseClass::Spawn(); + + SetCollisionGroup( COLLISION_GROUP_VEHICLE ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CObjectBunker::Precache( void ) +{ + PrecacheModel( BUNKER_MODEL ); + PrecacheModel( BUNKER_LADDER_MODEL ); +} + + +//------------------------------------------------------------------------------ +// Purpose: +//------------------------------------------------------------------------------ +void CObjectBunker::UpdateOnRemove( void ) +{ + if ( m_hLadder.Get() ) + { + UTIL_Remove( m_hLadder ); + m_hLadder = NULL; + } + + // Chain at end to mimic destructor unwind order + BaseClass::UpdateOnRemove(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CObjectBunker::FinishedBuilding( void ) +{ + BaseClass::FinishedBuilding(); + + // Create the ladder. + Vector vecOrigin; + QAngle vecAngles; + GetAttachment( "ladder", vecOrigin, vecAngles ); + m_hLadder = CObjectBunkerLadder::Create( vecOrigin, vecAngles, this ); + m_hLadder->ChangeTeam( GetTeamNumber() ); +} + +//----------------------------------------------------------------------------- +// Purpose: Gets info about the control panels +//----------------------------------------------------------------------------- +void CObjectBunker::GetControlPanelInfo( int nPanelIndex, const char *&pPanelName ) +{ + pPanelName = "screen_basic_with_disable"; +} + +//============================================================================== +// Bunker Ladder +//============================================================================== + +//------------------------------------------------------------------------------ +// Purpose: +//------------------------------------------------------------------------------ +CObjectBunkerLadder::CObjectBunkerLadder() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CObjectBunkerLadder *CObjectBunkerLadder::Create( const Vector &vOrigin, const QAngle &vAngles, CBaseEntity *pParent ) +{ + CObjectBunkerLadder *pLadder = static_cast<CObjectBunkerLadder*>( CBaseObject::Create( "obj_bunker_ladder", vOrigin, vAngles ) ); + if ( pLadder ) + { + pLadder->m_hBunker = pParent; + } + + return pLadder; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CObjectBunkerLadder::Spawn() +{ + Precache(); + SetModel( BUNKER_LADDER_MODEL ); + SetSolid( SOLID_VPHYSICS ); + m_takedamage = DAMAGE_NO; + + BaseClass::Spawn(); + + CollisionProp()->SetSurroundingBoundsType( USE_BEST_COLLISION_BOUNDS ); + IPhysicsObject *pPhysics = VPhysicsInitStatic(); + if ( pPhysics ) + { + pPhysics->EnableMotion( false ); + } + SetCollisionGroup( COLLISION_GROUP_VEHICLE ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CObjectBunkerLadder::Precache() +{ + PrecacheModel( BUNKER_LADDER_MODEL ); +} + + +//----------------------------------------------------------------------------- +// Purpose: Pass all damage back to the bunker +//----------------------------------------------------------------------------- +int CObjectBunkerLadder::OnTakeDamage( const CTakeDamageInfo &info ) +{ + return m_hBunker->OnTakeDamage( info ); +}
\ No newline at end of file |