From 17b4e4e3a35479c903ff11dcb81f7d7b2a7e7979 Mon Sep 17 00:00:00 2001 From: Wizzard <25581244+Wizzard@users.noreply.toomuchslop.com> Date: Wed, 20 Sep 2023 23:58:54 -0400 Subject: [PATCH] Fakeduck always when holding space --- src/features/anti_aim.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/features/anti_aim.c b/src/features/anti_aim.c index bc43af5..0eb0d42 100644 --- a/src/features/anti_aim.c +++ b/src/features/anti_aim.c @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include "features.h" #include "../include/sdk.h" @@ -11,6 +13,22 @@ float random_float(float min, float max) { return (max - min) * ((float)rand() / (float)RAND_MAX) + min; } +bool isSpacebarPressed() { + Display* display = XOpenDisplay(NULL); + if (!display) { + return false; // Could not open the display, assume not pressed + } + + char keys_return[32]; + XQueryKeymap(display, keys_return); + KeyCode kc = XKeysymToKeycode(display, XK_space); + bool pressed = (keys_return[kc >> 3] & (1 << (kc & 7))) != 0; + + XCloseDisplay(display); + return pressed; +} + + void anti_aim(usercmd_t* cmd) { if (cmd->buttons & IN_ATTACK || cmd->buttons & IN_USE) { if (cmd->buttons & IN_ATTACK) { @@ -47,13 +65,16 @@ void anti_aim(usercmd_t* cmd) { flipPitch = !flipPitch; view_angles.y += 30.0f; - + + bool isBunnyHopping = cmd->buttons & IN_JUMP; + bool isStationary = (cmd->forwardmove == 0.0f && cmd->sidemove == 0.0f); + // This shit busted right now - if (CVAR_ON(movement_fakeduck) && cmd->forwardmove == 0.0f && cmd->sidemove == 0.0f) { + if (CVAR_ON(movement_fakeduck) && (isStationary || isBunnyHopping || isSpacebarPressed())) { static int duckCounter = 0; - if (duckCounter < 5) { + if (duckCounter < 2) { cmd->buttons |= IN_DUCK; - } else if (duckCounter < 10) { + } else if (duckCounter < 4) { cmd->buttons &= ~IN_DUCK; } else { duckCounter = 0;