mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-02-05 11:34:41 +00:00
Hide all coop code under cvars
This commit is contained in:
parent
41afb5f4f1
commit
95578c3602
@ -27,6 +27,7 @@
|
||||
#include "scripted.h"
|
||||
#include "weapons.h"
|
||||
#include "soundent.h"
|
||||
#include "game.h"
|
||||
|
||||
//=========================================================
|
||||
// Monster's Anim Events Go Here
|
||||
@ -512,9 +513,7 @@ int CBarney::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float
|
||||
// Alright, now I'm pissed!
|
||||
PlaySentence( "BA_MAD", 4, VOL_NORM, ATTN_NORM );
|
||||
|
||||
if( pevAttacker->health <= 10 )
|
||||
Forget( bits_MEMORY_PROVOKED );
|
||||
else
|
||||
if( !mp_coop_noangry.value )
|
||||
Remember( bits_MEMORY_PROVOKED );
|
||||
StopFollowing( TRUE );
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ called when a player connects to a server
|
||||
*/
|
||||
BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] )
|
||||
{
|
||||
if( pEntity )
|
||||
if( mp_coop.value && pEntity )
|
||||
{
|
||||
CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ) ;
|
||||
if( pl )
|
||||
@ -86,12 +86,9 @@ BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddres
|
||||
pl->m_state = STATE_UNINITIALIZED;
|
||||
pl->RemoveAllItems( TRUE );
|
||||
BecomeSpectator( pl );
|
||||
//ClientPutInServer( pl->edict() );
|
||||
}
|
||||
}
|
||||
|
||||
//g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 );
|
||||
|
||||
return g_pGameRules->ClientConnected( pEntity, pszName, pszAddress, szRejectReason );
|
||||
|
||||
// a client connecting during an intermission can cause problems
|
||||
@ -139,9 +136,12 @@ void ClientDisconnect( edict_t *pEntity )
|
||||
UTIL_SetOrigin ( &pEntity->v, pEntity->v.origin );
|
||||
|
||||
g_pGameRules->ClientDisconnected( pEntity );
|
||||
CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pEntity );
|
||||
if( pPlayer )
|
||||
pPlayer->m_state = STATE_UNINITIALIZED;
|
||||
if( mp_coop.value )
|
||||
{
|
||||
CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pEntity );
|
||||
if( pPlayer )
|
||||
pPlayer->m_state = STATE_UNINITIALIZED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ void ClientPutInServer( edict_t *pEntity )
|
||||
|
||||
pPlayer = GetClassPtr((CBasePlayer *)pev);
|
||||
pPlayer->SetCustomDecalFrames(-1); // Assume none;
|
||||
if( pPlayer->m_state == STATE_UNINITIALIZED )
|
||||
if( mp_coop.value && pPlayer->m_state == STATE_UNINITIALIZED )
|
||||
g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 );
|
||||
|
||||
pPlayer->m_state = STATE_CONNECTED;
|
||||
@ -224,8 +224,12 @@ void ClientPutInServer( edict_t *pEntity )
|
||||
// Allocate a CBasePlayer for pev, and call spawn
|
||||
pPlayer->Spawn();
|
||||
|
||||
pPlayer->RemoveAllItems( TRUE );
|
||||
BecomeSpectator( pPlayer );
|
||||
// AGHL-like spectator
|
||||
if( mp_spectator.value )
|
||||
{
|
||||
pPlayer->RemoveAllItems( TRUE );
|
||||
BecomeSpectator( pPlayer );
|
||||
}
|
||||
|
||||
// Reset interpolation during first frame
|
||||
pPlayer->pev->effects |= EF_NOINTERP;
|
||||
@ -530,27 +534,31 @@ void ClientCommand( edict_t *pEntity )
|
||||
else if( FStrEq(pcmd, "m1"))
|
||||
{
|
||||
#define MENU_STR(VAR) (#VAR)
|
||||
CLIENT_COMMAND( pEntity,
|
||||
MENU_STR(touch_addbutton "_coops" "*black" "" 0.15 0.1 0.4 0.72 0 0 0 128 334\ntouch_addbutton "_coopst" "#COOP MENU" "" 0.16 0.11 0.41 0.3 0 255 0 255 78 1.5\nm2\n)
|
||||
);
|
||||
if( mp_coop.value )
|
||||
CLIENT_COMMAND( pEntity,
|
||||
MENU_STR(touch_addbutton "_coops" "*black" "" 0.15 0.1 0.4 0.72 0 0 0 128 334\ntouch_addbutton "_coopst" "#COOP MENU" "" 0.16 0.11 0.41 0.3 0 255 0 255 78 1.5\nm2\n)
|
||||
);
|
||||
}
|
||||
else if( FStrEq(pcmd, "m2"))
|
||||
{
|
||||
CLIENT_COMMAND( pEntity,
|
||||
MENU_STR(touch_addbutton "_coops1" "#1. Join coop" "menuselect 1;touch_hide _coops*" 0.16 0.21 0.39 0.3 255 255 255 255 334 1.5\ntouch_addbutton "_coops2" "#2. Become spectator" "menuselect 2;touch_hide _coops*" 0.16 0.31 0.39 0.4 255 255 255 255 334 1.5\nm3\n)
|
||||
);
|
||||
if( mp_coop.value )
|
||||
CLIENT_COMMAND( pEntity,
|
||||
MENU_STR(touch_addbutton "_coops1" "#1. Join coop" "menuselect 1;touch_hide _coops*" 0.16 0.21 0.39 0.3 255 255 255 255 334 1.5\ntouch_addbutton "_coops2" "#2. Become spectator" "menuselect 2;touch_hide _coops*" 0.16 0.31 0.39 0.4 255 255 255 255 334 1.5\nm3\n)
|
||||
);
|
||||
}
|
||||
else if( FStrEq(pcmd, "m3"))
|
||||
{
|
||||
CLIENT_COMMAND( pEntity,
|
||||
MENU_STR(touch_addbutton "_coops3" "#" "menuselect 3;touch_hide _coops*" 0.16 0.41 0.39 0.5 255 255 255 255 335 1.5\ntouch_addbutton "_coops4" "#" "menuselect 4;touch_hide _coops*" 0.16 0.51 0.39 0.6 255 255 255 255 335 1.5\nm4\n)
|
||||
);
|
||||
if( mp_coop.value )
|
||||
CLIENT_COMMAND( pEntity,
|
||||
MENU_STR(touch_addbutton "_coops3" "#" "menuselect 3;touch_hide _coops*" 0.16 0.41 0.39 0.5 255 255 255 255 335 1.5\ntouch_addbutton "_coops4" "#" "menuselect 4;touch_hide _coops*" 0.16 0.51 0.39 0.6 255 255 255 255 335 1.5\nm4\n)
|
||||
);
|
||||
}
|
||||
else if( FStrEq(pcmd, "m4"))
|
||||
{
|
||||
CLIENT_COMMAND( pEntity,
|
||||
MENU_STR(touch_addbutton "_coops5" "#" "menuselect 5;touch_hide _coops*" 0.16 0.61 0.39 0.7 255 255 255 255 335 1.5;wait;slot10\n)
|
||||
);
|
||||
if( mp_coop.value )
|
||||
CLIENT_COMMAND( pEntity,
|
||||
MENU_STR(touch_addbutton "_coops5" "#" "menuselect 5;touch_hide _coops*" 0.16 0.61 0.39 0.7 255 255 255 255 335 1.5;wait;slot10\n)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1891,7 +1899,7 @@ void CreateInstancedBaselines ( void )
|
||||
|
||||
void CvarValue2( const edict_t *pEnt, int requestID, const char *cvarName, const char *value )
|
||||
{
|
||||
if( pEnt && requestID == 111 && FStrEq( cvarName , "touch_enable" ) && atoi( value) )
|
||||
if( mp_coop.value && pEnt && requestID == 111 && FStrEq( cvarName , "touch_enable" ) && atoi( value) )
|
||||
{
|
||||
CBasePlayer *player = (CBasePlayer * ) CBaseEntity::Instance( (edict_t*)pEnt );
|
||||
player->m_fTouchMenu = !!atof( value );
|
||||
|
@ -592,7 +592,7 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib )
|
||||
{
|
||||
unsigned int cCount = 0;
|
||||
BOOL fDone = FALSE;
|
||||
int classs = Classify();
|
||||
|
||||
|
||||
if( HasMemory( bits_MEMORY_KILLED ) )
|
||||
{
|
||||
@ -604,19 +604,22 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib )
|
||||
Remember( bits_MEMORY_KILLED );
|
||||
|
||||
CBaseEntity *activator = CBaseEntity::Instance( pevAttacker );
|
||||
if( classs == CLASS_HUMAN_PASSIVE || classs == CLASS_PLAYER_ALLY )
|
||||
if( mp_coop.value )
|
||||
{
|
||||
if( activator && activator->IsPlayer() )
|
||||
int classs = Classify();
|
||||
if( !mp_coop_nofriendlyfire.value && classs == CLASS_HUMAN_PASSIVE || classs == CLASS_PLAYER_ALLY )
|
||||
{
|
||||
activator->pev->frags -= 30;
|
||||
activator->AddPoints( 0, true );
|
||||
activator->pev->frags -= 50;
|
||||
if( activator && activator->IsPlayer() )
|
||||
{
|
||||
activator->pev->frags -= 30;
|
||||
activator->AddPoints( 0, true );
|
||||
}
|
||||
}
|
||||
else if( classs >= 5 )
|
||||
{
|
||||
if( activator && activator->IsPlayer() )
|
||||
activator->AddPoints( 1, true );
|
||||
}
|
||||
}
|
||||
else if( classs >= 5 )
|
||||
{
|
||||
if( activator && activator->IsPlayer() )
|
||||
activator->AddPoints( 1, true );
|
||||
}
|
||||
|
||||
// clear the deceased's sound channels.(may have been firing or reloading when killed)
|
||||
|
@ -595,9 +595,10 @@ void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use
|
||||
// allow open door that closed sometime
|
||||
if( pev->size.x < 50 || pev->size.y < 50 )
|
||||
m_fActivated = true;
|
||||
if( !pev->target && m_savedtarget )
|
||||
pev->target = m_savedtarget, m_savedtarget = 0;
|
||||
}
|
||||
if( !pev->target && m_savedtarget )
|
||||
pev->target = m_savedtarget, m_savedtarget = 0;
|
||||
|
||||
DoorActivate();
|
||||
}
|
||||
}
|
||||
|
@ -55,8 +55,10 @@ cvar_t mp_coop_changelevel = { "mp_coop_changelevel", "0", FCVAR_SERVER };
|
||||
cvar_t mp_coop_nofriendlyfire = { "mp_coop_nofriendlyfire", "0", FCVAR_SERVER };
|
||||
cvar_t mp_coop_disabledmap = { "mp_coop_disabledmap", "", FCVAR_SERVER };
|
||||
cvar_t mp_coop_reconnect_hack = { "mp_coop_reconnect_hack", "0", FCVAR_SERVER };
|
||||
cvar_t mp_coop_noangry = { "mp_coop_noangry", "0", FCVAR_SERVER };
|
||||
cvar_t mp_unduck = { "mp_unduck", "0", FCVAR_SERVER };
|
||||
cvar_t mp_semclip = { "mp_semclip", "0", FCVAR_SERVER };
|
||||
cvar_t mp_spectator = { "mp_spectator", "0", FCVAR_SERVER };
|
||||
|
||||
// Engine Cvars
|
||||
cvar_t *g_psv_gravity = NULL;
|
||||
@ -506,6 +508,8 @@ void GameDLLInit( void )
|
||||
CVAR_REGISTER( &mp_unduck );
|
||||
CVAR_REGISTER( &mp_semclip );
|
||||
CVAR_REGISTER( &mp_coop_reconnect_hack );
|
||||
CVAR_REGISTER( &mp_coop_noangry );
|
||||
CVAR_REGISTER( &mp_spectator );
|
||||
|
||||
|
||||
CVAR_REGISTER( &mp_chattime );
|
||||
|
@ -55,6 +55,9 @@ extern cvar_t mp_coop_disabledmap;
|
||||
extern cvar_t mp_unduck;
|
||||
extern cvar_t mp_semclip;
|
||||
extern cvar_t mp_coop_reconnect_hack;
|
||||
extern cvar_t mp_coop_noangry;
|
||||
extern cvar_t mp_spectator;
|
||||
|
||||
extern bool g_fSavedDuck;
|
||||
extern bool g_fPause;
|
||||
|
||||
|
@ -177,7 +177,8 @@ CBaseEntity* CItem::Respawn( void )
|
||||
|
||||
SetThink( &CItem::Materialize );
|
||||
pev->nextthink = g_pGameRules->FlItemRespawnTime( this );
|
||||
pev->target = 0;
|
||||
if( mp_coop.value)
|
||||
pev->target = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -225,72 +225,75 @@ BOOL CHalfLifeMultiplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
|
||||
if( g_VoiceGameMgr.ClientCommand( pPlayer, pcmd ) )
|
||||
return TRUE;
|
||||
#endif
|
||||
if( FStrEq( pcmd, "joincoop" ) )
|
||||
if( mp_coop.value )
|
||||
{
|
||||
if( pPlayer->m_state == STATE_SPECTATOR_BEGIN )
|
||||
SpawnPlayer( pPlayer );
|
||||
else
|
||||
ClientPrint( pPlayer->pev, HUD_PRINTCONSOLE, "You cannot use joincoop now!\n\n" );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
if( FStrEq( pcmd, "menuselect" ) )
|
||||
{
|
||||
int imenu = atoi( CMD_ARGV( 1 ) );
|
||||
|
||||
switch( pPlayer->m_state )
|
||||
if( FStrEq( pcmd, "joincoop" ) )
|
||||
{
|
||||
case STATE_SPECTATOR_BEGIN:
|
||||
case STATE_SPECTATOR:
|
||||
if( imenu == 1 )
|
||||
{
|
||||
SpawnPlayer( pPlayer );
|
||||
pPlayer->m_state = STATE_SPAWNED;
|
||||
}
|
||||
if( imenu == 2 )
|
||||
{
|
||||
pPlayer->m_state = STATE_SPECTATOR;
|
||||
CLIENT_COMMAND( pPlayer->edict(), "touch_show _coopm*\n" );
|
||||
}
|
||||
break;
|
||||
case STATE_SPAWNED:
|
||||
if( g_iMenu )
|
||||
{
|
||||
CoopProcessMenu( pPlayer, imenu );
|
||||
return TRUE;
|
||||
}
|
||||
if( imenu == 1 )
|
||||
{
|
||||
pPlayer->RemoveAllItems( TRUE );
|
||||
SpawnPlayer( pPlayer );
|
||||
}
|
||||
if( imenu == 2 )
|
||||
{
|
||||
UTIL_CleanSpawnPoint( pPlayer->pev->origin, 150 );
|
||||
}
|
||||
if( imenu == 3 )
|
||||
{
|
||||
pPlayer->RemoveAllItems( TRUE );
|
||||
BecomeSpectator( pPlayer );
|
||||
pPlayer->m_state = STATE_SPECTATOR;
|
||||
}
|
||||
if( imenu == 4 )
|
||||
{
|
||||
CoopVoteMenu( pPlayer );
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
if( FStrEq( pcmd, "coopmenu" ) )
|
||||
{
|
||||
if( !g_iMenu )
|
||||
CoopMenu( pPlayer );
|
||||
else
|
||||
ClientPrint( pPlayer->pev, HUD_PRINTCONSOLE, "You cannot use coopmenu now!\n\n" );
|
||||
if( pPlayer->m_state == STATE_SPECTATOR_BEGIN )
|
||||
SpawnPlayer( pPlayer );
|
||||
else
|
||||
ClientPrint( pPlayer->pev, HUD_PRINTCONSOLE, "You cannot use joincoop now!\n\n" );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
if( FStrEq( pcmd, "menuselect" ) )
|
||||
{
|
||||
int imenu = atoi( CMD_ARGV( 1 ) );
|
||||
|
||||
switch( pPlayer->m_state )
|
||||
{
|
||||
case STATE_SPECTATOR_BEGIN:
|
||||
case STATE_SPECTATOR:
|
||||
if( imenu == 1 )
|
||||
{
|
||||
SpawnPlayer( pPlayer );
|
||||
pPlayer->m_state = STATE_SPAWNED;
|
||||
}
|
||||
if( imenu == 2 )
|
||||
{
|
||||
pPlayer->m_state = STATE_SPECTATOR;
|
||||
CLIENT_COMMAND( pPlayer->edict(), "touch_show _coopm*\n" );
|
||||
}
|
||||
break;
|
||||
case STATE_SPAWNED:
|
||||
if( g_iMenu )
|
||||
{
|
||||
CoopProcessMenu( pPlayer, imenu );
|
||||
return TRUE;
|
||||
}
|
||||
if( imenu == 1 )
|
||||
{
|
||||
pPlayer->RemoveAllItems( TRUE );
|
||||
SpawnPlayer( pPlayer );
|
||||
}
|
||||
if( imenu == 2 )
|
||||
{
|
||||
UTIL_CleanSpawnPoint( pPlayer->pev->origin, 150 );
|
||||
}
|
||||
if( imenu == 3 )
|
||||
{
|
||||
pPlayer->RemoveAllItems( TRUE );
|
||||
BecomeSpectator( pPlayer );
|
||||
pPlayer->m_state = STATE_SPECTATOR;
|
||||
}
|
||||
if( imenu == 4 )
|
||||
{
|
||||
CoopVoteMenu( pPlayer );
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
if( FStrEq( pcmd, "coopmenu" ) )
|
||||
{
|
||||
if( !g_iMenu )
|
||||
CoopMenu( pPlayer );
|
||||
else
|
||||
ClientPrint( pPlayer->pev, HUD_PRINTCONSOLE, "You cannot use coopmenu now!\n\n" );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return CGameRules::ClientCommand( pPlayer, pcmd );
|
||||
@ -652,16 +655,20 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl )
|
||||
if( pl->m_state <= STATE_CONNECTED )
|
||||
ClientPutInServer( pl->edict() );
|
||||
|
||||
if( pl->m_state == STATE_SPECTATOR_BEGIN )
|
||||
if( mp_coop.value )
|
||||
{
|
||||
|
||||
if( mp_coop.value )
|
||||
if( pl->m_state == STATE_SPECTATOR_BEGIN )
|
||||
{
|
||||
const char *menu[] = {
|
||||
"Join coop",
|
||||
"Join spectators"
|
||||
};
|
||||
ShowMenu( pl, "COOP SERVER", ARRAYSIZE( menu ), menu );
|
||||
|
||||
if( mp_coop.value )
|
||||
{
|
||||
const char *menu[] = {
|
||||
"Join coop",
|
||||
"Join spectators"
|
||||
};
|
||||
ShowMenu( pl, "COOP SERVER", ARRAYSIZE( menu ), menu );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -781,7 +788,7 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
|
||||
return;
|
||||
}
|
||||
|
||||
if( pPlayer->m_state == STATE_CONNECTED )
|
||||
if( mp_spectator.value && pPlayer->m_state == STATE_CONNECTED )
|
||||
{
|
||||
pPlayer->m_state = STATE_SPECTATOR_BEGIN;
|
||||
pPlayer->RemoveAllItems( TRUE );
|
||||
@ -789,7 +796,7 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
|
||||
return;
|
||||
}
|
||||
|
||||
if( pPlayer->m_state == STATE_POINT_SELECT && !(pPlayer->pev->flags & FL_SPECTATOR) )
|
||||
if( mp_coop.value && pPlayer->m_state == STATE_POINT_SELECT && !(pPlayer->pev->flags & FL_SPECTATOR) )
|
||||
{
|
||||
pPlayer->RemoveAllItems( TRUE );
|
||||
BecomeSpectator( pPlayer );
|
||||
|
@ -760,7 +760,8 @@ void CFuncTrain::Next( void )
|
||||
SetBits(pev->effects, EF_NOINTERP);
|
||||
UTIL_SetOrigin(pev, pTarg->pev->origin - (pev->mins + pev->maxs)* 0.5);
|
||||
Wait(); // Get on with doing the next path corner.
|
||||
pev->iuser1++; // Invalidate state for coop
|
||||
if( mp_coop_changelevel.value )
|
||||
pev->iuser1++; // Invalidate state for coop
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "scripted.h"
|
||||
#include "animation.h"
|
||||
#include "soundent.h"
|
||||
#include "game.h"
|
||||
|
||||
#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model
|
||||
|
||||
@ -745,9 +746,7 @@ int CScientist::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo
|
||||
{
|
||||
if( pevInflictor && pevInflictor->flags & FL_CLIENT )
|
||||
{
|
||||
if( pevAttacker->health <= 10 )
|
||||
Forget( bits_MEMORY_PROVOKED );
|
||||
else
|
||||
if( !mp_coop_noangry.value )
|
||||
Remember( bits_MEMORY_PROVOKED );
|
||||
|
||||
StopFollowing( TRUE );
|
||||
|
Loading…
x
Reference in New Issue
Block a user