Skip to content

Commit

Permalink
added multiple bones, code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ekknod committed Oct 15, 2023
1 parent fa2c3b6 commit c5360b0
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 130 deletions.
7 changes: 0 additions & 7 deletions cs2/shared/cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ static BOOL cs::initialize(void)
game_handle = vm::open_process_ex(PROCESS_NAME, CLIENT_DLL);
if (!game_handle)
{
#ifdef DEBUG
LOG("CS2 process not found\n");
#endif
return 0;
}

Expand Down Expand Up @@ -198,8 +196,6 @@ static BOOL cs::initialize(void)
//
// to-do schemas
//

#ifdef DEBUG
LOG("interfaces::cvar %p\n", (void *)interfaces::cvar);
LOG("interfaces::input %p\n", (void *)interfaces::input);
LOG("interfaces::resource %p\n", (void *)interfaces::resource);
Expand All @@ -209,7 +205,6 @@ static BOOL cs::initialize(void)
LOG("direct::view_angles %p\n", (void *)direct::view_angles);
LOG("direct::view_matrix %p\n", (void *)direct::view_matrix);
LOG("game is running\n");
#endif

#ifdef __linux__
PVOID dump_client = vm::dump_module(game_handle, client_dll, VM_MODULE_TYPE::Full);
Expand Down Expand Up @@ -630,9 +625,7 @@ QWORD cs::engine::get_convar(const char *name)

if (!strcmpi_imp(convar_name, name))
{
#ifdef DEBUG
LOG("get_convar [%s %p]\n", convar_name, (void *)entry);
#endif
return entry;
}
}
Expand Down
32 changes: 29 additions & 3 deletions cs2/shared/cs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,42 @@
#include "../../library/vm.h"
#include "../../library/math.h"

#ifndef _KERNEL_MODE

//
// enables global debug messages
//
#define DEBUG










#ifndef _KERNEL_MODE
#include <stdio.h>
#define DEBUG

#ifdef DEBUG
#define LOG(...) printf("[EC] " __VA_ARGS__)
#else
#define DEBUG
#define LOG(...) // __VA_ARGS__
#endif


#else

#ifdef DEBUG
#define LOG(...) DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[EC] " __VA_ARGS__)
#else
#define LOG(...) // __VA_ARGS__
#endif

#endif


namespace cs
{
enum class WEAPON_CLASS {
Expand Down
154 changes: 104 additions & 50 deletions cs2/shared/features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace features
aimbot_tick = 0;
}

inline void update_settings(void);
static vec3 get_target_angle(QWORD local_player, vec3 position, DWORD num_shots, vec2 aim_punch);
static void get_best_target(BOOL ffa, QWORD local_controller, QWORD local_player, DWORD num_shots, vec2 aim_punch, QWORD *target);
static void standalone_rcs(DWORD shots_fired, vec2 vec_punch, float sensitivity);
Expand All @@ -52,15 +53,49 @@ namespace features
#endif
}

namespace config
{
static BOOL rcs;
static BOOL aimbot_enabled;
static DWORD aimbot_button;
static float aimbot_fov;
static float aimbot_smooth;
static BOOL aimbot_multibone;
static DWORD triggerbot_button;
static BOOL visuals_enabled;
}

inline DWORD random_number(DWORD min, DWORD max)
{
return min + cs::engine::get_current_tick() % (max + 1 - min);
}

inline void update_settings(void)
inline void features::update_settings(void)
{
int crosshair_alpha = cs::get_crosshairalpha();


//
// default global settings
//
config::rcs = 0;
config::aimbot_enabled = 1;
config::aimbot_multibone = 1;
config::visuals_enabled = 2;


switch (weapon_class)
{
case cs::WEAPON_CLASS::Knife:
case cs::WEAPON_CLASS::Grenade:
config::aimbot_enabled = 0;
break;
case cs::WEAPON_CLASS::Pistol:
config::aimbot_multibone = 0;
break;
}


switch (crosshair_alpha)
{
//
Expand Down Expand Up @@ -185,47 +220,18 @@ void features::run(void)
goto NOT_INGAME;
}

//
// update cheat settings
//
update_settings();
weapon_class = cs::player::get_weapon_class(local_player);
if (weapon_class == cs::WEAPON_CLASS::Invalid)
{
return;
}


//
// get current weapon information
// update cheat settings
//
BOOL b_can_aimbot = 0;
float accurate_shots_fl = -0.08f;
update_settings();

weapon_class = cs::player::get_weapon_class(local_player);
if (weapon_class == cs::WEAPON_CLASS::Knife)
{
b_can_aimbot = 0;
}
else if (weapon_class == cs::WEAPON_CLASS::Grenade)
{
b_can_aimbot = 0;
}
else if (weapon_class == cs::WEAPON_CLASS::Pistol)
{
accurate_shots_fl = -0.04f;
b_can_aimbot = 1;
}
else if (weapon_class == cs::WEAPON_CLASS::Sniper)
{
b_can_aimbot = 1;
}
else if (weapon_class == cs::WEAPON_CLASS::Rifle)
{
b_can_aimbot = 1;
}
else
{
//
// invalid weapon class
//
return;
}

BOOL ffa = cs::gamemode::is_ffa();
DWORD num_shots = cs::player::get_shots_fired(local_player);
Expand All @@ -237,8 +243,14 @@ void features::run(void)
standalone_rcs(num_shots, aim_punch, sensitivity);
}

if (cs::input::is_button_down(config::triggerbot_button) && b_can_aimbot)
if (cs::input::is_button_down(config::triggerbot_button) && config::aimbot_enabled)
{
float accurate_shots_fl = -0.08f;
if (weapon_class == cs::WEAPON_CLASS::Pistol)
{
accurate_shots_fl = -0.04f;
}

//
// accurate shots only
//
Expand Down Expand Up @@ -298,15 +310,16 @@ void features::run(void)
aimbot_active = 0;


//
// no valid target found
//
if (aimbot_target == 0)
if (!config::aimbot_enabled)
{
return;
}

if (!b_can_aimbot)

//
// no valid target found
//
if (aimbot_target == 0)
{
return;
}
Expand All @@ -322,16 +335,45 @@ void features::run(void)
return;
}

vec3 head{};
if (!cs::node::get_bone_position(node, 6, &head))

vec2 view_angle = cs::engine::get_viewangles();


vec3 aimbot_angle{};
float aimbot_fov = 360.0f;

if (config::aimbot_multibone)
{
return;
}
for (DWORD i = 2; i < 7; i++)
{
vec3 pos{};
if (!cs::node::get_bone_position(node, i, &pos))
{
continue;
}

vec2 view_angle = cs::engine::get_viewangles();
vec3 aimbot_angle = get_target_angle(local_player, head, num_shots, aim_punch);
vec3 angle = get_target_angle(local_player, pos, num_shots, aim_punch);
float fov = math::get_fov(view_angle, angle);

if (math::get_fov(view_angle, aimbot_angle) > config::aimbot_fov)
if (fov < aimbot_fov)
{
aimbot_fov = fov;
aimbot_angle = angle;
}
}
}
else
{
vec3 head{};
if (!cs::node::get_bone_position(node, 6, &head))
{
return;
}
aimbot_angle = get_target_angle(local_player, head, num_shots, aim_punch);
aimbot_fov = math::get_fov(view_angle, aimbot_angle);
}

if (aimbot_fov > config::aimbot_fov)
{
return;
}
Expand Down Expand Up @@ -400,6 +442,10 @@ static vec3 features::get_target_angle(QWORD local_player, vec3 position, DWORD
{
vec3 eye_position = cs::node::get_origin(cs::player::get_node(local_player));
eye_position.z += cs::player::get_vec_view(local_player);

//
// which one is better???
//
// vec3 eye_position = cs::player::get_eye_position(local_player);

vec3 angle{};
Expand Down Expand Up @@ -492,6 +538,14 @@ static void features::get_best_target(BOOL ffa, QWORD local_controller, QWORD lo
}
#endif

//
// if aimbot is disabled, we can skip rest of the code
//
if (!config::aimbot_enabled)
{
continue;
}

vec3 best_angle = get_target_angle(local_player, head, num_shots, aim_punch);

float fov = math::get_fov(va, *(vec3*)&best_angle);
Expand Down
15 changes: 0 additions & 15 deletions cs2/shared/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ namespace input
extern void mouse1_up(void);
}


//
// implemented by application/driver
//
namespace config
{
extern BOOL rcs;
extern DWORD aimbot_button;
extern float aimbot_fov;
extern float aimbot_smooth;
extern BOOL aimbot_visibility_check;
extern DWORD triggerbot_button;
extern BOOL visuals_enabled;
}

namespace cs2
{
inline void run(void)
Expand Down
9 changes: 9 additions & 0 deletions library/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,15 @@ namespace math
return r;
}

inline vec3 vec_add(vec3 p0, vec3 p1)
{
vec3 r;
r.x = p0.x + p1.x;
r.y = p0.y + p1.y;
r.z = p0.z + p1.z;
return r;
}

inline float vec_distance(vec3 p0, vec3 p1)
{
return vec_length_sqrt(vec_sub(p0, p1));
Expand Down
11 changes: 0 additions & 11 deletions projects - CS2/DMA/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ namespace input
}
}

namespace config
{
BOOL rcs = 0;
DWORD aimbot_button = 314; // mouse left key
float aimbot_fov = 2.0f;
float aimbot_smooth = 30.0f;
BOOL aimbot_visibility_check = 0;
DWORD triggerbot_button = 318; // mouse forward key
BOOL visuals_enabled = 1;
}

int main(void)
{
while (1)
Expand Down
11 changes: 0 additions & 11 deletions projects - CS2/EFI/bootx64/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@ namespace input
}
}

namespace config
{
BOOL rcs = 0;
DWORD aimbot_button = 314; // mouse left key
float aimbot_fov = 2.0f;
float aimbot_smooth = 30.0f;
BOOL aimbot_visibility_check = 0;
DWORD triggerbot_button = 318; // mouse forward key
BOOL visuals_enabled = 2;
}

namespace km
{
NTSTATUS (__fastcall *memcpy_safe)(void *, void *, DWORD);
Expand Down
Loading

0 comments on commit c5360b0

Please sign in to comment.