diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index 53749ff2..685c09a8 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -33,7 +33,6 @@ extern DLL_GLOBAL BOOL g_fGameOver; extern int gmsgDeathMsg; // client dll messages extern int gmsgMOTD; -extern BOOL g_bIsDecayGame; int g_teamplay = 0; //========================================================= diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 6ad470d0..044af869 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -23,6 +23,8 @@ class CBasePlayer; class CItem; class CBasePlayerAmmo; +extern BOOL g_bIsDecayGame; + // weapon respawning return codes enum { @@ -61,6 +63,7 @@ class CGameRules public: virtual ~CGameRules(){} + virtual int CountPlayers() = 0; virtual void RefreshSkillData( void );// fill skill data struct with proper values virtual void Think( void ) = 0;// GR_Think - runs every server frame, should handle any timer tasks, periodic events, etc. virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ) = 0; // Can this item spawn (eg monsters don't spawn in deathmatch). @@ -174,6 +177,8 @@ class CHalfLifeRules : public CGameRules public: CHalfLifeRules ( void ); + virtual int CountPlayers() { return 1; }; + // GR_Think virtual void Think( void ); virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ); @@ -260,6 +265,8 @@ class CHalfLifeMultiplay : public CGameRules public: CHalfLifeMultiplay(); + virtual int CountPlayers(); + // GR_Think virtual void Think( void ); virtual void RefreshSkillData( void ); diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 5380a326..2611bf35 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -1443,7 +1443,7 @@ CountPlayers Determine the current # of active players on the server for map cycling logic ============== */ -int CountPlayers( void ) +int CHalfLifeMultiplay::CountPlayers( void ) { int num = 0; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 13e6202d..6251ca5d 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -2309,7 +2309,31 @@ void CTriggerRandom::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } if( !i ) - ALERT( at_console, "Randomly found entity `%s` not found!\n", szTargetName ); + ALERT( at_console, "Randomly found entity \"%s\" not found!\n", szTargetName ); +} + +class CTriggerAutoBot : public CBaseDelay +{ +public: + void Spawn(); + void Think(); +}; + +LINK_ENTITY_TO_CLASS( trigger_autobot, CTriggerAutoBot ) + +void CTriggerAutoBot::Spawn() +{ + pev->nextthink = gpGlobals->time + 9.0f; +} + +void CTriggerAutoBot::Think() +{ + if( g_bIsDecayGame && g_pGameRules->IsCoOp() ) + { + if( g_pGameRules->CountPlayers() == 1 ) + SERVER_COMMAND( "addbot\n" ); + UTIL_Remove( this ); + } } // this is a really bad idea.