Skip to content

Commit 5a54a04

Browse files
committed
Add HL2MP player collision avoidance + ally blood decal fix
1 parent c825038 commit 5a54a04

File tree

6 files changed

+63
-0
lines changed

6 files changed

+63
-0
lines changed

src/game/client/hl2mp/c_hl2mp_player.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,22 @@ IRagdoll* C_HL2MP_Player::GetRepresentativeRagdoll() const
992992
}
993993
}
994994

995+
#ifdef MAPBASE
996+
//-----------------------------------------------------------------------------
997+
// Purpose:
998+
//-----------------------------------------------------------------------------
999+
void C_HL2MP_Player::DispatchTraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator )
1000+
{
1001+
if ( info.GetAttacker() )
1002+
{
1003+
if ( !friendlyfire.GetInt() && HL2MPRules()->PlayerRelationship( this, info.GetAttacker() ) == GR_TEAMMATE )
1004+
return;
1005+
}
1006+
1007+
BaseClass::DispatchTraceAttack( info, vecDir, ptr, pAccumulator );
1008+
}
1009+
#endif
1010+
9951011
//HL2MPRAGDOLL
9961012

9971013

src/game/client/hl2mp/c_hl2mp_player.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ class C_HL2MP_Player : public C_BaseHLPlayer
100100
bool SuitPower_RemoveDevice( const CSuitPowerDevice& device );
101101
bool SuitPower_ShouldRecharge( void );
102102
float SuitPower_GetCurrentPercentage( void ) { return m_HL2Local.m_flSuitPower; }
103+
104+
#ifdef MAPBASE
105+
virtual void DispatchTraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator = NULL );
106+
107+
virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const;
108+
#endif
103109

104110
bool CanSprint( void );
105111
void StartSprinting( void );

src/game/server/hl2mp/hl2mp_player.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class CHL2MP_Player : public CHL2_Player
116116
int GetPlayerModelType( void ) { return m_iPlayerSoundType; }
117117

118118
#ifdef MAPBASE
119+
virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const;
120+
119121
// TF2-style AFK checking
120122
void CheckForIdle( void );
121123
void ResetIdleCheck( void ) { m_flLastAction = gpGlobals->curtime; }

src/game/shared/hl2mp/hl2mp_gamerules.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ extern CBaseEntity *g_pLastRebelSpawn;
6868

6969
#ifdef MAPBASE
7070
ConVar sv_hl2mp_npc_target_id( "sv_hl2mp_npc_target_id", "1", FCVAR_REPLICATED, "If enabled, NPCs will be identified when players look at them with their crosshairs." );
71+
ConVar hl2mp_avoidteammates( "hl2mp_avoidteammates", "1", FCVAR_REPLICATED, "If enabled, players on the same team will not collide with each other." );
7172
#endif
7273

7374

src/game/shared/hl2mp/hl2mp_player_shared.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,38 @@ void CHL2MP_Player::PlayStepSound( Vector &vecOrigin, surfacedata_t *psurface, f
125125
EmitSound( filter, entindex(), ep );
126126
}
127127

128+
#ifdef MAPBASE
129+
//-----------------------------------------------------------------------------
130+
// Purpose:
131+
// Input : collisionGroup -
132+
// Output : Returns true on success, false on failure.
133+
//-----------------------------------------------------------------------------
134+
bool CHL2MP_Player::ShouldCollide( int collisionGroup, int contentsMask ) const
135+
{
136+
extern ConVar hl2mp_avoidteammates;
137+
if ( ( collisionGroup == COLLISION_GROUP_PLAYER || collisionGroup == COLLISION_GROUP_PLAYER_MOVEMENT ) && hl2mp_avoidteammates.GetBool() )
138+
{
139+
// Co-op ignores all players
140+
if ( HL2MPRules() && HL2MPRules()->IsCoOp() )
141+
return false;
142+
143+
switch( GetTeamNumber() )
144+
{
145+
case TEAM_REBELS:
146+
if ( ( contentsMask & CONTENTS_TEAM1 ) )
147+
return false;
148+
break;
149+
150+
case TEAM_COMBINE:
151+
if ( ( contentsMask & CONTENTS_TEAM2 ) )
152+
return false;
153+
break;
154+
}
155+
}
156+
return BaseClass::ShouldCollide( collisionGroup, contentsMask );
157+
}
158+
#endif
159+
128160

129161
//==========================
130162
// ANIMATION CODE

src/game/shared/hl2mp/weapon_hl2mpbasebasebludgeon.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ void CBaseHL2MPBludgeonWeapon::Hit( trace_t &traceHit, Activity nHitActivity )
220220

221221
if ( this->PlayFleshyHittySoundOnHit() )
222222
WeaponSound( MELEE_HIT );
223+
224+
#ifdef MAPBASE_MP
225+
// Don't do impact effect if this is an ally
226+
if ( pHitEntity->MyNPCPointer() && pHitEntity->MyNPCPointer()->IsPlayerAlly( pPlayer ) )
227+
return;
228+
#endif
223229
}
224230

225231
// Apply an impact effect

0 commit comments

Comments
 (0)