Skip to content

Commit

Permalink
lerp over time
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciremun committed Feb 12, 2024
1 parent 15848fd commit c0ae52d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 16 deletions.
4 changes: 2 additions & 2 deletions 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 = 100.f;
float cfg_fraction_modifier = .5f;
bool cfg_replay_enabled = false;
bool cfg_replay_aim = true;
bool cfg_replay_keys = true;
Expand Down Expand Up @@ -70,7 +70,7 @@ static void ConfigHandler_WriteAll(ImGuiContext *ctx, ImGuiSettingsHandler *hand
buf->appendf("relax_checks_od=%d\n", (int)cfg_relax_checks_od);
buf->appendf("aimbot=%d\n", cfg_aimbot_lock);
buf->appendf("spins_per_minute=%d\n", cfg_spins_per_minute);
buf->appendf("fraction_modifier=%.3f\n", cfg_fraction_modifier);
buf->appendf("fraction_modifier=%.2f\n", cfg_fraction_modifier);
buf->appendf("replay=%d\n", (int)cfg_replay_enabled);
buf->appendf("replay_aim=%d\n", (int)cfg_replay_aim);
buf->appendf("replay_keys=%d\n", (int)cfg_replay_keys);
Expand Down
35 changes: 28 additions & 7 deletions freedom/features/aimbot.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "features/aimbot.h"

float elapsed_lerp = 0;

static inline Vector2<float> mouse_position()
{
Vector2<float> mouse_pos(.0f, .0f);
Expand All @@ -17,24 +19,30 @@ 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)
static inline void move_mouse_to_target(const Vector2<float> &target, const Vector2<float> &cursor_pos)
{
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);
if (elapsed_lerp < cfg_fraction_modifier)
{
float x = lerp(cursor_pos.x, target_on_screen.x, elapsed_lerp / cfg_fraction_modifier);
float y = lerp(cursor_pos.y, target_on_screen.y, elapsed_lerp / cfg_fraction_modifier);
elapsed_lerp += ImGui::GetIO().DeltaTime;
move_mouse_to(x, y);
}
else
move_mouse_to(target_on_screen.x, target_on_screen.y);
}

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

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

if (circle.type == HitObjectType::Circle)
{
move_mouse_to_target(circle.position, cursor_pos, t);
move_mouse_to_target(circle.position, cursor_pos);
}
else if (circle.type == HitObjectType::Slider)
{
Expand All @@ -53,7 +61,7 @@ void update_aimbot(Circle &circle, const int32_t audio_time)
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);
move_mouse_to_target(slider_ball, cursor_pos);
}
else if (circle.type == HitObjectType::Spinner && audio_time >= circle.start_time)
{
Expand All @@ -62,7 +70,7 @@ void update_aimbot(Circle &circle, const int32_t audio_time)
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);
move_mouse_to_target(next_point_on_circle, cursor_pos);
float three_pi = 3 * PI;
if (cfg_timewarp_enabled)
{
Expand All @@ -73,3 +81,16 @@ void update_aimbot(Circle &circle, const int32_t audio_time)
angle > 2 * PI ? angle = 0 : angle += cfg_spins_per_minute / three_pi * ImGui::GetIO().DeltaTime;
}
}

void aimbot_on_beatmap_load()
{
if (cfg_aimbot_lock)
{
elapsed_lerp = 0;
}
}

void aimbot_on_advance_hit_object()
{
elapsed_lerp = 0;
}
5 changes: 4 additions & 1 deletion freedom/features/relax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,8 @@ void update_relax(Circle &circle, const int32_t audio_time)

void relax_on_beatmap_load()
{
current_click = cfg_relax_style == 'a' ? right_click[0] : left_click[0];
if (cfg_relax_lock)
{
current_click = cfg_relax_style == 'a' ? right_click[0] : left_click[0];
}
}
2 changes: 2 additions & 0 deletions freedom/hitobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void process_hitobject()
if (parse_beatmap(osu_manager_ptr, current_beatmap))
{
relax_on_beatmap_load();
aimbot_on_beatmap_load();
replay_on_beatmap_load();
unmod_flashlight_on_beatmap_load();
unmod_hidden_on_beatmap_load();
Expand Down Expand Up @@ -85,6 +86,7 @@ void process_hitobject()
if (audio_time + od_check_ms >= circle.end_time)
{
current_beatmap.hit_object_idx++;
aimbot_on_advance_hit_object();
if (current_beatmap.hit_object_idx >= current_beatmap.hit_objects.size())
current_beatmap.ready = false;
}
Expand Down
5 changes: 1 addition & 4 deletions freedom/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void update_ui()
ImGui::SaveIniSettingsToDisk(ImGui::GetIO().IniFilename);
}
ImGui::Dummy(ImVec2(0.0f, 5.0f));
ImGui::SliderFloat("##fraction_modifier", &cfg_fraction_modifier, 50.f, 500.f, "Cursor Speed: %.0f");
ImGui::SliderFloat("##fraction_modifier", &cfg_fraction_modifier, .01f, 5.f, "Cursor Delay: %.2f");
if (ImGui::IsItemDeactivatedAfterEdit())
ImGui::SaveIniSettingsToDisk(ImGui::GetIO().IniFilename);
ImGui::Dummy(ImVec2(.0f, .5f));
Expand Down Expand Up @@ -682,9 +682,6 @@ void draw_debug_log()
ImGui::SetNextWindowSize(ImVec2(640.f, 480.f), ImGuiCond_Once);
ImGui::PushFont(font);
ImGui::Begin("Debug Log", &cfg_show_debug_log);
if (ImGui::Checkbox("Write Debug Log", &cfg_write_debug_log))
ImGui::SaveIniSettingsToDisk(ImGui::GetIO().IniFilename);
ImGui::Dummy(ImVec2(.0f, 2.f));
debug_log.draw();
ImGui::End();
ImGui::PopFont();
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, 0x65c940a0, 0x00000000,
0x65622074, 0x6e757220, 0x206e6920, 0x20534f44, 0x65646f6d, 0x0a0d0d2e, 0x00000024, 0x00000000, 0x00004550, 0x0003014c, 0x65c96575, 0x00000000,
0x00000000, 0x202200e0, 0x0030010b, 0x00001c00, 0x00000600, 0x00000000, 0x00003b26, 0x00002000, 0x00004000, 0x10000000, 0x00002000, 0x00000200,
0x00000004, 0x00000000, 0x00000004, 0x00000000, 0x00008000, 0x00000200, 0x00000000, 0x85400003, 0x00100000, 0x00001000, 0x00100000, 0x00001000,
0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x00003ad4, 0x0000004f, 0x00004000, 0x00000298, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
Expand Down Expand Up @@ -143,7 +143,7 @@ static const unsigned int utils_dll_data[9216/4] =
0x004c0030, 0x006e0041, 0x00510066, 0x003d003d, 0x00232f00, 0x007a003d, 0x0024006e, 0x004d004b, 0x004f0038, 0x00420050, 0x00560033, 0x00330044,
0x00450045, 0x00680051, 0x00410058, 0x003d003d, 0x00231700, 0x007a003d, 0x005f0072, 0x0035005f, 0x00300054, 0x003d006f, 0x00233f00, 0x007a003d,
0x00300045, 0x00440056, 0x0066005a, 0x004a0077, 0x00480045, 0x007a0033, 0x00440036, 0x00580033, 0x00710047, 0x0054006d, 0x0044006b, 0x00460052,
0x0077006b, 0x00470066, 0x00000100, 0x76655c42, 0x4c6c6de2, 0x38fb6585, 0x320c8957, 0x01200400, 0x20030801, 0x20050100, 0x11110101, 0x01012005,
0x0077006b, 0x00470066, 0x00000100, 0x25cf5906, 0x4e1cb742, 0x7c314ba1, 0x0912241b, 0x01200400, 0x20030801, 0x20050100, 0x11110101, 0x01012005,
0x07041d11, 0x04311101, 0x65120000, 0x12012005, 0x20050e35, 0x0e391201, 0x11002004, 0x00200331, 0x01000418, 0x07061808, 0x112d1102, 0x1215072d,
0x110e0229, 0x0120052d, 0x06001302, 0x01130120, 0x00050013, 0x08181802, 0x11020007, 0x71111c2d, 0x01022007, 0x01130013, 0x11010704, 0x0307082d,
0x0824111d, 0x20032411, 0x20030e00, 0x070e0800, 0x113d1106, 0x113d113d, 0x41121d3d, 0x00200408, 0x20043d11, 0x04591100, 0x35120020, 0x02020007,
Expand Down
2 changes: 2 additions & 0 deletions include/features/aimbot.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
#include "vector.h"
#include "config.h"

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

0 comments on commit c0ae52d

Please sign in to comment.