17 Commits

Author SHA1 Message Date
Wizzard
1f3e531610 Revert "Fix cvars not showing up"
This reverts commit 0e7f955c7d.
2023-09-19 10:55:51 -04:00
Wizzard
0e7f955c7d Fix cvars not showing up 2023-09-19 10:54:04 -04:00
Wizzard
f0485a3f36 Change cvar from 'cv_' to 'dz_' 2023-09-19 10:45:57 -04:00
Wizzard
02888c1158 Fix links 2023-09-19 10:42:56 -04:00
Wizzard
b9851de177 Fix readme 2023-09-19 10:40:05 -04:00
Wizzard
56f8ae79d7 Added cv_watermark 2023-09-19 10:38:01 -04:00
8dcc
f9db9ff1b6 Change value of cl_forwardspeed 2023-08-05 00:50:28 +02:00
8dcc
29a40f63da Add missing unload to include 2023-08-01 19:53:43 +02:00
8dcc
b7c6e74dd4 README - Add supported games 2023-08-01 13:35:36 +02:00
8dcc
510243c46d Add can_shoot to aimbot 2023-07-31 20:57:25 +02:00
8dcc
fb6ed02dd4 Add clip check to can_shoot 2023-07-31 20:10:45 +02:00
8dcc
42a7961142 Store clip from HUD_PostRunCmd 2023-07-31 20:10:27 +02:00
8dcc
da6cf86910 README - Add autoshoot to features 2023-07-31 18:06:21 +02:00
8dcc
3414d131f4 Add autoshoot
If this cvar is enabled (1), and the aimbot is enabled (fov>0), it will
stop attacking if there is no visible target.
2023-07-31 18:03:26 +02:00
8dcc
83278b9983 Change head offset if crouched 2023-07-31 18:03:14 +02:00
8dcc
4bb21a4ca6 Fix fov calculations, fix aimbot head offset 2023-07-31 17:40:01 +02:00
8dcc
51c302f492 Add alive check to localplayer 2023-07-31 16:10:47 +02:00
15 changed files with 90 additions and 57 deletions

View File

@@ -1,14 +1,20 @@
#+title: Half-Life cheat
#+options: toc:nil
#+startup: showeverything
#+author: 8dcc
#+author: Wizzard (Original arthur: [[https://github.com/8dcc/][8dcc]])
*Linux cheat for Half-Life 1 (and goldsrc).*
*Linux cheat for goldsrc games.*
#+TOC: headlines 2
* Description
Simple linux cheat for Half-Life 1 (and most /goldsrc/ games) made in C.
Simple linux cheat for most goldsrc games, made in C.
Supported games:
- [[https://store.steampowered.com/app/70/HalfLife/][Half-Life 1]]
- [[https://store.steampowered.com/app/10/CounterStrike/][Counter-Strike 1.6]]
- [[https://store.steampowered.com/app/20/Team_Fortress_Classic/][Team Fortress Classic]]
- [[https://store.steampowered.com/app/30/Day_of_Defeat/][Day of Defeat]]
This project was heavily inspired by [[https://github.com/UnkwUsr/hlhax][UnkwUsr/hlhax]], and would not have been
possible without his help. Make sure to check out his repo too.
@@ -19,34 +25,40 @@ 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 |
| Chams | =cv_chams= | off/players/hands/all* |
| Crosshair | =cv_crosshair= | off/length |
| Tracers | =cv_tracers= | off/on* |
| Bhop | =dz_bhop= | off/on |
| Autostrafe | =dz_autostrafe= | off/rage/legit |
| Aimbot | =dz_aimbot= | off/fov* |
| Autoshoot | =dz_autoshoot= | off/on* |
| ESP | =dz_esp= | off/3d-box/name/all |
| Chams | =dz_chams= | off/players/hands/all* |
| Crosshair | =dz_crosshair= | off/length |
| Tracers | =dz_tracers= | off/on* |
#+begin_quote
*Note:* Aimbot FOV goes from 0 (off) to 180 (all enemies)
#+end_quote
#+begin_quote
*Note:* If =dz_autoshoot= is enabled, and =dz_aimbot= is enabled, it will stop
attacking if there is no visible target.
#+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
[[https://git.deadzone.lol/Wizzard/goldsource-cheat/src/branch/main/src/hooks.c][src/hooks.c]]. Since this cheat is not hard to compile, I rather have less
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.
=bullet_tracers()= function inside [[https://git.deadzone.lol/Wizzard/goldsource-cheat/src/branch/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
$ cd hl-cheat
$ git clone --recurse-submodules https://git.deadzone.lol/Wizzard/goldsource-cheat
$ cd goldsource-cheat
$ make
...
#+end_src
@@ -55,7 +67,7 @@ Note that you will need to clone with =--recurse-submodules= for the sdk. If you
have already cloned it, you can just:
#+begin_src console
$ cd hl-cheat
$ cd goldsource-cheat
$ git submodule update --init --recursive
#+end_src
@@ -68,5 +80,5 @@ $ ./injector.sh
...
hl-cheat loaded!
goldsource-cheat loaded!
#+end_src

View File

@@ -30,7 +30,7 @@ if [ "$1" == "unload" ]; then
fi
if grep -q "$libpath" "/proc/$pid/maps"; then
echo -e "hl-cheat already loaded. Reloading...\n";
echo -e "goldsource-cheat already loaded. Reloading...\n";
# 0x2 -> RTLD_NOW
# 0x6 -> RTLD_LAZY | RTLD_NOLOAD

View File

@@ -6,21 +6,25 @@
DECL_CVAR(bhop);
DECL_CVAR(autostrafe);
DECL_CVAR(aimbot);
DECL_CVAR(autoshoot);
DECL_CVAR(esp);
DECL_CVAR(chams);
DECL_CVAR(crosshair);
DECL_CVAR(tracers);
DECL_CVAR(clmove);
DECL_CVAR(watermark);
bool cvars_init(void) {
REGISTER_CVAR(bhop, 1);
REGISTER_CVAR(autostrafe, 0);
REGISTER_CVAR(autostrafe, 1);
REGISTER_CVAR(aimbot, 0);
REGISTER_CVAR(autoshoot, 0); /* Only works with aimbot enabled */
REGISTER_CVAR(esp, 3);
REGISTER_CVAR(chams, 1);
REGISTER_CVAR(crosshair, 0);
REGISTER_CVAR(tracers, 0);
REGISTER_CVAR(tracers, 1);
REGISTER_CVAR(clmove, 0);
REGISTER_CVAR(watermark, 1);
return true;
}

View File

@@ -7,7 +7,7 @@
#include "../include/util.h"
/* Game units to add to the entity origin to get the head */
#define HEAD_OFFSET 0.8f
#define HEAD_OFFSET 25.f
/* Scale factor for aim punch */
#define AIM_PUNCH_MULT 2
@@ -42,7 +42,7 @@ static vec3_t get_closest_delta(vec3_t viewangles) {
/* 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;
float best_fov = dz_aimbot->value;
vec3_t best_delta = { 0, 0, 0 };
for (int i = 1; i <= i_engine->GetMaxClients(); i++) {
@@ -52,7 +52,10 @@ static vec3_t get_closest_delta(vec3_t viewangles) {
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));
vec3_t head_pos = ent->origin;
if (ent->curstate.usehull != 1) /* Get head if not crouched */
head_pos.z += HEAD_OFFSET;
if (!is_visible(local_eyes, head_pos)) /* We can't see player */
continue;
@@ -61,11 +64,10 @@ static vec3_t get_closest_delta(vec3_t viewangles) {
vec_norm(delta);
float fov = hypotf(delta.x, delta.y);
if (fov > 360.0f) {
if (fov > 360.0f)
fov = remainderf(fov, 360.0f);
if (fov > 180.0f)
fov = 360.0f - fov;
}
if (fov > 180.0f)
fov = 360.0f - fov;
if (fov < best_fov) {
best_fov = fov;
@@ -77,7 +79,7 @@ static vec3_t get_closest_delta(vec3_t viewangles) {
}
void aimbot(usercmd_t* cmd) {
if (!CVAR_ON(aimbot) || !(cmd->buttons & IN_ATTACK))
if (!CVAR_ON(aimbot) || !(cmd->buttons & IN_ATTACK) || !can_shoot())
return;
/* Calculate delta with the engine viewangles, not with the cmd ones */
@@ -92,6 +94,9 @@ void aimbot(usercmd_t* cmd) {
engine_viewangles.x += best_delta.x;
engine_viewangles.y += best_delta.y;
engine_viewangles.z += best_delta.z;
} else if (CVAR_ON(autoshoot)) {
/* No valid target and we have autoshoot, don't shoot */
cmd->buttons &= ~IN_ATTACK;
}
vec_copy(cmd->viewangles, engine_viewangles);

View File

@@ -15,7 +15,7 @@ enum chams_settings {
visible_flags visible_mode;
bool chams(void* this_ptr) {
const int setting = cv_chams->value == 5.0f ? 7 : cv_chams->value;
const int setting = dz_chams->value == 5.0f ? 7 : dz_chams->value;
if (setting == DISABLED)
return false;

View File

@@ -5,7 +5,7 @@
#include "../include/cvars.h"
#include "../include/util.h"
/* For cv_esp */
/* For dz_esp */
enum esp_values {
ESP_OFF = 0,
ESP_BOX = 1,
@@ -98,7 +98,7 @@ static bool gl_draw2dbox(vec3_t o, int bh) {
}
void esp(void) {
const int setting = (int)cv_esp->value;
const int setting = (int)dz_esp->value;
if (setting == ESP_OFF)
return;

View File

@@ -14,7 +14,7 @@ void custom_crosshair(void) {
int my = game_info->m_height / 2;
/* The real length is sqrt(2 * (len^2)) */
const int len = cv_crosshair->value;
const int len = dz_crosshair->value;
const int gap = 1;
const float w = 1;
const rgb_t col = { 255, 255, 255 };
@@ -32,7 +32,8 @@ void custom_crosshair(void) {
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())
if (!CVAR_ON(tracers) || !(cmd->buttons & IN_ATTACK) || !can_shoot() ||
!is_alive(localplayer))
return;
/* Get player eye pos, start of tracer */

View File

@@ -31,7 +31,7 @@ static void autostrafe_rage(usercmd_t* cmd) {
/* TODO: Get at runtime */
const float sv_airaccelerate = 10.0f;
const float sv_maxspeed = 320.0f;
const float cl_forwardspeed = 400.0f;
const float cl_forwardspeed = 425.0f;
const float cl_sidespeed = 400.0f;
float speed = vec_len2d(i_pmove->velocity);
@@ -82,7 +82,7 @@ void bhop(usercmd_t* cmd) {
/* Autostrafe if enabled. Check if we are in the air and holding space. */
if (is_jumping) {
switch ((int)cv_autostrafe->value) {
switch ((int)dz_autostrafe->value) {
case 1:
autostrafe_rage(cmd);
break;

View File

@@ -10,7 +10,10 @@
game_id this_game_id = HL;
vec3_t g_punchAngles = { 0, 0, 0 };
/* Weapon info */
float g_flNextAttack = 0.f, g_flNextPrimaryAttack = 0.f;
int g_iClip = 0;
void* hw;
void** h_client;
@@ -39,13 +42,13 @@ bool globals_init(void) {
*/
hw = dlopen("hw.so", RTLD_LAZY | RTLD_NOLOAD);
if (!hw) {
printf("hl-cheat: globals_init: can't open hw.so\n");
printf("goldsource-cheat: globals_init: can't open hw.so\n");
return false;
}
h_client = (void**)dlsym(hw, "hClientDLL");
if (!h_client) {
printf("hl-cheat: globals_init: can't find hClientDLL\n");
printf("goldsource-cheat: globals_init: can't find hClientDLL\n");
return false;
}
@@ -64,12 +67,12 @@ bool globals_init(void) {
if (!i_engine || !i_client || !i_pmove || !i_enginestudio ||
!i_studiomodelrenderer || !game_info) {
printf("hl-cheat: globals_init: couldn't load some symbols\n");
printf("goldsource-cheat: globals_init: couldn't load some symbols\n");
return false;
}
if (!protect_addr(i_studiomodelrenderer, PROT_READ | PROT_WRITE)) {
printf("hl-cheat: globals_init: couldn't unprotect address of SMR\n");
printf("goldsource-cheat: globals_init: couldn't unprotect address of SMR\n");
return false;
}

View File

@@ -74,8 +74,10 @@ void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) {
int h_HUD_Redraw(float time, int intermission) {
int ret = ORIGINAL(HUD_Redraw, time, intermission);
/* Watermark */
engine_draw_text(5, 5, "8dcc/hl-cheat", (rgb_t){ 255, 255, 255 });
if (dz_watermark->value) {
/* Watermark */
engine_draw_text(5, 5, "https://git.deadzone.lol/Wizzard/goldsource-cheat", (rgb_t){ 0, 255, 255 });
}
esp();
custom_crosshair();
@@ -111,6 +113,7 @@ void h_HUD_PostRunCmd(struct local_state_s* from, struct local_state_s* to,
g_flNextAttack = to->client.m_flNextAttack;
g_flNextPrimaryAttack =
to->weapondata[to->client.m_iId].m_flNextPrimaryAttack;
g_iClip = to->weapondata[to->client.m_iId].m_iClip;
}
}
@@ -161,8 +164,8 @@ void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
/*----------------------------------------------------------------------------*/
void h_CL_Move() {
if (cv_clmove->value != 0) {
for (int i = 0; i < (int)cv_clmove->value; i++)
if (dz_clmove->value != 0) {
for (int i = 0; i < (int)dz_clmove->value; i++)
CALL_ORIGINAL(detour_data_clmove, clmove_type);
}

View File

@@ -5,7 +5,7 @@
#include "sdk.h"
#include "globals.h"
#define CVAR_PREFIX "cv_"
#define CVAR_PREFIX "dz_"
#define CVAR_HACK_ID 0x4000 /* (1<<14) One that is not in use by the game */
/*
@@ -16,28 +16,30 @@
*
* prefix | meaning
* -------+-------------------------------
* cv_* | cvar variable
* dz_* | cvar variable
*/
#define DECL_CVAR(name) cvar_t* cv_##name = NULL;
#define DECL_CVAR(name) cvar_t* dz_##name = NULL;
#define DECL_CVAR_EXTERN(name) extern cvar_t* cv_##name;
#define DECL_CVAR_EXTERN(name) extern cvar_t* dz_##name;
#define REGISTER_CVAR(name, value) \
cv_##name = \
dz_##name = \
i_engine->pfnRegisterVariable(CVAR_PREFIX #name, #value, CVAR_HACK_ID);
#define CVAR_ON(name) (cv_##name->value != 0.0f)
#define CVAR_ON(name) (dz_##name->value != 0.0f)
/*----------------------------------------------------------------------------*/
DECL_CVAR_EXTERN(bhop);
DECL_CVAR_EXTERN(autostrafe);
DECL_CVAR_EXTERN(aimbot);
DECL_CVAR_EXTERN(autoshoot);
DECL_CVAR_EXTERN(esp);
DECL_CVAR_EXTERN(chams);
DECL_CVAR_EXTERN(crosshair);
DECL_CVAR_EXTERN(tracers);
DECL_CVAR_EXTERN(clmove);
DECL_CVAR_EXTERN(watermark);
/*----------------------------------------------------------------------------*/

View File

@@ -36,6 +36,7 @@ enum game_id {
extern game_id this_game_id;
extern vec3_t g_punchAngles;
extern float g_flNextAttack, g_flNextPrimaryAttack;
extern int g_iClip;
extern void* hw;
extern void** h_client; /* hClientDLL hander */

View File

@@ -3,6 +3,7 @@
#define MAIN_H_
void load(void);
void unload(void);
void self_unload(void);
#endif /* MAIN_H_ */

View File

@@ -13,25 +13,25 @@ static bool loaded = false;
__attribute__((constructor)) /* Entry point when injected */
void load(void) {
printf("hl-cheat injected!\n");
printf("goldsource-cheat injected!\n");
/* Initialize globals/interfaces */
if (!globals_init()) {
fprintf(stderr, "hl-cheat: load: error loading globals, aborting\n");
fprintf(stderr, "goldsource-cheat: load: error loading globals, aborting\n");
self_unload();
return;
}
/* Create cvars for settings */
if (!cvars_init()) {
fprintf(stderr, "hl-cheat: load: error creating cvars, aborting\n");
fprintf(stderr, "goldsource-cheat: load: error creating cvars, aborting\n");
self_unload();
return;
}
/* Hook functions */
if (!hooks_init()) {
fprintf(stderr, "hl-cheat: load: error hooking functions, aborting\n");
fprintf(stderr, "goldsource-cheat: load: error hooking functions, aborting\n");
self_unload();
return;
}
@@ -39,13 +39,13 @@ void load(void) {
/* Get game version after injecting */
this_game_id = get_cur_game();
i_engine->pfnClientCmd("echo \"hl-cheat loaded successfully!\"");
i_engine->pfnClientCmd("echo \"goldsource-cheat loaded successfully!\"");
loaded = true;
}
__attribute__((destructor)) /* Entry point when unloaded */
void unload() {
void unload(void) {
if (loaded) {
/* TODO: Remove our cvars */
@@ -55,7 +55,7 @@ void unload() {
GL_UNHOOK(glColor4f); /* Manually restore OpenGL hooks here */
}
printf("hl-cheat unloaded.\n\n");
printf("goldsource-cheat unloaded.\n\n");
}
void self_unload(void) {

View File

@@ -64,7 +64,8 @@ bool is_friend(cl_entity_t* ent) {
}
bool can_shoot(void) {
return g_flNextAttack <= 0.0f && g_flNextPrimaryAttack <= 0.0f;
return g_iClip > 0 && g_flNextAttack <= 0.0f &&
g_flNextPrimaryAttack <= 0.0f;
}
char* get_name(int ent_idx) {
@@ -270,7 +271,7 @@ bool protect_addr(void* ptr, int new_flags) {
int pgsz = getpagesize();
if (mprotect(p, pgsz, new_flags) == -1) {
printf("hl-cheat: error protecting %p\n", ptr);
printf("goldsource-cheat: error protecting %p\n", ptr);
return false;
}