diff --git a/src/Basehook.h b/src/Basehook.h index 6366c06..00cbc46 100644 --- a/src/Basehook.h +++ b/src/Basehook.h @@ -9,4 +9,6 @@ #include "Utilities/Linker.h" #include "Utilities/FindPattern.h" #include "Utilities/Interfaces.h" -#include "Utilities/NetVars.h" \ No newline at end of file +#include "Utilities/NetVars.h" + +#include "Game/Entity.h" \ No newline at end of file diff --git a/src/GUI/Components.cpp b/src/GUI/Components.cpp index 9fecc07..9a3024b 100644 --- a/src/GUI/Components.cpp +++ b/src/GUI/Components.cpp @@ -8,7 +8,12 @@ void GUI::DrawFramerateCounter() { } void GUI::DrawConfigurationWindow() { - ImGui::Begin("cstrike-basehook-linux", nullptr); - ImGui::Text("Hello, world!"); + ImGui::Begin("Settings", nullptr); + ImGui::PushItemWidth(-1); + + ImGui::Checkbox("Auto-bunnyhop", &GUI::BunnyHop::Enabled); + ImGui::Spacing(); + + ImGui::PopItemWidth(); ImGui::End(); } diff --git a/src/GUI/GUI.cpp b/src/GUI/GUI.cpp index fd077bf..ecd377b 100644 --- a/src/GUI/GUI.cpp +++ b/src/GUI/GUI.cpp @@ -2,6 +2,8 @@ bool GUI::IsVisible = false; +bool GUI::BunnyHop::Enabled = true; + void GUI::Render() { // Draw various global components. GUI::DrawFramerateCounter(); diff --git a/src/GUI/GUI.h b/src/GUI/GUI.h index 8e98d8d..12db6a8 100644 --- a/src/GUI/GUI.h +++ b/src/GUI/GUI.h @@ -6,6 +6,10 @@ namespace GUI { extern bool IsVisible; + namespace BunnyHop { + extern bool Enabled; + } + void DrawFramerateCounter(); void DrawConfigurationWindow(); diff --git a/src/Game/Entity.h b/src/Game/Entity.h new file mode 100644 index 0000000..885cd13 --- /dev/null +++ b/src/Game/Entity.h @@ -0,0 +1,11 @@ +#pragma once + +class C_BaseEntity: public IClientEntity { +}; + +class C_BasePlayer: public C_BaseEntity { + public: + int GetFlags() { + return *reinterpret_cast(uintptr_t(this) + NetVars::GetOffset("CBasePlayer", "m_fFlags")); + } +}; \ No newline at end of file diff --git a/src/Hooks/CreateMove.cpp b/src/Hooks/CreateMove.cpp index 1ba6d2c..43dd5d4 100644 --- a/src/Hooks/CreateMove.cpp +++ b/src/Hooks/CreateMove.cpp @@ -12,10 +12,17 @@ void Hooks::CreateMove(IBaseClientDLL* thisptr, int sequence, float frametime, b // Get the current user command. CUserCmd* cmd = input->GetUserCmd(sequence); - if (cmd->buttons & IN_JUMP) { - cmd->buttons |= IN_ATTACK; - } + // Get the LocalPlayer entity. + C_BasePlayer* localplayer = static_cast(entitylist->GetClientEntity(engine->GetLocalPlayer())); + + // No need to validate if we stop here since we haven't changed anything yet. + if (!localplayer) + return; + // Auto-bunnyhop when jump key is held. (releases the IN_JUMP button when on ground) + if (GUI::BunnyHop::Enabled && cmd->buttons & IN_JUMP && !(localplayer->GetFlags() & FL_ONGROUND)) + cmd->buttons &= ~IN_JUMP; + // Re-calculate the command checksum after making changes. input->VerifyUserCmd(cmd, sequence); } \ No newline at end of file