Files
goldsrc-cheat/src/features/anti_aim.c

80 lines
2.2 KiB
C
Raw Normal View History

#include <math.h>
#include <stdlib.h>
#include <time.h>
#include "features.h"
#include "../include/sdk.h"
#include "../include/cvars.h"
#include "../include/util.h"
float random_float(float min, float max) {
return (max - min) * ((float)rand() / (float)RAND_MAX) + min;
}
void anti_aim(usercmd_t* cmd) {
2023-09-20 23:19:16 -04:00
if (cmd->buttons & IN_ATTACK || cmd->buttons & IN_USE) {
if (cmd->buttons & IN_ATTACK) {
i_engine->pfnClientCmd("echo \"Attack detected. Spinbot stopped.\"");
} else if (cmd->buttons & IN_USE) {
i_engine->pfnClientCmd("echo \"Use key detected. Spinbot stopped.\"");
}
return;
}
2023-09-20 23:10:57 -04:00
if (!CVAR_ON(movement_antiaim)) {
return;
}
if (!is_alive(localplayer)) {
return;
}
vec3_t view_angles;
i_engine->GetViewAngles(view_angles);
static bool lbyBreak = false;
if (lbyBreak) {
view_angles.y += 120.0f;
}
lbyBreak = !lbyBreak;
static bool flipPitch = false;
if (flipPitch) {
view_angles.x = 89.0f;
} else {
view_angles.x = -89.0f;
}
flipPitch = !flipPitch;
view_angles.y += 30.0f;
// This shit busted right now
if (CVAR_ON(movement_fakeduck) && cmd->forwardmove == 0.0f && cmd->sidemove == 0.0f) {
static int duckCounter = 0;
if (duckCounter < 5) {
cmd->buttons |= IN_DUCK;
} else if (duckCounter < 10) {
cmd->buttons &= ~IN_DUCK;
} else {
duckCounter = 0;
}
duckCounter++;
}
if (view_angles.y > 180.0f) view_angles.y -= 360.0f;
if (view_angles.y < -180.0f) view_angles.y += 360.0f;
if (CVAR_ON(movement_antiaim_view)) {
i_engine->SetViewAngles(view_angles);
2023-09-20 23:10:57 -04:00
i_engine->pfnClientCmd("echo \"Set view angles directly using movement_antiaim_view.\"");
} else {
vec_copy(cmd->viewangles, view_angles);
2023-09-20 23:10:57 -04:00
i_engine->pfnClientCmd("echo \"Set view angles silently.\"");
}
static float last_log_time = 0.0f;
if (cmd->msec - last_log_time >= 5000.0f) {
i_engine->pfnClientCmd("echo \"Advanced Anti-Aim has adjusted view angles.\"");
last_log_time = cmd->msec;
}
}