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 long standing jump bug & movement lag based on FPS #755

Closed
wants to merge 13 commits into from
Closed
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_hostages_rescued_ratio | 1.0 | 0.0 | 1.0 | Ratio of hostages rescued to win the round. |
| mp_legacy_vehicle_block | 1 | 0 | 1 | Legacy func_vehicle behavior when blocked by another entity.<br/>`0` New behavior <br/>`1` Legacy behavior |
| mp_dying_time | 3.0 | 0.0 | - | Time for switch to free observing after death.<br/>`0` - disable spectating around death.<br/>`>0.00001` - time delay to start spectate.<br/>`NOTE`: The countdown starts when the player’s death animation is finished.|
| sv_legacy_movement | 0 | 0 | 1 | Legacy movement. The new one fixes FPS based jump and movement.<br/>`0` Legacy behaviour <br/>`1` New behaviour |
</details>

## How to install zBot for CS 1.6?
Expand Down
7 changes: 7 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,10 @@ mp_legacy_vehicle_block "1"
//
// Default value: "3.0"
mp_dying_time "3.0"

// Legacy movement. The new one fixes FPS based jump and movement.
// 0 - Legacy behavior
// 1 - New behavior
//
// Default value: "0"
sv_legacy_movement "0"
2 changes: 2 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f
cvar_t sv_enablebunnyhopping = { "sv_enablebunnyhopping", "0", 0, 0.0f, nullptr };
cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0f, nullptr };
cvar_t give_c4_frags = { "mp_give_c4_frags", "3", 0, 3.0f, nullptr };
cvar_t sv_legacy_movement = { "sv_legacy_movement", "0", 0, 0.0f, nullptr };

cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr };

Expand Down Expand Up @@ -415,6 +416,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&sv_enablebunnyhopping);
CVAR_REGISTER(&plant_c4_anywhere);
CVAR_REGISTER(&give_c4_frags);
CVAR_REGISTER(&sv_legacy_movement);

CVAR_REGISTER(&hostages_rescued_ratio);

Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ extern cvar_t give_c4_frags;
extern cvar_t hostages_rescued_ratio;
extern cvar_t legacy_vehicle_block;
extern cvar_t dying_time;
extern cvar_t sv_legacy_movement;

#endif

Expand Down
44 changes: 30 additions & 14 deletions regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2775,43 +2775,59 @@ void PM_CheckParameters()

void PM_ReduceTimers()
{
if (pmove->flTimeStepSound > 0)
float frame_msec = pmove->cmd.msec;

if (pmove->flTimeStepSound > 0.0)
{
pmove->flTimeStepSound -= pmove->cmd.msec;
pmove->flTimeStepSound -= frame_msec;

if (pmove->flTimeStepSound < 0)
if (pmove->flTimeStepSound < 0.0)
{
pmove->flTimeStepSound = 0;
pmove->flTimeStepSound = 0.0;
}
}

#ifdef REGAMEDLL_ADD
if(sv_legacy_movement.value > 0.0)
{
if(frame_msec < 10.0)
{
frame_msec *= 1.65f;
}
else
{
frame_msec *= 1.45f;
}
}
#endif

if (pmove->flDuckTime > 0)
if (pmove->flDuckTime > 0.0)
{
pmove->flDuckTime -= pmove->cmd.msec;
pmove->flDuckTime -= frame_msec;

if (pmove->flDuckTime < 0)
if (pmove->flDuckTime < 0.0)
{
pmove->flDuckTime = 0;
pmove->flDuckTime = 0.0;
}
}

if (pmove->flSwimTime > 0)
if (pmove->flSwimTime > 0.0)
{
pmove->flSwimTime -= pmove->cmd.msec;
pmove->flSwimTime -= frame_msec;

if (pmove->flSwimTime < 0)
if (pmove->flSwimTime < 0.0)
{
pmove->flSwimTime = 0;
pmove->flSwimTime = 0.0;
}
}

if (pmove->fuser2 > 0.0)
{
pmove->fuser2 -= pmove->cmd.msec;
pmove->fuser2 -= frame_msec;

if (pmove->fuser2 < 0.0)
{
pmove->fuser2 = 0;
pmove->fuser2 = 0.0;
}
}
}
Expand Down