Add auto-bunnyhop to CreateMove hook.
* TODO: Store NetVar offsets statically. Signed-off-by: aixxe <me@aixxe.net>
This commit is contained in:
parent
d53dbcabfd
commit
8287f60778
|
@ -10,3 +10,5 @@
|
||||||
#include "Utilities/FindPattern.h"
|
#include "Utilities/FindPattern.h"
|
||||||
#include "Utilities/Interfaces.h"
|
#include "Utilities/Interfaces.h"
|
||||||
#include "Utilities/NetVars.h"
|
#include "Utilities/NetVars.h"
|
||||||
|
|
||||||
|
#include "Game/Entity.h"
|
|
@ -8,7 +8,12 @@ void GUI::DrawFramerateCounter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::DrawConfigurationWindow() {
|
void GUI::DrawConfigurationWindow() {
|
||||||
ImGui::Begin("cstrike-basehook-linux", nullptr);
|
ImGui::Begin("Settings", nullptr);
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::PushItemWidth(-1);
|
||||||
|
|
||||||
|
ImGui::Checkbox("Auto-bunnyhop", &GUI::BunnyHop::Enabled);
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
ImGui::PopItemWidth();
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
bool GUI::IsVisible = false;
|
bool GUI::IsVisible = false;
|
||||||
|
|
||||||
|
bool GUI::BunnyHop::Enabled = true;
|
||||||
|
|
||||||
void GUI::Render() {
|
void GUI::Render() {
|
||||||
// Draw various global components.
|
// Draw various global components.
|
||||||
GUI::DrawFramerateCounter();
|
GUI::DrawFramerateCounter();
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
extern bool IsVisible;
|
extern bool IsVisible;
|
||||||
|
|
||||||
|
namespace BunnyHop {
|
||||||
|
extern bool Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void DrawFramerateCounter();
|
void DrawFramerateCounter();
|
||||||
void DrawConfigurationWindow();
|
void DrawConfigurationWindow();
|
||||||
|
|
||||||
|
|
|
@ -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"));
|
||||||
|
}
|
||||||
|
};
|
|
@ -12,9 +12,16 @@ void Hooks::CreateMove(IBaseClientDLL* thisptr, int sequence, float frametime, b
|
||||||
// Get the current user command.
|
// Get the current user command.
|
||||||
CUserCmd* cmd = input->GetUserCmd(sequence);
|
CUserCmd* cmd = input->GetUserCmd(sequence);
|
||||||
|
|
||||||
if (cmd->buttons & IN_JUMP) {
|
// Get the LocalPlayer entity.
|
||||||
cmd->buttons |= IN_ATTACK;
|
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.
|
// Re-calculate the command checksum after making changes.
|
||||||
input->VerifyUserCmd(cmd, sequence);
|
input->VerifyUserCmd(cmd, sequence);
|
||||||
|
|
Loading…
Reference in New Issue