Add auto-bunnyhop to CreateMove hook.

* TODO: Store NetVar offsets statically.

Signed-off-by: aixxe <me@aixxe.net>
This commit is contained in:
aixxe 2016-12-21 15:23:43 +00:00
parent d53dbcabfd
commit 8287f60778
6 changed files with 37 additions and 6 deletions

View File

@ -9,4 +9,6 @@
#include "Utilities/Linker.h"
#include "Utilities/FindPattern.h"
#include "Utilities/Interfaces.h"
#include "Utilities/NetVars.h"
#include "Utilities/NetVars.h"
#include "Game/Entity.h"

View File

@ -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();
}

View File

@ -2,6 +2,8 @@
bool GUI::IsVisible = false;
bool GUI::BunnyHop::Enabled = true;
void GUI::Render() {
// Draw various global components.
GUI::DrawFramerateCounter();

View File

@ -6,6 +6,10 @@
namespace GUI {
extern bool IsVisible;
namespace BunnyHop {
extern bool Enabled;
}
void DrawFramerateCounter();
void DrawConfigurationWindow();

11
src/Game/Entity.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
class C_BaseEntity: public IClientEntity {
};
class C_BasePlayer: public C_BaseEntity {
public:
int GetFlags() {
return *reinterpret_cast<int*>(uintptr_t(this) + NetVars::GetOffset("CBasePlayer", "m_fFlags"));
}
};

View File

@ -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<C_BasePlayer*>(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);
}