summaryrefslogtreecommitdiff
path: root/game/server/tf2/tf_obj_empgenerator.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/tf2/tf_obj_empgenerator.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/server/tf2/tf_obj_empgenerator.cpp')
-rw-r--r--game/server/tf2/tf_obj_empgenerator.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/game/server/tf2/tf_obj_empgenerator.cpp b/game/server/tf2/tf_obj_empgenerator.cpp
new file mode 100644
index 0000000..45a0ba2
--- /dev/null
+++ b/game/server/tf2/tf_obj_empgenerator.cpp
@@ -0,0 +1,96 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+#include "cbase.h"
+#include "tf_player.h"
+#include "tf_team.h"
+#include "tf_gamerules.h"
+#include "tf_obj.h"
+#include "tf_obj_empgenerator.h"
+#include "ndebugoverlay.h"
+
+BEGIN_DATADESC( CObjectEMPGenerator )
+
+ DEFINE_THINKFUNC( EMPThink ),
+
+END_DATADESC()
+
+IMPLEMENT_SERVERCLASS_ST(CObjectEMPGenerator, DT_ObjectEMPGenerator)
+END_SEND_TABLE();
+
+LINK_ENTITY_TO_CLASS(obj_empgenerator, CObjectEMPGenerator);
+PRECACHE_REGISTER(obj_empgenerator);
+
+ConVar obj_empgenerator_health( "obj_empgenerator_health","100", FCVAR_NONE, "EMP Generator health" );
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+CObjectEMPGenerator::CObjectEMPGenerator()
+{
+ UseClientSideAnimation();
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CObjectEMPGenerator::Spawn()
+{
+ BaseClass::Spawn();
+
+ Precache();
+ SetModel( EMPGENERATOR_MODEL );
+ SetSolid( SOLID_BBOX );
+ SetCollisionGroup( TFCOLLISION_GROUP_COMBATOBJECT );
+
+ UTIL_SetSize(this, EMPGENERATOR_MINS, EMPGENERATOR_MAXS);
+ m_takedamage = DAMAGE_YES;
+ m_iHealth = obj_empgenerator_health.GetInt();
+
+ SetThink( EMPThink );
+ SetNextThink( gpGlobals->curtime + EMPGENERATOR_RATE );
+ m_flExpiresAt = gpGlobals->curtime + EMPGENERATOR_LIFETIME;
+
+ SetType( OBJ_EMPGENERATOR );
+ m_fObjectFlags |= OF_SUPPRESS_NOTIFY_UNDER_ATTACK | OF_SUPPRESS_TECH_ANALYZER |
+ OF_DONT_AUTO_REPAIR | OF_DONT_PREVENT_BUILD_NEAR_OBJ | OF_DOESNT_NEED_POWER;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CObjectEMPGenerator::Precache()
+{
+ PrecacheModel( EMPGENERATOR_MODEL );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Look for enemies to EMP
+//-----------------------------------------------------------------------------
+void CObjectEMPGenerator::EMPThink( void )
+{
+ if ( !GetTeam() )
+ return;
+
+ // Time to die?
+ if ( gpGlobals->curtime > m_flExpiresAt )
+ {
+ UTIL_Remove( this );
+ return;
+ }
+
+ // Look for nearby enemies to EMP
+ CBaseEntity *pEntity = NULL;
+ for ( CEntitySphereQuery sphere( GetAbsOrigin(), EMPGENERATOR_RADIUS ); ( pEntity = sphere.GetCurrentEntity() ) != NULL; sphere.NextEntity() )
+ {
+ if ( InSameTeam( pEntity ) )
+ continue;
+ if ( !pEntity->CanBePoweredUp() )
+ continue;
+
+ pEntity->AttemptToPowerup( POWERUP_EMP, EMPGENERATOR_EMP_TIME );
+ }
+}