void Movement::AutoPeek(CUserCmd* cmd, float wish_yaw) {
if (g_input.GetKeyState(g_menu.main.aimbot.autopeek.get())) {
if (start_position.IsZero()) {
start_position = g_cl.m_local->GetAbsOrigin();
if (!(g_cl.m_flags & FL_ONGROUND)) {
CTraceFilterWorldOnly filter;
CGameTrace trace;
g_csgo.m_engine_trace->TraceRay(Ray(start_position, start_position - vec3_t(0.0f, 0.0f, 1000.0f)), MASK_SOLID, &filter, &trace);
if (trace.m_fraction < 1.0f)
start_position = trace.m_endpos + vec3_t(0.0f, 0.0f, 2.0f);
}
}
else {
bool revolver_shoot = g_cl.m_weapon_id == REVOLVER && !g_cl.m_revolver_fire && (cmd->m_buttons & IN_ATTACK || cmd->m_buttons & IN_ATTACK2);
if (g_cl.m_old_shot)
fired_shot = true;
if (fired_shot) {
vec3_t current_position = g_cl.m_local->GetAbsOrigin();
vec3_t difference = current_position - start_position;
if (difference.length_2d() > 5.0f && difference.length_2d() < 300.0f) {
vec3_t velocity = vec3_t(difference.x * cos(wish_yaw / 180.0f * math::pi) + difference.y * sin(wish_yaw / 180.0f * math::pi), difference.y * cos(wish_yaw / 180.0f * math::pi) - difference.x * sin(wish_yaw / 180.0f * math::pi), difference.z);
if (difference.length_2d() < 50.0f) {
cmd->m_forward_move = -velocity.x * 20.0f;
cmd->m_side_move = velocity.y * 20.0f;
}
else if (difference.length_2d() < 100.0f) {
cmd->m_forward_move = -velocity.x * 10.0f;
cmd->m_side_move = velocity.y * 10.0f;
}
else if (difference.length_2d() < 150.0f) {
cmd->m_forward_move = -velocity.x * 5.0f;
cmd->m_side_move = velocity.y * 5.0f;
}
else if (difference.length_2d() < 250.0f) {
cmd->m_forward_move = -velocity.x * 2.0f;
cmd->m_side_move = velocity.y * 2.0f;
}
else {
cmd->m_forward_move = -velocity.x * 1.0f;
cmd->m_side_move = velocity.y * 1.0f;
}
}
else {
fired_shot = false;
start_position.clear();
}
}
}
}
else {
fired_shot = false;
start_position.clear();
}
}