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

Unquantize CKZ vertical velocity #77

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions src/kz/mode/kz_mode_ckz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ void KZClassicModeService::OnProcessUsercmds(void *cmds, int numcmds)

void KZClassicModeService::OnProcessMovement()
{
this->CheckVelocityQuantization();
this->RemoveCrouchJumpBind();
this->ReduceDuckSlowdown();
this->InterpolateViewAngles();
Expand All @@ -285,6 +286,9 @@ void KZClassicModeService::OnProcessMovementPost()
this->InsertSubtickTiming(g_pKZUtils->GetServerGlobals()->tickcount * ENGINE_FIXED_TICK_INTERVAL + 0.5 * ENGINE_FIXED_TICK_INTERVAL, true);
this->RestoreInterpolatedViewAngles();
this->oldDuckPressed = this->forcedUnduck || this->player->IsButtonDown(IN_DUCK, true);
Vector velocity;
this->player->GetVelocity(&velocity);
this->postProcessMovementZSpeed = velocity.z;
}

void KZClassicModeService::InsertSubtickTiming(float time, bool future)
Expand Down Expand Up @@ -502,3 +506,11 @@ f32 KZClassicModeService::GetPrestrafeGain()
{
return PS_SPEED_MAX * pow(MAX(this->leftPreRatio, this->rightPreRatio) / PS_MAX_PS_TIME, PS_RATIO_TO_SPEED);
}

void KZClassicModeService::CheckVelocityQuantization()
{
if (this->postProcessMovementZSpeed > this->player->currentMoveData->m_vecVelocity.z && this->postProcessMovementZSpeed - this->player->currentMoveData->m_vecVelocity.z < 0.03125f)
{
this->player->currentMoveData->m_vecVelocity.z = this->postProcessMovementZSpeed;
}
}
3 changes: 2 additions & 1 deletion src/kz/mode/kz_mode_ckz.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class KZClassicModeService : public KZModeService
f32 lastJumpReleaseTime{};
bool oldDuckPressed{};
bool forcedUnduck{};

f32 postProcessMovementZSpeed{};
struct AngleHistory
{
f32 rate;
Expand Down Expand Up @@ -115,6 +115,7 @@ class KZClassicModeService : public KZModeService
void CalcPrestrafe();
f32 GetPrestrafeGain();

void CheckVelocityQuantization();
void RemoveCrouchJumpBind();
/*
Ported from DanZay's SimpleKZ:
Expand Down