diff --git a/src/features/aim.c b/src/features/aim.c index 15dd215..3689427 100644 --- a/src/features/aim.c +++ b/src/features/aim.c @@ -53,109 +53,104 @@ typedef struct { float radius; } hitbox_t; -bool get_hitbox(cl_entity_t* ent, int hitbox_index, hitbox_t* out_hitbox) { - if (!ent || !out_hitbox) +bool get_hitbox(cl_entity_t* ent, int hitbox_id, hitbox_t* out_hitbox) { + if (!ent || !out_hitbox) { return false; + } - vec_copy(out_hitbox->origin, ent->origin); - out_hitbox->radius = 12.0f; - + out_hitbox->radius = 5.0f; + + bool is_ak47 = (g_currentWeaponID == 30); + + studiohdr_t* studio = NULL; if (ent->model) { - studiohdr_t* studio = (studiohdr_t*)i_enginestudio->Mod_Extradata(ent->model); - if (studio) { - if (hitbox_index == HITBOX_HEAD) { - vec3_t view_offset; - view_offset.x = 0.0f; - view_offset.y = 0.0f; - view_offset.z = 28.0f; - - if (!ent->player) { - view_offset.z = 25.0f; - } - - out_hitbox->origin = vec_add(ent->origin, view_offset); - - vec3_t head_offset; - head_offset.x = 0.0f; - head_offset.y = 0.0f; - head_offset.z = 0.0f; - - float yaw = ent->angles.y * (M_PI / 180.0f); - head_offset.x = cos(yaw) * 3.0f; - head_offset.y = sin(yaw) * 3.0f; - - out_hitbox->origin = vec_add(out_hitbox->origin, head_offset); - out_hitbox->radius = 5.0f; - - static int debug_count = 0; - if (debug_count++ % 500 == 0) { - printf("Head hitbox: origin=(%.1f, %.1f, %.1f), radius=%.1f\n", - out_hitbox->origin.x, out_hitbox->origin.y, out_hitbox->origin.z, out_hitbox->radius); - } - - return true; - } - else if (hitbox_index == HITBOX_CHEST) { - vec3_t chest_offset; - chest_offset.x = 0.0f; - chest_offset.y = 0.0f; - chest_offset.z = 18.0f; - - out_hitbox->origin = vec_add(ent->origin, chest_offset); - out_hitbox->radius = 10.0f; - return true; - } - else if (hitbox_index == HITBOX_STOMACH) { - vec3_t stomach_offset; - stomach_offset.x = 0.0f; - stomach_offset.y = 0.0f; - stomach_offset.z = 12.0f; - - out_hitbox->origin = vec_add(ent->origin, stomach_offset); - out_hitbox->radius = 10.0f; - return true; - } - else if (hitbox_index == HITBOX_PELVIS) { - vec3_t pelvis_offset; - pelvis_offset.x = 0.0f; - pelvis_offset.y = 0.0f; - pelvis_offset.z = 8.0f; - - out_hitbox->origin = vec_add(ent->origin, pelvis_offset); - out_hitbox->radius = 8.0f; - return true; - } - } + studio = (studiohdr_t*)i_enginestudio->Mod_Extradata(ent->model); } - switch (hitbox_index) { - case HITBOX_HEAD: - out_hitbox->origin.z += 32.0f; + switch (hitbox_id) { + case 0: { + vec3_t view_offset; + view_offset.x = 0.0f; + view_offset.y = 0.0f; + + if (is_ak47) { + view_offset.z = 26.0f; + } else { + view_offset.z = 27.0f; + } + + out_hitbox->origin = vec_add(ent->origin, view_offset); out_hitbox->radius = 7.0f; - break; - case HITBOX_CHEST: - out_hitbox->origin.z += 20.0f; + vec3_t head_offset; + head_offset.x = 0.0f; + head_offset.y = 0.0f; + head_offset.z = 0.0f; + + if (is_ak47) { + head_offset.z = -1.0f; + } + + out_hitbox->origin = vec_add(out_hitbox->origin, head_offset); + + static int debug_counter = 0; + if (debug_counter++ % 500 == 0) { + i_engine->Con_Printf("Head hitbox: Origin(%.1f,%.1f,%.1f) Radius(%.1f) WeaponID: %d\n", + out_hitbox->origin.x, out_hitbox->origin.y, out_hitbox->origin.z, + out_hitbox->radius, g_currentWeaponID); + } + + return true; + } + case 1: { + vec3_t chest_offset; + chest_offset.x = 0.0f; + chest_offset.y = 0.0f; + chest_offset.z = 18.0f; + + out_hitbox->origin = vec_add(ent->origin, chest_offset); out_hitbox->radius = 10.0f; - break; + return true; + } + case 2: { + vec3_t stomach_offset; + stomach_offset.x = 0.0f; + stomach_offset.y = 0.0f; + stomach_offset.z = 12.0f; - case HITBOX_STOMACH: - out_hitbox->origin.z += 12.0f; - out_hitbox->radius = 10.0f; - break; + out_hitbox->origin = vec_add(ent->origin, stomach_offset); + out_hitbox->radius = 9.0f; + return true; + } + case 3: { + vec3_t pelvis_offset; + pelvis_offset.x = 0.0f; + pelvis_offset.y = 0.0f; + pelvis_offset.z = 6.0f; - case HITBOX_PELVIS: - out_hitbox->origin.z += 6.0f; + out_hitbox->origin = vec_add(ent->origin, pelvis_offset); out_hitbox->radius = 8.0f; - break; - + return true; + } default: - out_hitbox->origin.z += 16.0f; - out_hitbox->radius = 12.0f; - break; + if (is_ak47) { + vec3_t fallback_offset; + fallback_offset.x = 0.0f; + fallback_offset.y = 0.0f; + fallback_offset.z = 20.0f; + + out_hitbox->origin = vec_add(ent->origin, fallback_offset); + } else { + vec3_t fallback_offset; + fallback_offset.x = 0.0f; + fallback_offset.y = 0.0f; + fallback_offset.z = 25.0f; + + out_hitbox->origin = vec_add(ent->origin, fallback_offset); + } + out_hitbox->radius = 8.0f; + return true; } - - return true; } bool is_hitbox_visible(vec3_t eye_pos, hitbox_t* hitbox) { @@ -288,152 +283,128 @@ static int s_firing_frames = 0; void aimbot(usercmd_t* cmd) { if (!g_settings.aimbot_enabled) return; + + if (!is_alive(localplayer)) + return; + + if (g_settings.aimbot_require_key && !(cmd->buttons & IN_ATTACK)) + return; + + bool can_fire = g_flCurrentTime >= g_flNextPrimaryAttack; - bool original_attack_state = (cmd->buttons & IN_ATTACK) != 0; + vec3_t eye_pos; + vec_copy(eye_pos, localplayer->origin); + eye_pos.z += 28.0f; - vec3_t view_height; - i_engine->pEventAPI->EV_LocalPlayerViewheight(view_height); - vec3_t eye_pos = vec_add(localplayer->origin, view_height); + vec3_t viewangles; + i_engine->GetViewAngles(viewangles); + + static int shot_count = 0; + static float last_shot_time = 0.0f; + + if (cmd->buttons & IN_ATTACK) { + if (g_flCurrentTime - last_shot_time > 0.08f) { + shot_count++; + last_shot_time = g_flCurrentTime; + + if (shot_count % 5 == 0) { + i_engine->Con_Printf("Shot counter: %d shots in spray\n", shot_count); + } + } + } else { + if (g_flCurrentTime - last_shot_time > 0.25f) { + if (shot_count > 3) { + i_engine->Con_Printf("Reset shot counter from %d\n", shot_count); + } + shot_count = 0; + } + } + + if (cmd->buttons & IN_ATTACK) { + if (g_currentWeaponID == 30) { + viewangles.x -= g_punchAngles[0] * 1.2f; + viewangles.y -= g_punchAngles[1] * 0.8f; + + if (shot_count >= 3) { + float extra_comp = CLAMP((shot_count - 2) * 0.3f, 0.0f, 3.0f); + viewangles.x -= extra_comp; + + if (shot_count % 5 == 0) { + i_engine->Con_Printf("AK-47 Extra comp: %.1f degrees down\n", extra_comp); + } + } + } else { + viewangles.x -= g_punchAngles[0] * 0.6f; + viewangles.y -= g_punchAngles[1] * 0.4f; + } + } + + target_t best_target = get_best_target(viewangles, eye_pos); + + if (!best_target.entity) { + return; + } + + vec3_t aim_direction = vec_sub(best_target.aim_point, eye_pos); + vec3_t aim_angles = vec_to_ang(aim_direction); + + if (g_currentWeaponID == 30) { + if (shot_count > 0) { + float ak_compensation = CLAMP(shot_count * 0.25f, 0.0f, 6.0f); + + aim_angles.x -= ak_compensation; + + if (shot_count % 5 == 0) { + i_engine->Con_Printf("AK-47 aim adjust: Shot %d, Aiming %.1f lower\n", + shot_count, ak_compensation); + } + } + } vec3_t engine_viewangles; i_engine->GetViewAngles(engine_viewangles); - // Simplified recoil detection - we'll let no_recoil.c handle actual compensation - bool is_firing = original_attack_state && can_shoot(); - - // Just track firing for debugging - if (is_firing) { - s_firing_frames++; - } else { - if (s_firing_frames > 0) { - s_firing_frames = 0; + if (g_settings.aimbot_smoothing_enabled && !g_settings.aimbot_silent) { + vec3_t delta; + delta.x = aim_angles.x - engine_viewangles.x; + delta.y = aim_angles.y - engine_viewangles.y; + delta.z = 0.0f; + + if (delta.y > 180.0f) delta.y -= 360.0f; + if (delta.y < -180.0f) delta.y += 360.0f; + + float smooth_factor = g_settings.aimbot_smooth; + + if (g_currentWeaponID == 30 && shot_count > 1) { + smooth_factor *= 0.7f; } - } - - vec_copy(s_last_viewangles, engine_viewangles); - - target_t best_target = get_best_target(engine_viewangles, eye_pos); - bool valid_target_found = (best_target.entity && best_target.is_visible); - - bool can_fire = can_shoot(); - - static int frame_counter = 0; - bool should_debug = (frame_counter++ % 100 == 0); - - if (should_debug) { - printf("Aimbot: Target=%d, CanFire=%d, FOV=%.1f, Frames=%d\n", - valid_target_found, can_fire, - valid_target_found ? best_target.fov : 0.0f, - s_firing_frames); - } - - if (!valid_target_found) { - if (g_settings.aimbot_autoshoot) { - cmd->buttons &= ~IN_ATTACK; - } - return; - } - - vec3_t to_target = vec_sub(best_target.aim_point, eye_pos); - vec3_t aim_angles = vec_to_ang(to_target); - - ang_clamp(&aim_angles); - - vec3_t delta = vec_sub(aim_angles, engine_viewangles); - vec_norm(&delta); - - float aim_error = sqrtf(delta.x * delta.x + delta.y * delta.y); - bool aimed_accurately = (aim_error < 2.5f); - - static vec3_t smooth_angles = {0, 0, 0}; - static bool tracking_active = false; - static float tracking_time = 0.0f; - - if (!tracking_active && valid_target_found) { - vec_copy(smooth_angles, engine_viewangles); - tracking_active = true; - tracking_time = 0.0f; - } else if (tracking_active && valid_target_found) { - tracking_time += 0.016f; - tracking_time = fminf(tracking_time, 1.0f); - } else if (tracking_active && !valid_target_found) { - tracking_active = false; - } - - if (g_settings.aimbot_silent) { - cmd->viewangles.x = aim_angles.x; - cmd->viewangles.y = aim_angles.y; - cmd->viewangles.z = 0; - } else { - if (g_settings.aimbot_smoothing_enabled && tracking_active) { - float smoothing = g_settings.aimbot_smooth; - if (smoothing <= 0.1f) smoothing = 0.1f; - - float base_factor = 1.0f / (smoothing * 1.5f); - float adaptive_factor = base_factor * (1.0f - (tracking_time * 0.5f)); - - float ease_factor = fminf(1.0f, adaptive_factor); - float t = 1.0f - pow(1.0f - ease_factor, 3); - - float pitch_diff = aim_angles.x - smooth_angles.x; - if (pitch_diff > 180.0f) pitch_diff -= 360.0f; - if (pitch_diff < -180.0f) pitch_diff += 360.0f; - smooth_angles.x += pitch_diff * t; - - float yaw_diff = aim_angles.y - smooth_angles.y; - if (yaw_diff > 180.0f) yaw_diff -= 360.0f; - if (yaw_diff < -180.0f) yaw_diff += 360.0f; - smooth_angles.y += yaw_diff * t; - - smooth_angles.z = 0; - - if (smooth_angles.x > 180.0f) smooth_angles.x -= 360.0f; - if (smooth_angles.x < -180.0f) smooth_angles.x += 360.0f; - if (smooth_angles.y > 180.0f) smooth_angles.y -= 360.0f; - if (smooth_angles.y < -180.0f) smooth_angles.y += 360.0f; - - engine_viewangles = smooth_angles; - } else { - engine_viewangles = aim_angles; - vec_copy(smooth_angles, aim_angles); + + if (best_target.fov < g_settings.aimbot_fov * 0.5f) { + smooth_factor *= 0.6f; } + if (smooth_factor < 1.0f) smooth_factor = 1.0f; + + vec3_t smooth_angles; + smooth_angles.x = engine_viewangles.x + delta.x / smooth_factor; + smooth_angles.y = engine_viewangles.y + delta.y / smooth_factor; + smooth_angles.z = 0.0f; + + ang_clamp(&smooth_angles); + + engine_viewangles = smooth_angles; + + i_engine->SetViewAngles(engine_viewangles); + } + else if (g_settings.aimbot_silent) { + vec_copy(cmd->viewangles, aim_angles); + } + else { + engine_viewangles = aim_angles; i_engine->SetViewAngles(engine_viewangles); - - cmd->viewangles.x = engine_viewangles.x; - cmd->viewangles.y = engine_viewangles.y; - cmd->viewangles.z = 0; } - if (can_fire) { - if (g_settings.aimbot_autoshoot && aimed_accurately) { - cmd->buttons |= IN_ATTACK; - if (should_debug) printf("AUTO-FIRING (error: %.2f)\n", aim_error); - } - else if (g_settings.aimbot_require_key) { - if (original_attack_state) { - if (aimed_accurately) { - cmd->buttons |= IN_ATTACK; - if (should_debug) printf("MANUAL-FIRING with key (error: %.2f)\n", aim_error); - } else { - cmd->buttons &= ~IN_ATTACK; - } - } else { - cmd->buttons &= ~IN_ATTACK; - } - } - else if (!g_settings.aimbot_require_key) { - if (should_debug && original_attack_state) - printf("PRESERVING manual fire\n"); - } - } else { - if (g_settings.aimbot_autoshoot || g_settings.aimbot_require_key) { - cmd->buttons &= ~IN_ATTACK; - } - - if (should_debug && original_attack_state) { - printf("CAN'T FIRE: NextAttack=%.3f, Primary=%.3f\n", - g_flNextAttack, g_flNextPrimaryAttack); - } + if (g_settings.aimbot_autoshoot && best_target.is_visible && can_fire) { + cmd->buttons |= IN_ATTACK; } } \ No newline at end of file diff --git a/src/features/anti_aim.c b/src/features/anti_aim.c index 6d09375..87f719f 100644 --- a/src/features/anti_aim.c +++ b/src/features/anti_aim.c @@ -264,21 +264,35 @@ void anti_aim(usercmd_t* cmd) { next_switch = g_flCurrentTime + random_float(0.4f, 0.8f); } + if (!g_settings.antiaim_view) { + vec3_t real_angles; + i_engine->GetViewAngles(real_angles); + + vec3_t server_angles; + vec_copy(server_angles, real_angles); + server_angles.y += (switch_side ? 58.0f : -58.0f); + + if (server_angles.y > 180.0f) server_angles.y -= 360.0f; + if (server_angles.y < -180.0f) server_angles.y += 360.0f; + + vec_copy(cmd->viewangles, server_angles); + i_engine->SetViewAngles(real_angles); + + static float last_desync_log = 0.0f; + if (g_flCurrentTime > last_desync_log + 3.0f) { + i_engine->Con_Printf("Desync active: Server %.1f, Client %.1f (invisible to user)\n", + server_angles.y, real_angles.y); + last_desync_log = g_flCurrentTime; + } + + return; + } + float desync_amount = switch_side ? 58.0f : -58.0f; - - static vec3_t real_angles; - vec_copy(real_angles, view_angles); - view_angles.y += desync_amount; if (view_angles.y > 180.0f) view_angles.y -= 360.0f; if (view_angles.y < -180.0f) view_angles.y += 360.0f; - - if (!g_settings.antiaim_view) { - vec_copy(cmd->viewangles, view_angles); - i_engine->SetViewAngles(real_angles); - return; - } } bool should_fake_duck = false; diff --git a/src/features/no_recoil.c b/src/features/no_recoil.c index 83115d2..aa423e9 100644 --- a/src/features/no_recoil.c +++ b/src/features/no_recoil.c @@ -8,95 +8,177 @@ static time_t last_log_time = 0; static vec3_t last_punch = {0, 0, 0}; - static vec3_t previous_viewangles = {0, 0, 0}; -#define AK47_RECOIL_MULT 500.0f -#define DEFAULT_RECOIL_MULT 300.0f +#define WEAPON_AK47 30 +#define WEAPON_M4A1 31 +#define WEAPON_AWP 33 +#define WEAPON_DEAGLE 26 + +#define AK47_RECOIL_VERT_MULT 2.8f +#define AK47_RECOIL_HORIZ_MULT 0.9f +#define DEFAULT_RECOIL_VERT_MULT 2.0f +#define DEFAULT_RECOIL_HORIZ_MULT 0.6f + +static float ak47_pattern[] = { + 0.0f, + 2.2f, + 3.0f, + 3.5f, + 3.9f, + 4.0f, + 3.8f, + 3.5f, + 3.2f, + 2.9f, + 2.7f, + 2.5f, + 2.2f, + 2.0f, + 1.9f, + 1.7f, + 1.6f, + 1.5f, + 1.4f, + 1.3f, + 1.2f, + 1.1f, + 1.0f, + 0.9f, + 0.8f, + 0.8f, + 0.7f, + 0.7f, + 0.6f, + 0.6f +}; + +static int bullet_count = 0; +static float last_shot_time = 0.0f; +static int current_weapon_id = -1; void no_recoil(usercmd_t* cmd) { if (!is_alive(localplayer) || (!g_settings.aimbot_norecoil && !g_settings.aimbot_recoil_comp)) { return; } + if (!(cmd->buttons & IN_ATTACK)) { + if (g_flCurrentTime - last_shot_time > 0.2f) { + if (bullet_count > 0) { + i_engine->Con_Printf("Recoil: Reset spray pattern from %d bullets\n", bullet_count); + bullet_count = 0; + } + } + return; + } + vec3_t current_viewangles; i_engine->GetViewAngles(current_viewangles); - vec3_t angle_change; - angle_change.x = current_viewangles.x - previous_viewangles.x; - angle_change.y = current_viewangles.y - previous_viewangles.y; - angle_change.z = current_viewangles.z - previous_viewangles.z; + bool is_ak47 = false; + bool is_high_recoil_weapon = false; + + if (g_currentWeaponID == WEAPON_AK47) { + is_ak47 = true; + is_high_recoil_weapon = true; + } + else if (g_currentWeaponID == WEAPON_M4A1) { + is_high_recoil_weapon = true; + } + else if (g_flNextPrimaryAttack - g_flNextAttack < 0.15f) { + is_high_recoil_weapon = true; + if (g_flNextPrimaryAttack - g_flNextAttack < 0.11f) { + is_ak47 = true; + } + } - vec_copy(previous_viewangles, current_viewangles); - - if (cmd->buttons & IN_ATTACK) { - bool applied = false; - float multiplier = 0; - - vec3_t punch_angles; - vec_copy(punch_angles, g_punchAngles); - - bool is_high_recoil_weapon = false; + last_shot_time = g_flCurrentTime; + + static float last_attack_time = 0.0f; + bool is_new_shot = g_flCurrentTime - last_attack_time > 0.05f; + + if (is_new_shot) { + bullet_count++; + last_attack_time = g_flCurrentTime; - if (g_flNextPrimaryAttack - g_flNextAttack < 0.15f) { - is_high_recoil_weapon = true; + if (bullet_count > 1 && (bullet_count % 3 == 0 || bullet_count <= 5)) { + i_engine->Con_Printf("Recoil comp: Shot #%d, Weapon: %s\n", + bullet_count, is_ak47 ? "AK-47" : (is_high_recoil_weapon ? "High Recoil" : "Standard")); } - - if (g_settings.aimbot_norecoil) { - if (is_high_recoil_weapon) { - multiplier = AK47_RECOIL_MULT; - } else { - multiplier = DEFAULT_RECOIL_MULT; + } + + vec3_t punch_angles; + vec_copy(punch_angles, g_punchAngles); + + float vert_mult = 0.0f; + float horiz_mult = 0.0f; + float pattern_compensation = 0.0f; + + if (g_settings.aimbot_norecoil) { + if (is_ak47) { + vert_mult = AK47_RECOIL_VERT_MULT; + horiz_mult = AK47_RECOIL_HORIZ_MULT; + + if (bullet_count > 0 && bullet_count <= 30) { + pattern_compensation = ak47_pattern[bullet_count-1] * 0.6f; } - - static int shot_counter = 0; - if (is_high_recoil_weapon) { - if (shot_counter < 3) { - punch_angles[0] *= 1.2f; - shot_counter++; - } - } else { - shot_counter = 0; - } - - cmd->viewangles[0] -= (punch_angles[0] * multiplier); - cmd->viewangles[1] -= (punch_angles[1] * multiplier * 0.7f); // Less horizontal comp - - static int sustained_fire = 0; - if (punch_angles[0] > 0.001f || punch_angles[1] > 0.001f) { - sustained_fire++; - - if (sustained_fire > 4 && is_high_recoil_weapon) { - cmd->viewangles[0] -= 0.3f * (sustained_fire * 0.1f); - } - } else { - sustained_fire = 0; - } - - applied = true; + } + else if (is_high_recoil_weapon) { + vert_mult = 2.2f; + horiz_mult = 0.8f; + } + else { + vert_mult = 1.9f; + horiz_mult = 0.7f; } - else if (g_settings.aimbot_recoil_comp) { - if (is_high_recoil_weapon) { - multiplier = 40.0f; - } else { - multiplier = 20.0f; + + cmd->viewangles[0] -= (punch_angles[0] * vert_mult); + cmd->viewangles[1] -= (punch_angles[1] * horiz_mult); + + if (pattern_compensation > 0) { + cmd->viewangles[0] -= pattern_compensation; + + if (is_ak47 && bullet_count <= 5) { + i_engine->Con_Printf("AK-47 pattern comp: Shot #%d, Compensation: %.2f degrees\n", + bullet_count, pattern_compensation); } - - cmd->viewangles[0] -= (punch_angles[0] * multiplier); - cmd->viewangles[1] -= (punch_angles[1] * multiplier * 0.6f); - - applied = true; } - - time_t current_time = time(NULL); - if (applied && current_time - last_log_time >= 2) { - printf("Applied recoil control - Weapon: %s, Multiplier: %.1f, PunchX: %.3f, PunchY: %.3f, Compensation: (%.2f, %.2f)\n", - is_high_recoil_weapon ? "High Recoil" : "Standard", - multiplier, punch_angles[0], punch_angles[1], - -punch_angles[0] * multiplier, -punch_angles[1] * multiplier); + } + else if (g_settings.aimbot_recoil_comp) { + if (is_ak47) { + vert_mult = 2.0f; + horiz_mult = 0.7f; - last_log_time = current_time; + if (bullet_count > 0 && bullet_count <= 30) { + pattern_compensation = ak47_pattern[bullet_count-1] * 0.35f; + } + } + else if (is_high_recoil_weapon) { + vert_mult = 1.7f; + horiz_mult = 0.6f; + } + else { + vert_mult = 1.3f; + horiz_mult = 0.5f; } + + cmd->viewangles[0] -= (punch_angles[0] * vert_mult); + cmd->viewangles[1] -= (punch_angles[1] * horiz_mult); + + if (pattern_compensation > 0) { + cmd->viewangles[0] -= pattern_compensation; + } + } + + time_t current_time = time(NULL); + if (current_time - last_log_time >= 2) { + if (bullet_count > 0) { + i_engine->Con_Printf("Recoil control - Weapon: %s, Bullet: %d, VMult: %.1f, HMult: %.1f, Pattern: %.1f\n", + is_ak47 ? "AK-47" : (is_high_recoil_weapon ? "High Recoil" : "Standard"), + bullet_count, vert_mult, horiz_mult, pattern_compensation); + } + + last_log_time = current_time; } ang_clamp(&cmd->viewangles);