Skip to content
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

Fix another infinite climb bug #144

Merged
merged 4 commits into from
Nov 13, 2018
Merged
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
52 changes: 32 additions & 20 deletions mp/src/game/shared/sdk/sdk_gamemovement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2836,7 +2836,21 @@ void CSDKGameMovement::FullWalkMove ()
}
}
#endif
if (CheckMantel())

// Check if we're manteling
bool canMantel = CheckMantel();

// Calculate planarized wall normal
Vector vecWallNormal = m_pSDKPlayer->m_Shared.GetMantelWallNormal();
vecWallNormal.z = 0;
VectorNormalize(vecWallNormal);

if (canMantel && vecWallNormal.Dot(Vector(m_vecForward.x, m_vecForward.y, 0).Normalized()) > -0.05) {
m_pSDKPlayer->m_Shared.ResetManteling();
canMantel = false;
}

if (canMantel)
{
/*Move up the height of the bbox over the time of the animation
TODO: How get animation duration? Make this use the crouch bbox.*/
Expand All @@ -2863,29 +2877,27 @@ void CSDKGameMovement::FullWalkMove ()
pr2[2] += gpGlobals->frametime*a;

TraceBBox (pr1, pr2, mins, maxs, tr);
if (tr.fraction == 1 && !tr.startsolid && !tr.allsolid)
{
mv->SetAbsOrigin (tr.endpos);
if (m_pSDKPlayer->m_Shared.IsManteling())
{
// Try to push the player onto the ledge.
Vector vecOrigin = mv->GetAbsOrigin();
Vector vecTarget = vecOrigin + Vector(m_vecForward.x, m_vecForward.y, 0).Normalized();
if (tr.fraction != 1 || tr.startsolid || tr.allsolid) {
m_pSDKPlayer->m_Shared.ResetManteling();
return;
}

TraceBBox(vecOrigin, vecTarget, mins, maxs, tr);
mv->SetAbsOrigin (tr.endpos);

if (!tr.DidHit ())
{
mv->SetAbsOrigin (tr.endpos);
m_pSDKPlayer->m_Shared.ResetManteling();
m_pSDKPlayer->Instructor_LessonLearned("mantel");
}
else
SetGroundEntity(&tr);
}
// Try to push the player onto the ledge.
Vector vecOrigin = mv->GetAbsOrigin();
Vector vecTarget = vecOrigin - vecWallNormal;

TraceBBox(vecOrigin, vecTarget, mins, maxs, tr);

if (!tr.DidHit ())
{
mv->SetAbsOrigin (tr.endpos);
m_pSDKPlayer->m_Shared.ResetManteling();
m_pSDKPlayer->Instructor_LessonLearned("mantel");
}
else
m_pSDKPlayer->m_Shared.ResetManteling();
SetGroundEntity(&tr);

return;
}
Expand Down