Skip to content

Commit

Permalink
rewrite aimbot
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciremun committed Jan 8, 2024
1 parent 26b4a40 commit 5ad83a4
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 93 deletions.
6 changes: 3 additions & 3 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
ar_lock=1
ar_value=10.0
cs_lock=0
cs_value=5.0
cs_value=4.0
od_lock=0
od_value=5.0
od_value=8.0
visible=1
font_size=30
relax=0
relax_style=a
relax_checks_od=1
aimbot=0
spins_per_minute=300
fraction_modifier=0.040
fraction_modifier=100.000
replay=0
replay_aim=1
replay_keys=1
Expand Down
4 changes: 4 additions & 0 deletions freedom/clrhost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,17 @@ static inline bool set_classmethods_from_strings()
v = invoke_csharp_method(L"Freedom.Utils", L"SetClassMethod", cm_updatevariables_ws.c_str()); RETURN_IF_FALSE();
#undef RETURN_IF_FALSE
ImGui::SaveIniSettingsToDisk(ImGui::GetIO().IniFilename);
FR_INFO("[+] All classmethods are set");
return true;
}

bool prepare_all_methods_fast()
{
if (!set_classmethods_from_strings())
{
FR_INFO("[!] Failed to set some classmethods, fallback to slow method");
return false;
}
VARIANT v = invoke_csharp_method(L"Freedom.Utils", L"prepare_all_methods_fast");
if (variant_ok(&v) && v.intVal == 1)
{
Expand Down
2 changes: 1 addition & 1 deletion freedom/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
int cfg_font_size = 30;
int cfg_spins_per_minute = 300;
bool cfg_mod_menu_visible = true;
float cfg_fraction_modifier = 0.04f;
float cfg_fraction_modifier = 100.f;
bool cfg_replay_enabled = false;
bool cfg_replay_aim = true;
bool cfg_replay_keys = true;
Expand Down
128 changes: 61 additions & 67 deletions freedom/features/aimbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,77 @@

static bool target_first_circle = true;

static float fraction_of_the_distance = 0.0f;
static Vector2 direction(0.0f, 0.0f);
static Vector2 mouse_position(0.0f, 0.0f);
static inline Vector2<float> mouse_position()
{
Vector2<float> mouse_pos(.0f, .0f);
uintptr_t osu_manager = *(uintptr_t*)(osu_manager_ptr);
if (!osu_manager) return mouse_pos;
uintptr_t osu_ruleset_ptr = *(uintptr_t*)(osu_manager + OSU_MANAGER_RULESET_PTR_OFFSET);
if (!osu_ruleset_ptr) return mouse_pos;
mouse_pos.x = *(float*)(osu_ruleset_ptr + OSU_RULESET_MOUSE_X_OFFSET);
mouse_pos.y = *(float*)(osu_ruleset_ptr + OSU_RULESET_MOUSE_Y_OFFSET);
return mouse_pos;
}

static inline float lerp(float a, float b, float t)
{
return a + t * (b - a);
}

static inline void move_mouse_to_target(const Vector2<float> &target, const Vector2<float> &cursor_pos, float t)
{
Vector2 target_on_screen = playfield_to_screen(target);
Vector2 predicted_position(lerp(cursor_pos.x, target_on_screen.x, t), lerp(cursor_pos.y, target_on_screen.y, t));
move_mouse_to(predicted_position.x, predicted_position.y);
}

void update_aimbot(Circle &circle, const int32_t audio_time)
{
if (cfg_aimbot_lock)
if (!cfg_aimbot_lock)
return;

float t = cfg_fraction_modifier * ImGui::GetIO().DeltaTime;
Vector2 cursor_pos = mouse_position();

if (circle.type == HitObjectType::Circle)
{
if (fraction_of_the_distance)
{
if (fraction_of_the_distance > 1.0f)
{
fraction_of_the_distance = 0.0f;
}
else
{
Vector2 next_mouse_position = mouse_position + direction * fraction_of_the_distance;
move_mouse_to(next_mouse_position.x, next_mouse_position.y);
fraction_of_the_distance += cfg_fraction_modifier;
}
}
if (target_first_circle)
{
direction = prepare_hitcircle_target(osu_manager_ptr, circle.position, mouse_position);
fraction_of_the_distance = cfg_fraction_modifier;
target_first_circle = false;
}
if (audio_time >= circle.start_time)
move_mouse_to_target(circle.position, cursor_pos, t);
}
else if (circle.type == HitObjectType::Slider)
{
uintptr_t osu_manager = *(uintptr_t *)(osu_manager_ptr);
if (!osu_manager) return;
uintptr_t hit_manager_ptr = *(uintptr_t *)(osu_manager + OSU_MANAGER_HIT_MANAGER_OFFSET);
if (!hit_manager_ptr) return;
uintptr_t hit_objects_list_ptr = *(uintptr_t *)(hit_manager_ptr + OSU_HIT_MANAGER_HIT_OBJECTS_LIST_OFFSET);
uintptr_t hit_objects_list_items_ptr = *(uintptr_t *)(hit_objects_list_ptr + 0x4);
uintptr_t hit_object_ptr = *(uintptr_t *)(hit_objects_list_items_ptr + 0x8 + 0x4 * current_beatmap.hit_object_idx);
uintptr_t animation_ptr = *(uintptr_t *)(hit_object_ptr + OSU_HIT_OBJECT_ANIMATION_OFFSET);
float slider_ball_x = *(float *)(animation_ptr + OSU_ANIMATION_SLIDER_BALL_X_OFFSET);
float slider_ball_y = *(float *)(animation_ptr + OSU_ANIMATION_SLIDER_BALL_Y_OFFSET);
Vector2 slider_ball(slider_ball_x, slider_ball_y);
move_mouse_to_target(slider_ball, cursor_pos, t);
}
else if (circle.type == HitObjectType::Spinner && audio_time >= circle.start_time)
{
auto& center = circle.position;
constexpr float radius = 60.0f;
constexpr float PI = 3.14159f;
static float angle = .0f;
Vector2 next_point_on_circle(center.x + radius * cosf(angle), center.y + radius * sinf(angle));
move_mouse_to_target(next_point_on_circle, cursor_pos, t);
float three_pi = 3 * PI;
if (cfg_timewarp_enabled)
{
if (circle.type == HitObjectType::Slider)
{
uintptr_t osu_manager = *(uintptr_t *)(osu_manager_ptr);
uintptr_t hit_manager_ptr = *(uintptr_t *)(osu_manager + OSU_MANAGER_HIT_MANAGER_OFFSET);
uintptr_t hit_objects_list_ptr = *(uintptr_t *)(hit_manager_ptr + OSU_HIT_MANAGER_HIT_OBJECTS_LIST_OFFSET);
uintptr_t hit_objects_list_items_ptr = *(uintptr_t *)(hit_objects_list_ptr + 0x4);
uintptr_t hit_object_ptr = *(uintptr_t *)(hit_objects_list_items_ptr + 0x8 + 0x4 * current_beatmap.hit_object_idx);
uintptr_t animation_ptr = *(uintptr_t *)(hit_object_ptr + OSU_HIT_OBJECT_ANIMATION_OFFSET);
float slider_ball_x = *(float *)(animation_ptr + OSU_ANIMATION_SLIDER_BALL_X_OFFSET);
float slider_ball_y = *(float *)(animation_ptr + OSU_ANIMATION_SLIDER_BALL_Y_OFFSET);
Vector2<float> slider_ball(slider_ball_x, slider_ball_y);
direction = prepare_hitcircle_target(osu_manager_ptr, slider_ball, mouse_position);
fraction_of_the_distance = cfg_fraction_modifier;
}
if (circle.type == HitObjectType::Spinner)
{
auto& center = circle.position;
static const float radius = 60.0f;
static const float PI = 3.14159f;
static float angle = .0f;
Vector2 next_point_on_circle(center.x + radius * cosf(angle), center.y + radius * sinf(angle));
direction = prepare_hitcircle_target(osu_manager_ptr, next_point_on_circle, mouse_position);
fraction_of_the_distance = 1.0f;
angle > 2 * PI ? angle = 0 : angle += cfg_spins_per_minute / (2 * PI) * ImGui::GetIO().DeltaTime;
}
auto timewarp_playback_rate = cfg_timewarp_playback_rate / 100.0;
if (timewarp_playback_rate > 1.0)
three_pi /= timewarp_playback_rate;
}
angle > 2 * PI ? angle = 0 : angle += cfg_spins_per_minute / three_pi * ImGui::GetIO().DeltaTime;
}
}

void aimbot_on_beatmap_load()
{
target_first_circle = true;
}

void advance_aimbot()
{
if (cfg_aimbot_lock)
{
Circle& next_circle = current_beatmap.current_circle();
switch (next_circle.type)
{
case HitObjectType::Circle:
case HitObjectType::Slider:
case HitObjectType::Spinner:
{
direction = prepare_hitcircle_target(osu_manager_ptr, next_circle.position, mouse_position);
fraction_of_the_distance = cfg_fraction_modifier;
} break;
}
}
}
3 changes: 0 additions & 3 deletions freedom/hitobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,11 @@ void process_hitobject()
update_relax(circle, audio_time);

// NOTE(Ciremun): Advance HitObject Index
// Aimbot: Aim at the next circle
if (audio_time + od_check_ms >= circle.end_time)
{
current_beatmap.hit_object_idx++;
if (current_beatmap.hit_object_idx >= current_beatmap.hit_objects.size())
current_beatmap.ready = false;
else
advance_aimbot();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions freedom/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ void update_ui()
ImGui::SaveIniSettingsToDisk(ImGui::GetIO().IniFilename);
}
ImGui::Dummy(ImVec2(0.0f, 5.0f));
ImGui::SliderFloat("##fraction_modifier", &cfg_fraction_modifier, 0.001f, 0.5f, "Cursor Speed: %.3f");
ImGui::SliderFloat("##fraction_modifier", &cfg_fraction_modifier, 50.f, 500.f, "Cursor Speed: %.0f");
if (ImGui::IsItemDeactivatedAfterEdit())
ImGui::SaveIniSettingsToDisk(ImGui::GetIO().IniFilename);
ImGui::Dummy(ImVec2(.0f, .5f));
ImGui::SliderInt("##spins_per_minute", &cfg_spins_per_minute, 0, 477, "Spins Per Minute: %d");
ImGui::SliderInt("##spins_per_minute", &cfg_spins_per_minute, 0, 600, "Spins Per Minute: %d");
if (ImGui::IsItemDeactivatedAfterEdit())
ImGui::SaveIniSettingsToDisk(ImGui::GetIO().IniFilename);
ImGui::SetCursorPosY(ImGui::GetWindowHeight() - ImGui::GetFrameHeightWithSpacing());
Expand Down
4 changes: 2 additions & 2 deletions include/baked_utils_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ static const unsigned int utils_dll_data[9216/4] =
{
0x00905a4d, 0x00000003, 0x00000004, 0x0000ffff, 0x000000b8, 0x00000000, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000080, 0x0eba1f0e, 0xcd09b400, 0x4c01b821, 0x685421cd, 0x70207369, 0x72676f72, 0x63206d61, 0x6f6e6e61,
0x65622074, 0x6e757220, 0x206e6920, 0x20534f44, 0x65646f6d, 0x0a0d0d2e, 0x00000024, 0x00000000, 0x00004550, 0x0003014c, 0x659b9342, 0x00000000,
0x65622074, 0x6e757220, 0x206e6920, 0x20534f44, 0x65646f6d, 0x0a0d0d2e, 0x00000024, 0x00000000, 0x00004550, 0x0003014c, 0x659bbcd9, 0x00000000,
0x00000000, 0x202200e0, 0x0030010b, 0x00001c00, 0x00000600, 0x00000000, 0x00003a2e, 0x00002000, 0x00004000, 0x10000000, 0x00002000, 0x00000200,
0x00000004, 0x00000000, 0x00000004, 0x00000000, 0x00008000, 0x00000200, 0x00000000, 0x85400003, 0x00100000, 0x00001000, 0x00100000, 0x00001000,
0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x000039dc, 0x0000004f, 0x00004000, 0x00000298, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
Expand Down Expand Up @@ -136,7 +136,7 @@ static const unsigned int utils_dll_data[9216/4] =
0x00750042, 0x00470068, 0x0024005a, 0x00790048, 0x0030005a, 0x0041004c, 0x0066006e, 0x003d0051, 0x2f00003d, 0x003d0023, 0x006e007a, 0x004b0024,
0x0038004d, 0x0050004f, 0x00330042, 0x00440056, 0x00450033, 0x00510045, 0x00580068, 0x003d0041, 0x1700003d, 0x003d0023, 0x0072007a, 0x005f005f,
0x00540035, 0x006f0030, 0x3f00003d, 0x003d0023, 0x0045007a, 0x00560030, 0x005a0044, 0x00770066, 0x0045004a, 0x00330048, 0x0036007a, 0x00330044,
0x00470058, 0x006d0071, 0x006b0054, 0x00520044, 0x006b0046, 0x00660077, 0x01000047, 0x00000000, 0xd4a0c1cd, 0x44f14cbe, 0x94852898, 0x776e938a,
0x00470058, 0x006d0071, 0x006b0054, 0x00520044, 0x006b0046, 0x00660077, 0x01000047, 0x00000000, 0x840563f5, 0x49f4670b, 0x82c085b8, 0x33016735,
0x01200400, 0x20030801, 0x20050100, 0x11110101, 0x01012005, 0x20051511, 0x29110101, 0x11010704, 0x0000043d, 0x20055112, 0x0e451201, 0x12012005,
0x20040e49, 0x033d1100, 0x04180020, 0x18080100, 0x11020706, 0x07391139, 0x02351215, 0x0539110e, 0x13020120, 0x01200600, 0x00130113, 0x18020005,
0x00070818, 0x1c391102, 0x20076911, 0x00130102, 0x07040113, 0x09391101, 0x0e1d0607, 0x080e0e0e, 0x00200308, 0x02200808, 0x0e1d0e1d, 0x00067111,
Expand Down
15 changes: 0 additions & 15 deletions include/features/aimbot.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,3 @@

void update_aimbot(Circle &circle, const int32_t audio_time);
void aimbot_on_beatmap_load();
void advance_aimbot();

template <typename T>
Vector2<T> prepare_hitcircle_target(uintptr_t osu_manager_ptr, const Vector2<float> &position, Vector2<T> &mouse_position)
{
uintptr_t osu_manager = *(uintptr_t *)(osu_manager_ptr);
uintptr_t osu_ruleset_ptr = *(uintptr_t *)(osu_manager + OSU_MANAGER_RULESET_PTR_OFFSET);
float mouse_x = *(float *)(osu_ruleset_ptr + OSU_RULESET_MOUSE_X_OFFSET);
float mouse_y = *(float *)(osu_ruleset_ptr + OSU_RULESET_MOUSE_Y_OFFSET);
mouse_position.x = mouse_x;
mouse_position.y = mouse_y;
Vector2 circle_position_on_screen = playfield_to_screen(position);
Vector2 direction = circle_position_on_screen - mouse_position;
return direction;
}

0 comments on commit 5ad83a4

Please sign in to comment.