Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ tf_c.so
*~

# Config files
*.tf_c.bin
*.tf_c.bin

# clang-format
.clang-format
21 changes: 11 additions & 10 deletions config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please provide style guidelines, i tried my best to replicate it on my .clang-format and i messed this up

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;
Expand Down
3 changes: 2 additions & 1 deletion config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ struct config
struct
{
int bunny_hop;
int autostrafe;
bool do_thirdperson;
int legit_autostrafe;
int rage_autostrafe;
} misc;
struct
{
Expand Down
2 changes: 1 addition & 1 deletion hooks/create_move/aimbot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 6 additions & 5 deletions hooks/create_move/create_move.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also idk why it did this


#include "create_move.h"

#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
Expand All @@ -28,7 +28,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;
Expand All @@ -50,19 +50,20 @@ __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;
Expand Down
6 changes: 4 additions & 2 deletions hooks/create_move/create_move.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "../../source_sdk/user_cmd.h"

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

__int64_t create_move_hook(void *this, float sample_time, struct user_cmd *user_cmd);
Expand All @@ -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);
void autostrafe(void *localplayer, struct user_cmd *user_cmd);
void rage_autostrafe(void *localplayer, struct user_cmd *user_cmd);
91 changes: 76 additions & 15 deletions hooks/create_move/movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,38 @@
#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 <math.h>
#include <stdbool.h>

void bunny_hop(void *localplayer, struct user_cmd *user_cmd)
{
/* scouts double jump only works sometimes, very inconsistent
* 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;
}

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;
}
Expand All @@ -41,26 +44,84 @@ 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;
}

// 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;
const bool on_water = get_ent_flags(localplayer) & FL_INWATER;

if(on_ground)
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)
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)
{
// inspired from:
// https://github.com/degeneratehyperbola/NEPS

if (!config.misc.rage_autostrafe || get_player_class(localplayer) == TF_CLASS_SCOUT)
{
return;
}

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)
{
return;
}

const struct vec3_t velocity = get_ent_velocity(localplayer);
const float speed = vec_lenght2d(velocity);

if (speed < 2)
{
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;

// 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)
{
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;
}
140 changes: 74 additions & 66 deletions hooks/menu/menu.c

Large diffs are not rendered by default.

37 changes: 30 additions & 7 deletions utils/math/math_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
}

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;
}
5 changes: 4 additions & 1 deletion utils/math/math_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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);