mirror of https://github.com/FWGS/hlsdk-xash3d
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 gmsgDeathMsg; // client dll messages
|
||||||
extern int gmsgMOTD;
|
extern int gmsgMOTD;
|
||||||
|
|
||||||
extern BOOL g_bIsDecayGame;
|
|
||||||
int g_teamplay = 0;
|
int g_teamplay = 0;
|
||||||
|
|
||||||
//=========================================================
|
//=========================================================
|
||||||
|
|
|
@ -23,6 +23,8 @@ class CBasePlayer;
|
||||||
class CItem;
|
class CItem;
|
||||||
class CBasePlayerAmmo;
|
class CBasePlayerAmmo;
|
||||||
|
|
||||||
|
extern BOOL g_bIsDecayGame;
|
||||||
|
|
||||||
// weapon respawning return codes
|
// weapon respawning return codes
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -61,6 +63,7 @@ class CGameRules
|
||||||
public:
|
public:
|
||||||
virtual ~CGameRules(){}
|
virtual ~CGameRules(){}
|
||||||
|
|
||||||
|
virtual int CountPlayers() = 0;
|
||||||
virtual void RefreshSkillData( void );// fill skill data struct with proper values
|
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 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).
|
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:
|
public:
|
||||||
CHalfLifeRules ( void );
|
CHalfLifeRules ( void );
|
||||||
|
|
||||||
|
virtual int CountPlayers() { return 1; };
|
||||||
|
|
||||||
// GR_Think
|
// GR_Think
|
||||||
virtual void Think( void );
|
virtual void Think( void );
|
||||||
virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity );
|
virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity );
|
||||||
|
@ -260,6 +265,8 @@ class CHalfLifeMultiplay : public CGameRules
|
||||||
public:
|
public:
|
||||||
CHalfLifeMultiplay();
|
CHalfLifeMultiplay();
|
||||||
|
|
||||||
|
virtual int CountPlayers();
|
||||||
|
|
||||||
// GR_Think
|
// GR_Think
|
||||||
virtual void Think( void );
|
virtual void Think( void );
|
||||||
virtual void RefreshSkillData( void );
|
virtual void RefreshSkillData( void );
|
||||||
|
|
|
@ -1443,7 +1443,7 @@ CountPlayers
|
||||||
Determine the current # of active players on the server for map cycling logic
|
Determine the current # of active players on the server for map cycling logic
|
||||||
==============
|
==============
|
||||||
*/
|
*/
|
||||||
int CountPlayers( void )
|
int CHalfLifeMultiplay::CountPlayers( void )
|
||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
|
|
|
@ -2309,7 +2309,31 @@ void CTriggerRandom::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !i )
|
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.
|
// this is a really bad idea.
|
||||||
|
|
Loading…
Reference in New Issue