From 86bd3362674a584e577e348418814c47318f6436 Mon Sep 17 00:00:00 2001 From: LeaoMartelo Date: Tue, 31 Dec 2024 19:08:34 -0300 Subject: [PATCH 1/5] rage autostrafe kinda works but dosent feel right random push forward sometimes --- .gitignore | 5 ++- hooks/create_move/create_move.c | 11 ++--- hooks/create_move/create_move.h | 6 ++- hooks/create_move/movement.c | 77 ++++++++++++++++++++++++++------- utils/math/math_utils.c | 37 +++++++++++++--- utils/math/math_utils.h | 5 ++- 6 files changed, 110 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 735842f..d3dfc30 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ tf_c.so *~ # Config files -*.tf_c.bin \ No newline at end of file +*.tf_c.bin + +# clang-format +.clang-format diff --git a/hooks/create_move/create_move.c b/hooks/create_move/create_move.c index cec6492..771cf64 100644 --- a/hooks/create_move/create_move.c +++ b/hooks/create_move/create_move.c @@ -1,11 +1,12 @@ #include "../../config/config.h" -#include "../../utils/utils.h" #include "../../source_sdk/cvar/convar/convar.h" #include "../../source_sdk/cvar/cvar.h" #include "../../source_sdk/engine_client/engine_client.h" #include "../../source_sdk/entity/entity.h" #include "../../source_sdk/user_cmd.h" +#include "../../utils/utils.h" #include "../paint_traverse/paint_traverse.h" + #include "create_move.h" #include @@ -28,7 +29,7 @@ __int64_t create_move_hook(void *this, float sample_time, struct user_cmd *user_ log_msg("CreateMove hooked!\n"); hooked = true; } - + if (!is_in_game()) { return rc; @@ -50,19 +51,19 @@ __int64_t create_move_hook(void *this, float sample_time, struct user_cmd *user_ { set_thirdperson(localplayer, false); } - + if (user_cmd->tick_count > 1) { clear_render_queue(); aimbot(localplayer, user_cmd); bunny_hop(localplayer, user_cmd); - autostrafe(localplayer, user_cmd); + rage_autostrafe(localplayer, user_cmd); } if (silent_aim) { return false; - } + } else { return rc; diff --git a/hooks/create_move/create_move.h b/hooks/create_move/create_move.h index a0e4aa1..6a22703 100644 --- a/hooks/create_move/create_move.h +++ b/hooks/create_move/create_move.h @@ -1,5 +1,7 @@ #include "../../source_sdk/user_cmd.h" +#include +#include #include __int64_t create_move_hook(void *this, float sample_time, struct user_cmd *user_cmd); @@ -10,7 +12,7 @@ void aimbot(void *localplayer, struct user_cmd *user_cmd); void hitscan_aimbot(void *localplayer, struct user_cmd *user_cmd); void projectile_aimbot(void *localplayer, struct user_cmd *user_cmd, int weapon_id); - /* MOVEMENT */ void bunny_hop(void *localplayer, struct user_cmd *user_cmd); -void autostrafe(void *localplayer, struct user_cmd *user_cmd); \ No newline at end of file +void autostrafe(void *localplayer, struct user_cmd *user_cmd); +void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd); diff --git a/hooks/create_move/movement.c b/hooks/create_move/movement.c index 5387a3d..5ed38d9 100644 --- a/hooks/create_move/movement.c +++ b/hooks/create_move/movement.c @@ -2,8 +2,11 @@ #include "../../source_sdk/entity/entity.h" #include "../../source_sdk/math/vec3.h" #include "../../source_sdk/user_cmd.h" +#include "../../utils/math/math_utils.h" #include "../../utils/utils.h" #include "create_move.h" +#include +#include void bunny_hop(void *localplayer, struct user_cmd *user_cmd) { @@ -11,7 +14,7 @@ void bunny_hop(void *localplayer, struct user_cmd *user_cmd) * i haven't figured out why (FROM TESTING: i belive the on ground flag sometimes is not getting set correctly) * in any case, i'll just disable bhop on scout until i figure it out */ - if(!config.misc.bunny_hop || get_player_class(localplayer) == TF_CLASS_SCOUT) + if (!config.misc.bunny_hop || get_player_class(localplayer) == TF_CLASS_SCOUT) { return; } @@ -19,18 +22,18 @@ void bunny_hop(void *localplayer, struct user_cmd *user_cmd) static bool was_jumping = false; bool on_ground = (get_ent_flags(localplayer) & FL_ONGROUND); - if(user_cmd->buttons & IN_JUMP) + if (user_cmd->buttons & IN_JUMP) { - if(!was_jumping && !on_ground) + if (!was_jumping && !on_ground) { user_cmd->buttons &= ~IN_JUMP; } - else if(was_jumping) + else if (was_jumping) { was_jumping = false; } - } - else if(!was_jumping) + } + else if (!was_jumping) { was_jumping = true; } @@ -41,26 +44,70 @@ void autostrafe(void *localplayer, struct user_cmd *user_cmd) // TBD: figure out how to implement directional / rage autostrafe // i don't think this kind of autostrafe does anything - if(!config.misc.autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT) + if (!config.misc.autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT) { return; } - // assume default value - float cl_sidespeed = 450.0f; - bool on_ground = get_ent_flags(localplayer) & FL_ONGROUND; + const float cl_sidespeed = 450.0f; // assume default value + const bool on_ground = get_ent_flags(localplayer) & FL_ONGROUND; - if(on_ground) + if (on_ground) { return; } - if(user_cmd->mouse_dx < 0) + if (user_cmd->mouse_dx < 0) { - user_cmd->sidemove = -cl_sidespeed; - } - else if(user_cmd->mouse_dx > 0) + user_cmd->sidemove = -cl_sidespeed; + } + else if (user_cmd->mouse_dx > 0) { user_cmd->sidemove = cl_sidespeed; } } + +void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) +{ + const bool on_ground = get_ent_flags(localplayer) & FL_ONGROUND; + + if (on_ground) + { + return; + } + + const struct vec3_t velocity = get_ent_velocity(localplayer); + const float speed = vec_lenght2d(velocity); + + if (speed < 30) + { + return; + } + + // assume default vallues + const float sv_airaccelerate = 10.0f; + const float sv_maxspeed = 320.0f; + const float cl_forwardspeed = 450.0f; + const float cl_sidespeed = 450.0f; + + float terminal = sv_airaccelerate / sv_maxspeed * 100.0f / speed; + + if (terminal < -1 || terminal > 1) + { + return; + } + + float bdelta = acosf(terminal); + + struct vec3_t viewangles = get_ent_angles(localplayer); + + float yaw = deg_2_rad(viewangles.y); + float velocity_direction = atan2f(velocity.y, velocity.x) - yaw; + float target_angle = atan2f(-user_cmd->sidemove, user_cmd->forwardmove); + float delta = delta_rad_angle2f(velocity_direction, target_angle); + + float move_direction = delta < 0 ? velocity_direction + bdelta : velocity_direction - bdelta; + + user_cmd->forwardmove = cosf(move_direction) * cl_forwardspeed; + user_cmd->sidemove = -sinf(move_direction) * cl_sidespeed; +} diff --git a/utils/math/math_utils.c b/utils/math/math_utils.c index 032c290..fad1ca4 100644 --- a/utils/math/math_utils.c +++ b/utils/math/math_utils.c @@ -13,7 +13,7 @@ struct vec3_t get_difference(struct vec3_t pos1, struct vec3_t pos2) float get_distance(struct vec3_t pos1, struct vec3_t pos2) { - return sqrt(((pos1.x - pos2.x)*(pos1.x - pos2.x)) + ((pos1.y - pos2.y)*(pos1.y - pos2.y)) + ((pos1.z - pos2.z)*(pos1.z - pos2.z))); + return sqrt(((pos1.x - pos2.x) * (pos1.x - pos2.x)) + ((pos1.y - pos2.y) * (pos1.y - pos2.y)) + ((pos1.z - pos2.z) * (pos1.z - pos2.z))); } float positive_quadratic_root(float a, float b, float c) @@ -100,11 +100,34 @@ struct vec3_t get_view_angle(struct vec3_t diff) float pitch_angle = atan2(diff.z, c) * 180 / M_PI; float yaw_angle = atan2(diff.y, diff.x) * 180 / M_PI; - struct vec3_t view_angle = { - .x = -pitch_angle, - .y = yaw_angle, - .z = 0 - }; + struct vec3_t view_angle = {.x = -pitch_angle, .y = yaw_angle, .z = 0}; return view_angle; -} \ No newline at end of file +} + +float vec_lenght2d(struct vec3_t vec) +{ + return sqrtf(vec.x * vec.x + vec.y * vec.y); +} + +float deg_2_rad(float n) +{ + return n * M_PI / 180.0f; +} + +float delta_rad_angle2f(float a, float b) +{ + + float delta = isfinite(a - b) ? remainder(a - b, 360) : 0; + + if (a > b && delta >= M_PI) + { + delta -= M_PI * 2; + } + else if (delta <= -M_PI) + { + delta += M_PI * 2; + } + + return delta; +} diff --git a/utils/math/math_utils.h b/utils/math/math_utils.h index 49de650..1a06128 100644 --- a/utils/math/math_utils.h +++ b/utils/math/math_utils.h @@ -5,4 +5,7 @@ struct vec3_t get_difference(struct vec3_t pos1, struct vec3_t pos2); float get_distance(struct vec3_t pos1, struct vec3_t pos2); float angle_between_vectors(struct vec3_t vec1, struct vec3_t vec2); void angle_vectors(struct vec3_t angles, struct vec3_t *forward, struct vec3_t *right, struct vec3_t *up); -struct vec3_t get_view_angle(struct vec3_t diff); \ No newline at end of file +struct vec3_t get_view_angle(struct vec3_t diff); +float vec_lenght2d(struct vec3_t vec); +float deg_2_rad(float n); +float delta_rad_angle2f(float a, float b); From 034a4e33c5a07e9a86603a1bb817e6597585a233 Mon Sep 17 00:00:00 2001 From: LeaoMartelo Date: Tue, 31 Dec 2024 20:07:07 -0300 Subject: [PATCH 2/5] ragestrafe fix + cleanup --- config/config.c | 21 ++--- config/config.h | 3 +- hooks/create_move/create_move.c | 2 +- hooks/create_move/movement.c | 24 ++++-- hooks/menu/menu.c | 140 +++++++++++++++++--------------- 5 files changed, 107 insertions(+), 83 deletions(-) diff --git a/config/config.c b/config/config.c index 1a496b1..ad20d13 100644 --- a/config/config.c +++ b/config/config.c @@ -17,37 +17,38 @@ bool init_config() config.aimbot.key.is_pressed = false; config.misc.bunny_hop = 1; - config.misc.autostrafe = 1; + config.misc.legit_autostrafe = 0; + config.misc.rage_autostrafe = 1; config.misc.do_thirdperson = false; config.aimbot.aimbot_enabled = 1; config.aimbot.draw_fov = 1; config.aimbot.fov = 10.0f; - config.aimbot.fov_color = (struct nk_colorf){ 207.0f / 255.0f, 115.0f / 255.0f, 54.0f / 255.0f, 0.25f }; + config.aimbot.fov_color = (struct nk_colorf){207.0f / 255.0f, 115.0f / 255.0f, 54.0f / 255.0f, 0.25f}; config.aimbot.projectile_time_step = 0.01f; config.aimbot.projectile_max_time = 1.0f; config.aimbot.projectile_tolerance_time = 0.05f; config.aimbot.key.use_key = 1; - config.aimbot.key.binding = (struct key_binding){ INPUT_MOUSE, SDL_BUTTON_X2, false }; + config.aimbot.key.binding = (struct key_binding){INPUT_MOUSE, SDL_BUTTON_X2, false}; config.aimbot.key.is_pressed = false; config.aimbot.projectile_preview.draw_line = 1; - config.aimbot.projectile_preview.line_color = (struct nk_colorf){ 1.0f, 0.0f, 0.0f, 1.0f }; + config.aimbot.projectile_preview.line_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.draw_box = 1; - config.aimbot.projectile_preview.box_color = (struct nk_colorf){ 1.0f, 0.0f, 0.0f, 1.0f }; + config.aimbot.projectile_preview.box_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.only_draw_if_target = 1; config.aimbot.projectile_preview.previous_shot_line = 1; - config.aimbot.projectile_preview.previous_shot_line_color = (struct nk_colorf){ 1.0f, 0.0f, 0.0f, 1.0f }; + config.aimbot.projectile_preview.previous_shot_line_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.previous_shot_box = 1; - config.aimbot.projectile_preview.previous_shot_box_color = (struct nk_colorf){ 1.0f, 0.0f, 0.0f, 1.0f }; + config.aimbot.projectile_preview.previous_shot_box_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.draw_timer = 1; - config.aimbot.projectile_preview.timer_color = (struct nk_colorf){ 1.0f, 0.0f, 0.0f, 1.0f }; + config.aimbot.projectile_preview.timer_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.previous_shot_linger_time = 0.5f; config.aimbot.projectile_preview.draw_entity_prediction = 1; - config.aimbot.projectile_preview.entity_prediction_color = (struct nk_colorf){ 1.0f, 1.0f, 1.0f, 1.0f }; + config.aimbot.projectile_preview.entity_prediction_color = (struct nk_colorf){1.0f, 1.0f, 1.0f, 1.0f}; config.esp.player_health_bar = 1; config.esp.player_bounding_box = 1; config.esp.player_name = 1; config.esp.team_color = 1; - config.esp.esp_color = (struct nk_colorf){ 1.0f, 1.0f, 1.0f, 1.0f}; + config.esp.esp_color = (struct nk_colorf){1.0f, 1.0f, 1.0f, 1.0f}; config.esp.ammo_hp_ents_name = 1; config.esp.ammo_hp_ents_bounding_box = 1; config.esp.sentry_name = 1; diff --git a/config/config.h b/config/config.h index 1c6cb7b..9f6c1fe 100644 --- a/config/config.h +++ b/config/config.h @@ -28,8 +28,9 @@ struct config struct { int bunny_hop; - int autostrafe; bool do_thirdperson; + int legit_autostrafe; + int rage_autostrafe; } misc; struct { diff --git a/hooks/create_move/create_move.c b/hooks/create_move/create_move.c index 771cf64..1fdd19e 100644 --- a/hooks/create_move/create_move.c +++ b/hooks/create_move/create_move.c @@ -9,7 +9,6 @@ #include "create_move.h" -#include #include #include #include @@ -57,6 +56,7 @@ __int64_t create_move_hook(void *this, float sample_time, struct user_cmd *user_ clear_render_queue(); aimbot(localplayer, user_cmd); bunny_hop(localplayer, user_cmd); + autostrafe(localplayer, user_cmd); rage_autostrafe(localplayer, user_cmd); } diff --git a/hooks/create_move/movement.c b/hooks/create_move/movement.c index 5ed38d9..d3a19b7 100644 --- a/hooks/create_move/movement.c +++ b/hooks/create_move/movement.c @@ -44,15 +44,17 @@ void autostrafe(void *localplayer, struct user_cmd *user_cmd) // TBD: figure out how to implement directional / rage autostrafe // i don't think this kind of autostrafe does anything - if (!config.misc.autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT) + if (!config.misc.legit_autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT) { return; } const float cl_sidespeed = 450.0f; // assume default value + const bool on_ground = get_ent_flags(localplayer) & FL_ONGROUND; + const bool on_water = get_ent_flags(localplayer) & FL_INWATER; - if (on_ground) + if (on_ground || on_water) { return; } @@ -69,9 +71,18 @@ void autostrafe(void *localplayer, struct user_cmd *user_cmd) void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) { + // inspired from: + // https://github.com/degeneratehyperbola/NEPS + + if (!config.misc.rage_autostrafe) + { + return; + } + const bool on_ground = get_ent_flags(localplayer) & FL_ONGROUND; + const bool on_water = get_ent_flags(localplayer) & FL_INWATER; - if (on_ground) + if (on_ground || on_water) { return; } @@ -79,7 +90,7 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) const struct vec3_t velocity = get_ent_velocity(localplayer); const float speed = vec_lenght2d(velocity); - if (speed < 30) + if (speed < 2) { return; } @@ -90,7 +101,10 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) const float cl_forwardspeed = 450.0f; const float cl_sidespeed = 450.0f; - float terminal = sv_airaccelerate / sv_maxspeed * 100.0f / speed; + // this is hardcoded in tf2, unless a sourcemod that changes movement touched it + const float wishspeed = 30.0f; + + float terminal = wishspeed / sv_airaccelerate / sv_maxspeed * 100.0f / speed; if (terminal < -1 || terminal > 1) { diff --git a/hooks/menu/menu.c b/hooks/menu/menu.c index 9c94f72..ad1d2e3 100644 --- a/hooks/menu/menu.c +++ b/hooks/menu/menu.c @@ -1,58 +1,65 @@ +#include "menu.h" #include "../../config/config.h" #include "../../utils/utils.h" -#include "menu.h" #include #define HEADER_SIZE 40 #define ROW_SIZE 20 -#define NK_TEXT_ROW(ctx, text, flags) \ - do { \ - nk_layout_row_dynamic((ctx), ROW_SIZE, 1); \ - nk_label((ctx), (text), (flags)); \ - } while(0) \ +#define NK_TEXT_ROW(ctx, text, flags) \ + do \ + { \ + nk_layout_row_dynamic((ctx), ROW_SIZE, 1); \ + nk_label((ctx), (text), (flags)); \ + } while (0) -#define NK_HEADER_ROW(ctx, text, flags) \ - do { \ - nk_layout_row_dynamic((ctx), HEADER_SIZE, 1); \ - nk_label((ctx), (text), (flags)); \ - } while(0) \ +#define NK_HEADER_ROW(ctx, text, flags) \ + do \ + { \ + nk_layout_row_dynamic((ctx), HEADER_SIZE, 1); \ + nk_label((ctx), (text), (flags)); \ + } while (0) -#define NK_CHECKBOX_ROW(ctx, text, active_ptr) \ - do { \ - nk_layout_row_dynamic((ctx), ROW_SIZE, 1); \ - nk_checkbox_label((ctx), (text), (active_ptr)); \ - } while(0) \ +#define NK_CHECKBOX_ROW(ctx, text, active_ptr) \ + do \ + { \ + nk_layout_row_dynamic((ctx), ROW_SIZE, 1); \ + nk_checkbox_label((ctx), (text), (active_ptr)); \ + } while (0) -#define NK_FLOAT_SLIDER_ROW(ctx, text, value_ptr, min, max, step) \ - do { \ - nk_layout_row_dynamic((ctx), ROW_SIZE, 2); \ - nk_label((ctx), (text), NK_TEXT_LEFT); \ - nk_slider_float((ctx), (min), (value_ptr), (max), (step));\ - } while(0) \ +#define NK_FLOAT_SLIDER_ROW(ctx, text, value_ptr, min, max, step) \ + do \ + { \ + nk_layout_row_dynamic((ctx), ROW_SIZE, 2); \ + nk_label((ctx), (text), NK_TEXT_LEFT); \ + nk_slider_float((ctx), (min), (value_ptr), (max), (step)); \ + } while (0) -#define NK_COLOR_PICKER_ROW(ctx, text, color_ptr) \ - do { \ - nk_layout_row_dynamic((ctx), ROW_SIZE, 2); \ - nk_label((ctx), (text), NK_TEXT_LEFT); \ - if (nk_combo_begin_color((ctx), nk_rgb_cf(*(color_ptr)), nk_vec2(nk_widget_width(ctx), 400))) { \ - nk_layout_row_dynamic((ctx), 120, 1); \ - *(color_ptr) = nk_color_picker((ctx), *(color_ptr), NK_RGBA); \ - nk_layout_row_dynamic((ctx), 25, 1); \ - nk_combo_end(ctx); \ - } \ - } while(0) \ +#define NK_COLOR_PICKER_ROW(ctx, text, color_ptr) \ + do \ + { \ + nk_layout_row_dynamic((ctx), ROW_SIZE, 2); \ + nk_label((ctx), (text), NK_TEXT_LEFT); \ + if (nk_combo_begin_color((ctx), nk_rgb_cf(*(color_ptr)), nk_vec2(nk_widget_width(ctx), 400))) \ + { \ + nk_layout_row_dynamic((ctx), 120, 1); \ + *(color_ptr) = nk_color_picker((ctx), *(color_ptr), NK_RGBA); \ + nk_layout_row_dynamic((ctx), 25, 1); \ + nk_combo_end(ctx); \ + } \ + } while (0) -#define NK_COMBO_BOX_ROW(ctx, id_token, label, text_options, options_count, ...) \ - do { \ - static const char **id_token##_options = text_options; \ - static int *id_token##_selections[] = { __VA_ARGS__ }; \ - static char id_token##_preview_text[128] = ""; \ - nk_layout_row_dynamic((ctx), ROW_SIZE, 2); \ - nk_label((ctx), (label), NK_TEXT_LEFT); \ - multi_select_combo_box((ctx), id_token##_options, id_token##_selections, options_count, id_token##_preview_text); \ - } while(0) \ +#define NK_COMBO_BOX_ROW(ctx, id_token, label, text_options, options_count, ...) \ + do \ + { \ + static const char **id_token##_options = text_options; \ + static int *id_token##_selections[] = {__VA_ARGS__}; \ + static char id_token##_preview_text[128] = ""; \ + nk_layout_row_dynamic((ctx), ROW_SIZE, 2); \ + nk_label((ctx), (label), NK_TEXT_LEFT); \ + multi_select_combo_box((ctx), id_token##_options, id_token##_selections, options_count, id_token##_preview_text); \ + } while (0) void watermark(struct nk_context *ctx) { @@ -122,7 +129,7 @@ void draw_aim_tab(struct nk_context *ctx) char fov_text[32]; // \xC2\xB0 is the UTF-8 encoding for the degree symbol sprintf(fov_text, "Aimbot FOV: %.0f\xC2\xB0", config.aimbot.fov); - + NK_CHECKBOX_ROW(ctx, "Aimbot enabled", &config.aimbot.aimbot_enabled); NK_CHECKBOX_ROW(ctx, "Use aim key", &config.aimbot.key.use_key); NK_FLOAT_SLIDER_ROW(ctx, fov_text, &config.aimbot.fov, 1.0f, 50.0f, 1.0f); @@ -135,8 +142,8 @@ void draw_aim_tab(struct nk_context *ctx) NK_HEADER_ROW(ctx, "Projectile", NK_TEXT_LEFT); { - static const char *proj_preview_options[] = { "Trace line", "3D Box", "Only draw on target" }; - static const char *previous_shot_options[] = { "Trace line", "3D Box", "Timer" }; + static const char *proj_preview_options[] = {"Trace line", "3D Box", "Only draw on target"}; + static const char *previous_shot_options[] = {"Trace line", "3D Box", "Timer"}; NK_COMBO_BOX_ROW(ctx, projectile_preview, "Projectile preview:", proj_preview_options, 3, &config.aimbot.projectile_preview.draw_line, &config.aimbot.projectile_preview.draw_box, &config.aimbot.projectile_preview.only_draw_if_target); if (config.aimbot.projectile_preview.draw_line) @@ -222,7 +229,7 @@ void draw_esp_tab(struct nk_context *ctx) NK_HEADER_ROW(ctx, "Entity ESP", NK_TEXT_LEFT); { - static const char *entity_esp_options[] = { "Name", "Bounding box" }; + static const char *entity_esp_options[] = {"Name", "Bounding box"}; NK_COMBO_BOX_ROW(ctx, ammo_hp, "Ammo/HP:", entity_esp_options, 2, &config.esp.ammo_hp_ents_name, &config.esp.ammo_hp_ents_bounding_box); NK_COMBO_BOX_ROW(ctx, sentry, "Sentry:", entity_esp_options, 2, &config.esp.sentry_name, &config.esp.sentry_bounding_box); NK_COMBO_BOX_ROW(ctx, teleporter, "Teleporter:", entity_esp_options, 2, &config.esp.teleporter_name, &config.esp.teleporter_bounding_box); @@ -236,7 +243,8 @@ void draw_misc_tab(struct nk_context *ctx) NK_HEADER_ROW(ctx, "General", NK_TEXT_LEFT); { NK_CHECKBOX_ROW(ctx, "Bunny hop", &config.misc.bunny_hop); - NK_CHECKBOX_ROW(ctx, "Auto strafe", &config.misc.autostrafe); + NK_CHECKBOX_ROW(ctx, "Simple Auto strafe", &config.misc.legit_autostrafe); + NK_CHECKBOX_ROW(ctx, "Multidirectional Auto strafe", &config.misc.rage_autostrafe); // TBD: Add thirdperson key stuff + bool nk_layout_row_dynamic(ctx, 20, 1); if (nk_button_label(ctx, "Save config")) @@ -287,26 +295,26 @@ void draw_tab(struct nk_context *ctx, const char *name, int *tab, int index) void draw_menu(struct nk_context *ctx) { if (nk_begin(ctx, "TF_C", nk_rect(200, 200, 500, 600), NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_TITLE)) - { - static int tab = 0; + { + static int tab = 0; - nk_layout_row_dynamic(ctx, 30, 3); - draw_tab(ctx, "Aim", &tab, 0); - draw_tab(ctx, "ESP", &tab, 1); - draw_tab(ctx, "Misc", &tab, 2); + nk_layout_row_dynamic(ctx, 30, 3); + draw_tab(ctx, "Aim", &tab, 0); + draw_tab(ctx, "ESP", &tab, 1); + draw_tab(ctx, "Misc", &tab, 2); - switch (tab) - { - case 0: - draw_aim_tab(ctx); - break; - case 1: - draw_esp_tab(ctx); - break; - case 2: - draw_misc_tab(ctx); - break; - } + switch (tab) + { + case 0: + draw_aim_tab(ctx); + break; + case 1: + draw_esp_tab(ctx); + break; + case 2: + draw_misc_tab(ctx); + break; } + } nk_end(ctx); -} \ No newline at end of file +} From 4314869b3030df70ec18aa26a58a74ffe3861734 Mon Sep 17 00:00:00 2001 From: LeaoMartelo Date: Tue, 31 Dec 2024 20:43:23 -0300 Subject: [PATCH 3/5] i think autoformat fucked something up --- config/config.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/config/config.c b/config/config.c index ad20d13..ae496e8 100644 --- a/config/config.c +++ b/config/config.c @@ -12,7 +12,7 @@ bool init_config() { FILE *config_file = fopen(config_path, "rb"); - if (config_file == NULL || !fread(&config, sizeof(struct config), 1, config_file)) + if ( config_file == NULL || !fread(&config, sizeof(struct config), 1, config_file) ) { config.aimbot.key.is_pressed = false; @@ -23,32 +23,32 @@ bool init_config() config.aimbot.aimbot_enabled = 1; config.aimbot.draw_fov = 1; config.aimbot.fov = 10.0f; - config.aimbot.fov_color = (struct nk_colorf){207.0f / 255.0f, 115.0f / 255.0f, 54.0f / 255.0f, 0.25f}; + config.aimbot.fov_color = (struct nk_colorf) {207.0f / 255.0f, 115.0f / 255.0f, 54.0f / 255.0f, 0.25f}; config.aimbot.projectile_time_step = 0.01f; config.aimbot.projectile_max_time = 1.0f; config.aimbot.projectile_tolerance_time = 0.05f; config.aimbot.key.use_key = 1; - config.aimbot.key.binding = (struct key_binding){INPUT_MOUSE, SDL_BUTTON_X2, false}; + config.aimbot.key.binding = (struct key_binding) {INPUT_MOUSE, SDL_BUTTON_X2, false}; config.aimbot.key.is_pressed = false; config.aimbot.projectile_preview.draw_line = 1; - config.aimbot.projectile_preview.line_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; + config.aimbot.projectile_preview.line_color = (struct nk_colorf) {1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.draw_box = 1; - config.aimbot.projectile_preview.box_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; + config.aimbot.projectile_preview.box_color = (struct nk_colorf) {1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.only_draw_if_target = 1; config.aimbot.projectile_preview.previous_shot_line = 1; - config.aimbot.projectile_preview.previous_shot_line_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; + config.aimbot.projectile_preview.previous_shot_line_color = (struct nk_colorf) {1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.previous_shot_box = 1; - config.aimbot.projectile_preview.previous_shot_box_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; + config.aimbot.projectile_preview.previous_shot_box_color = (struct nk_colorf) {1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.draw_timer = 1; - config.aimbot.projectile_preview.timer_color = (struct nk_colorf){1.0f, 0.0f, 0.0f, 1.0f}; + config.aimbot.projectile_preview.timer_color = (struct nk_colorf) {1.0f, 0.0f, 0.0f, 1.0f}; config.aimbot.projectile_preview.previous_shot_linger_time = 0.5f; config.aimbot.projectile_preview.draw_entity_prediction = 1; - config.aimbot.projectile_preview.entity_prediction_color = (struct nk_colorf){1.0f, 1.0f, 1.0f, 1.0f}; + config.aimbot.projectile_preview.entity_prediction_color = (struct nk_colorf) {1.0f, 1.0f, 1.0f, 1.0f}; config.esp.player_health_bar = 1; config.esp.player_bounding_box = 1; config.esp.player_name = 1; config.esp.team_color = 1; - config.esp.esp_color = (struct nk_colorf){1.0f, 1.0f, 1.0f, 1.0f}; + config.esp.esp_color = (struct nk_colorf) {1.0f, 1.0f, 1.0f, 1.0f}; config.esp.ammo_hp_ents_name = 1; config.esp.ammo_hp_ents_bounding_box = 1; config.esp.sentry_name = 1; @@ -71,12 +71,12 @@ bool save_config() { FILE *config_file = fopen(config_path, "wb"); - if (config_file == NULL) + if ( config_file == NULL ) { return false; } - if (!fwrite(&config, sizeof(struct config), 1, config_file)) + if ( !fwrite(&config, sizeof(struct config), 1, config_file) ) { fclose(config_file); return false; From fc8afde516f63db4ace44dff204e0fd48ef5d9c2 Mon Sep 17 00:00:00 2001 From: LeaoMartelo Date: Wed, 1 Jan 2025 00:50:20 -0300 Subject: [PATCH 4/5] disable rage-strafe for scout aswell, makes double jumping weird --- hooks/create_move/movement.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hooks/create_move/movement.c b/hooks/create_move/movement.c index d3a19b7..b49bf08 100644 --- a/hooks/create_move/movement.c +++ b/hooks/create_move/movement.c @@ -14,7 +14,7 @@ void bunny_hop(void *localplayer, struct user_cmd *user_cmd) * i haven't figured out why (FROM TESTING: i belive the on ground flag sometimes is not getting set correctly) * in any case, i'll just disable bhop on scout until i figure it out */ - if (!config.misc.bunny_hop || get_player_class(localplayer) == TF_CLASS_SCOUT) + if ( !config.misc.bunny_hop || get_player_class(localplayer) == TF_CLASS_SCOUT ) { return; } @@ -22,18 +22,18 @@ void bunny_hop(void *localplayer, struct user_cmd *user_cmd) static bool was_jumping = false; bool on_ground = (get_ent_flags(localplayer) & FL_ONGROUND); - if (user_cmd->buttons & IN_JUMP) + if ( user_cmd->buttons & IN_JUMP ) { - if (!was_jumping && !on_ground) + if ( !was_jumping && !on_ground ) { user_cmd->buttons &= ~IN_JUMP; } - else if (was_jumping) + else if ( was_jumping ) { was_jumping = false; } } - else if (!was_jumping) + else if ( !was_jumping ) { was_jumping = true; } @@ -44,7 +44,7 @@ void autostrafe(void *localplayer, struct user_cmd *user_cmd) // TBD: figure out how to implement directional / rage autostrafe // i don't think this kind of autostrafe does anything - if (!config.misc.legit_autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT) + if ( !config.misc.legit_autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT ) { return; } @@ -54,16 +54,16 @@ void autostrafe(void *localplayer, struct user_cmd *user_cmd) const bool on_ground = get_ent_flags(localplayer) & FL_ONGROUND; const bool on_water = get_ent_flags(localplayer) & FL_INWATER; - if (on_ground || on_water) + if ( on_ground || on_water ) { return; } - if (user_cmd->mouse_dx < 0) + if ( user_cmd->mouse_dx < 0 ) { user_cmd->sidemove = -cl_sidespeed; } - else if (user_cmd->mouse_dx > 0) + else if ( user_cmd->mouse_dx > 0 ) { user_cmd->sidemove = cl_sidespeed; } @@ -74,7 +74,7 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) // inspired from: // https://github.com/degeneratehyperbola/NEPS - if (!config.misc.rage_autostrafe) + if ( !config.misc.rage_autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT ) { return; } @@ -82,7 +82,7 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) const bool on_ground = get_ent_flags(localplayer) & FL_ONGROUND; const bool on_water = get_ent_flags(localplayer) & FL_INWATER; - if (on_ground || on_water) + if ( on_ground || on_water ) { return; } @@ -90,7 +90,7 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) const struct vec3_t velocity = get_ent_velocity(localplayer); const float speed = vec_lenght2d(velocity); - if (speed < 2) + if ( speed < 2 ) { return; } @@ -106,7 +106,7 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) float terminal = wishspeed / sv_airaccelerate / sv_maxspeed * 100.0f / speed; - if (terminal < -1 || terminal > 1) + if ( terminal < -1 || terminal > 1 ) { return; } From 5bf172a54bc2aad3af880fd0fcdc88748637ad96 Mon Sep 17 00:00:00 2001 From: LeaoMartelo Date: Wed, 1 Jan 2025 00:52:46 -0300 Subject: [PATCH 5/5] unscrew autoformat --- config/config.c | 6 +++--- hooks/create_move/aimbot.c | 2 +- hooks/create_move/movement.c | 26 +++++++++++++------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/config/config.c b/config/config.c index ae496e8..491741f 100644 --- a/config/config.c +++ b/config/config.c @@ -12,7 +12,7 @@ bool init_config() { FILE *config_file = fopen(config_path, "rb"); - if ( config_file == NULL || !fread(&config, sizeof(struct config), 1, config_file) ) + if (config_file == NULL || !fread(&config, sizeof(struct config), 1, config_file)) { config.aimbot.key.is_pressed = false; @@ -71,12 +71,12 @@ bool save_config() { FILE *config_file = fopen(config_path, "wb"); - if ( config_file == NULL ) + if (config_file == NULL) { return false; } - if ( !fwrite(&config, sizeof(struct config), 1, config_file) ) + if (!fwrite(&config, sizeof(struct config), 1, config_file)) { fclose(config_file); return false; diff --git a/hooks/create_move/aimbot.c b/hooks/create_move/aimbot.c index bf05378..334d19a 100644 --- a/hooks/create_move/aimbot.c +++ b/hooks/create_move/aimbot.c @@ -23,7 +23,7 @@ void aimbot(void *localplayer, struct user_cmd *user_cmd) int weapon_id = get_weapon_id(active_weapon); bool is_projectile_class = get_player_class(localplayer) == TF_CLASS_SOLDIER; bool is_projectile_weapon = weapon_id == TF_WEAPON_ROCKETLAUNCHER || weapon_id == TF_WEAPON_ROCKETLAUNCHER_DIRECTHIT; - + if (is_projectile_class && is_projectile_weapon) { projectile_aimbot(localplayer, user_cmd, weapon_id); diff --git a/hooks/create_move/movement.c b/hooks/create_move/movement.c index b49bf08..050b9c5 100644 --- a/hooks/create_move/movement.c +++ b/hooks/create_move/movement.c @@ -14,7 +14,7 @@ void bunny_hop(void *localplayer, struct user_cmd *user_cmd) * i haven't figured out why (FROM TESTING: i belive the on ground flag sometimes is not getting set correctly) * in any case, i'll just disable bhop on scout until i figure it out */ - if ( !config.misc.bunny_hop || get_player_class(localplayer) == TF_CLASS_SCOUT ) + if (!config.misc.bunny_hop || get_player_class(localplayer) == TF_CLASS_SCOUT) { return; } @@ -22,18 +22,18 @@ void bunny_hop(void *localplayer, struct user_cmd *user_cmd) static bool was_jumping = false; bool on_ground = (get_ent_flags(localplayer) & FL_ONGROUND); - if ( user_cmd->buttons & IN_JUMP ) + if (user_cmd->buttons & IN_JUMP) { - if ( !was_jumping && !on_ground ) + if (!was_jumping && !on_ground) { user_cmd->buttons &= ~IN_JUMP; } - else if ( was_jumping ) + else if (was_jumping) { was_jumping = false; } } - else if ( !was_jumping ) + else if (!was_jumping) { was_jumping = true; } @@ -44,7 +44,7 @@ void autostrafe(void *localplayer, struct user_cmd *user_cmd) // TBD: figure out how to implement directional / rage autostrafe // i don't think this kind of autostrafe does anything - if ( !config.misc.legit_autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT ) + if (!config.misc.legit_autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT) { return; } @@ -54,16 +54,16 @@ void autostrafe(void *localplayer, struct user_cmd *user_cmd) const bool on_ground = get_ent_flags(localplayer) & FL_ONGROUND; const bool on_water = get_ent_flags(localplayer) & FL_INWATER; - if ( on_ground || on_water ) + if (on_ground || on_water) { return; } - if ( user_cmd->mouse_dx < 0 ) + if (user_cmd->mouse_dx < 0) { user_cmd->sidemove = -cl_sidespeed; } - else if ( user_cmd->mouse_dx > 0 ) + else if (user_cmd->mouse_dx > 0) { user_cmd->sidemove = cl_sidespeed; } @@ -74,7 +74,7 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) // inspired from: // https://github.com/degeneratehyperbola/NEPS - if ( !config.misc.rage_autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT ) + if (!config.misc.rage_autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT) { return; } @@ -82,7 +82,7 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) const bool on_ground = get_ent_flags(localplayer) & FL_ONGROUND; const bool on_water = get_ent_flags(localplayer) & FL_INWATER; - if ( on_ground || on_water ) + if (on_ground || on_water) { return; } @@ -90,7 +90,7 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) const struct vec3_t velocity = get_ent_velocity(localplayer); const float speed = vec_lenght2d(velocity); - if ( speed < 2 ) + if (speed < 2) { return; } @@ -106,7 +106,7 @@ void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd) float terminal = wishspeed / sv_airaccelerate / sv_maxspeed * 100.0f / speed; - if ( terminal < -1 || terminal > 1 ) + if (terminal < -1 || terminal > 1) { return; }