Skip to content

Commit

Permalink
Fix CBaseEntity::CanBeHitByMeleeAttack() not blocking damage from CTr…
Browse files Browse the repository at this point in the history
…aceFilterMelee
  • Loading branch information
Blixibon committed Nov 3, 2023
1 parent 0e110b7 commit c6ee153
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sp/src/game/server/basecombatcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,11 @@ bool CTraceFilterMelee::ShouldHitEntity( IHandleEntity *pHandleEntity, int conte
if ( pEntity->m_takedamage == DAMAGE_NO )
return false;

#ifdef MAPBASE // Moved from CheckTraceHullAttack()
if( m_pPassEnt && !pEntity->CanBeHitByMeleeAttack( const_cast<CBaseEntity*>(EntityFromEntityHandle( m_pPassEnt ) ) ) )
return false;
#endif

// FIXME: Do not translate this to the driver because the driver only accepts damage from the vehicle
// Translate the vehicle into its driver for damage
/*
Expand Down Expand Up @@ -1311,6 +1316,10 @@ bool CTraceFilterMelee::ShouldHitEntity( IHandleEntity *pHandleEntity, int conte
}
else
{
#ifdef MAPBASE
// Do not override an existing hit entity
if (!m_pHit)
#endif
m_pHit = pEntity;

// Make sure if the player is holding this, he drops it
Expand Down Expand Up @@ -1386,11 +1395,13 @@ CBaseEntity *CBaseCombatCharacter::CheckTraceHullAttack( const Vector &vStart, c
pEntity = traceFilter.m_pHit;
}

#ifndef MAPBASE // Moved to CTraceFilterMelee
if( pEntity && !pEntity->CanBeHitByMeleeAttack(this) )
{
// If we touched something, but it shouldn't be hit, return nothing.
pEntity = NULL;
}
#endif

return pEntity;

Expand Down

0 comments on commit c6ee153

Please sign in to comment.