From a749d11369f962a2953af7eaf06cdb9770f745aa Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sun, 28 Oct 2018 12:44:19 +0100 Subject: [PATCH] Ignore breakables when determining mantelability --- mp/src/game/shared/sdk/sdk_gamemovement.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/mp/src/game/shared/sdk/sdk_gamemovement.cpp b/mp/src/game/shared/sdk/sdk_gamemovement.cpp index cafe8acd7..f1cf8068d 100644 --- a/mp/src/game/shared/sdk/sdk_gamemovement.cpp +++ b/mp/src/game/shared/sdk/sdk_gamemovement.cpp @@ -2502,6 +2502,17 @@ inline void CSDKGameMovement::TraceBBox(const Vector& start, const Vector& end, TraceBBox(start, end, mins, maxs, pm, PlayerSolidMask(), pExtraShouldHitCheckFn); } +static bool ShouldHitFuncIgnoreBreakables(IHandleEntity *pHandleEntity, int contentsMask) { + CBaseEntity *pEntity = EntityFromEntityHandle(pHandleEntity); + if (!pEntity) + return true; + + if (pEntity->GetHealth() == 0) + return true; + + return false; +} + bool CSDKGameMovement::CheckMantel() { trace_t tr; @@ -2537,7 +2548,7 @@ bool CSDKGameMovement::CheckMantel() /*Then probe forward for free space*/ pr1 = pr2; pr2 = pr1 + dir*4; - TraceBBox (pr1, pr2, vecMins, vecMaxs, tr); + TraceBBox (pr1, pr2, vecMins, vecMaxs, tr, &ShouldHitFuncIgnoreBreakables); if (tr.fraction < 1) /*Not enough space to stand on for potential ledge, or too far down wall*/ return false; @@ -2545,7 +2556,7 @@ bool CSDKGameMovement::CheckMantel() /*Find ground to stand on*/ pr1 = pr2; pr2[2] -= da_acro_mantel_height.GetFloat (); - TraceBBox (pr1, pr2, vecMins, vecMaxs, tr); + TraceBBox (pr1, pr2, vecMins, vecMaxs, tr, &ShouldHitFuncIgnoreBreakables); if (tr.fraction == 1) return false; @@ -2558,7 +2569,7 @@ bool CSDKGameMovement::CheckMantel() /*Then check whether we have enough vertical space to stand on the ledge*/ pr1 = pr2 = tr.endpos; pr2.z += 4; - TraceBBox(pr1, pr2, VEC_HULL_MIN, VEC_HULL_MAX, tr); + TraceBBox(pr1, pr2, VEC_HULL_MIN, VEC_HULL_MAX, tr, &ShouldHitFuncIgnoreBreakables); if (tr.fraction < 1 || tr.allsolid || tr.startsolid) /*Blocked by ceiling*/ @@ -2566,7 +2577,7 @@ bool CSDKGameMovement::CheckMantel() pr1 = mv->GetAbsOrigin(); pr2 = pr1 + dir*4; - TraceBBox (pr1, pr2, vecMins, vecMaxs, tr); + TraceBBox (pr1, pr2, vecMins, vecMaxs, tr, &ShouldHitFuncIgnoreBreakables); // Only mantel with steep planes. if (tr.plane.normal.z > 0.3)