Adjust melee hit trace

► Check if the specific entity can be hit by a melee attack. If the entity cannot be hit, it is ignored.
► If the attacker or the victim is not a combat character (like NPCs), apply the damage to passive entities (like props, objects, etc.).
This commit is contained in:
speedvoltage 2025-03-12 11:22:52 +01:00
parent a62efecf62
commit a2dd2943bf

View file

@ -1139,6 +1139,9 @@ bool CTraceFilterMelee::ShouldHitEntity( IHandleEntity *pHandleEntity, int conte
if ( pEntity->m_takedamage == DAMAGE_NO )
return false;
if ( m_pPassEnt && !pEntity->CanBeHitByMeleeAttack( const_cast< CBaseEntity * >( EntityFromEntityHandle( m_pPassEnt ) ) ) )
return false;
// 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
/*
@ -1182,7 +1185,8 @@ bool CTraceFilterMelee::ShouldHitEntity( IHandleEntity *pHandleEntity, int conte
}
else
{
m_pHit = pEntity;
if ( !m_pHit )
m_pHit = pEntity;
// Make sure if the player is holding this, he drops it
Pickup_ForcePlayerToDropThisObject( pEntity );