Skip to content

Commit 0d3848e

Browse files
authored
Merge pull request #3 from BitlDevelopmentStudios/NPC
[HL2DM] NPC support for multiplayer
2 parents 74c078b + f203943 commit 0d3848e

File tree

121 files changed

+4207
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+4207
-408
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This base is specific to multiplayer mod projects.
2121
- Full support of the Half-Life 2 Survivor animation set for all mods.
2222
- reset.bat file in each mod folder, used for cleaning up config/temporary files for easy mod distribution
2323
- Implemented bhopping functionality that can be enabled or disabled by server owners in TF2 and HL2DM.
24+
- Multiplayer NPC support with the BDSBASE_NPC compile definition.
2425

2526
## Setup:
2627
Read Autumn's setup guide at README_FROG.md for detailed setup.

src/game/client/fx_blood.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@
2525
// memdbgon must be the last include file in a .cpp file!!!
2626
#include "tier0/memdbgon.h"
2727

28-
#ifdef BDSBASE
29-
#ifdef TF_CLIENT_DLL
30-
ConVar r_classic_blood("r_classic_blood", "0", FCVAR_DEVELOPMENTONLY);
31-
#else
32-
ConVar r_classic_blood("r_classic_blood", "0", FCVAR_ARCHIVE);
33-
#endif
34-
#endif
35-
3628
CLIENTEFFECT_REGISTER_BEGIN( PrecacheEffectBloodSpray )
3729
CLIENTEFFECT_MATERIAL( "effects/blood_core" )
3830
CLIENTEFFECT_MATERIAL( "effects/blood_gore" )
@@ -510,24 +502,6 @@ DECLARE_CLIENT_EFFECT( "bloodspray", BloodSprayCallback );
510502
void BloodImpactCallback( const CEffectData & data )
511503
{
512504
bool bFoundBlood = false;
513-
514-
#ifdef BDSBASE
515-
if (!r_classic_blood.GetBool())
516-
{
517-
// Find which sort of blood we are
518-
for (int i = 0; i < ARRAYSIZE(bloodCallbacks); i++)
519-
{
520-
if (bloodCallbacks[i].nColor == data.m_nColor)
521-
{
522-
QAngle vecAngles;
523-
VectorAngles(-data.m_vNormal, vecAngles);
524-
DispatchParticleEffect(bloodCallbacks[i].lpszParticleSystemName, data.m_vOrigin, vecAngles);
525-
bFoundBlood = true;
526-
break;
527-
}
528-
}
529-
}
530-
#else
531505
// Find which sort of blood we are
532506
for (int i = 0; i < ARRAYSIZE(bloodCallbacks); i++)
533507
{
@@ -540,7 +514,6 @@ void BloodImpactCallback( const CEffectData & data )
540514
break;
541515
}
542516
}
543-
#endif
544517

545518
if ( bFoundBlood == false )
546519
{

src/game/client/hl2/hud_locator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ bool CHudLocator::ShouldDraw( void )
128128
if( pPlayer->GetVehicle() )
129129
return false;
130130

131+
#ifdef HL2_EPISODIC
131132
if( pPlayer->m_HL2Local.m_vecLocatorOrigin == vec3_invalid )
132133
return false;
134+
#endif //HL2_EPISODIC
133135

134136
return true;
135137
}

src/game/client/weapon_selection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ void CBaseHudWeaponSelection::UserCmd_Slot10(void)
401401
}
402402

403403
#ifdef BDSBASE
404+
#ifdef HL2_CLIENT_DLL
404405
void ClientInstantPhysSwap()
405406
{
406407
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
@@ -433,6 +434,7 @@ void ClientInstantPhysSwap()
433434

434435
static ConCommand cl_physswap("phys_swap", ClientInstantPhysSwap, "Client-predicted physcannon swap for low-latency switching.");
435436
#endif
437+
#endif
436438

437439
//-----------------------------------------------------------------------------
438440
// Purpose: returns true if the CHudMenu should take slot1, etc commands

src/game/server/EntityDissolve.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ CEntityDissolve *CEntityDissolve::Create( CBaseEntity *pTarget, const char *pMat
232232
// Necessary to cause it to do the appropriate death cleanup
233233
if ( pTarget->m_lifeState == LIFE_ALIVE )
234234
{
235-
CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 );
235+
#ifdef BDSBASE_NPC
236+
CBasePlayer* pPlayer = UTIL_GetLocalPlayer();
237+
#else
238+
CBasePlayer* pPlayer = UTIL_PlayerByIndex(1);
239+
#endif //BDSBASE
236240
CTakeDamageInfo ragdollInfo( pPlayer, pPlayer, 10000.0, DMG_SHOCK | DMG_REMOVENORAGDOLL | DMG_PREVENT_PHYSICS_FORCE );
237241
pTarget->TakeDamage( ragdollInfo );
238242
}
@@ -347,7 +351,11 @@ void CEntityDissolve::DissolveThink( void )
347351
// Necessary to cause it to do the appropriate death cleanup
348352
// Yeah, the player may have nothing to do with it, but
349353
// passing NULL to TakeDamage causes bad things to happen
350-
CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 );
354+
#ifdef BDSBASE_NPC
355+
CBasePlayer* pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin());
356+
#else
357+
CBasePlayer* pPlayer = UTIL_PlayerByIndex(1);
358+
#endif //BDSBASE
351359
int iNoPhysicsDamage = g_pGameRules->Damage_GetNoPhysicsForce();
352360
CTakeDamageInfo info( pPlayer, pPlayer, 10000.0, DMG_GENERIC | DMG_REMOVENORAGDOLL | iNoPhysicsDamage );
353361
pTarget->TakeDamage( info );

src/game/server/EnvHudHint.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ void CEnvHudHint::InputShowHudHint( inputdata_t &inputdata )
8989
}
9090
else
9191
{
92+
#ifdef BDSBASE_NPC
93+
pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin());
94+
#else
9295
pPlayer = UTIL_GetLocalPlayer();
96+
#endif //BDSBASE
9397
}
9498

9599
if ( !pPlayer || !pPlayer->IsNetClient() )
@@ -126,7 +130,11 @@ void CEnvHudHint::InputHideHudHint( inputdata_t &inputdata )
126130
}
127131
else
128132
{
133+
#ifdef BDSBASE_NPC
134+
pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin());
135+
#else
129136
pPlayer = UTIL_GetLocalPlayer();
137+
#endif //BDSBASE
130138
}
131139

132140
if ( !pPlayer || !pPlayer->IsNetClient() )

src/game/server/EnvMessage.cpp

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ void CMessage::InputShowMessage( inputdata_t &inputdata )
105105
}
106106
else
107107
{
108+
#ifdef BDSBASE_NPC
109+
pPlayer = UTIL_GetLocalPlayer(); // just show it to the host, if there is one
110+
#else
108111
pPlayer = (gpGlobals->maxClients > 1) ? NULL : UTIL_GetLocalPlayer();
112+
#endif //BDSBASE
109113
}
110114

111115
if ( pPlayer && pPlayer->IsPlayer() )
@@ -219,12 +223,19 @@ void CCredits::RollOutroCredits()
219223
{
220224
sv_unlockedchapters.SetValue( "15" );
221225

222-
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
223-
224-
CSingleUserRecipientFilter user( pPlayer );
226+
#ifdef BDSBASE_NPC
227+
CRecipientFilter filter;
228+
filter.AddAllPlayers();
229+
filter.MakeReliable();
230+
UserMessageBegin(filter, "CreditsMsg");
231+
#else
232+
CBasePlayer* pPlayer = UTIL_GetLocalPlayer();
233+
234+
CSingleUserRecipientFilter user(pPlayer);
225235
user.MakeReliable();
226236

227-
UserMessageBegin( user, "CreditsMsg" );
237+
UserMessageBegin(user, "CreditsMsg");
238+
#endif //BDSBASE
228239
WRITE_BYTE( 3 );
229240
MessageEnd();
230241
}
@@ -241,20 +252,38 @@ void CCredits::InputRollOutroCredits( inputdata_t &inputdata )
241252

242253
void CCredits::InputShowLogo( inputdata_t &inputdata )
243254
{
244-
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
245-
246-
CSingleUserRecipientFilter user( pPlayer );
255+
#ifdef BDSBASE_NPC
256+
CRecipientFilter filter;
257+
filter.AddAllPlayers();
258+
filter.MakeReliable();
259+
260+
// Modification. Set to how old patched AI SDK had code.
261+
//CSingleUserRecipientFilter user( pPlayer );
262+
//user.MakeReliable();
263+
#else
264+
CBasePlayer* pPlayer = UTIL_GetLocalPlayer();
265+
266+
CSingleUserRecipientFilter user(pPlayer);
247267
user.MakeReliable();
268+
#endif //BDSBASE
248269

249270
if ( m_flLogoLength )
250271
{
251-
UserMessageBegin( user, "LogoTimeMsg" );
272+
#ifdef BDSBASE_NPC
273+
UserMessageBegin(filter, "LogoTimeMsg");
274+
#else
275+
UserMessageBegin(user, "LogoTimeMsg");
276+
#endif //BDSBASE
252277
WRITE_FLOAT( m_flLogoLength );
253278
MessageEnd();
254279
}
255280
else
256281
{
257-
UserMessageBegin( user, "CreditsMsg" );
282+
#ifdef BDSBASE_NPC
283+
UserMessageBegin(filter, "CreditsMsg");
284+
#else
285+
UserMessageBegin(user, "CreditsMsg");
286+
#endif //BDSBASE
258287
WRITE_BYTE( 1 );
259288
MessageEnd();
260289
}
@@ -267,12 +296,21 @@ void CCredits::InputSetLogoLength( inputdata_t &inputdata )
267296

268297
void CCredits::InputRollCredits( inputdata_t &inputdata )
269298
{
270-
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
299+
#ifdef BDSBASE_NPC
300+
CRecipientFilter filter;
301+
filter.AddAllPlayers();
302+
filter.MakeReliable();
303+
304+
UserMessageBegin(filter, "CreditsMsg");
305+
WRITE_BYTE(2); // Modification: Added from old patched AI SDK.
306+
#else
307+
CBasePlayer* pPlayer = UTIL_GetLocalPlayer();
271308

272-
CSingleUserRecipientFilter user( pPlayer );
309+
CSingleUserRecipientFilter user(pPlayer);
273310
user.MakeReliable();
274311

275-
UserMessageBegin( user, "CreditsMsg" );
276-
WRITE_BYTE( 2 );
312+
UserMessageBegin(user, "CreditsMsg");
313+
WRITE_BYTE(2);
314+
#endif //BDSBASE
277315
MessageEnd();
278316
}

0 commit comments

Comments
 (0)