mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-03-12 13:31:33 +00:00
Add trigger_autobot implementation.
This commit is contained in:
parent
783b336f1e
commit
fef80cff55
@ -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;
|
||||
|
||||
//=========================================================
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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…
x
Reference in New Issue
Block a user