Skip to content

Commit

Permalink
small update
Browse files Browse the repository at this point in the history
fix not aiming at target
fixed return (doesn't work if there are more than 128 dice)
backtrack optimization
update no recoil
and some minor fixes
  • Loading branch information
pa1n-dev committed Mar 22, 2024
1 parent adf9a36 commit d132445
Show file tree
Hide file tree
Showing 23 changed files with 201 additions and 186 deletions.
1 change: 0 additions & 1 deletion dependencies/imgui/imgui_widgets.cpp
Expand Up @@ -47,7 +47,6 @@ Index of this file:
#include <stdint.h> // intptr_t
#endif

#include <windows.h>
#include <map>

//-------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion dllmain.cpp
Expand Up @@ -5,7 +5,7 @@ void initialize()
while (!utilities::game_is_full_loaded())
std::this_thread::sleep_for(std::chrono::milliseconds(25));

//utilities::attach_console();
utilities::attach_console();

interfaces::initialize();
hooks::initialize();
Expand Down
97 changes: 45 additions & 52 deletions features/aimbot/aimbot.cpp
Expand Up @@ -5,7 +5,7 @@

void aimbot::run(c_user_cmd* cmd)
{
target_info = {};
target = {};

if (!settings::aimbot::globals::enable)
return;
Expand All @@ -18,8 +18,8 @@ void aimbot::run(c_user_cmd* cmd)
if (!weapon)
return;

target_info = find_best_target(cmd, local_player);
if (!target_info.entity)
target = find_best_target(cmd, local_player);
if (!target.entity)
return;

if (settings::menu::opened)
Expand All @@ -37,39 +37,38 @@ void aimbot::run(c_user_cmd* cmd)
if (lag_compensation::get_is_locked())
return;

smooth(cmd->view_angles, target_info.shoot_angle);
smooth(cmd->view_angles, target.shoot_angle);

cmd->view_angles = target_info.shoot_angle;
cmd->view_angles = target.shoot_angle;

if (!settings::aimbot::globals::silent)
interfaces::engine->set_view_angles(cmd->view_angles);
interfaces::engine->set_view_angles(target.shoot_angle);

if (settings::aimbot::globals::automatic_fire)
cmd->buttons |= IN_ATTACK;
{
if (cmd->command_number & 1)
cmd->buttons |= IN_ATTACK;
}

bool adjust_interp;
history::can_restore_to_simulation_time(target_info.simulation_time, &adjust_interp);
history::can_restore_to_simulation_time(target.simulation_time, &adjust_interp);

if (adjust_interp)
{
float interp = utilities::ticks_to_time(interfaces::global_vars->tick_count) - target_info.simulation_time;
lag_compensation::update_desired_values(true, interp, 1.f);
}
else
{
//cmd->tick_count = utilities::time_to_ticks(target_info.simulation_time);
//lag_compensation::update_desired_values(false, 0.f, 0.f);
float interp = utilities::ticks_to_time(interfaces::global_vars->tick_count) - target.simulation_time;
if (interp > 0.f)
lag_compensation::update_desired_values(true, interp, 1.f);
}
}

aimbot::target_info_t aimbot::find_best_target(c_user_cmd* cmd, c_base_entity* local_player)
target_info aimbot::find_best_target(c_user_cmd* cmd, c_base_entity* local_player)
{
target_info_t target_info;
priority_info_t& priority_info = target_info.priority_info;
target_info target;
priority_info& priority = target.priority_info;

const q_angle& view_angles = cmd->view_angles;
const c_vector& eye_position = local_player->get_eye_position();
const c_vector& origin = local_player->get_abs_origin();
const q_angle& view_angles = cmd->view_angles;

for (size_t i = 1; i <= interfaces::entity_list->get_highest_entity_index(); i++)
{
Expand All @@ -79,60 +78,54 @@ aimbot::target_info_t aimbot::find_best_target(c_user_cmd* cmd, c_base_entity* l
continue;

float simulation_time = entity->get_simulation_time();

int distance = origin.distance_to(entity->get_abs_origin());
int health = entity->get_health();
c_vector shoot_pos;

if (!get_hit_position(local_player, entity, shoot_pos))
{
if (!settings::aimbot::accuracy::backtrack)
continue;

std::vector<lag_record> records;
history::get_usable_records(i, &records, settings::aimbot::accuracy::backtrack);

if (records.empty())
lag_record record;
if (!history::get_latest_record(i, record))
continue;

auto record = records.back();

if (!get_hit_position(local_player, entity, shoot_pos, record.bone_to_world))
continue;

simulation_time = record.simulation_time;
distance = record.origin.distance_to(entity->get_abs_origin());
}

q_angle shoot_angle = utilities::calc_angle(eye_position, shoot_pos);

float fov = utilities::get_fov(view_angles, shoot_angle);

if (fov > settings::aimbot::globals::fov)
continue;

int distance = entity->get_abs_origin().distance_to(origin);
int health = entity->get_health();

bool should_skip = false;
switch (settings::aimbot::globals::priority)
{
case 0: should_skip = fov > priority_info.fov; break;
case 1: should_skip = distance > priority_info.distance; break;
case 2: should_skip = health > priority_info.health; break;
case 0: should_skip = fov > priority.fov; break;
case 1: should_skip = distance > priority.distance; break;
case 2: should_skip = health > priority.health; break;
}

if (should_skip)
continue;

priority_info.fov = fov;
priority_info.distance = distance;
priority_info.health = health;
priority.fov = fov;
priority.distance = distance;
priority.health = health;

target_info.entity = entity;
target_info.shoot_pos = shoot_pos;
target_info.shoot_angle = shoot_angle;
target_info.simulation_time = simulation_time;
target.entity = entity;
target.shoot_pos = shoot_pos;
target.shoot_angle = shoot_angle;
target.simulation_time = simulation_time;
}

return target_info;
return target;
}

bool aimbot::check_hitbox_group(int group)
Expand All @@ -146,17 +139,8 @@ bool aimbot::check_hitbox_group(int group)
}
}

bool aimbot::get_hit_position(c_base_entity* local_player, c_base_entity* entity, c_vector& shoot_pos, matrix3x4* bone_to_world)
bool aimbot::get_hit_position(c_base_entity* local_player, c_base_entity* entity, c_vector& shoot_pos, std::shared_ptr<matrix3x4[]> bone_to_world)
{
if (bone_to_world == nullptr)
{
bone_to_world = new matrix3x4[MAX_STUDIO_BONES];

entity->invalidate_bone_cache();
if (!entity->get_client_renderable()->setup_bones(bone_to_world, MAX_STUDIO_BONES, BONE_USED_BY_ANYTHING, interfaces::global_vars->curtime))
return false;
}

void* model = entity->get_client_renderable()->get_model();
if (!model)
return false;
Expand All @@ -165,10 +149,19 @@ bool aimbot::get_hit_position(c_base_entity* local_player, c_base_entity* entity
if (!hdr)
return false;

mstudiohitboxset_t* hitbox_set = hdr->hitbox_set(0);
mstudiohitboxset_t* hitbox_set = hdr->hitbox_set(entity->hitbox_set());
if (!hitbox_set)
return false;

if (!bone_to_world)
{
bone_to_world.reset(new matrix3x4[hdr->num_bones]);

entity->invalidate_bone_cache();
if (!entity->get_client_renderable()->setup_bones(bone_to_world.get(), hdr->num_bones, BONE_USED_BY_ANYTHING, interfaces::global_vars->curtime))
return false;
}

bool found_hitbox = false;

for (int i = 0; i < hitbox_set->num_hitboxes; i++)
Expand Down
36 changes: 18 additions & 18 deletions features/aimbot/aimbot.h
@@ -1,30 +1,30 @@
#pragma once
#include "../../hooks/hooks.h"

namespace aimbot
struct priority_info
{
struct priority_info_t
{
float fov = FLT_MAX;
float distance = FLT_MAX;
float health = FLT_MAX;
};
float fov = FLT_MAX;
float distance = FLT_MAX;
float health = FLT_MAX;
};

struct target_info_t
{
c_base_entity* entity = nullptr;
struct target_info
{
c_base_entity* entity = nullptr;

c_vector shoot_pos;
q_angle shoot_angle;
float simulation_time = 0.f;
priority_info_t priority_info;
};
c_vector shoot_pos;
q_angle shoot_angle;
float simulation_time;
priority_info priority_info;
};

inline target_info_t target_info;
namespace aimbot
{
inline target_info target;

void run(c_user_cmd* cmd);
target_info_t find_best_target(c_user_cmd* cmd, c_base_entity* local_player);
target_info find_best_target(c_user_cmd* cmd, c_base_entity* local_player);
bool check_hitbox_group(int group);
bool get_hit_position(c_base_entity* local_player, c_base_entity* entity, c_vector& shoot_pos, matrix3x4* bone_to_world = nullptr);
bool get_hit_position(c_base_entity* local_player, c_base_entity* entity, c_vector& shoot_pos, std::shared_ptr<matrix3x4[]> bone_to_world = nullptr);
void smooth(const q_angle& view_angles, q_angle& angle);
}
64 changes: 32 additions & 32 deletions features/aimbot/backtrack/history.cpp
Expand Up @@ -95,37 +95,38 @@ bool history::can_restore_to_simulation_time(float simulation_time, bool* need_t
return true;
}

void history::get_usable_records(int index, std::vector<lag_record>* out_records, float max_time)
bool history::get_latest_record(int index, lag_record& out_record)
{
c_base_entity* entity = interfaces::entity_list->get_entity(index);
if (!entity || !entity->is_player())
return false;

auto& track = records[index - 1];

if (track.empty())
return;
return false;

bool record_found = false;
c_vector prev_origin = entity->get_abs_origin();

for (const auto& record : track)
{
if (max_time != -1.f)
{
float delta = utilities::ticks_to_time(interfaces::global_vars->tick_count) - record.arrive_time;

if (delta > max_time)
break;
}

if (is_delta_too_big(record.vec_origin, prev_origin))
if (is_delta_too_big(record.origin, prev_origin))
break;

if (!can_restore_to_simulation_time(record.simulation_time))
break;

out_records->push_back(record);
float delta = utilities::ticks_to_time(interfaces::global_vars->tick_count) - record.arrive_time;
if (delta > settings::aimbot::accuracy::backtrack)
break;

out_record = record;
prev_origin = record.origin;

prev_origin = record.vec_origin;
record_found = true;
}

return record_found;
}

void history::update()
Expand Down Expand Up @@ -153,30 +154,29 @@ void history::update()
continue;
}

for (auto it = track.begin(); it != track.end(); )
{
const lag_record& record = *it;

float delta = utilities::ticks_to_time(interfaces::global_vars->tick_count) - record.arrive_time;

if (delta > 1.f)
{
it = track.erase(it);
}
else
{
++it;
}
}
track.erase(std::remove_if(track.begin(), track.end(),
[](const lag_record& r)
{
return utilities::ticks_to_time(interfaces::global_vars->tick_count) - r.simulation_time > 1.f;
}), track.end());

lag_record record;

record.arrive_time = utilities::ticks_to_time(estimate_server_arrive_tick());
record.simulation_time = entity->get_simulation_time();
record.vec_origin = entity->get_abs_origin();
record.origin = entity->get_abs_origin();

void* model = entity->get_client_renderable()->get_model();
if (!model)
continue;

studiohdr_t* hdr = interfaces::model_info->get_studio_model(model);
if (!hdr)
continue;

record.bone_to_world.reset(new matrix3x4[hdr->num_bones]);

entity->invalidate_bone_cache();
if (!entity->get_client_renderable()->setup_bones(record.bone_to_world, MAX_STUDIO_BONES, BONE_USED_BY_ANYTHING, interfaces::global_vars->curtime))
if (!entity->get_client_renderable()->setup_bones(record.bone_to_world.get(), hdr->num_bones, BONE_USED_BY_ANYTHING, interfaces::global_vars->curtime))
continue;

track.insert(track.begin(), record);
Expand Down
19 changes: 5 additions & 14 deletions features/aimbot/backtrack/history.h
Expand Up @@ -3,20 +3,11 @@

struct lag_record
{
float arrive_time = 0.0f;
float simulation_time = 0.0f;
std::shared_ptr<matrix3x4[]> bone_to_world;

c_vector vec_origin;
c_vector vec_mins;
c_vector vec_maxs;
q_angle ang_render;

int sequence;
float cycle;
float eye_yaw;
float eye_pitch;

matrix3x4 bone_to_world[MAX_STUDIO_BONES];
float arrive_time;
float simulation_time;
c_vector origin;
};

namespace history
Expand All @@ -27,6 +18,6 @@ namespace history
int estimate_server_arrive_tick();
bool is_delta_too_big(const c_vector& from, const c_vector& to);
bool can_restore_to_simulation_time(float simulation_time, bool* need_to_adjust_interp = nullptr);
void get_usable_records(int index, std::vector<lag_record>* out_records, float max_time = -1.f);
bool get_latest_record(int index, lag_record& out_record);
void update();
}

0 comments on commit d132445

Please sign in to comment.