Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Adding Strafe Key #724

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 12 additions & 2 deletions src/ATGUI/Tabs/misctab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,19 @@ void Misc::RenderTab()
}

if (Settings::AutoStrafe::type == AutostrafeType::AS_RAGE)
{
ImGui::Checkbox("Silent", &Settings::AutoStrafe::silent);
SetTooltip("Strafes won't be visible for spectators");
}

ImGui::Columns(2, NULL, true);
{
ImGui::Checkbox("Strafe Key", &Settings::AutoStrafe::StrafeKey::enabled);
SetTooltip("Strafes only when a key is held");
}
ImGui::NextColumn();
{
ImGui::Checkbox("Silent", &Settings::AutoStrafe::silent);
SetTooltip("Strafes won't be visible for spectators");
UI::KeyBindButton(&Settings::AutoStrafe::StrafeKey::key);
}

ImGui::Columns(1);
Expand Down
4 changes: 4 additions & 0 deletions src/Hacks/autostrafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
bool Settings::AutoStrafe::enabled = false;
AutostrafeType Settings::AutoStrafe::type = AutostrafeType::AS_FORWARDS;
bool Settings::AutoStrafe::silent = true;
bool Settings::AutoStrafe::StrafeKey::enabled = false;
ButtonCode_t Settings::AutoStrafe::StrafeKey::key = ButtonCode_t::KEY_LSHIFT;

void LegitStrafe(C_BasePlayer* localplayer, CUserCmd* cmd)
{
Expand Down Expand Up @@ -82,6 +84,8 @@ void AutoStrafe::CreateMove(CUserCmd* cmd)
{
if (!Settings::AutoStrafe::enabled)
return;
if (Settings::AutoStrafe::StrafeKey::enabled && !inputSystem->IsButtonDown(Settings::AutoStrafe::StrafeKey::key))
return;

C_BasePlayer* localplayer = (C_BasePlayer*) entityList->GetClientEntity(engine->GetLocalPlayer());
if (!localplayer)
Expand Down
7 changes: 6 additions & 1 deletion src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ void Settings::LoadDefaultsOrSave(std::string path)
settings["AutoStrafe"]["enabled"] = Settings::AutoStrafe::enabled;
settings["AutoStrafe"]["type"] = (int) Settings::AutoStrafe::type;
settings["AutoStrafe"]["silent"] = Settings::AutoStrafe::silent;
settings["AutoStrafe"]["StrafeKey"]["enabled"] = Settings::AutoStrafe::StrafeKey::enabled;
settings["AutoStrafe"]["StrafeKey"]["key"] = Util::GetButtonName(Settings::AutoStrafe::StrafeKey::key);

settings["Noflash"]["enabled"] = Settings::Noflash::enabled;
settings["Noflash"]["value"] = Settings::Noflash::value;
Expand Down Expand Up @@ -732,7 +734,10 @@ void Settings::LoadConfig(std::string path)
GetVal(settings["AutoStrafe"]["enabled"], &Settings::AutoStrafe::enabled);
GetVal(settings["AutoStrafe"]["type"], (int*)& Settings::AutoStrafe::type);
GetVal(settings["AutoStrafe"]["silent"], &Settings::AutoStrafe::silent);


GetVal(settings["AutoStrafe"]["StrafeKey"]["enabled"], &Settings::AutoStrafe::StrafeKey::enabled);
GetButtonCode(settings["AutoStrafe"]["StrafeKey"]["key"], &Settings::AutoStrafe::StrafeKey::key);

GetVal(settings["Noflash"]["enabled"], &Settings::Noflash::enabled);
GetVal(settings["Noflash"]["value"], &Settings::Noflash::value);

Expand Down
6 changes: 6 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,12 @@ namespace Settings
extern bool enabled;
extern AutostrafeType type;
extern bool silent;

namespace StrafeKey
{
extern bool enabled;
extern ButtonCode_t key;
}
}

namespace Noflash
Expand Down