Skip to content

Commit

Permalink
fix: improve slope boost ensurance cheat
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzyhau committed Oct 23, 2024
1 parent 92924ce commit c35d07c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Variable sar_autorecord("sar_autorecord", "0", -1, 1, "Enables or disables autom
Variable sar_autojump("sar_autojump", "0", "Enables automatic jumping on the server.\n");
Variable sar_autostrafe("sar_autostrafe", "0", "Automatically strafes in your current wishdir.\n");
Variable sar_ensure_slope_boost("sar_ensure_slope_boost", "0", "Ensures a successful slope boost.");
Variable sar_jumpboost("sar_jumpboost", "0", 0,
Variable sar_jumpboost("sar_jumpboost", "0", 0,
"Enables special game movement on the server.\n"
"0 = Default,\n"
"1 = Orange Box Engine,\n"
Expand Down Expand Up @@ -444,13 +444,17 @@ void Cheats::EnsureSlopeBoost(const CHLMoveData *move, void *player, CGameTrace
if (!server->AllowsMovementChanges() || !sar_ensure_slope_boost.GetBool()) {
return;
}

Vector velocity = move->m_vecVelocity;
Vector hitNormal = (*tr)->plane.normal;

bool goingDown = move->m_vecVelocity.z < 0;
bool goingDown = velocity.z < 0;
bool isntAlreadyGrounded = !(SE(player)->ground_entity());
bool landedOnSlope = (*tr)->plane.normal.z < 1.0f;
bool landedOnSlope = hitNormal.z < 1.0f;
bool wantsToSnapToGround = (*tr)->fraction >= 0.000001f;
bool boostingTowardsVelocity = hitNormal.x * velocity.x + hitNormal.y * velocity.y >= 0;

if (goingDown && isntAlreadyGrounded && landedOnSlope && wantsToSnapToGround) {
if (goingDown && isntAlreadyGrounded && landedOnSlope && wantsToSnapToGround && boostingTowardsVelocity) {
// Nulling out pointer by reference, so that it's passed in CGameMovement::SetGroundEntity,
// preventing being grounded on this call, letting the player to boost off slope
*tr = NULL;
Expand Down

0 comments on commit c35d07c

Please sign in to comment.