summaryrefslogtreecommitdiff
path: root/game/server/tf/halloween/zombie/zombie_spawner.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/tf/halloween/zombie/zombie_spawner.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/server/tf/halloween/zombie/zombie_spawner.cpp')
-rw-r--r--game/server/tf/halloween/zombie/zombie_spawner.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/game/server/tf/halloween/zombie/zombie_spawner.cpp b/game/server/tf/halloween/zombie/zombie_spawner.cpp
new file mode 100644
index 0000000..cf0e3cb
--- /dev/null
+++ b/game/server/tf/halloween/zombie/zombie_spawner.cpp
@@ -0,0 +1,86 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//
+//
+//=============================================================================
+#include "cbase.h"
+
+#include "tf_shareddefs.h"
+#include "zombie.h"
+#include "zombie_spawner.h"
+
+LINK_ENTITY_TO_CLASS( tf_zombie_spawner, CZombieSpawner );
+
+BEGIN_DATADESC( CZombieSpawner )
+ DEFINE_KEYFIELD( m_flZombieLifeTime, FIELD_FLOAT, "zombie_lifetime" ),
+ DEFINE_KEYFIELD( m_nMaxActiveZombies, FIELD_INTEGER, "max_zombies" ),
+ DEFINE_KEYFIELD( m_bInfiniteZombies, FIELD_BOOLEAN, "infinite_zombies" ),
+ DEFINE_KEYFIELD( m_nSkeletonType, FIELD_INTEGER, "zombie_type" ),
+ DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ),
+ DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ),
+ DEFINE_INPUTFUNC( FIELD_INTEGER, "SetMaxActiveZombies", InputSetMaxActiveZombies ),
+END_DATADESC()
+
+CZombieSpawner::CZombieSpawner()
+{
+ m_bEnabled = false;
+ m_bInfiniteZombies = false;
+ m_nMaxActiveZombies = 1;
+ m_flZombieLifeTime = 0;
+ m_nSkeletonType = 0;
+ m_nSpawned = 0;
+}
+
+
+void CZombieSpawner::Spawn()
+{
+ BaseClass::Spawn();
+
+ SetNextThink( gpGlobals->curtime );
+}
+
+
+void CZombieSpawner::Think()
+{
+ m_activeZombies.FindAndFastRemove( NULL );
+
+ if ( m_bEnabled && ( ( m_bInfiniteZombies && m_activeZombies.Count() < m_nMaxActiveZombies ) || ( !m_bInfiniteZombies && m_nSpawned < m_nMaxActiveZombies ) ) )
+ {
+ CZombie *pZombie = CZombie::SpawnAtPos( GetAbsOrigin(), m_flZombieLifeTime, TF_TEAM_HALLOWEEN, NULL, (CZombie::SkeletonType_t)m_nSkeletonType );
+ if ( pZombie )
+ {
+ m_nSpawned++;
+ m_activeZombies.AddToTail( pZombie );
+ }
+
+ SetNextThink( gpGlobals->curtime + RandomFloat( 1.5f, 3.f ) );
+ return;
+ }
+
+ SetNextThink( gpGlobals->curtime + 0.2f );
+}
+
+
+void CZombieSpawner::InputEnable( inputdata_t &inputdata )
+{
+ m_bEnabled = true;
+
+ SetNextThink( gpGlobals->curtime );
+}
+
+
+void CZombieSpawner::InputDisable( inputdata_t &inputdata )
+{
+ m_bEnabled = false;
+ m_nSpawned = 0;
+
+ m_activeZombies.Purge();
+
+ SetNextThink( gpGlobals->curtime );
+}
+
+
+void CZombieSpawner::InputSetMaxActiveZombies( inputdata_t &inputdata )
+{
+ m_nMaxActiveZombies = inputdata.value.Int();
+}