Compare commits
14 Commits
release1
...
bone_posit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d7d974d88 | ||
|
|
04720aa4a3 | ||
|
|
d5cfc33837 | ||
|
|
77e8b04214 | ||
|
|
772f4a1d7a | ||
|
|
e43eeb2d3b | ||
|
|
762368d75f | ||
|
|
67f4c5ed88 | ||
|
|
e83dad0409 | ||
|
|
e9f3031ca1 | ||
|
|
9f64f544de | ||
|
|
3a514789a7 | ||
|
|
8d735ece89 | ||
|
|
2a57c69444 |
2
Makefile
2
Makefile
@@ -5,7 +5,7 @@ INCLUDES=-Isrc/include/sdk/common -Isrc/include/sdk/public -Isrc/include/sdk/pm_
|
||||
CFLAGS=-Wall -Wextra -Wno-write-strings -m32 -fPIC $(INCLUDES)
|
||||
LDFLAGS=-lm
|
||||
|
||||
OBJS=obj/main.c.o obj/globals.c.o obj/cvars.c.o obj/hooks.c.o obj/detour.c.o obj/util.c.o obj/features/movement.c.o obj/features/esp.c.o obj/features/chams.c.o obj/features/misc.c.o
|
||||
OBJS=obj/main.c.o obj/globals.c.o obj/cvars.c.o obj/hooks.c.o obj/detour.c.o obj/util.c.o obj/features/movement.c.o obj/features/esp.c.o obj/features/chams.c.o obj/features/aim.c.o obj/features/misc.c.o
|
||||
BIN=libhlcheat.so
|
||||
|
||||
.PHONY: clean all inject
|
||||
|
||||
@@ -20,11 +20,17 @@ Also make sure to check out [[https://github.com/deboogerxyz/ahc][deboogerxyz/ah
|
||||
| Feature | Command | Values (0..n) |
|
||||
|------------+---------------+------------------------|
|
||||
| Bhop | =cv_bhop= | off/on |
|
||||
| Autostrafe | =cv_autostrafe= | off/rage/legit |
|
||||
| Aimbot | =cv_aimbot= | off/fov* |
|
||||
| ESP | =cv_esp= | off/3d-box/name/all |
|
||||
| Autostrafe | =sv_autostrafe= | off/rage/legit |
|
||||
| Chams | =cv_chams= | off/players/hands/all* |
|
||||
| Crosshair | =cv_crosshair= | off/length |
|
||||
|
||||
|
||||
#+begin_quote
|
||||
*Note:* Aimbot FOV goes from 0 (off) to 180 (all enemies)
|
||||
#+end_quote
|
||||
|
||||
#+begin_quote
|
||||
*Note:* Chams color can be changed from the =h_glColor4f()= function inside
|
||||
[[https://github.com/8dcc/hl-cheat/blob/main/src/hooks.c][src/hooks.c]]. Since this cheat is not hard to compile, I rather have less
|
||||
|
||||
14
src/cvars.c
14
src/cvars.c
@@ -5,18 +5,20 @@
|
||||
|
||||
DECL_CVAR(bhop);
|
||||
DECL_CVAR(autostrafe);
|
||||
DECL_CVAR(aimbot);
|
||||
DECL_CVAR(esp);
|
||||
DECL_CVAR(chams);
|
||||
DECL_CVAR(crosshair);
|
||||
DECL_CVAR(clmove);
|
||||
|
||||
bool cvars_init(void) {
|
||||
cv_bhop = REGISTER_CVAR("bhop", "1");
|
||||
cv_autostrafe = REGISTER_CVAR("autostrafe", "0");
|
||||
cv_esp = REGISTER_CVAR("esp", "3");
|
||||
cv_chams = REGISTER_CVAR("chams", "1");
|
||||
cv_crosshair = REGISTER_CVAR("crosshair", "0");
|
||||
cv_clmove = REGISTER_CVAR("clmove", "0");
|
||||
REGISTER_CVAR(bhop, 1);
|
||||
REGISTER_CVAR(autostrafe, 0);
|
||||
REGISTER_CVAR(aimbot, 0);
|
||||
REGISTER_CVAR(esp, 3);
|
||||
REGISTER_CVAR(chams, 1);
|
||||
REGISTER_CVAR(crosshair, 0);
|
||||
REGISTER_CVAR(clmove, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
74
src/features/aim.c
Normal file
74
src/features/aim.c
Normal file
@@ -0,0 +1,74 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "features.h"
|
||||
#include "../include/sdk.h"
|
||||
#include "../include/cvars.h"
|
||||
#include "../include/util.h"
|
||||
|
||||
/* Game units to add to the entity origin to get the head */
|
||||
#define HEAD_OFFSET 0.8f
|
||||
|
||||
static vec3_t get_closest_delta(vec3_t viewangles) {
|
||||
vec3_t view_height;
|
||||
i_engine->pEventAPI->EV_LocalPlayerViewheight(view_height);
|
||||
vec3_t local_eyes = vec_add(localplayer->origin, view_height);
|
||||
/* TODO: Compensate aim punch */
|
||||
|
||||
/* These 2 vars are used to store the best target across iterations.
|
||||
* NOTE: The default value of best_fov will be the aimbot fov */
|
||||
float best_fov = cv_aimbot->value;
|
||||
vec3_t best_delta = { 0, 0, 0 };
|
||||
|
||||
for (int i = 1; i <= i_engine->GetMaxClients(); i++) {
|
||||
cl_entity_t* ent = get_player(i);
|
||||
|
||||
if (!is_alive(ent) || is_friend(ent))
|
||||
continue;
|
||||
|
||||
/* TODO: Get bones origin instead of calculating from ent origin */
|
||||
const vec3_t head_pos = vec_add(ent->origin, vec3(0, 0, HEAD_OFFSET));
|
||||
const vec3_t enemy_angle = vec_to_ang(vec_sub(head_pos, local_eyes));
|
||||
|
||||
const vec3_t delta = vec_sub(enemy_angle, viewangles);
|
||||
vec_norm(delta);
|
||||
|
||||
float fov = hypotf(delta.x, delta.y);
|
||||
if (fov > 360.0f) {
|
||||
fov = remainderf(fov, 360.0f);
|
||||
if (fov > 180.0f)
|
||||
fov = 360.0f - fov;
|
||||
}
|
||||
|
||||
if (fov < best_fov) {
|
||||
best_fov = fov;
|
||||
vec_copy(best_delta, delta);
|
||||
}
|
||||
}
|
||||
|
||||
return best_delta;
|
||||
}
|
||||
|
||||
void aimbot(usercmd_t* cmd) {
|
||||
if (!CVAR_ON(aimbot) || !(cmd->buttons & IN_ATTACK))
|
||||
return;
|
||||
|
||||
/* Calculate delta with the engine viewangles, not with the cmd ones */
|
||||
vec3_t engine_viewangles;
|
||||
i_engine->GetViewAngles(engine_viewangles);
|
||||
|
||||
/* TODO: Add setting for lowest health */
|
||||
vec3_t best_delta = get_closest_delta(engine_viewangles);
|
||||
if (!vec_is_zero(best_delta)) {
|
||||
/* NOTE: We can divide the best delta here to add smoothing */
|
||||
|
||||
engine_viewangles.x += best_delta.x;
|
||||
engine_viewangles.y += best_delta.y;
|
||||
engine_viewangles.z += best_delta.z;
|
||||
}
|
||||
|
||||
vec_copy(cmd->viewangles, engine_viewangles);
|
||||
|
||||
/* NOTE: Uncomment to disable silent aim */
|
||||
/* i_engine->SetViewAngles(engine_viewangles); */
|
||||
}
|
||||
@@ -36,14 +36,14 @@ bool gl_draw3dbox(vec3_t o, int bh, int bw, int lw) {
|
||||
* |/ O|/ z(-)
|
||||
* 7---8
|
||||
*/
|
||||
vec3_t p1 = vec3(o[0] - bw / 2, o[1] + bw / 2, o[2] + bh / 2);
|
||||
vec3_t p2 = vec3(o[0] + bw / 2, o[1] + bw / 2, o[2] + bh / 2);
|
||||
vec3_t p3 = vec3(o[0] - bw / 2, o[1] - bw / 2, o[2] + bh / 2);
|
||||
vec3_t p4 = vec3(o[0] + bw / 2, o[1] - bw / 2, o[2] + bh / 2);
|
||||
vec3_t p5 = vec3(o[0] - bw / 2, o[1] + bw / 2, o[2] - bh / 2);
|
||||
vec3_t p6 = vec3(o[0] + bw / 2, o[1] + bw / 2, o[2] - bh / 2);
|
||||
vec3_t p7 = vec3(o[0] - bw / 2, o[1] - bw / 2, o[2] - bh / 2);
|
||||
vec3_t p8 = vec3(o[0] + bw / 2, o[1] - bw / 2, o[2] - bh / 2);
|
||||
vec3_t p1 = vec3(o.x - bw / 2, o.y + bw / 2, o.z + bh / 2);
|
||||
vec3_t p2 = vec3(o.x + bw / 2, o.y + bw / 2, o.z + bh / 2);
|
||||
vec3_t p3 = vec3(o.x - bw / 2, o.y - bw / 2, o.z + bh / 2);
|
||||
vec3_t p4 = vec3(o.x + bw / 2, o.y - bw / 2, o.z + bh / 2);
|
||||
vec3_t p5 = vec3(o.x - bw / 2, o.y + bw / 2, o.z - bh / 2);
|
||||
vec3_t p6 = vec3(o.x + bw / 2, o.y + bw / 2, o.z - bh / 2);
|
||||
vec3_t p7 = vec3(o.x - bw / 2, o.y - bw / 2, o.z - bh / 2);
|
||||
vec3_t p8 = vec3(o.x + bw / 2, o.y - bw / 2, o.z - bh / 2);
|
||||
|
||||
vec2_t s1, s2, s3, s4, s5, s6, s7, s8;
|
||||
if (!world_to_screen(p1, s1) || !world_to_screen(p2, s2) ||
|
||||
@@ -78,8 +78,8 @@ static bool gl_draw2dbox(vec3_t o, int bh) {
|
||||
const rgb_t out_col = { 0, 0, 0 }; /* Outline */
|
||||
|
||||
/* Get top and bottom of player from origin with box height */
|
||||
const vec3_t bot = vec3(o[0], o[1], o[2] - bh / 2);
|
||||
const vec3_t top = vec3(o[0], o[1], o[2] + bh / 2);
|
||||
const vec3_t bot = vec3(o.x, o.y, o.z - bh / 2);
|
||||
const vec3_t top = vec3(o.x, o.y, o.z + bh / 2);
|
||||
|
||||
vec2_t s_bot, s_top;
|
||||
if (!world_to_screen(bot, s_bot) || !world_to_screen(top, s_top))
|
||||
@@ -121,7 +121,7 @@ void esp(void) {
|
||||
continue;
|
||||
|
||||
/* Draw name on top of the player. */
|
||||
vec3_t top = vec3(ent->origin[0], ent->origin[1], ent->origin[2] + bh);
|
||||
vec3_t top = vec3(ent->origin.x, ent->origin.y, ent->origin.z + bh);
|
||||
vec2_t s_top;
|
||||
|
||||
if (!world_to_screen(top, s_top))
|
||||
|
||||
@@ -26,6 +26,9 @@ void correct_movement(usercmd_t* cmd, vec3_t old_angles);
|
||||
extern visible_flags visible_mode;
|
||||
bool chams(void* this_ptr);
|
||||
|
||||
/* src/features/aim.c */
|
||||
void aimbot(usercmd_t* cmd);
|
||||
|
||||
/* src/features/misc.c */
|
||||
void custom_crosshair(void);
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ static void autostrafe_rage(usercmd_t* cmd) {
|
||||
i_engine->GetViewAngles(viewangles);
|
||||
|
||||
/* Get our desired angles and delta */
|
||||
float yaw = DEG2RAD(viewangles[1]);
|
||||
float vel_dir = atan2f(i_pmove->velocity[1], i_pmove->velocity[0]) - yaw;
|
||||
float yaw = DEG2RAD(viewangles.y);
|
||||
float vel_dir = atan2f(i_pmove->velocity.y, i_pmove->velocity.x) - yaw;
|
||||
float target_ang = atan2f(-cmd->sidemove, cmd->forwardmove);
|
||||
float delta = angle_delta_rad(vel_dir, target_ang);
|
||||
|
||||
@@ -101,8 +101,8 @@ void bhop(usercmd_t* cmd) {
|
||||
* https://github.com/deboogerxyz/ahc/blob/0492646e28dd7234a8cd431d37b152dc18a21b04/ahc.c#L377
|
||||
*/
|
||||
void correct_movement(usercmd_t* cmd, vec3_t old_angles) {
|
||||
float old_y = old_angles[1] + (old_angles[1] < 0 ? 360 : 0);
|
||||
float new_y = cmd->viewangles[1] + (cmd->viewangles[1] < 0 ? 360 : 0);
|
||||
float old_y = old_angles.y + (old_angles.y < 0 ? 360 : 0);
|
||||
float new_y = cmd->viewangles.y + (cmd->viewangles.y < 0 ? 360 : 0);
|
||||
float delta = (new_y < old_y) ? fabsf(new_y - old_y)
|
||||
: 360 - fabsf(new_y - old_y);
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
|
||||
enum game_id this_game_id = HL;
|
||||
|
||||
/* Bone origins of each player, updated in studiorendermodel */
|
||||
vec3_t g_bones[64][128];
|
||||
|
||||
void* hw;
|
||||
void** h_client;
|
||||
DECL_INTF(cl_enginefunc_t, engine);
|
||||
|
||||
@@ -58,6 +58,7 @@ void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) {
|
||||
localplayer = i_engine->GetLocalPlayer();
|
||||
|
||||
bhop(cmd);
|
||||
aimbot(cmd);
|
||||
|
||||
correct_movement(cmd, old_angles);
|
||||
vec_clamp(cmd->viewangles);
|
||||
@@ -80,6 +81,14 @@ int h_HUD_Redraw(float time, int intermission) {
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
void h_StudioRenderModel(void* this_ptr) {
|
||||
/* Update bones array */
|
||||
cl_entity_t* ent = i_enginestudio->GetCurrentEntity();
|
||||
bone_matrix* mat = (bone_matrix*)i_enginestudio->StudioGetBoneTransform();
|
||||
for (int i = 0; i < 128; i++) {
|
||||
const vec3_t bone_orig = matrix_3x4_origin((*mat)[i]);
|
||||
vec_copy(g_bones[ent->index][i], bone_orig);
|
||||
}
|
||||
|
||||
if (!chams(this_ptr))
|
||||
ORIGINAL(StudioRenderModel, this_ptr);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
#define DECL_CVAR_EXTERN(name) extern cvar_t* cv_##name;
|
||||
|
||||
#define REGISTER_CVAR(name, value) \
|
||||
i_engine->pfnRegisterVariable(CVAR_PREFIX name, value, CVAR_HACK_ID);
|
||||
cv_##name = \
|
||||
i_engine->pfnRegisterVariable(CVAR_PREFIX #name, #value, CVAR_HACK_ID);
|
||||
|
||||
#define CVAR_ON(name) (cv_##name->value != 0.0f)
|
||||
|
||||
@@ -31,6 +32,7 @@
|
||||
|
||||
DECL_CVAR_EXTERN(bhop);
|
||||
DECL_CVAR_EXTERN(autostrafe);
|
||||
DECL_CVAR_EXTERN(aimbot);
|
||||
DECL_CVAR_EXTERN(esp);
|
||||
DECL_CVAR_EXTERN(chams);
|
||||
DECL_CVAR_EXTERN(crosshair);
|
||||
|
||||
@@ -34,6 +34,7 @@ enum game_id {
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
extern game_id this_game_id;
|
||||
extern vec3_t g_bones[64][128];
|
||||
|
||||
extern void* hw;
|
||||
extern void** h_client; /* hClientDLL hander */
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "sdk/cl_dll/wrect.h"
|
||||
#include "sdk/cl_dll/cl_dll.h"
|
||||
|
||||
/* event_api_s */
|
||||
#include "sdk/common/event_api.h"
|
||||
|
||||
/* usercmd_t */
|
||||
#include "sdk/common/usercmd.h"
|
||||
|
||||
@@ -32,6 +35,9 @@
|
||||
/* engine_studio_api_t */
|
||||
#include "sdk/common/r_studioint.h"
|
||||
|
||||
typedef float matrix_3x4[3][4];
|
||||
typedef matrix_3x4 bone_matrix[128];
|
||||
|
||||
/*
|
||||
* Credits:
|
||||
* https://github.com/UnkwUsr/hlhax/blob/26491984996c8389efec977ed940c5a67a0ecca4/src/sdk.h#L45
|
||||
|
||||
@@ -14,13 +14,19 @@ typedef struct {
|
||||
uint8_t r, g, b;
|
||||
} rgb_t;
|
||||
|
||||
#define DEG2RAD(n) ((n)*M_PI / 180.0)
|
||||
#define DEG2RAD(n) ((n)*M_PI / 180.0f)
|
||||
#define RAD2DEG(n) ((n)*180.0f / M_PI)
|
||||
#define CLAMP(val, min, max) \
|
||||
(((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
|
||||
|
||||
#define gl_drawline_points(p0, p1, w, col) \
|
||||
gl_drawline(p0[0], p0[1], p1[0], p1[1], w, col);
|
||||
|
||||
#define vec_copy(dst, src) \
|
||||
dst.x = src.x; \
|
||||
dst.y = src.y; \
|
||||
dst.z = src.z;
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
cl_entity_t* get_player(int ent_idx);
|
||||
@@ -30,10 +36,15 @@ bool is_friend(cl_entity_t* ent);
|
||||
char* get_name(int ent_idx);
|
||||
game_id get_cur_game(void);
|
||||
vec3_t vec3(float x, float y, float z);
|
||||
vec3_t vec_add(vec3_t a, vec3_t b);
|
||||
vec3_t vec_sub(vec3_t a, vec3_t b);
|
||||
bool vec_is_zero(vec3_t v);
|
||||
float vec_len2d(vec3_t v);
|
||||
void vec_clamp(vec3_t v);
|
||||
void vec_norm(vec3_t v);
|
||||
float angle_delta_rad(float a, float b);
|
||||
vec3_t vec_to_ang(vec3_t v);
|
||||
vec3_t matrix_3x4_origin(matrix_3x4 m);
|
||||
bool world_to_screen(vec3_t vec, vec2_t screen);
|
||||
void engine_draw_text(int x, int y, char* s, rgb_t c);
|
||||
void gl_drawbox(int x, int y, int w, int h, rgb_t c);
|
||||
|
||||
60
src/util.c
60
src/util.c
@@ -93,15 +93,35 @@ game_id get_cur_game(void) {
|
||||
vec3_t vec3(float x, float y, float z) {
|
||||
vec3_t ret;
|
||||
|
||||
ret[0] = x;
|
||||
ret[1] = y;
|
||||
ret[2] = z;
|
||||
ret.x = x;
|
||||
ret.y = y;
|
||||
ret.z = z;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
vec3_t vec_add(vec3_t a, vec3_t b) {
|
||||
vec3_t ret;
|
||||
|
||||
ret.x = a.x + b.x;
|
||||
ret.y = a.y + b.y;
|
||||
ret.z = a.z + b.z;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
vec3_t vec_sub(vec3_t a, vec3_t b) {
|
||||
vec3_t ret;
|
||||
|
||||
ret.x = a.x - b.x;
|
||||
ret.y = a.y - b.y;
|
||||
ret.z = a.z - b.z;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool vec_is_zero(vec3_t v) {
|
||||
return v[0] == 0.0f && v[1] == 0.0f && v[2] == 0.0f;
|
||||
return v.x == 0.0f && v.y == 0.0f && v.z == 0.0f;
|
||||
}
|
||||
|
||||
float vec_len2d(vec3_t v) {
|
||||
@@ -109,9 +129,15 @@ float vec_len2d(vec3_t v) {
|
||||
}
|
||||
|
||||
void vec_clamp(vec3_t v) {
|
||||
v[0] = CLAMP(v[0], -89.0f, 89.0f);
|
||||
v[1] = CLAMP(remainderf(v[1], 360.0f), -180.0f, 180.0f); /* v.y % 360 */
|
||||
v[2] = CLAMP(v[2], -50.0f, 50.0f);
|
||||
v.x = CLAMP(v.x, -89.0f, 89.0f);
|
||||
v.y = CLAMP(remainderf(v.y, 360.0f), -180.0f, 180.0f); /* v.y % 360 */
|
||||
v.z = CLAMP(v.z, -50.0f, 50.0f);
|
||||
}
|
||||
|
||||
void vec_norm(vec3_t v) {
|
||||
v.x = isfinite(v.x) ? remainder(v.x, 360) : 0;
|
||||
v.y = isfinite(v.y) ? remainder(v.y, 360) : 0;
|
||||
v.z = 0.0f;
|
||||
}
|
||||
|
||||
float angle_delta_rad(float a, float b) {
|
||||
@@ -125,6 +151,26 @@ float angle_delta_rad(float a, float b) {
|
||||
return delta;
|
||||
}
|
||||
|
||||
vec3_t vec_to_ang(vec3_t v) {
|
||||
vec3_t ret;
|
||||
|
||||
ret.x = RAD2DEG(atan2(-v.z, hypot(v.x, v.y)));
|
||||
ret.y = RAD2DEG(atan2(v.y, v.x));
|
||||
ret.z = 0.0f;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
vec3_t matrix_3x4_origin(matrix_3x4 m) {
|
||||
vec3_t ret;
|
||||
|
||||
ret.x = m[0][3];
|
||||
ret.y = m[1][3];
|
||||
ret.z = m[2][3];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool world_to_screen(vec3_t vec, vec2_t screen) {
|
||||
if (vec_is_zero(vec))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user