Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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 3 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
2 changes: 2 additions & 0 deletions BunnymodXT/cvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace CVars
CVarWrapper _bxt_bunnysplit_time_update_frequency("_bxt_bunnysplit_time_update_frequency", "41");
CVarWrapper _bxt_save_runtime_data_in_demos("_bxt_save_runtime_data_in_demos", "1");
CVarWrapper _bxt_tas_script_generation("_bxt_tas_script_generation", "1337");
CVarWrapper bxt_tas_clientmaxspeed_in_prediction("bxt_tas_clientmaxspeed_in_prediction", "1");
CVarWrapper bxt_taslog_filename("bxt_taslog_filename", "taslogger.log");
CVarWrapper bxt_autopause("bxt_autopause", "0");
CVarWrapper bxt_interprocess_enable("bxt_interprocess_enable", "0");
Expand Down Expand Up @@ -186,6 +187,7 @@ namespace CVars
&_bxt_norefresh,
&_bxt_save_runtime_data_in_demos,
&_bxt_tas_script_generation,
&bxt_tas_clientmaxspeed_in_prediction,
&bxt_taslog_filename,
&bxt_autopause,
&bxt_interprocess_enable,
Expand Down
1 change: 1 addition & 0 deletions BunnymodXT/cvars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace CVars
extern CVarWrapper _bxt_bunnysplit_time_update_frequency;
extern CVarWrapper _bxt_save_runtime_data_in_demos;
extern CVarWrapper _bxt_tas_script_generation;
extern CVarWrapper bxt_tas_clientmaxspeed_in_prediction;
extern CVarWrapper bxt_taslog_filename;
extern CVarWrapper bxt_autopause;
extern CVarWrapper bxt_interprocess_enable;
Expand Down
23 changes: 22 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 @@ -3778,6 +3789,7 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded()
RegisterCVar(CVars::_bxt_taslog);
RegisterCVar(CVars::_bxt_min_frametime);
RegisterCVar(CVars::_bxt_tas_script_generation);
RegisterCVar(CVars::bxt_tas_clientmaxspeed_in_prediction);
RegisterCVar(CVars::bxt_taslog_filename);
RegisterCVar(CVars::bxt_autopause);
RegisterCVar(CVars::bxt_bhopcap);
Expand Down Expand Up @@ -3867,6 +3879,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 +4746,19 @@ 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();

if (CVars::bxt_tas_clientmaxspeed_in_prediction.GetBool() && cl.DoesGameDirMatch("paranoia"))
vars.Maxspeed = cl.pEngfuncs->GetClientMaxspeed() * 3.2f; // GetMaxSpeed is factor here, 3.2f is approx. multiplier for walkmove
else if (CVars::bxt_tas_clientmaxspeed_in_prediction.GetBool() && cl.pEngfuncs && (cl.pEngfuncs->GetClientMaxspeed() > 0.0f))
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