Skip to content

[TF2] Add explosion creep #1273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
34 changes: 31 additions & 3 deletions src/game/shared/tf/tf_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5715,6 +5715,8 @@ void CTFRadiusDamageInfo::CalculateFalloff( void )
}
}

ConVar tf_explosion_creep( "tf_explosion_creep", "12" );

//-----------------------------------------------------------------------------
// Purpose: Attempt to apply the radius damage to the specified entity
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -5746,11 +5748,37 @@ int CTFRadiusDamageInfo::ApplyToEntity( CBaseEntity *pEntity )
UTIL_TraceLine( vecSrc, vecSpot, MASK_RADIUS_DAMAGE, &filterSelf, &tr );
}

// If we don't trace the whole way to the target, and we didn't hit the target entity, we're blocked
// If we don't trace the whole way to the target, and we didn't hit the target entity, we're blocked, so do a more robust check
if ( tr.fraction != 1.f && tr.m_pEnt != pEntity )
{
// Don't let projectiles block damage
return 0;
if( tf_explosion_creep.GetBool() )
{
Vector vecToTarget = vecSpot - vecSrc;
VectorNormalize( vecToTarget );

// We're going to deflect the blast along the surface that
// interrupted a trace from explosion to this target.
Vector vecUp, vecDeflect;
CrossProduct( vecToTarget, tr.plane.normal, vecUp );
CrossProduct( tr.plane.normal, vecUp, vecDeflect );
VectorNormalize( vecDeflect );

// Trace along the surface that intercepted the blast...
//NDebugOverlay::Line( vecSrc, vecSrc + (vecDeflect * tf_explosion_creep.GetFloat()), 255, 255, 0, false, 10 );
UTIL_TraceLine( vecSrc, vecSrc + (vecDeflect * tf_explosion_creep.GetFloat()), MASK_RADIUS_DAMAGE, &filter, &tr );

// ...to see if there's a nearby edge that the explosion would 'spill over' if the blast were fully simulated.
//NDebugOverlay::Line( tr.endpos, vecSpot, 255, 0, 0, false, 10 );
UTIL_TraceLine( tr.endpos, vecSpot, MASK_RADIUS_DAMAGE, &filter, &tr );

if( tr.fraction != 1.0 && tr.DidHitWorld() ) {
return 0;
}
}
else
{
return 0;
}
}

// Adjust the damage - apply falloff.
Expand Down