Skip to content

Commit

Permalink
by default no speed change
Browse files Browse the repository at this point in the history
  • Loading branch information
khanghugo committed Mar 15, 2024
1 parent c5b04ca commit 31ee8e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion BunnymodXT/cvars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
X(bxt_ch_checkpoint_onground_only, "0") \
X(bxt_ch_fix_sticky_slide, "0") \
X(bxt_ch_fix_sticky_slide_offset, "0.01") \
X(bxt_ch_noclip_speed, "1000")
X(bxt_ch_noclip_speed, "0")

class CVarWrapper
{
Expand Down
13 changes: 6 additions & 7 deletions BunnymodXT/modules/ServerDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2816,20 +2816,19 @@ HOOK_DEF_2(ServerDLL, void, __cdecl, PM_Move, struct playermove_s*, ppmove, int,
int *movetype = reinterpret_cast<int*>(pmove + offMoveType);

auto start_origin = Vector(origin);
auto ch_noclip_vel = CVars::bxt_ch_noclip_speed.GetFloat();

if (*movetype == MOVETYPE_NOCLIP) {
auto new_maxspeed = CVars::bxt_ch_noclip_speed.GetFloat();

if (*movetype == MOVETYPE_NOCLIP && ch_noclip_vel != 0.f) {
ch_noclip_vel_prev_maxspeed = *maxspeed;
ch_noclip_vel_prev_clientmaxspeed = *clientmaxspeed;

if (*clientmaxspeed == 0.0f)
*clientmaxspeed = *maxspeed;

cmd->forwardmove = cmd->forwardmove / *clientmaxspeed * new_maxspeed;
cmd->sidemove = cmd->sidemove / *clientmaxspeed * new_maxspeed;
cmd->upmove = cmd->upmove / *clientmaxspeed * new_maxspeed;
*maxspeed = *clientmaxspeed = new_maxspeed;
cmd->forwardmove = cmd->forwardmove / *clientmaxspeed * ch_noclip_vel;
cmd->sidemove = cmd->sidemove / *clientmaxspeed * ch_noclip_vel;
cmd->upmove = cmd->upmove / *clientmaxspeed * ch_noclip_vel;
*maxspeed = *clientmaxspeed = ch_noclip_vel;
}

ORIG_PM_Move(ppmove, server);
Expand Down

0 comments on commit 31ee8e9

Please sign in to comment.