Compare commits
	
		
			1 Commits
		
	
	
		
			c7ee48dfa6
			...
			bone_posit
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 1d7d974d88 | 
							
								
								
									
										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) | CFLAGS=-Wall -Wextra -Wno-write-strings -m32 -fPIC $(INCLUDES) | ||||||
| LDFLAGS=-lm | 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/aim.c.o obj/features/misc.c.o obj/game_detection.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 | BIN=libhlcheat.so | ||||||
|  |  | ||||||
| .PHONY: clean all inject | .PHONY: clean all inject | ||||||
|   | |||||||
							
								
								
									
										50
									
								
								README.org
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								README.org
									
									
									
									
									
								
							| @@ -1,20 +1,14 @@ | |||||||
| #+title: Half-Life cheat | #+title: Half-Life cheat | ||||||
| #+options: toc:nil | #+options: toc:nil | ||||||
| #+startup: showeverything | #+startup: showeverything | ||||||
| #+author: Wizzard (Original arthur: [[https://github.com/8dcc/][8dcc]]) | #+author: 8dcc | ||||||
|  |  | ||||||
| *Linux cheat for goldsrc games.* | *Linux cheat for Half-Life 1 (and goldsrc).* | ||||||
|  |  | ||||||
| #+TOC: headlines 2 | #+TOC: headlines 2 | ||||||
|  |  | ||||||
| * Description | * Description | ||||||
| Simple linux cheat for most goldsrc games, made in C. | Simple linux cheat for Half-Life 1 (and 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 | 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. | possible without his help. Make sure to check out his repo too. | ||||||
| @@ -25,44 +19,28 @@ Also make sure to check out [[https://github.com/deboogerxyz/ahc][deboogerxyz/ah | |||||||
|  |  | ||||||
| | Feature    | Command       | Values (0..n)          | | | Feature    | Command       | Values (0..n)          | | ||||||
| |------------+---------------+------------------------| | |------------+---------------+------------------------| | ||||||
| | Bhop       | =dz_bhop=       | off/on                 | | | Bhop       | =cv_bhop=       | off/on                 | | ||||||
| | Autostrafe | =dz_autostrafe= | off/rage/legit         | | | Autostrafe | =cv_autostrafe= | off/rage/legit         | | ||||||
| | Aimbot     | =dz_aimbot=     | off/fov*               | | | Aimbot     | =cv_aimbot=     | off/fov*               | | ||||||
| | Autoshoot  | =dz_autoshoot=  | off/on*                | | | ESP        | =cv_esp=        | off/3d-box/name/all    | | ||||||
| | ESP        | =dz_esp=        | off/3d-box/name/all    | | | Chams      | =cv_chams=      | off/players/hands/all* | | ||||||
| | Chams      | =dz_chams=      | off/players/hands/all* | | | Crosshair  | =cv_crosshair=  | off/length             | | ||||||
| | Crosshair  | =dz_crosshair=  | off/length             | |  | ||||||
| | Tracers    | =dz_tracers=    | off/on*                | |  | ||||||
|  |  | ||||||
|  |  | ||||||
| #+begin_quote | #+begin_quote | ||||||
| *Note:* Aimbot FOV goes from 0 (off) to 180 (all enemies) | *Note:* Aimbot FOV goes from 0 (off) to 180 (all enemies) | ||||||
| #+end_quote | #+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 | #+begin_quote | ||||||
| *Note:* Chams color can be changed from the =h_glColor4f()= function inside | *Note:* Chams color can be changed from the =h_glColor4f()= function inside | ||||||
| [[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 | [[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 | ||||||
| console variables than more customization at runtime. | console variables than more customization at runtime. | ||||||
| #+end_quote | #+end_quote | ||||||
|  |  | ||||||
| #+begin_quote |  | ||||||
| *Note:* Bullet tracer color, width and time can be changed at the bottom of the |  | ||||||
| =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 |  | ||||||
|  |  | ||||||
| #+begin_quote |  | ||||||
| *Note:* You can disable the watermark with dz_watermark 0 |  | ||||||
| #+end_quote |  | ||||||
|  |  | ||||||
| * Building | * Building | ||||||
| #+begin_src console | #+begin_src console | ||||||
| $ git clone --recurse-submodules https://git.deadzone.lol/Wizzard/goldsource-cheat | $ git clone --recurse-submodules https://github.com/8dcc/hl-cheat | ||||||
| $ cd goldsource-cheat | $ cd hl-cheat | ||||||
| $ make | $ make | ||||||
| ... | ... | ||||||
| #+end_src | #+end_src | ||||||
| @@ -71,7 +49,7 @@ Note that you will need to clone with =--recurse-submodules= for the sdk. If you | |||||||
| have already cloned it, you can just: | have already cloned it, you can just: | ||||||
|  |  | ||||||
| #+begin_src console | #+begin_src console | ||||||
| $ cd goldsource-cheat | $ cd hl-cheat | ||||||
| $ git submodule update --init --recursive | $ git submodule update --init --recursive | ||||||
| #+end_src | #+end_src | ||||||
|  |  | ||||||
| @@ -84,5 +62,5 @@ $ ./injector.sh | |||||||
|  |  | ||||||
| ... | ... | ||||||
|  |  | ||||||
| goldsource-cheat loaded! | hl-cheat loaded! | ||||||
| #+end_src | #+end_src | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ if [ "$1" == "unload" ]; then | |||||||
| fi | fi | ||||||
|  |  | ||||||
| if grep -q "$libpath" "/proc/$pid/maps"; then | if grep -q "$libpath" "/proc/$pid/maps"; then | ||||||
|     echo -e "goldsource-cheat already loaded. Reloading...\n"; |     echo -e "hl-cheat already loaded. Reloading...\n"; | ||||||
|  |  | ||||||
|     # 0x2 -> RTLD_NOW |     # 0x2 -> RTLD_NOW | ||||||
|     # 0x6 -> RTLD_LAZY | RTLD_NOLOAD |     # 0x6 -> RTLD_LAZY | RTLD_NOLOAD | ||||||
|   | |||||||
| @@ -6,25 +6,19 @@ | |||||||
| DECL_CVAR(bhop); | DECL_CVAR(bhop); | ||||||
| DECL_CVAR(autostrafe); | DECL_CVAR(autostrafe); | ||||||
| DECL_CVAR(aimbot); | DECL_CVAR(aimbot); | ||||||
| DECL_CVAR(autoshoot); |  | ||||||
| DECL_CVAR(esp); | DECL_CVAR(esp); | ||||||
| DECL_CVAR(chams); | DECL_CVAR(chams); | ||||||
| DECL_CVAR(crosshair); | DECL_CVAR(crosshair); | ||||||
| DECL_CVAR(tracers); |  | ||||||
| DECL_CVAR(clmove); | DECL_CVAR(clmove); | ||||||
| DECL_CVAR(watermark); |  | ||||||
|  |  | ||||||
| bool cvars_init(void) { | bool cvars_init(void) { | ||||||
|     REGISTER_CVAR(bhop, 1); |     REGISTER_CVAR(bhop, 1); | ||||||
|     REGISTER_CVAR(autostrafe, 1); |     REGISTER_CVAR(autostrafe, 0); | ||||||
|     REGISTER_CVAR(aimbot, 0); |     REGISTER_CVAR(aimbot, 0); | ||||||
|     REGISTER_CVAR(autoshoot, 0); /* Only works with aimbot enabled */ |  | ||||||
|     REGISTER_CVAR(esp, 3); |     REGISTER_CVAR(esp, 3); | ||||||
|     REGISTER_CVAR(chams, 1); |     REGISTER_CVAR(chams, 1); | ||||||
|     REGISTER_CVAR(crosshair, 0); |     REGISTER_CVAR(crosshair, 0); | ||||||
|     REGISTER_CVAR(tracers, 1); |  | ||||||
|     REGISTER_CVAR(clmove, 0); |     REGISTER_CVAR(clmove, 0); | ||||||
|     REGISTER_CVAR(watermark, 1); |  | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,42 +7,17 @@ | |||||||
| #include "../include/util.h" | #include "../include/util.h" | ||||||
|  |  | ||||||
| /* Game units to add to the entity origin to get the head */ | /* Game units to add to the entity origin to get the head */ | ||||||
| #define HEAD_OFFSET 25.f | #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) { | 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; |     vec3_t view_height; | ||||||
|     i_engine->pEventAPI->EV_LocalPlayerViewheight(view_height); |     i_engine->pEventAPI->EV_LocalPlayerViewheight(view_height); | ||||||
|     vec3_t local_eyes = vec_add(localplayer->origin, 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. |     /* These 2 vars are used to store the best target across iterations. | ||||||
|      * NOTE: The default value of best_fov will be the aimbot fov */ |      * NOTE: The default value of best_fov will be the aimbot fov */ | ||||||
|     float best_fov    = dz_aimbot->value; |     float best_fov    = cv_aimbot->value; | ||||||
|     vec3_t best_delta = { 0, 0, 0 }; |     vec3_t best_delta = { 0, 0, 0 }; | ||||||
|  |  | ||||||
|     for (int i = 1; i <= i_engine->GetMaxClients(); i++) { |     for (int i = 1; i <= i_engine->GetMaxClients(); i++) { | ||||||
| @@ -52,22 +27,18 @@ static vec3_t get_closest_delta(vec3_t viewangles) { | |||||||
|             continue; |             continue; | ||||||
|  |  | ||||||
|         /* TODO: Get bones origin instead of calculating from ent origin */ |         /* TODO: Get bones origin instead of calculating from ent origin */ | ||||||
|         vec3_t head_pos = ent->origin; |         const vec3_t head_pos = vec_add(ent->origin, vec3(0, 0, HEAD_OFFSET)); | ||||||
|         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; |  | ||||||
|  |  | ||||||
|         const vec3_t enemy_angle = vec_to_ang(vec_sub(head_pos, local_eyes)); |         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); |         vec_norm(delta); | ||||||
|  |  | ||||||
|         float fov = hypotf(delta.x, delta.y); |         float fov = hypotf(delta.x, delta.y); | ||||||
|         if (fov > 360.0f) |         if (fov > 360.0f) { | ||||||
|             fov = remainderf(fov, 360.0f); |             fov = remainderf(fov, 360.0f); | ||||||
|             if (fov > 180.0f) |             if (fov > 180.0f) | ||||||
|                 fov = 360.0f - fov; |                 fov = 360.0f - fov; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if (fov < best_fov) { |         if (fov < best_fov) { | ||||||
|             best_fov = fov; |             best_fov = fov; | ||||||
| @@ -79,7 +50,7 @@ static vec3_t get_closest_delta(vec3_t viewangles) { | |||||||
| } | } | ||||||
|  |  | ||||||
| void aimbot(usercmd_t* cmd) { | void aimbot(usercmd_t* cmd) { | ||||||
|     if (!CVAR_ON(aimbot) || !(cmd->buttons & IN_ATTACK) || !can_shoot()) |     if (!CVAR_ON(aimbot) || !(cmd->buttons & IN_ATTACK)) | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|     /* Calculate delta with the engine viewangles, not with the cmd ones */ |     /* Calculate delta with the engine viewangles, not with the cmd ones */ | ||||||
| @@ -94,9 +65,6 @@ void aimbot(usercmd_t* cmd) { | |||||||
|         engine_viewangles.x += best_delta.x; |         engine_viewangles.x += best_delta.x; | ||||||
|         engine_viewangles.y += best_delta.y; |         engine_viewangles.y += best_delta.y; | ||||||
|         engine_viewangles.z += best_delta.z; |         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); |     vec_copy(cmd->viewangles, engine_viewangles); | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ enum chams_settings { | |||||||
| visible_flags visible_mode; | visible_flags visible_mode; | ||||||
|  |  | ||||||
| bool chams(void* this_ptr) { | bool chams(void* this_ptr) { | ||||||
|     const int setting = dz_chams->value == 5.0f ? 7 : dz_chams->value; |     const int setting = cv_chams->value == 5.0f ? 7 : cv_chams->value; | ||||||
|     if (setting == DISABLED) |     if (setting == DISABLED) | ||||||
|         return false; |         return false; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include "../include/cvars.h" | #include "../include/cvars.h" | ||||||
| #include "../include/util.h" | #include "../include/util.h" | ||||||
|  |  | ||||||
| /* For dz_esp */ | /* For cv_esp */ | ||||||
| enum esp_values { | enum esp_values { | ||||||
|     ESP_OFF  = 0, |     ESP_OFF  = 0, | ||||||
|     ESP_BOX  = 1, |     ESP_BOX  = 1, | ||||||
| @@ -98,7 +98,7 @@ static bool gl_draw2dbox(vec3_t o, int bh) { | |||||||
| } | } | ||||||
|  |  | ||||||
| void esp(void) { | void esp(void) { | ||||||
|     const int setting = (int)dz_esp->value; |     const int setting = (int)cv_esp->value; | ||||||
|     if (setting == ESP_OFF) |     if (setting == ESP_OFF) | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,6 +31,5 @@ void aimbot(usercmd_t* cmd); | |||||||
|  |  | ||||||
| /* src/features/misc.c */ | /* src/features/misc.c */ | ||||||
| void custom_crosshair(void); | void custom_crosshair(void); | ||||||
| void bullet_tracers(usercmd_t* cmd); |  | ||||||
|  |  | ||||||
| #endif /* FEATURES_H_ */ | #endif /* FEATURES_H_ */ | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ void custom_crosshair(void) { | |||||||
|     int my = game_info->m_height / 2; |     int my = game_info->m_height / 2; | ||||||
|  |  | ||||||
|     /* The real length is sqrt(2 * (len^2)) */ |     /* The real length is sqrt(2 * (len^2)) */ | ||||||
|     const int len   = dz_crosshair->value; |     const int len   = cv_crosshair->value; | ||||||
|     const int gap   = 1; |     const int gap   = 1; | ||||||
|     const float w   = 1; |     const float w   = 1; | ||||||
|     const rgb_t col = { 255, 255, 255 }; |     const rgb_t col = { 255, 255, 255 }; | ||||||
| @@ -29,30 +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); | ||||||
|     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() || |  | ||||||
|         !is_alive(localplayer)) |  | ||||||
|         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); |  | ||||||
| } |  | ||||||
|   | |||||||
| @@ -31,7 +31,7 @@ static void autostrafe_rage(usercmd_t* cmd) { | |||||||
|     /* TODO: Get at runtime */ |     /* TODO: Get at runtime */ | ||||||
|     const float sv_airaccelerate = 10.0f; |     const float sv_airaccelerate = 10.0f; | ||||||
|     const float sv_maxspeed      = 320.0f; |     const float sv_maxspeed      = 320.0f; | ||||||
|     const float cl_forwardspeed  = 425.0f; |     const float cl_forwardspeed  = 400.0f; | ||||||
|     const float cl_sidespeed     = 400.0f; |     const float cl_sidespeed     = 400.0f; | ||||||
|  |  | ||||||
|     float speed = vec_len2d(i_pmove->velocity); |     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. */ |     /* Autostrafe if enabled. Check if we are in the air and holding space. */ | ||||||
|     if (is_jumping) { |     if (is_jumping) { | ||||||
|         switch ((int)dz_autostrafe->value) { |         switch ((int)cv_autostrafe->value) { | ||||||
|             case 1: |             case 1: | ||||||
|                 autostrafe_rage(cmd); |                 autostrafe_rage(cmd); | ||||||
|                 break; |                 break; | ||||||
|   | |||||||
| @@ -1,68 +0,0 @@ | |||||||
| #include "include/game_detection.h" |  | ||||||
| #include <string.h>  |  | ||||||
| #include <stdio.h> |  | ||||||
|  |  | ||||||
| static GameType current_game = GAME_UNKNOWN; |  | ||||||
|  |  | ||||||
| GameType get_current_game(void) { |  | ||||||
|     if (current_game != GAME_UNKNOWN) { |  | ||||||
|         return current_game; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     FILE *fp = fopen("/proc/self/cmdline", "r"); |  | ||||||
|     if (fp) { |  | ||||||
|         char buf[1024]; |  | ||||||
|         size_t size = fread(buf, sizeof(char), sizeof(buf) - 1, fp); |  | ||||||
|         fclose(fp); |  | ||||||
|  |  | ||||||
|         if (size > 0) { |  | ||||||
|             buf[size] = '\0'; |  | ||||||
|  |  | ||||||
|             char *gameTypeToken = NULL; |  | ||||||
|             char *steamToken = NULL; |  | ||||||
|  |  | ||||||
|             int tokensFound = 0; |  | ||||||
|  |  | ||||||
|             for (char *token = buf; token < buf + size; token += strlen(token) + 1) { |  | ||||||
|                 tokensFound++; |  | ||||||
|  |  | ||||||
|                 if (strcmp(token, "-game") == 0) { |  | ||||||
|                     gameTypeToken = token + strlen(token) + 1; |  | ||||||
|                 } else if (strcmp(token, "-steam") == 0) { |  | ||||||
|                     steamToken = token; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (gameTypeToken) { |  | ||||||
|                 if (strcmp(gameTypeToken, "cstrike") == 0) { |  | ||||||
|                     current_game = GAME_CS16; |  | ||||||
|                 } else if (strcmp(gameTypeToken, "dod") == 0) { |  | ||||||
|                     current_game = GAME_DAY_OF_DEFEAT; |  | ||||||
|                 } else if (strcmp(gameTypeToken, "tfc") == 0) { |  | ||||||
|                     current_game = GAME_TFC; |  | ||||||
|                 } |  | ||||||
|             } else if (steamToken && tokensFound == 2) { |  | ||||||
|                 // If only `-steam` is found and no `-game`, with only two tokens, assume it's Half-Life 1 |  | ||||||
|                 current_game = GAME_HALFLIFE; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return current_game; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| int IsCS16(void) { |  | ||||||
|     return get_current_game() == GAME_CS16; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| int IsHalfLife(void) { |  | ||||||
|     return get_current_game() == GAME_HALFLIFE; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| int IsDayOfDefeat(void) { |  | ||||||
|     return get_current_game() == GAME_DAY_OF_DEFEAT; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| int IsTFC(void) { |  | ||||||
|     return get_current_game() == GAME_TFC; |  | ||||||
| } |  | ||||||
| @@ -8,12 +8,10 @@ | |||||||
| #include "include/sdk.h" | #include "include/sdk.h" | ||||||
| #include "include/util.h" | #include "include/util.h" | ||||||
|  |  | ||||||
| game_id this_game_id = HL; | enum game_id this_game_id = HL; | ||||||
| vec3_t g_punchAngles = { 0, 0, 0 }; |  | ||||||
|  |  | ||||||
| /* Weapon info */ | /* Bone origins of each player, updated in studiorendermodel */ | ||||||
| float g_flNextAttack = 0.f, g_flNextPrimaryAttack = 0.f; | vec3_t g_bones[64][128]; | ||||||
| int g_iClip = 0; |  | ||||||
|  |  | ||||||
| void* hw; | void* hw; | ||||||
| void** h_client; | void** h_client; | ||||||
| @@ -42,13 +40,13 @@ bool globals_init(void) { | |||||||
|      */ |      */ | ||||||
|     hw = dlopen("hw.so", RTLD_LAZY | RTLD_NOLOAD); |     hw = dlopen("hw.so", RTLD_LAZY | RTLD_NOLOAD); | ||||||
|     if (!hw) { |     if (!hw) { | ||||||
|         printf("goldsource-cheat: globals_init: can't open hw.so\n"); |         printf("hl-cheat: globals_init: can't open hw.so\n"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     h_client = (void**)dlsym(hw, "hClientDLL"); |     h_client = (void**)dlsym(hw, "hClientDLL"); | ||||||
|     if (!h_client) { |     if (!h_client) { | ||||||
|         printf("goldsource-cheat: globals_init: can't find hClientDLL\n"); |         printf("hl-cheat: globals_init: can't find hClientDLL\n"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -67,12 +65,12 @@ bool globals_init(void) { | |||||||
|  |  | ||||||
|     if (!i_engine || !i_client || !i_pmove || !i_enginestudio || |     if (!i_engine || !i_client || !i_pmove || !i_enginestudio || | ||||||
|         !i_studiomodelrenderer || !game_info) { |         !i_studiomodelrenderer || !game_info) { | ||||||
|         printf("goldsource-cheat: globals_init: couldn't load some symbols\n"); |         printf("hl-cheat: globals_init: couldn't load some symbols\n"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!protect_addr(i_studiomodelrenderer, PROT_READ | PROT_WRITE)) { |     if (!protect_addr(i_studiomodelrenderer, PROT_READ | PROT_WRITE)) { | ||||||
|         printf("goldsource-cheat: globals_init: couldn't unprotect address of SMR\n"); |         printf("hl-cheat: globals_init: couldn't unprotect address of SMR\n"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										46
									
								
								src/hooks.c
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								src/hooks.c
									
									
									
									
									
								
							| @@ -11,8 +11,6 @@ | |||||||
| DECL_HOOK(CL_CreateMove); | DECL_HOOK(CL_CreateMove); | ||||||
| DECL_HOOK(HUD_Redraw); | DECL_HOOK(HUD_Redraw); | ||||||
| DECL_HOOK(StudioRenderModel); | DECL_HOOK(StudioRenderModel); | ||||||
| DECL_HOOK(CalcRefdef); |  | ||||||
| DECL_HOOK(HUD_PostRunCmd); |  | ||||||
|  |  | ||||||
| /* OpenGL hooks */ | /* OpenGL hooks */ | ||||||
| DECL_HOOK(glColor4f); | DECL_HOOK(glColor4f); | ||||||
| @@ -29,8 +27,6 @@ bool hooks_init(void) { | |||||||
|     HOOK(i_client, CL_CreateMove); |     HOOK(i_client, CL_CreateMove); | ||||||
|     HOOK(i_client, HUD_Redraw); |     HOOK(i_client, HUD_Redraw); | ||||||
|     HOOK(i_studiomodelrenderer, StudioRenderModel); |     HOOK(i_studiomodelrenderer, StudioRenderModel); | ||||||
|     HOOK(i_client, CalcRefdef); |  | ||||||
|     HOOK(i_client, HUD_PostRunCmd); |  | ||||||
|  |  | ||||||
|     /* OpenGL hooks */ |     /* OpenGL hooks */ | ||||||
|     GL_HOOK(glColor4f); |     GL_HOOK(glColor4f); | ||||||
| @@ -63,7 +59,6 @@ void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) { | |||||||
|  |  | ||||||
|     bhop(cmd); |     bhop(cmd); | ||||||
|     aimbot(cmd); |     aimbot(cmd); | ||||||
|     bullet_tracers(cmd); |  | ||||||
|  |  | ||||||
|     correct_movement(cmd, old_angles); |     correct_movement(cmd, old_angles); | ||||||
|     vec_clamp(cmd->viewangles); |     vec_clamp(cmd->viewangles); | ||||||
| @@ -74,10 +69,8 @@ void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) { | |||||||
| int h_HUD_Redraw(float time, int intermission) { | int h_HUD_Redraw(float time, int intermission) { | ||||||
|     int ret = ORIGINAL(HUD_Redraw, time, intermission); |     int ret = ORIGINAL(HUD_Redraw, time, intermission); | ||||||
|  |  | ||||||
|     if (dz_watermark->value) { |  | ||||||
|     /* Watermark */ |     /* Watermark */ | ||||||
|         engine_draw_text(5, 5, "https://git.deadzone.lol/Wizzard/goldsource-cheat", (rgb_t){ 0, 255, 255 }); |     engine_draw_text(5, 5, "8dcc/hl-cheat", (rgb_t){ 255, 255, 255 }); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     esp(); |     esp(); | ||||||
|     custom_crosshair(); |     custom_crosshair(); | ||||||
| @@ -88,37 +81,20 @@ int h_HUD_Redraw(float time, int intermission) { | |||||||
| /*----------------------------------------------------------------------------*/ | /*----------------------------------------------------------------------------*/ | ||||||
|  |  | ||||||
| void h_StudioRenderModel(void* this_ptr) { | 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)) |     if (!chams(this_ptr)) | ||||||
|         ORIGINAL(StudioRenderModel, 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; |  | ||||||
|         g_iClip = to->weapondata[to->client.m_iId].m_iClip; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /*----------------------------------------------------------------------------*/ |  | ||||||
|  |  | ||||||
| void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { | void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { | ||||||
|     /* This visible_mode variable is changed inside the chams() function, which |     /* This visible_mode variable is changed inside the chams() function, which | ||||||
|      * is called from the StudioRenderModel hook. |      * is called from the StudioRenderModel hook. | ||||||
| @@ -164,8 +140,8 @@ void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { | |||||||
| /*----------------------------------------------------------------------------*/ | /*----------------------------------------------------------------------------*/ | ||||||
|  |  | ||||||
| void h_CL_Move() { | void h_CL_Move() { | ||||||
|     if (dz_clmove->value != 0) { |     if (cv_clmove->value != 0) { | ||||||
|         for (int i = 0; i < (int)dz_clmove->value; i++) |         for (int i = 0; i < (int)cv_clmove->value; i++) | ||||||
|             CALL_ORIGINAL(detour_data_clmove, clmove_type); |             CALL_ORIGINAL(detour_data_clmove, clmove_type); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include "sdk.h" | #include "sdk.h" | ||||||
| #include "globals.h" | #include "globals.h" | ||||||
|  |  | ||||||
| #define CVAR_PREFIX  "dz_" | #define CVAR_PREFIX  "cv_" | ||||||
| #define CVAR_HACK_ID 0x4000 /* (1<<14) One that is not in use by the game */ | #define CVAR_HACK_ID 0x4000 /* (1<<14) One that is not in use by the game */ | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -16,30 +16,27 @@ | |||||||
|  * |  * | ||||||
|  * prefix | meaning |  * prefix | meaning | ||||||
|  * -------+------------------------------- |  * -------+------------------------------- | ||||||
|  * dz_*   | cvar variable |  * cv_*   | cvar variable | ||||||
|  */ |  */ | ||||||
| #define DECL_CVAR(name) cvar_t* dz_##name = NULL; | #define DECL_CVAR(name) cvar_t* cv_##name = NULL; | ||||||
|  |  | ||||||
| #define DECL_CVAR_EXTERN(name) extern cvar_t* dz_##name; | #define DECL_CVAR_EXTERN(name) extern cvar_t* cv_##name; | ||||||
|  |  | ||||||
| #define REGISTER_CVAR(name, value) \ | #define REGISTER_CVAR(name, value) \ | ||||||
|     dz_##name =                    \ |     cv_##name =                    \ | ||||||
|       i_engine->pfnRegisterVariable(CVAR_PREFIX #name, #value, CVAR_HACK_ID); |       i_engine->pfnRegisterVariable(CVAR_PREFIX #name, #value, CVAR_HACK_ID); | ||||||
|  |  | ||||||
| #define CVAR_ON(name) (dz_##name->value != 0.0f) | #define CVAR_ON(name) (cv_##name->value != 0.0f) | ||||||
|  |  | ||||||
| /*----------------------------------------------------------------------------*/ | /*----------------------------------------------------------------------------*/ | ||||||
|  |  | ||||||
| DECL_CVAR_EXTERN(bhop); | DECL_CVAR_EXTERN(bhop); | ||||||
| DECL_CVAR_EXTERN(autostrafe); | DECL_CVAR_EXTERN(autostrafe); | ||||||
| DECL_CVAR_EXTERN(aimbot); | DECL_CVAR_EXTERN(aimbot); | ||||||
| DECL_CVAR_EXTERN(autoshoot); |  | ||||||
| DECL_CVAR_EXTERN(esp); | DECL_CVAR_EXTERN(esp); | ||||||
| DECL_CVAR_EXTERN(chams); | DECL_CVAR_EXTERN(chams); | ||||||
| DECL_CVAR_EXTERN(crosshair); | DECL_CVAR_EXTERN(crosshair); | ||||||
| DECL_CVAR_EXTERN(tracers); |  | ||||||
| DECL_CVAR_EXTERN(clmove); | DECL_CVAR_EXTERN(clmove); | ||||||
| DECL_CVAR_EXTERN(watermark); |  | ||||||
|  |  | ||||||
| /*----------------------------------------------------------------------------*/ | /*----------------------------------------------------------------------------*/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,17 +0,0 @@ | |||||||
| #ifndef _GAME_DETECT_H_ |  | ||||||
| #define _GAME_DETECT_H_ |  | ||||||
|  |  | ||||||
| typedef enum { |  | ||||||
|     GAME_UNKNOWN = 0, |  | ||||||
|     GAME_HALFLIFE, |  | ||||||
|     GAME_CS16, |  | ||||||
|     GAME_TFC, |  | ||||||
|     GAME_DAY_OF_DEFEAT |  | ||||||
| } GameType; |  | ||||||
|  |  | ||||||
| GameType get_current_game(void); |  | ||||||
| int IsCS16(void); |  | ||||||
| int IsHalfLife(void); |  | ||||||
| int IsDayOfDefeat(void); |  | ||||||
|  |  | ||||||
| #endif |  | ||||||
| @@ -34,9 +34,7 @@ enum game_id { | |||||||
| /*----------------------------------------------------------------------------*/ | /*----------------------------------------------------------------------------*/ | ||||||
|  |  | ||||||
| extern game_id this_game_id; | extern game_id this_game_id; | ||||||
| extern vec3_t g_punchAngles; | extern vec3_t g_bones[64][128]; | ||||||
| extern float g_flNextAttack, g_flNextPrimaryAttack; |  | ||||||
| extern int g_iClip; |  | ||||||
|  |  | ||||||
| extern void* hw; | extern void* hw; | ||||||
| extern void** h_client; /* hClientDLL hander */ | extern void** h_client; /* hClientDLL hander */ | ||||||
|   | |||||||
| @@ -95,10 +95,6 @@ void hooks_restore(void); | |||||||
| DECL_HOOK_EXTERN(void, CL_CreateMove, float, usercmd_t*, int); | DECL_HOOK_EXTERN(void, CL_CreateMove, float, usercmd_t*, int); | ||||||
| DECL_HOOK_EXTERN(int, HUD_Redraw, float, int); | DECL_HOOK_EXTERN(int, HUD_Redraw, float, int); | ||||||
| DECL_HOOK_EXTERN(void, StudioRenderModel, void*); | 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 */ | /* OpenGL hooks */ | ||||||
| DECL_HOOK_EXTERN(void, glColor4f, GLfloat, GLfloat, GLfloat, GLfloat); | DECL_HOOK_EXTERN(void, glColor4f, GLfloat, GLfloat, GLfloat, GLfloat); | ||||||
|   | |||||||
| @@ -3,7 +3,6 @@ | |||||||
| #define MAIN_H_ | #define MAIN_H_ | ||||||
|  |  | ||||||
| void load(void); | void load(void); | ||||||
| void unload(void); |  | ||||||
| void self_unload(void); | void self_unload(void); | ||||||
|  |  | ||||||
| #endif /* MAIN_H_ */ | #endif /* MAIN_H_ */ | ||||||
|   | |||||||
| @@ -62,7 +62,7 @@ typedef struct cl_clientfuncs_s { | |||||||
|     void (*CL_CameraOffset)(float* ofs); |     void (*CL_CameraOffset)(float* ofs); | ||||||
|     struct kbutton_s* (*KB_Find)(const char* name); |     struct kbutton_s* (*KB_Find)(const char* name); | ||||||
|     void (*CAM_Think)(void); |     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, |     int (*HUD_AddEntity)(int type, struct cl_entity_s* ent, | ||||||
|                          const char* modelname); |                          const char* modelname); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -22,11 +22,10 @@ typedef struct { | |||||||
| #define gl_drawline_points(p0, p1, w, col) \ | #define gl_drawline_points(p0, p1, w, col) \ | ||||||
|     gl_drawline(p0[0], p0[1], p1[0], p1[1], 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) \ | #define vec_copy(dst, src) \ | ||||||
|     dst[0] = src[0];       \ |     dst.x = src.x;         \ | ||||||
|     dst[1] = src[1];       \ |     dst.y = src.y;         \ | ||||||
|     dst[2] = src[2]; |     dst.z = src.z; | ||||||
|  |  | ||||||
| /*----------------------------------------------------------------------------*/ | /*----------------------------------------------------------------------------*/ | ||||||
|  |  | ||||||
| @@ -34,7 +33,6 @@ cl_entity_t* get_player(int ent_idx); | |||||||
| bool is_alive(cl_entity_t* ent); | bool is_alive(cl_entity_t* ent); | ||||||
| bool valid_player(cl_entity_t* ent); | bool valid_player(cl_entity_t* ent); | ||||||
| bool is_friend(cl_entity_t* ent); | bool is_friend(cl_entity_t* ent); | ||||||
| bool can_shoot(void); |  | ||||||
| char* get_name(int ent_idx); | char* get_name(int ent_idx); | ||||||
| game_id get_cur_game(void); | game_id get_cur_game(void); | ||||||
| vec3_t vec3(float x, float y, float z); | 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); | vec3_t matrix_3x4_origin(matrix_3x4 m); | ||||||
| bool world_to_screen(vec3_t vec, vec2_t screen); | bool world_to_screen(vec3_t vec, vec2_t screen); | ||||||
| void engine_draw_text(int x, int y, char* s, rgb_t c); | 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_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); | void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col); | ||||||
| bool protect_addr(void* ptr, int new_flags); | bool protect_addr(void* ptr, int new_flags); | ||||||
|   | |||||||
							
								
								
									
										42
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										42
									
								
								src/main.c
									
									
									
									
									
								
							| @@ -8,31 +8,30 @@ | |||||||
| #include "include/cvars.h" | #include "include/cvars.h" | ||||||
| #include "include/hooks.h" | #include "include/hooks.h" | ||||||
| #include "include/util.h" | #include "include/util.h" | ||||||
| #include "include/game_detection.h" |  | ||||||
|  |  | ||||||
| static bool loaded = false; | static bool loaded = false; | ||||||
|  |  | ||||||
| __attribute__((constructor)) /* Entry point when injected */ | __attribute__((constructor)) /* Entry point when injected */ | ||||||
| void load(void) { | void load(void) { | ||||||
|     printf("goldsource-cheat injected!\n"); |     printf("hl-cheat injected!\n"); | ||||||
|  |  | ||||||
|     /* Initialize globals/interfaces */ |     /* Initialize globals/interfaces */ | ||||||
|     if (!globals_init()) { |     if (!globals_init()) { | ||||||
|         fprintf(stderr, "goldsource-cheat: load: error loading globals, aborting\n"); |         fprintf(stderr, "hl-cheat: load: error loading globals, aborting\n"); | ||||||
|         self_unload(); |         self_unload(); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Create cvars for settings */ |     /* Create cvars for settings */ | ||||||
|     if (!cvars_init()) { |     if (!cvars_init()) { | ||||||
|         fprintf(stderr, "goldsource-cheat: load: error creating cvars, aborting\n"); |         fprintf(stderr, "hl-cheat: load: error creating cvars, aborting\n"); | ||||||
|         self_unload(); |         self_unload(); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Hook functions */ |     /* Hook functions */ | ||||||
|     if (!hooks_init()) { |     if (!hooks_init()) { | ||||||
|         fprintf(stderr, "goldsource-cheat: load: error hooking functions, aborting\n"); |         fprintf(stderr, "hl-cheat: load: error hooking functions, aborting\n"); | ||||||
|         self_unload(); |         self_unload(); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| @@ -40,40 +39,13 @@ void load(void) { | |||||||
|     /* Get game version after injecting */ |     /* Get game version after injecting */ | ||||||
|     this_game_id = get_cur_game(); |     this_game_id = get_cur_game(); | ||||||
|  |  | ||||||
|     i_engine->pfnClientCmd("echo \"goldsource-cheat loaded successfully!\""); |     i_engine->pfnClientCmd("echo \"hl-cheat loaded successfully!\""); | ||||||
|     i_engine->pfnClientCmd("echo \"Deadzone rulez!\""); |  | ||||||
|     i_engine->pfnClientCmd("echo \"https://git.deadzone.lol/Wizzard/goldsource-cheat\""); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     GameType game = get_current_game(); |  | ||||||
|     switch(game) { |  | ||||||
|         case GAME_HALFLIFE: |  | ||||||
|             i_engine->pfnClientCmd("echo \"Detected Game: Half-Life 1\""); |  | ||||||
|             break; |  | ||||||
|         case GAME_CS16: |  | ||||||
|             i_engine->pfnClientCmd("echo \"Detected Game: Counter-Strike 1.6\""); |  | ||||||
|             break; |  | ||||||
|         case GAME_DAY_OF_DEFEAT: |  | ||||||
|             i_engine->pfnClientCmd("echo \"Detected Game: Day of Defeat\""); |  | ||||||
|             break; |  | ||||||
|         case GAME_TFC: |  | ||||||
|             i_engine->pfnClientCmd("echo \"Detected Game: Team Fortress Classic\""); |  | ||||||
|             break; |  | ||||||
|         default: |  | ||||||
|             i_engine->pfnClientCmd("echo \"Detected Game: Unknown Game\""); |  | ||||||
|             break; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     return; |  | ||||||
|      |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     loaded = true; |     loaded = true; | ||||||
| } | } | ||||||
|  |  | ||||||
| __attribute__((destructor)) /* Entry point when unloaded */ | __attribute__((destructor)) /* Entry point when unloaded */ | ||||||
| void unload(void) { | void unload() { | ||||||
|     if (loaded) { |     if (loaded) { | ||||||
|         /* TODO: Remove our cvars */ |         /* TODO: Remove our cvars */ | ||||||
|  |  | ||||||
| @@ -83,7 +55,7 @@ void unload(void) { | |||||||
|         GL_UNHOOK(glColor4f); /* Manually restore OpenGL hooks here */ |         GL_UNHOOK(glColor4f); /* Manually restore OpenGL hooks here */ | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     printf("goldsource-cheat unloaded.\n\n"); |     printf("hl-cheat unloaded.\n\n"); | ||||||
| } | } | ||||||
|  |  | ||||||
| void self_unload(void) { | void self_unload(void) { | ||||||
|   | |||||||
							
								
								
									
										20
									
								
								src/util.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/util.c
									
									
									
									
									
								
							| @@ -63,11 +63,6 @@ bool is_friend(cl_entity_t* ent) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| bool can_shoot(void) { |  | ||||||
|     return g_iClip > 0 && g_flNextAttack <= 0.0f && |  | ||||||
|            g_flNextPrimaryAttack <= 0.0f; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| char* get_name(int ent_idx) { | char* get_name(int ent_idx) { | ||||||
|     hud_player_info_t info; |     hud_player_info_t info; | ||||||
|     i_engine->pfnGetPlayerInfo(ent_idx, &info); |     i_engine->pfnGetPlayerInfo(ent_idx, &info); | ||||||
| @@ -209,19 +204,6 @@ void engine_draw_text(int x, int y, char* s, rgb_t c) { | |||||||
|     i_engine->pfnDrawConsoleString(x, y, s); |     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) { | void gl_drawbox(int x, int y, int w, int h, rgb_t c) { | ||||||
|     /* Line width */ |     /* Line width */ | ||||||
|     const int lw = 1; |     const int lw = 1; | ||||||
| @@ -271,7 +253,7 @@ bool protect_addr(void* ptr, int new_flags) { | |||||||
|     int pgsz = getpagesize(); |     int pgsz = getpagesize(); | ||||||
|  |  | ||||||
|     if (mprotect(p, pgsz, new_flags) == -1) { |     if (mprotect(p, pgsz, new_flags) == -1) { | ||||||
|         printf("goldsource-cheat: error protecting %p\n", ptr); |         printf("hl-cheat: error protecting %p\n", ptr); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user