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

No ghost bunnyhopping + landing slowdown rework #857

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

AdamTadeusz
Copy link
Contributor

@AdamTadeusz AdamTadeusz commented Jan 23, 2025

Description

This PR does two things.

  1. Disables ghost bunnyhopping by default, following the same methodology as rains anti bunnyhopping plugin except using the current player max speed before slowdown from landing as a non-recon instead of using each classes max wallrun speed as the max.
  2. Reworks the deceleration due to landing as a non-recon. After taking some videos in slow motion of an assault character running forward with a zr68s in their hands, jumping and then landing, I have observed that the character's max speed is set to 75 for 0.25 seconds, and then the acceleration is nerfed for a further 1/3 of a second, while the player slowly builds their speed back up to max speed. Given that after the initial 0.25 seconds after landing the player speed dips further below 75 before building back up to max speed, I believe the original game sets the max speed of the player to some value which increases linearly after landing, where a max speed low enough means that after 0.25 seconds this linearly increasing value does not yet pass 75 and so the speed dips for a moment.

This PR also includes the fixes to player speed when forced to duck from PR #846

Toolchain

  • Windows MSVC VS2022
  • Linux GCC Distro Native [Specify distro + GCC version]
  • Linux GCC 10 Sniper 3.0

Linked Issues

@AdamTadeusz AdamTadeusz requested a review from a team January 23, 2025 14:45
brysondev
brysondev previously approved these changes Jan 25, 2025
…tead keep track of whether player is carrying a weapon_ghost
@AdamTadeusz AdamTadeusz requested a review from brysondev January 27, 2025 15:29
brysondev
brysondev previously approved these changes Jan 27, 2025
static constexpr float RECON_SPRINT_SPEED_MODIFIER = 0.75;
static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 0.6;
speed /= m_iNeoClass == NEO_CLASS_RECON ? RECON_SPRINT_SPEED_MODIFIER : OTHER_CLASSES_SPRINT_SPEED_MODIFIER;
static constexpr float RECON_SPRINT_SPEED_MODIFIER = 1.35;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this defined in a header somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I don't think so? Also I just did this pre-emptively in preperation for your pr to fix these values, if you're defining this in the header somewhere then ill update the pr once i see what that looks like

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#define NEO_RECON_SPRINT_SPEED (NEO_BASE_SPRINT_SPEED * NEO_RECON_SPEED_MODIFIER)

Copy link
Contributor Author

@AdamTadeusz AdamTadeusz Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically this is the NEO_SPRINT_MODIFIER which has a value of 1.6, but recons have a different sprint modifier to the other classes

NEO_RECON_SPRINT_SPEED has a value of 272 if I'm not mistaken

(Edit) perhaps they have the same sprint speed modifier, I'm not going to pretend I know how to dive into the dll of the original game and get the exact values, but following the calculations here https://steamcommunity.com/sharedfiles/filedetails/?id=281690103 and ones ive taken myself I can say with confidence that assuming recons have a different sprint speed modifier is a decent enough way of getting the correct speed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nagrywanie.ekranu.2025-01-29.174832.mp4

Here is a recording of the sprint speed of a recon in the original after removing all weapons (hence why the viewmodel is slightly off), the value of 272 is 2 units off and we're currently using the speed with a knife or other very light weapon as the base speed anyway (which despite Agiels protests I don't think is really an issue).

static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 0.6;
speed /= m_iNeoClass == NEO_CLASS_RECON ? RECON_SPRINT_SPEED_MODIFIER : OTHER_CLASSES_SPRINT_SPEED_MODIFIER;
static constexpr float RECON_SPRINT_SPEED_MODIFIER = 1.35;
static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 1.6;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

static constexpr float RECON_SPRINT_SPEED_MODIFIER = 0.75;
static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 0.6;
speed /= m_iNeoClass == NEO_CLASS_RECON ? RECON_SPRINT_SPEED_MODIFIER : OTHER_CLASSES_SPRINT_SPEED_MODIFIER;
static constexpr float RECON_SPRINT_SPEED_MODIFIER = 1.35;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 0.6;
speed /= m_iNeoClass == NEO_CLASS_RECON ? RECON_SPRINT_SPEED_MODIFIER : OTHER_CLASSES_SPRINT_SPEED_MODIFIER;
static constexpr float RECON_SPRINT_SPEED_MODIFIER = 1.35;
static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 1.6;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@AdamTadeusz AdamTadeusz requested a review from a team February 6, 2025 17:18
@Agiel
Copy link
Contributor

Agiel commented Feb 6, 2025

I had a look at the slowdown in OGNT again and it's slightly more convoluted than I remember.
Basically when you jump as a non-recon, your "slowdown factor" is set to 40.
This value decays by timeDelta * 35.
It is then applied to the max speed with the formula speed *= MAX(0.01, 1 - slowFactor / 20).
Finally, after applying all the other speed multipliers, it does

if speed < 55
  speed = 75

@AdamTadeusz
Copy link
Contributor Author

I had a look at the slowdown in OGNT again and it's slightly more convoluted than I remember. Basically when you jump as a non-recon, your "slowdown factor" is set to 40. This value decays by timeDelta * 35. It is then applied to the max speed with the formula speed *= MAX(0.01, 1 - slowFactor / 20). Finally, after applying all the other speed multipliers, it does

if speed < 55
  speed = 75

So that supports what I've been observing with the player speed in slow motion. I drew a little graph to illustrate it with your code
image

I think this is one of those things where we could improve on the original, I don't think having this hitch where the player speed falls for a bit after player speed exceeds 55 only to start rising again is necessary or feels good

@Agiel
Copy link
Contributor

Agiel commented Feb 7, 2025

I agree. One of 55 or 75 is probably a typo anyway. I guess making it 75 would be the least noticeable? Unless that would interfere with crouchwalk or something. What's the slowest speed you can reach currently by crouch/walking/aiming? I wouldn't mind making it 55 either, but that'd probably make bhopping harder.

@Agiel
Copy link
Contributor

Agiel commented Feb 7, 2025

Alternatively, apply the jump slowdown first, and cap it at 75. Then do the walk/crouch/aim modifiers after and cap to whatever feels good.

@AdamTadeusz
Copy link
Contributor Author

in the original you crouch walk with a pz at a speed of 60.75, and aiming in brings your speed back up to 75. I think back we thought the min speed was 56 so in rebuild aiming in lowers your speed to 56. Regardless of what the speed is after landing we bring it back up to at least 56 at the end

@Agiel
Copy link
Contributor

Agiel commented Feb 7, 2025

Right, so we probably shouldn't cap it at 75 then. Best to do the jump slowdown first at 75, and then apply walk/crouch/aim and cap at 55.

@AdamTadeusz
Copy link
Contributor Author

AdamTadeusz commented Feb 7, 2025

I assume we want the weapon slowdown done before the jump slowdown?

Also
const float timeSinceLanding = gpGlobals->curtime - m_flLastAirborneJumpOkTime;
constexpr float SLOWDOWN_TIME = 1.15f;
if (timeSinceLanding < SLOWDOWN_TIME)
{
speed = MAX(75,speed * MAX(0.01, 1 - (((SLOWDOWN_TIME - timeSinceLanding) * 35) * 0.05)));
}
This should be the equivalent without defining a slowdown variable

(Edit) no need for that division tbh

constexpr float SLOWDOWN_TIME = 1.15f;
if (timeSinceLanding < SLOWDOWN_TIME)
{
speed = MAX(75,speed * MAX(0.01, 1 - (((SLOWDOWN_TIME - timeSinceLanding) * 35) * 0.05)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to contract it further. 35 * 0.05 = 1.75.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we don't need the inner max as well, it shouldn't make a noticeable difference right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. And with the outer if-statement it shouldn't blow up in the wrong direction.
I realized something else though. In OGNT it's timeSinceJump but here it's timeSinceLanding. We'll want to subtract the air time from SLOWDOWN_TIME.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, walking off of a ledge in the original does not cause a slowdown

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that's going to be annoying...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Players can't bhop with the ghost
3 participants