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

TAS-related: Get client player maxspeed in HL modifications if it's available #325

Merged
merged 6 commits into from
Aug 24, 2022
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
24 changes: 23 additions & 1 deletion BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2707,6 +2707,17 @@ struct HwDLL::Cmd_BXT_Timer_Reset
}
};

struct HwDLL::Cmd_BXT_Get_ClientMaxSpeed
{
NO_USAGE();

static void handler()
{
if (ClientDLL::GetInstance().pEngfuncs)
HwDLL::GetInstance().ORIG_Con_Printf("Client maxspeed: %f\n", ClientDLL::GetInstance().pEngfuncs->GetClientMaxspeed());
}
};

struct HwDLL::Cmd_BXT_TAS_Autojump_Down
{
NO_USAGE();
Expand Down Expand Up @@ -3867,6 +3878,7 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded()
wrapper::Add<Cmd_BXT_Timer_Start, Handler<>>("bxt_timer_start");
wrapper::Add<Cmd_BXT_Timer_Stop, Handler<>>("bxt_timer_stop");
wrapper::Add<Cmd_BXT_Timer_Reset, Handler<>>("bxt_timer_reset");
wrapper::Add<Cmd_BXT_Get_ClientMaxSpeed, Handler<>>("bxt_get_clientmaxspeed");
wrapper::Add<Cmd_BXT_TAS_Autojump_Down, Handler<>, Handler<const char*>>("+bxt_tas_autojump");
wrapper::Add<Cmd_BXT_TAS_Autojump_Up, Handler<>, Handler<const char*>>("-bxt_tas_autojump");
wrapper::Add<Cmd_BXT_TAS_Ducktap_Down, Handler<>, Handler<const char*>>("+bxt_tas_ducktap");
Expand Down Expand Up @@ -4733,11 +4745,21 @@ void HwDLL::FindCVarsIfNeeded()
HLStrafe::MovementVars HwDLL::GetMovementVars()
{
auto vars = HLStrafe::MovementVars();
auto &cl = ClientDLL::GetInstance();

FindCVarsIfNeeded();
vars.Frametime = GetFrameTime();
vars.Maxvelocity = CVars::sv_maxvelocity.GetFloat();
vars.Maxspeed = CVars::sv_maxspeed.GetFloat();

static bool is_paranoia = cl.DoesGameDirMatch("paranoia");

if (is_paranoia)
vars.Maxspeed = cl.pEngfuncs->GetClientMaxspeed() * CVars::sv_maxspeed.GetFloat() / 100.0f; // GetMaxSpeed is factor here
else if (cl.pEngfuncs && (cl.pEngfuncs->GetClientMaxspeed() > 0.0f) && (CVars::sv_maxspeed.GetFloat() > cl.pEngfuncs->GetClientMaxspeed()))
vars.Maxspeed = cl.pEngfuncs->GetClientMaxspeed(); // Get true maxspeed in CS games & other mods (Poke646 e.g.)
else
vars.Maxspeed = CVars::sv_maxspeed.GetFloat();

vars.Stopspeed = CVars::sv_stopspeed.GetFloat();
vars.Friction = CVars::sv_friction.GetFloat();
vars.Edgefriction = CVars::edgefriction.GetFloat();
Expand Down
1 change: 1 addition & 0 deletions BunnymodXT/modules/HwDLL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ class HwDLL : public IHookableNameFilterOrdered
struct Cmd_BXT_Timer_Start;
struct Cmd_BXT_Timer_Stop;
struct Cmd_BXT_Timer_Reset;
struct Cmd_BXT_Get_ClientMaxSpeed;
struct Cmd_BXT_TAS_Autojump_Down;
struct Cmd_BXT_TAS_Autojump_Up;
struct Cmd_BXT_TAS_Ducktap_Down;
Expand Down