Browse Source

Add trigger_autobot implementation.

decay-pc
Night Owl 6 years ago
parent
commit
fef80cff55
  1. 1
      dlls/gamerules.cpp
  2. 7
      dlls/gamerules.h
  3. 2
      dlls/multiplay_gamerules.cpp
  4. 26
      dlls/triggers.cpp

1
dlls/gamerules.cpp

@ -33,7 +33,6 @@ extern DLL_GLOBAL BOOL g_fGameOver; @@ -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;
//=========================================================

7
dlls/gamerules.h

@ -23,6 +23,8 @@ class CBasePlayer; @@ -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 @@ -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 @@ -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 @@ -260,6 +265,8 @@ class CHalfLifeMultiplay : public CGameRules
public:
CHalfLifeMultiplay();
virtual int CountPlayers();
// GR_Think
virtual void Think( void );
virtual void RefreshSkillData( void );

2
dlls/multiplay_gamerules.cpp

@ -1443,7 +1443,7 @@ CountPlayers @@ -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;

26
dlls/triggers.cpp

@ -2309,7 +2309,31 @@ void CTriggerRandom::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP @@ -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.

Loading…
Cancel
Save