Fix non silent aim missing it's first shot

This commit is contained in:
Wizzard 2023-09-20 20:37:29 -04:00
parent 9a109b3882
commit 1d99e0758a
1 changed files with 10 additions and 12 deletions

View File

@ -91,6 +91,7 @@ static vec3_t get_closest_delta(vec3_t viewangles) {
void aimbot(usercmd_t* cmd) { void aimbot(usercmd_t* cmd) {
static bool shouldShootNextFrame = false; static bool shouldShootNextFrame = false;
static bool hasAdjustedView = false;
if (!CVAR_ON(aim_aimbot) || !can_shoot()) if (!CVAR_ON(aim_aimbot) || !can_shoot())
return; return;
@ -107,23 +108,20 @@ void aimbot(usercmd_t* cmd) {
if (CVAR_ON(aim_aimbot_silent)) { if (CVAR_ON(aim_aimbot_silent)) {
vec_copy(cmd->viewangles, engine_viewangles); vec_copy(cmd->viewangles, engine_viewangles);
if (cmd->buttons & IN_ATTACK) { if (cmd->buttons & IN_ATTACK) {
if (shouldShootNextFrame) {
cmd->buttons |= IN_ATTACK; cmd->buttons |= IN_ATTACK;
shouldShootNextFrame = false;
} else {
cmd->buttons &= ~IN_ATTACK;
shouldShootNextFrame = true;
}
} }
} else { } else {
if (cmd->buttons & IN_ATTACK) { // Ensure left click is pressed before adjusting aim for non-silent if (cmd->buttons & IN_ATTACK) {
if (hasAdjustedView) {
hasAdjustedView = false; // Reset flag
} else {
i_engine->SetViewAngles(engine_viewangles); i_engine->SetViewAngles(engine_viewangles);
hasAdjustedView = true;
cmd->buttons &= ~IN_ATTACK; // Defer the shot to the next frame
}
} }
} }
} else if (CVAR_ON(aim_autoshoot) && (cmd->buttons & IN_ATTACK)) { } else if (CVAR_ON(aim_autoshoot) && (cmd->buttons & IN_ATTACK)) {
cmd->buttons &= ~IN_ATTACK; cmd->buttons &= ~IN_ATTACK;
} else {
shouldShootNextFrame = false; // Reset
} }
} }