Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
followingthefasciaplane authored Oct 4, 2024
1 parent c6d3357 commit 54693f2
Showing 1 changed file with 33 additions and 90 deletions.
123 changes: 33 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,110 +1,53 @@
## CS:S crouch air-acceleration fix
## CS:S Crouch Air-Acceleration Fix

this sourcemod plugin fixes the reduced air acceleration that occurs when crouching in counter-strike: source. ive only tested that this works on css, you might need to change some things for other games, but the principle should remain the same.
This SourceMod plugin addresses the reduced air acceleration that occurs when crouching in Counter-Strike: Source.
This plugin has been tested on Counter-Strike: Source. While the principle may apply to other Source engine games, you'll need to add support for it. The same principle should also be applicable to +speed.
This plugin does not change the behavior of crouching in terms of bounding box, hull size, or ground movement. It simply patches air acceleration while crouched to match that of standing.

## why this happens
### Background

so, there is a direct reduction in air acceleration when crouching, we all know this forever, and here's why:
In Counter-Strike: Source, air acceleration is directly reduced while crouching. This occurs due to the following code in the `CCSGameMovement` class:

```
```cpp
void CCSGameMovement::HandleDuckingSpeedCrop()
{
//=============================================================================
// HPE_BEGIN:
// [Forrest]
//=============================================================================
// Movement speed in free look camera mode is unaffected by ducking state.
if ( player->GetObserverMode() == OBS_MODE_ROAMING )
return;
//=============================================================================
// HPE_END
//=============================================================================
if ( !( m_iSpeedCropped & SPEED_CROPPED_DUCK ) )
{
if ( ( mv->m_nButtons & IN_DUCK ) || ( player->m_Local.m_bDucking ) || ( player->GetFlags() & FL_DUCKING ) )
{
mv->m_flForwardMove *= CS_PLAYER_SPEED_DUCK_MODIFIER;
mv->m_flSideMove *= CS_PLAYER_SPEED_DUCK_MODIFIER;
mv->m_flUpMove *= CS_PLAYER_SPEED_DUCK_MODIFIER;
m_iSpeedCropped |= SPEED_CROPPED_DUCK;
}
}
// ...
if ( ( mv->m_nButtons & IN_DUCK ) || ( player->m_Local.m_bDucking ) || ( player->GetFlags() & FL_DUCKING ) )
{
mv->m_flForwardMove *= CS_PLAYER_SPEED_DUCK_MODIFIER;
mv->m_flSideMove *= CS_PLAYER_SPEED_DUCK_MODIFIER;
mv->m_flUpMove *= CS_PLAYER_SPEED_DUCK_MODIFIER;
m_iSpeedCropped |= SPEED_CROPPED_DUCK;
}
// ...
}
```

as we can see, this cheeky method in CCSGameMovement scales our FSU by ~0.34 whenever we are ducked..... and this is the cause of our problem here
This method scales the player's FSU by approximately 0.34 when ducking.

## i don't get why our FSU matters for aa
### Impact on Air Acceleration

it matters because if we look here:
The scaling of movement values affects air acceleration due to how the AirMove function calculates wishvel and wishspeed:

```
```cpp
void CGameMovement::AirMove( void )
{
int i;
Vector wishvel;
float fmove, smove;
Vector wishdir;
float wishspeed;
Vector forward, right, up;
AngleVectors (mv->m_vecViewAngles, &forward, &right, &up); // Determine movement angles
// Copy movement amounts
fmove = mv->m_flForwardMove;
smove = mv->m_flSideMove;
// Zero out z components of movement vectors
forward[2] = 0;
right[2] = 0;
VectorNormalize(forward); // Normalize remainder of vectors
VectorNormalize(right); //
for (i=0 ; i<2 ; i++) // Determine x and y parts of velocity
wishvel[i] = forward[i]*fmove + right[i]*smove;
wishvel[2] = 0; // Zero out z part of velocity
VectorCopy (wishvel, wishdir); // Determine maginitude of speed of move
wishspeed = VectorNormalize(wishdir);
//
// clamp to server defined max speed
//
if ( wishspeed != 0 && (wishspeed > mv->m_flMaxSpeed))
{
VectorScale (wishvel, mv->m_flMaxSpeed/wishspeed, wishvel);
wishspeed = mv->m_flMaxSpeed;
}
AirAccelerate( wishdir, wishspeed, sv_airaccelerate.GetFloat() );
// Add in any base velocity to the current velocity.
VectorAdd(mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity );
TryPlayerMove();
// Now pull the base velocity back out. Base velocity is set if you are on a moving object, like a conveyor (or maybe another monster?)
VectorSubtract( mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity );
// ...
fmove = mv->m_flForwardMove;
smove = mv->m_flSideMove;

for (i=0 ; i<2 ; i++)
wishvel[i] = forward[i]*fmove + right[i]*smove;

VectorCopy (wishvel, wishdir);
wishspeed = VectorNormalize(wishdir);
// ...
}
```
specifically these lines:

```
// Copy movement amounts
fmove = mv->m_flForwardMove;
smove = mv->m_flSideMove;
for (i=0 ; i<2 ; i++) // Determine x and y parts of velocity
wishvel[i] = forward[i]*fmove + right[i]*smove;
VectorCopy (wishvel, wishdir); // Determine maginitude of speed of move
wishspeed = VectorNormalize(wishdir);
```
The scaled movement values directly influence the wishvel calculation, which in turn affects the wishspeed passed to the AirAccelerate.
so as we can see our FSU is actually what determines our wishvel in airmove, which is then passed to airaccelerate... so basically, this HandleDuckingSpeedCrop is not scaling our FSU only, its also scaling our wishspeed in AA by the same amount.
### Solution
## so lets kill this function if a player is midair
This plugin prevents the `HandleDuckingSpeedCrop` function from executing when a player is mid-air, maintaining standard air acceleration values while crouching.
i agree, so thats what we have done here

0 comments on commit 54693f2

Please sign in to comment.