1 Commits

Author SHA1 Message Date
8dcc
1d7d974d88 Store bone positions inside array from StudioRenderModel 2023-07-30 15:11:26 +02:00
13 changed files with 20 additions and 128 deletions

View File

@@ -25,7 +25,6 @@ Also make sure to check out [[https://github.com/deboogerxyz/ahc][deboogerxyz/ah
| ESP | =cv_esp= | off/3d-box/name/all |
| Chams | =cv_chams= | off/players/hands/all* |
| Crosshair | =cv_crosshair= | off/length |
| Tracers | =cv_tracers= | off/on* |
#+begin_quote
@@ -38,11 +37,6 @@ Also make sure to check out [[https://github.com/deboogerxyz/ahc][deboogerxyz/ah
console variables than more customization at runtime.
#+end_quote
#+begin_quote
*Note:* Bullet tracer color, width and time can be changed at the bottom of the
=bullet_tracers()= function inside [[https://github.com/8dcc/hl-cheat/blob/main/src/features/misc.c][src/features/misc.c]]. See previous chams note.
#+end_quote
* Building
#+begin_src console
$ git clone --recurse-submodules https://github.com/8dcc/hl-cheat

View File

@@ -9,7 +9,6 @@ DECL_CVAR(aimbot);
DECL_CVAR(esp);
DECL_CVAR(chams);
DECL_CVAR(crosshair);
DECL_CVAR(tracers);
DECL_CVAR(clmove);
bool cvars_init(void) {
@@ -19,7 +18,6 @@ bool cvars_init(void) {
REGISTER_CVAR(esp, 3);
REGISTER_CVAR(chams, 1);
REGISTER_CVAR(crosshair, 0);
REGISTER_CVAR(tracers, 0);
REGISTER_CVAR(clmove, 0);
return true;

View File

@@ -9,36 +9,11 @@
/* Game units to add to the entity origin to get the head */
#define HEAD_OFFSET 0.8f
/* Scale factor for aim punch */
#define AIM_PUNCH_MULT 2
static bool is_visible(vec3_t start, vec3_t end) {
/* Syntax: PM_TraceLine(start, end, flags, usehulll, ignore_pe); */
pmtrace_t* tr =
i_engine->PM_TraceLine(start, end, PM_TRACELINE_PHYSENTSONLY, 2, -1);
/* We didn't hit a valid entity */
if (tr->ent <= 0)
return false;
/* Get entity index from physents, check if we can't get a valid player */
const int ent_idx = i_pmove->physents[tr->ent].info;
if (!get_player(ent_idx))
return false;
/* We hit a valid player */
return true;
}
static vec3_t get_closest_delta(vec3_t viewangles) {
/* Compensate aim punch. We get g_punchAngles from CalcRefdef hook */
viewangles.x += g_punchAngles.x * AIM_PUNCH_MULT;
viewangles.y += g_punchAngles.y * AIM_PUNCH_MULT;
viewangles.z += g_punchAngles.z * AIM_PUNCH_MULT;
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 */
@@ -53,11 +28,9 @@ static vec3_t get_closest_delta(vec3_t viewangles) {
/* TODO: Get bones origin instead of calculating from ent origin */
const vec3_t head_pos = vec_add(ent->origin, vec3(0, 0, HEAD_OFFSET));
if (!is_visible(local_eyes, head_pos)) /* We can't see player */
continue;
const vec3_t enemy_angle = vec_to_ang(vec_sub(head_pos, local_eyes));
const vec3_t delta = vec_sub(enemy_angle, viewangles);
const vec3_t delta = vec_sub(enemy_angle, viewangles);
vec_norm(delta);
float fov = hypotf(delta.x, delta.y);

View File

@@ -31,6 +31,5 @@ void aimbot(usercmd_t* cmd);
/* src/features/misc.c */
void custom_crosshair(void);
void bullet_tracers(usercmd_t* cmd);
#endif /* FEATURES_H_ */

View File

@@ -29,29 +29,3 @@ void custom_crosshair(void) {
gl_drawline(mx - gap, my + gap, mx - gap - len, my + gap + len, w, col);
gl_drawline(mx + gap, my + gap, mx + gap + len, my + gap + len, w, col);
}
void bullet_tracers(usercmd_t* cmd) {
/* Only draw if we are holding attack and we can shoot */
if (!CVAR_ON(tracers) || !(cmd->buttons & IN_ATTACK) || !can_shoot())
return;
/* Get player eye pos, start of tracer */
vec3_t view_height;
i_engine->pEventAPI->EV_LocalPlayerViewheight(view_height);
vec3_t local_eyes = vec_add(localplayer->origin, view_height);
/* Get forward vector from viewangles */
vec3_t fwd;
i_engine->pfnAngleVectors(cmd->viewangles, fwd, NULL, NULL);
const int tracer_len = 3000;
vec3_t end;
end.x = local_eyes.x + fwd.x * tracer_len;
end.y = local_eyes.y + fwd.y * tracer_len;
end.z = local_eyes.z + fwd.z * tracer_len;
/* NOTE: Change tracer settings here */
const float w = 0.8;
const float time = 2;
draw_tracer(local_eyes, end, (rgb_t){ 66, 165, 245 }, 1, w, time);
}

View File

@@ -8,9 +8,10 @@
#include "include/sdk.h"
#include "include/util.h"
game_id this_game_id = HL;
vec3_t g_punchAngles = { 0, 0, 0 };
float g_flNextAttack = 0.f, g_flNextPrimaryAttack = 0.f;
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;

View File

@@ -11,8 +11,6 @@
DECL_HOOK(CL_CreateMove);
DECL_HOOK(HUD_Redraw);
DECL_HOOK(StudioRenderModel);
DECL_HOOK(CalcRefdef);
DECL_HOOK(HUD_PostRunCmd);
/* OpenGL hooks */
DECL_HOOK(glColor4f);
@@ -29,8 +27,6 @@ bool hooks_init(void) {
HOOK(i_client, CL_CreateMove);
HOOK(i_client, HUD_Redraw);
HOOK(i_studiomodelrenderer, StudioRenderModel);
HOOK(i_client, CalcRefdef);
HOOK(i_client, HUD_PostRunCmd);
/* OpenGL hooks */
GL_HOOK(glColor4f);
@@ -63,7 +59,6 @@ void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) {
bhop(cmd);
aimbot(cmd);
bullet_tracers(cmd);
correct_movement(cmd, old_angles);
vec_clamp(cmd->viewangles);
@@ -86,36 +81,20 @@ 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);
}
/*----------------------------------------------------------------------------*/
void h_CalcRefdef(ref_params_t* params) {
/* Store punch angles for CreateMove */
vec_copy(g_punchAngles, params->punchangle);
ORIGINAL(CalcRefdef, params);
}
/*----------------------------------------------------------------------------*/
void h_HUD_PostRunCmd(struct local_state_s* from, struct local_state_s* to,
struct usercmd_s* cmd, int runfuncs, double time,
unsigned int random_seed) {
ORIGINAL(HUD_PostRunCmd, from, to, cmd, runfuncs, time, random_seed);
/* Store attack information to check if we can shoot */
if (runfuncs) {
g_flNextAttack = to->client.m_flNextAttack;
g_flNextPrimaryAttack =
to->weapondata[to->client.m_iId].m_flNextPrimaryAttack;
}
}
/*----------------------------------------------------------------------------*/
void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
/* This visible_mode variable is changed inside the chams() function, which
* is called from the StudioRenderModel hook.

View File

@@ -36,7 +36,6 @@ DECL_CVAR_EXTERN(aimbot);
DECL_CVAR_EXTERN(esp);
DECL_CVAR_EXTERN(chams);
DECL_CVAR_EXTERN(crosshair);
DECL_CVAR_EXTERN(tracers);
DECL_CVAR_EXTERN(clmove);
/*----------------------------------------------------------------------------*/

View File

@@ -34,8 +34,7 @@ enum game_id {
/*----------------------------------------------------------------------------*/
extern game_id this_game_id;
extern vec3_t g_punchAngles;
extern float g_flNextAttack, g_flNextPrimaryAttack;
extern vec3_t g_bones[64][128];
extern void* hw;
extern void** h_client; /* hClientDLL hander */

View File

@@ -95,10 +95,6 @@ void hooks_restore(void);
DECL_HOOK_EXTERN(void, CL_CreateMove, float, usercmd_t*, int);
DECL_HOOK_EXTERN(int, HUD_Redraw, float, int);
DECL_HOOK_EXTERN(void, StudioRenderModel, void*);
DECL_HOOK_EXTERN(void, CalcRefdef, ref_params_t*);
DECL_HOOK_EXTERN(void, HUD_PostRunCmd, struct local_state_s*,
struct local_state_s*, struct usercmd_s*, int, double,
unsigned int);
/* OpenGL hooks */
DECL_HOOK_EXTERN(void, glColor4f, GLfloat, GLfloat, GLfloat, GLfloat);

View File

@@ -62,7 +62,7 @@ typedef struct cl_clientfuncs_s {
void (*CL_CameraOffset)(float* ofs);
struct kbutton_s* (*KB_Find)(const char* name);
void (*CAM_Think)(void);
void (*CalcRefdef)(struct ref_params_s* pparams);
void (*V_CalcRefdef)(struct ref_params_s* pparams);
int (*HUD_AddEntity)(int type, struct cl_entity_s* ent,
const char* modelname);

View File

@@ -22,11 +22,10 @@ typedef struct {
#define gl_drawline_points(p0, p1, w, col) \
gl_drawline(p0[0], p0[1], p1[0], p1[1], w, col);
/* Use indexes so it works for float[] as well as vec3_t */
#define vec_copy(dst, src) \
dst[0] = src[0]; \
dst[1] = src[1]; \
dst[2] = src[2];
dst.x = src.x; \
dst.y = src.y; \
dst.z = src.z;
/*----------------------------------------------------------------------------*/
@@ -34,7 +33,6 @@ cl_entity_t* get_player(int ent_idx);
bool is_alive(cl_entity_t* ent);
bool valid_player(cl_entity_t* ent);
bool is_friend(cl_entity_t* ent);
bool can_shoot(void);
char* get_name(int ent_idx);
game_id get_cur_game(void);
vec3_t vec3(float x, float y, float z);
@@ -49,7 +47,6 @@ 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 draw_tracer(vec3_t start, vec3_t end, rgb_t c, float a, float w, float t);
void gl_drawbox(int x, int y, int w, int h, rgb_t c);
void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col);
bool protect_addr(void* ptr, int new_flags);

View File

@@ -63,10 +63,6 @@ bool is_friend(cl_entity_t* ent) {
}
}
bool can_shoot(void) {
return g_flNextAttack <= 0.0f && g_flNextPrimaryAttack <= 0.0f;
}
char* get_name(int ent_idx) {
hud_player_info_t info;
i_engine->pfnGetPlayerInfo(ent_idx, &info);
@@ -208,19 +204,6 @@ void engine_draw_text(int x, int y, char* s, rgb_t c) {
i_engine->pfnDrawConsoleString(x, y, s);
}
void draw_tracer(vec3_t start, vec3_t end, rgb_t c, float a, float w,
float time) {
static const char* MDL_STR = "sprites/laserbeam.spr";
static int beam_idx = i_engine->pEventAPI->EV_FindModelIndex(MDL_STR);
float r = c.r / 255.f;
float g = c.g / 255.f;
float b = c.b / 255.f;
i_engine->pEfxAPI->R_BeamPoints(start, end, beam_idx, time, w, 0, a, 0, 0,
0, r, g, b);
}
void gl_drawbox(int x, int y, int w, int h, rgb_t c) {
/* Line width */
const int lw = 1;