Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ including radial fog, rope code, and treesway)
- https://github.com/entropy-zero/source-sdk-2013 (skill_changed game event)
- https://github.com/Nbc66/source-sdk-2013-ce/tree/v142 (Base for VS2019 toolset support)

Mapbase also contains parts of Source Engine Co-Operative Base Modification (SecobMod), mainly the multiplayer NPC support by Winston.
- https://developer.valvesoftware.com/wiki/Co-Operative_Base_(Mod)

//-------------------------------------------------------------------------------------------------------------------------

Valve Developer Community (VDC) sources:
Expand Down
4 changes: 4 additions & 0 deletions src/game/client/c_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ void cc_cl_interp_all_changed( IConVar *pConVar, const char *pOldString, float f


static ConVar cl_extrapolate( "cl_extrapolate", "1", FCVAR_CHEAT, "Enable/disable extrapolation if interpolation history runs out." );
#ifdef MAPBASE_MP // From SecobMod
static ConVar cl_interp_npcs( "cl_interp_npcs", "0.25", FCVAR_USERINFO, "Interpolate NPC positions starting this many seconds in past (or cl_interp, if greater)" );
#else
static ConVar cl_interp_npcs( "cl_interp_npcs", "0.0", FCVAR_USERINFO, "Interpolate NPC positions starting this many seconds in past (or cl_interp, if greater)" );
#endif
static ConVar cl_interp_all( "cl_interp_all", "0", 0, "Disable interpolation list optimizations.", 0, 0, 0, 0, cc_cl_interp_all_changed );
ConVar r_drawmodeldecals( "r_drawmodeldecals", "1", FCVAR_ALLOWED_IN_COMPETITIVE );
extern ConVar cl_showerror;
Expand Down
8 changes: 8 additions & 0 deletions src/game/server/EntityDissolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ CEntityDissolve *CEntityDissolve::Create( CBaseEntity *pTarget, const char *pMat
// Necessary to cause it to do the appropriate death cleanup
if ( pTarget->m_lifeState == LIFE_ALIVE )
{
#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
#else
CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 );
#endif
CTakeDamageInfo ragdollInfo( pPlayer, pPlayer, 10000.0, DMG_SHOCK | DMG_REMOVENORAGDOLL | DMG_PREVENT_PHYSICS_FORCE );
pTarget->TakeDamage( ragdollInfo );
}
Expand Down Expand Up @@ -347,7 +351,11 @@ void CEntityDissolve::DissolveThink( void )
// Necessary to cause it to do the appropriate death cleanup
// Yeah, the player may have nothing to do with it, but
// passing NULL to TakeDamage causes bad things to happen
#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 );
#endif
int iNoPhysicsDamage = g_pGameRules->Damage_GetNoPhysicsForce();
CTakeDamageInfo info( pPlayer, pPlayer, 10000.0, DMG_GENERIC | DMG_REMOVENORAGDOLL | iNoPhysicsDamage );
pTarget->TakeDamage( info );
Expand Down
8 changes: 8 additions & 0 deletions src/game/server/EnvHudHint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ void CEnvHudHint::InputShowHudHint( inputdata_t &inputdata )
}
else
{
#ifdef MAPBASE_MP // From SecobMod
pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
pPlayer = UTIL_GetLocalPlayer();
#endif
}

if ( !pPlayer || !pPlayer->IsNetClient() )
Expand Down Expand Up @@ -132,7 +136,11 @@ void CEnvHudHint::InputHideHudHint( inputdata_t &inputdata )
}
else
{
#ifdef MAPBASE_MP // From SecobMod
pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
pPlayer = UTIL_GetLocalPlayer();
#endif
}

if ( !pPlayer || !pPlayer->IsNetClient() )
Expand Down
17 changes: 16 additions & 1 deletion src/game/server/EnvMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,16 @@ void CCredits::RollOutroCredits()
if (Mapbase_GetChapterCount() <= 0 && sv_unlockedchapters.GetInt() < 15)
#endif
sv_unlockedchapters.SetValue( "15" );


#ifdef MAPBASE_MP // From SecobMod
CRecipientFilter user;
user.AddAllPlayers();
#else
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();

CSingleUserRecipientFilter user( pPlayer );
user.MakeReliable();
#endif

UserMessageBegin( user, "CreditsMsg" );
WRITE_BYTE( 3 );
Expand All @@ -293,10 +298,15 @@ void CCredits::InputRollOutroCredits( inputdata_t &inputdata )

void CCredits::InputShowLogo( inputdata_t &inputdata )
{
#ifdef MAPBASE_MP // From SecobMod
CRecipientFilter user;
user.AddAllPlayers();
#else
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();

CSingleUserRecipientFilter user( pPlayer );
user.MakeReliable();
#endif

if ( m_flLogoLength )
{
Expand Down Expand Up @@ -325,10 +335,15 @@ void CCredits::InputSetLogoLength( inputdata_t &inputdata )

void CCredits::InputRollCredits( inputdata_t &inputdata )
{
#ifdef MAPBASE_MP // From SecobMod
CRecipientFilter user;
user.AddAllPlayers();
#else
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();

CSingleUserRecipientFilter user( pPlayer );
user.MakeReliable();
#endif

UserMessageBegin( user, "CreditsMsg" );
WRITE_BYTE( 2 );
Expand Down
52 changes: 52 additions & 0 deletions src/game/server/ai_basenpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,11 @@ void CAI_BaseNPC::Ignite( float flFlameLifetime, bool bNPCOnly, float flSize, bo
#endif

#ifdef HL2_EPISODIC
#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
CBasePlayer *pPlayer = AI_GetSinglePlayer();
#endif
if ( pPlayer && pPlayer->IRelationType( this ) != D_LI )
{
CNPC_Alyx *alyx = CNPC_Alyx::GetAlyx();
Expand Down Expand Up @@ -1200,7 +1204,11 @@ int CAI_BaseNPC::OnTakeDamage_Alive( const CTakeDamageInfo &info )
{
// See if the person that injured me is an NPC.
CAI_BaseNPC *pAttacker = info.GetAttacker()->MyNPCPointer();
#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
CBasePlayer *pPlayer = AI_GetSinglePlayer();
#endif

if( pAttacker && pAttacker->IsAlive() && pPlayer )
{
Expand Down Expand Up @@ -3738,7 +3746,11 @@ void CAI_BaseNPC::UpdateEfficiency( bool bInPVS )

//---------------------------------

#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
CBasePlayer *pPlayer = AI_GetSinglePlayer();
#endif
static Vector vPlayerEyePosition;
static Vector vPlayerForward;
static int iPrevFrame = -1;
Expand Down Expand Up @@ -3985,7 +3997,11 @@ void CAI_BaseNPC::UpdateSleepState( bool bInPVS )
#ifdef MAPBASE
#define Wake() Wake(pLocalPlayer)
#endif
#ifdef MAPBASE_MP
CBasePlayer *pLocalPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
CBasePlayer *pLocalPlayer = AI_GetSinglePlayer();
#endif
if ( !pLocalPlayer )
{
if ( gpGlobals->maxClients > 1 )
Expand Down Expand Up @@ -4188,7 +4204,11 @@ void CAI_BaseNPC::RebalanceThinks()

int i;

#ifdef MAPBASE_MP
CBasePlayer *pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
CBasePlayer *pPlayer = AI_GetSinglePlayer();
#endif
Vector vPlayerForward;
Vector vPlayerEyePosition;

Expand Down Expand Up @@ -4469,7 +4489,11 @@ void CAI_BaseNPC::SetPlayerAvoidState( void )

GetPlayerAvoidBounds( &vMins, &vMaxs );

#ifdef MAPBASE_MP
CBasePlayer *pLocalPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
CBasePlayer *pLocalPlayer = AI_GetSinglePlayer();
#endif

if ( pLocalPlayer )
{
Expand Down Expand Up @@ -5571,14 +5595,22 @@ void CAI_BaseNPC::RunAI( void )
}
}

#ifdef MAPBASE_MP // From SecobMod
if( ai_debug_loners.GetBool() && !IsInSquad() )
#else
if( ai_debug_loners.GetBool() && !IsInSquad() && AI_IsSinglePlayer() )
#endif
{
Vector right;
Vector vecPoint;

vecPoint = EyePosition() + Vector( 0, 0, 12 );

#ifdef MAPBASE_MP // From SecobMod
UTIL_GetNearestPlayer( GetAbsOrigin() )->GetVectors( NULL, &right, NULL );
#else
UTIL_GetLocalPlayer()->GetVectors( NULL, &right, NULL );
#endif

NDebugOverlay::Line( vecPoint, vecPoint + Vector( 0, 0, 64 ), 255, 0, 0, false , 0.1 );
NDebugOverlay::Line( vecPoint, vecPoint + Vector( 0, 0, 32 ) + right * 32, 255, 0, 0, false , 0.1 );
Expand Down Expand Up @@ -10325,7 +10357,11 @@ void CAI_BaseNPC::DrawDebugGeometryOverlays(void)

info.SetDamage( m_iHealth );
info.SetAttacker( this );
#ifdef MAPBASE_MP // From SecobMod
info.SetInflictor( (CBaseEntity *)this );
#else
info.SetInflictor( ( AI_IsSinglePlayer() ) ? (CBaseEntity *)AI_GetSinglePlayer() : (CBaseEntity *)this );
#endif
info.SetDamageType( DMG_GENERIC );

m_debugOverlays &= ~OVERLAY_NPC_KILL_BIT;
Expand Down Expand Up @@ -13970,7 +14006,11 @@ bool CAI_BaseNPC::CineCleanup()
{
SetLocalOrigin( origin );

#ifdef MAPBASE_MP // From SecobMod
int drop = UTIL_DropToFloor( this, MASK_NPCSOLID, UTIL_GetNearestVisiblePlayer( this ) );
#else
int drop = UTIL_DropToFloor( this, MASK_NPCSOLID, UTIL_GetLocalPlayer() );
#endif

// Origin in solid? Set to org at the end of the sequence
if ( ( drop < 0 ) || sv_test_scripted_sequences.GetBool() )
Expand Down Expand Up @@ -14051,7 +14091,11 @@ void CAI_BaseNPC::Teleport( const Vector *newPosition, const QAngle *newAngles,

bool CAI_BaseNPC::FindSpotForNPCInRadius( Vector *pResult, const Vector &vStartPos, CAI_BaseNPC *pNPC, float radius, bool bOutOfPlayerViewcone )
{
#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetNearestPlayer( pNPC->GetAbsOrigin() );
#else
CBasePlayer *pPlayer = AI_GetSinglePlayer();
#endif
QAngle fan;

fan.x = 0;
Expand Down Expand Up @@ -14644,13 +14688,17 @@ bool CAI_BaseNPC::IsPlayerAlly( CBasePlayer *pPlayer )
{
if ( pPlayer == NULL )
{
#ifdef MAPBASE_MP // From SecobMod
pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
// in multiplayer mode we need a valid pPlayer
// or override this virtual function
if ( !AI_IsSinglePlayer() )
return false;

// NULL means single player mode
pPlayer = UTIL_GetLocalPlayer();
#endif
}

return ( !pPlayer || IRelationType( pPlayer ) == D_LI );
Expand Down Expand Up @@ -14948,7 +14996,11 @@ bool CAI_BaseNPC::FindNearestValidGoalPos( const Vector &vTestPoint, Vector *pRe

if ( vCandidate != vec3_invalid )
{
#ifdef MAPBASE_MP // From SecobMod
AI_Waypoint_t *pPathToPoint = GetPathfinder()->BuildRoute( GetAbsOrigin(), vCandidate, UTIL_GetNearestPlayer( GetAbsOrigin() ), 5 * 12, NAV_NONE, true );
#else
AI_Waypoint_t *pPathToPoint = GetPathfinder()->BuildRoute( GetAbsOrigin(), vCandidate, AI_GetSinglePlayer(), 5*12, NAV_NONE, true );
#endif
if ( pPathToPoint )
{
GetPathfinder()->UnlockRouteNodes( pPathToPoint );
Expand Down
8 changes: 8 additions & 0 deletions src/game/server/ai_basenpc_schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3532,7 +3532,11 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask )
case TASK_FACE_PLAYER:
{
// Get edict for one player
#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetNearestVisiblePlayer( this );
#else
CBasePlayer *pPlayer = AI_GetSinglePlayer();
#endif
if ( pPlayer )
{
GetMotor()->SetIdealYawToTargetAndUpdate( pPlayer->GetAbsOrigin(), AI_KEEP_YAW_SPEED );
Expand Down Expand Up @@ -3866,7 +3870,11 @@ void CAI_BaseNPC::RunTask( const Task_t *pTask )

if( pHint )
{
#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
CBasePlayer *pPlayer = AI_GetSinglePlayer();
#endif
Vector vecGoal = pHint->GetAbsOrigin();

if( vecGoal.DistToSqr(GetAbsOrigin()) < vecGoal.DistToSqr(pPlayer->GetAbsOrigin()) )
Expand Down
9 changes: 9 additions & 0 deletions src/game/server/ai_behavior_fear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ void CAI_FearBehavior::GatherConditions()
// -I haven't seen the player in 2 seconds
//
// Here's the distance check:
#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
#else
CBasePlayer *pPlayer = AI_GetSinglePlayer();
#endif
if( pPlayer != NULL && GetAbsOrigin().DistToSqr(pPlayer->GetAbsOrigin()) >= Square( ai_fear_player_dist.GetFloat() * 1.5f ) )
{
SetCondition(COND_FEAR_SEPARATED_FROM_PLAYER);
Expand Down Expand Up @@ -492,7 +496,12 @@ CAI_Hint *CAI_FearBehavior::FindFearWithdrawalDest()
#ifdef MAPBASE
hintCriteria.SetFlag(bits_HINT_NODE_USE_GROUP);
#endif

#ifdef MAPBASE_MP // From SecobMod
hintCriteria.AddIncludePosition( UTIL_GetNearestPlayer( GetAbsOrigin() )->GetAbsOrigin(), (ai_fear_player_dist.GetFloat()) );
#else
hintCriteria.AddIncludePosition( AI_GetSinglePlayer()->GetAbsOrigin(), ( ai_fear_player_dist.GetFloat() ) );
#endif

pHint = CAI_HintManager::FindHint( pOuter, hintCriteria );

Expand Down
9 changes: 9 additions & 0 deletions src/game/server/ai_behavior_follow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2163,11 +2163,20 @@ void CAI_FollowGoal::EnableGoal( CAI_BaseNPC *pAI )
CBaseEntity *pGoalEntity = GetGoalEntity();
if ( !pGoalEntity && AI_IsSinglePlayer() )
{
#ifdef MAPBASE_MP // From SecobMod
CBasePlayer *pPlayer = UTIL_GetNearestPlayer( GetAbsOrigin() );
if ( pAI->IRelationType( pPlayer ) == D_LI )
{
pGoalEntity = pPlayer;
SetGoalEntity( pGoalEntity );
}
#else
if ( pAI->IRelationType(UTIL_GetLocalPlayer()) == D_LI )
{
pGoalEntity = UTIL_GetLocalPlayer();
SetGoalEntity( pGoalEntity );
}
#endif
}

if ( pGoalEntity )
Expand Down
Loading
Loading