mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-03-12 13:31:33 +00:00
Update player spawn code. Define new cmds.
This commit is contained in:
parent
ff598b10e2
commit
981ffd6085
@ -90,29 +90,6 @@ char scientist_sounds[][30] = { SC_SND1, SC_SND2, SC_SND3, SC_SND4, SC_SND5 };
|
||||
|
||||
LINK_ENTITY_TO_CLASS( bot, CBot );
|
||||
|
||||
|
||||
inline edict_t *CREATE_FAKE_CLIENT( const char *netname )
|
||||
{
|
||||
return (*g_engfuncs.pfnCreateFakeClient)( netname );
|
||||
}
|
||||
|
||||
inline char *GET_INFOBUFFER( edict_t *e )
|
||||
{
|
||||
return (*g_engfuncs.pfnGetInfoKeyBuffer)( e );
|
||||
}
|
||||
|
||||
inline char *GET_INFO_KEY_VALUE( const char *infobuffer, const char *key )
|
||||
{
|
||||
return (g_engfuncs.pfnInfoKeyValue( infobuffer, key ));
|
||||
}
|
||||
|
||||
inline void SET_CLIENT_KEY_VALUE( int clientIndex, const char *infobuffer,
|
||||
const char *key, const char *value )
|
||||
{
|
||||
(*g_engfuncs.pfnSetClientKeyValue)( clientIndex, infobuffer, key, value );
|
||||
}
|
||||
|
||||
|
||||
void BotDebug( char *buffer )
|
||||
{
|
||||
// print out debug messages to the HUD of all players
|
||||
|
@ -350,7 +350,7 @@ public:
|
||||
|
||||
enum EGON_FIRESTATE { FIRE_OFF, FIRE_CHARGE };
|
||||
int m_fireState;
|
||||
int DecayID;
|
||||
int m_iDecay;
|
||||
};
|
||||
|
||||
// Ugly technique to override base member functions
|
||||
@ -782,5 +782,8 @@ public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void KeyValue( KeyValueData *pkvd );
|
||||
|
||||
private:
|
||||
BOOL m_bIsSlaveCoOp;
|
||||
};
|
||||
#endif
|
||||
|
@ -63,6 +63,7 @@ extern void CopyToBodyQue( entvars_t* pev );
|
||||
extern int giPrecacheGrunt;
|
||||
extern int gmsgSayText;
|
||||
extern int gmsgBhopcap;
|
||||
extern BOOL g_bIsSlaveCoOp;
|
||||
|
||||
extern cvar_t allow_spectators;
|
||||
|
||||
@ -532,6 +533,44 @@ void ClientCommand( edict_t *pEntity )
|
||||
{
|
||||
Host_Say( pEntity, 1 );
|
||||
}
|
||||
else if( FStrEq( pcmd, "changeplayer" ) )
|
||||
{
|
||||
if( g_pGameRules->IsCoOp() )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else if( FStrEq( pcmd, "changeplayer2" ) )
|
||||
{
|
||||
if( g_pGameRules->IsCoOp() )
|
||||
{
|
||||
CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev );
|
||||
pPlayer->m_iDecay = ( pPlayer->m_iDecay == 1 ) ? 2 : 1;
|
||||
ALERT( at_console, "Player 1 index changed to %d\n", pPlayer->m_iDecay );
|
||||
}
|
||||
}
|
||||
else if( FStrEq( pcmd, "euukraine" ) )
|
||||
{
|
||||
if( g_pGameRules->IsCoOp() )
|
||||
{
|
||||
if( FStrEq( CMD_ARGV( 1 ), "visafree" ) )
|
||||
{
|
||||
// Unlock alien campaign
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( FStrEq( pcmd, "test1" ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ALL, SVC_INTERMISSION );
|
||||
MESSAGE_END();
|
||||
}
|
||||
else if( FStrEq( pcmd, "stripall" ) )
|
||||
{
|
||||
if( g_pGameRules->IsCoOp() )
|
||||
{
|
||||
GetClassPtr( (CBasePlayer *)pev )->PackDeadPlayerItems();
|
||||
}
|
||||
}
|
||||
else if( FStrEq( pcmd, "fullupdate" ) )
|
||||
{
|
||||
GetClassPtr( (CBasePlayer *)pev )->ForceClientDllUpdate();
|
||||
@ -654,7 +693,10 @@ void ClientCommand( edict_t *pEntity )
|
||||
if( !IS_DEDICATED_SERVER() )
|
||||
{
|
||||
// If user types "addbot" in console, add a bot with skin and name
|
||||
BotCreate( CMD_ARGV( 1 ), CMD_ARGV( 2 ), CMD_ARGV( 3 ) );
|
||||
if( g_bIsSlaveCoOp )
|
||||
BotCreate( "player/dm_slave/dm_slave", "R-4913", 0 );
|
||||
else
|
||||
BotCreate( "ginacol", "Colette", 0 );// TODO: Give normal bodygroups/skins/names for bots.
|
||||
}
|
||||
else
|
||||
CLIENT_PRINTF( pEntity, print_console, "addbot not allowed from client!\n" );
|
||||
|
@ -161,4 +161,23 @@ inline void *GET_PRIVATE( edict_t *pent )
|
||||
|
||||
#define PLAYER_CNX_STATS ( *g_engfuncs.pfnGetPlayerStats )
|
||||
|
||||
inline edict_t *CREATE_FAKE_CLIENT( const char *netname )
|
||||
{
|
||||
return (*g_engfuncs.pfnCreateFakeClient)( netname );
|
||||
}
|
||||
|
||||
inline char *GET_INFOBUFFER( edict_t *e )
|
||||
{
|
||||
return (*g_engfuncs.pfnGetInfoKeyBuffer)( e );
|
||||
}
|
||||
|
||||
inline char *GET_INFO_KEY_VALUE( const char *infobuffer, const char *key )
|
||||
{
|
||||
return (g_engfuncs.pfnInfoKeyValue( infobuffer, key ) );
|
||||
}
|
||||
|
||||
inline void SET_CLIENT_KEY_VALUE( int clientIndex, const char *infobuffer, const char *key, const char *value )
|
||||
{
|
||||
(*g_engfuncs.pfnSetClientKeyValue)( clientIndex, infobuffer, key, value );
|
||||
}
|
||||
#endif //ENGINECALLBACK_H
|
||||
|
@ -33,6 +33,7 @@ extern DLL_GLOBAL BOOL g_fGameOver;
|
||||
extern int gmsgDeathMsg; // client dll messages
|
||||
extern int gmsgMOTD;
|
||||
|
||||
extern BOOL g_bIsDecayGame;
|
||||
int g_teamplay = 0;
|
||||
|
||||
//=========================================================
|
||||
@ -311,8 +312,14 @@ CGameRules *InstallGameRules( void )
|
||||
{
|
||||
SERVER_COMMAND( "exec game.cfg\n" );
|
||||
SERVER_EXECUTE();
|
||||
ALERT( at_console, "Installing game rule...\n" );
|
||||
|
||||
if( !gpGlobals->deathmatch )
|
||||
if( g_bIsDecayGame )
|
||||
{
|
||||
return new CHalfLifeRules;
|
||||
//return new CDecayRules;
|
||||
}
|
||||
else if( !gpGlobals->deathmatch )
|
||||
{
|
||||
// generic half-life
|
||||
g_teamplay = 0;
|
||||
|
@ -170,7 +170,7 @@ void CItem::Materialize( void )
|
||||
}
|
||||
|
||||
#define SF_SUIT_SHORTLOGON 0x0001
|
||||
|
||||
extern int g_iStartSuit;
|
||||
class CItemSuit : public CItem
|
||||
{
|
||||
void Spawn( void )
|
||||
@ -188,10 +188,13 @@ class CItemSuit : public CItem
|
||||
if( pPlayer->pev->weapons & ( 1<<WEAPON_SUIT ) )
|
||||
return FALSE;
|
||||
|
||||
if( pev->spawnflags & SF_SUIT_SHORTLOGON )
|
||||
EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A0" ); // short version of suit logon,
|
||||
else
|
||||
EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_AAx" ); // long version of suit logon
|
||||
if( !g_iStartSuit )
|
||||
{
|
||||
if( pev->spawnflags & SF_SUIT_SHORTLOGON )
|
||||
EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A0" ); // short version of suit logon,
|
||||
else
|
||||
EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_AAx" ); // long version of suit logon
|
||||
}
|
||||
|
||||
pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT );
|
||||
return TRUE;
|
||||
|
@ -47,6 +47,10 @@ extern DLL_GLOBAL int g_iSkillLevel, gDisplayTitle;
|
||||
|
||||
extern "C" int g_bhopcap;
|
||||
|
||||
extern BOOL g_bIsSlaveCoOp;
|
||||
extern BOOL g_bIsDecayGame;
|
||||
extern int g_iStartSuit;
|
||||
|
||||
BOOL gInitHUD = TRUE;
|
||||
|
||||
extern void CopyToBodyQue( entvars_t *pev);
|
||||
@ -192,7 +196,7 @@ int gmsgLensFlare = 0;
|
||||
int gmsgAimFrame = 0;
|
||||
int gmsgNotepad = 0;
|
||||
int gmsgChangeMode = 0;
|
||||
int gmsgChangePlr = 0;
|
||||
int gmsgChangePlayer = 0;
|
||||
int gmsgCamera = 0;
|
||||
int gmsgSparePlayer = 0;
|
||||
int gmsgAlienState = 0;
|
||||
@ -249,7 +253,7 @@ void LinkUserMessages( void )
|
||||
gmsgAimFrame = REG_USER_MSG( "AimFrame", 14 );
|
||||
gmsgNotepad = REG_USER_MSG( "Notepad", -1 );
|
||||
gmsgChangeMode = REG_USER_MSG( "ChangeMode", 1 );
|
||||
gmsgChangePlr = REG_USER_MSG( "ChangePlr", 1 );
|
||||
gmsgChangePlayer = REG_USER_MSG( "ChangePlr", 1 );
|
||||
gmsgCamera = REG_USER_MSG( "Camera", 7 );
|
||||
gmsgSparePlayer = REG_USER_MSG( "SparePlayer", 1 );
|
||||
gmsgAlienState = REG_USER_MSG( "AlienState", 1 );
|
||||
@ -2839,7 +2843,11 @@ void CBasePlayer::Spawn( void )
|
||||
m_iStepLeft = 0;
|
||||
m_flFieldOfView = 0.5;// some monsters use this to determine whether or not the player is looking at them.
|
||||
|
||||
m_bloodColor = BLOOD_COLOR_RED;
|
||||
if( g_bIsSlaveCoOp )
|
||||
m_bloodColor = BLOOD_COLOR_GREEN;
|
||||
else
|
||||
m_bloodColor = BLOOD_COLOR_RED;
|
||||
|
||||
m_flNextAttack = UTIL_WeaponTimeBase();
|
||||
StartSneaking();
|
||||
|
||||
@ -2852,7 +2860,11 @@ void CBasePlayer::Spawn( void )
|
||||
g_pGameRules->SetDefaultPlayerTeam( this );
|
||||
g_pGameRules->GetPlayerSpawnSpot( this );
|
||||
|
||||
SET_MODEL( ENT( pev ), "models/player.mdl" );
|
||||
if( g_bIsSlaveCoOp )
|
||||
SET_MODEL( ENT( pev ), "models/player/dm_slave/dm_slave.mdl" );
|
||||
else
|
||||
SET_MODEL( ENT( pev ), "models/player.mdl" );
|
||||
|
||||
g_ulModelIndexPlayer = pev->modelindex;
|
||||
pev->sequence = LookupActivity( ACT_IDLE );
|
||||
|
||||
@ -2894,6 +2906,50 @@ void CBasePlayer::Spawn( void )
|
||||
pBotCam = NULL;
|
||||
// END BOT
|
||||
g_pGameRules->PlayerSpawn( this );
|
||||
|
||||
if( g_bIsSlaveCoOp )
|
||||
SET_CLIENT_KEY_VALUE( entindex(), GET_INFOBUFFER( edict() ), "model", "player/dm_slave/dm_slave" );
|
||||
else
|
||||
SET_CLIENT_KEY_VALUE( entindex(), GET_INFOBUFFER( edict() ), "model", "ginacol" );
|
||||
|
||||
if( m_iDecay == 1 )
|
||||
{
|
||||
SetBodygroup( 1, 1 );
|
||||
pev->skin = 1;
|
||||
}
|
||||
else if( m_iDecay == 2 )
|
||||
{
|
||||
SetBodygroup( 1, 0 );
|
||||
pev->skin = 0;
|
||||
}
|
||||
else
|
||||
SetBodygroup( 0, 0 );
|
||||
|
||||
if( gmsgChangePlayer )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgChangePlayer, NULL, pev );
|
||||
WRITE_BYTE( m_iDecay );
|
||||
MESSAGE_END();
|
||||
}
|
||||
else
|
||||
{
|
||||
ALERT( at_console, "Message gmsgChangePlayer not found in client!\n" );
|
||||
}
|
||||
ALERT( at_console, "(CBasePlayer::Spawn) m_iDecay = %d\n", m_iDecay );
|
||||
|
||||
if( g_iStartSuit )
|
||||
{
|
||||
if( !g_bIsSlaveCoOp )
|
||||
{
|
||||
CBaseEntity *pWeaponEntity;
|
||||
GiveNamedItem( "item_suit" );
|
||||
|
||||
while( ( pWeaponEntity = UTIL_FindEntityByClassname( pWeaponEntity, "game_player_equip" ) ) != NULL )
|
||||
{
|
||||
pWeaponEntity->Touch( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBasePlayer::Precache( void )
|
||||
@ -2981,7 +3037,10 @@ int CBasePlayer::Restore( CRestore &restore )
|
||||
pev->fixangle = TRUE; // turn this way immediately
|
||||
|
||||
// Copied from spawn() for now
|
||||
m_bloodColor = BLOOD_COLOR_RED;
|
||||
if( g_bIsSlaveCoOp )
|
||||
m_bloodColor = BLOOD_COLOR_GREEN;
|
||||
else
|
||||
m_bloodColor = BLOOD_COLOR_RED;
|
||||
|
||||
g_ulModelIndexPlayer = pev->modelindex;
|
||||
|
||||
@ -4636,7 +4695,7 @@ void CDeadHEV::Spawn( void )
|
||||
pev->effects = 0;
|
||||
pev->yaw_speed = 8;
|
||||
pev->sequence = 0;
|
||||
pev->body = 1;
|
||||
SetBodygroup( 1, 4 );
|
||||
m_bloodColor = BLOOD_COLOR_RED;
|
||||
|
||||
pev->sequence = LookupSequence( m_szPoses[m_iPose] );
|
||||
|
@ -2136,7 +2136,7 @@ void CPlayerSpawnTrigger::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, US
|
||||
|| !pActivator
|
||||
|| !pActivator->IsPlayer()
|
||||
|| !m_iPlayerIndex
|
||||
|| pActivator->DecayID == m_iPlayerIndex )
|
||||
|| pActivator->m_iDecay == m_iPlayerIndex )
|
||||
{
|
||||
SUB_UseTargets( this, triggerType, 0 );
|
||||
|
||||
|
@ -450,6 +450,9 @@ LINK_ENTITY_TO_CLASS( worldspawn, CWorld )
|
||||
#define SF_WORLD_FORCETEAM 0x0004 // Force teams
|
||||
|
||||
extern DLL_GLOBAL BOOL g_fGameOver;
|
||||
int g_iStartSuit = 0;
|
||||
BOOL g_bIsSlaveCoOp = FALSE;
|
||||
BOOL g_bIsDecayGame = FALSE;
|
||||
float g_flWeaponCheat;
|
||||
|
||||
void CWorld::Spawn( void )
|
||||
@ -477,6 +480,13 @@ void CWorld::Precache( void )
|
||||
g_pGameRules = NULL;
|
||||
}
|
||||
|
||||
if( g_bIsDecayGame )
|
||||
{
|
||||
g_bIsSlaveCoOp = m_bIsSlaveCoOp;
|
||||
if( !CBaseEntity::Create( "trigger_autobot", g_vecZero, g_vecZero, NULL ) );
|
||||
ALERT( at_aiconsole, "Autobot entity was not created!\n" );
|
||||
}
|
||||
|
||||
g_pGameRules = InstallGameRules();
|
||||
|
||||
//!!!UNDONE why is there so much Spawn code in the Precache function? I'll just keep it here
|
||||
@ -729,6 +739,21 @@ void CWorld::KeyValue( KeyValueData *pkvd )
|
||||
}
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if( FStrEq( pkvd->szKeyName, "startsuit" ) )
|
||||
{
|
||||
g_iStartSuit = atoi( pkvd->szValue );
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if( FStrEq( pkvd->szKeyName, "decay" ) )
|
||||
{
|
||||
g_bIsDecayGame = ( atoi( pkvd->szValue ) != 0 );
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if( FStrEq( pkvd->szKeyName, "slavecoop" ) )
|
||||
{
|
||||
m_bIsSlaveCoOp = ( atoi( pkvd->szValue ) != 0 );
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
CBaseEntity::KeyValue( pkvd );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user