2023-07-20 11:44:04 -04:00
|
|
|
|
|
|
|
#include "include/hooks.h"
|
|
|
|
#include "include/sdk.h"
|
|
|
|
#include "include/globals.h"
|
2023-07-24 04:15:03 -04:00
|
|
|
#include "include/util.h"
|
2023-07-25 16:10:26 -04:00
|
|
|
#include "include/cvars.h"
|
2023-07-25 17:03:04 -04:00
|
|
|
#include "include/detour.h" /* 8dcc/detour-lib */
|
|
|
|
#include "features/features.h" /* bhop(), esp(), etc. */
|
2023-07-20 17:21:01 -04:00
|
|
|
|
2023-07-25 17:03:04 -04:00
|
|
|
/* Normal VMT hooks */
|
2023-07-20 11:44:04 -04:00
|
|
|
DECL_HOOK(CL_CreateMove);
|
2023-07-21 09:42:01 -04:00
|
|
|
DECL_HOOK(HUD_Redraw);
|
2023-07-24 10:17:57 -04:00
|
|
|
DECL_HOOK(StudioRenderModel);
|
2023-07-20 11:44:04 -04:00
|
|
|
|
2023-07-25 17:03:04 -04:00
|
|
|
/* OpenGL hooks */
|
2023-07-25 08:20:38 -04:00
|
|
|
DECL_HOOK(glColor4f);
|
|
|
|
|
2023-07-25 17:03:04 -04:00
|
|
|
/* Detour hooks */
|
|
|
|
static detour_data_t detour_data_clmove;
|
|
|
|
DECL_DETOUR_TYPE(void, clmove_type);
|
2023-07-25 14:36:44 -04:00
|
|
|
DECL_HOOK(CL_Move);
|
|
|
|
|
2023-07-25 17:03:04 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
2023-07-20 11:44:04 -04:00
|
|
|
bool hooks_init(void) {
|
2023-07-20 14:25:49 -04:00
|
|
|
HOOK(i_client, CL_CreateMove);
|
2023-07-21 09:42:01 -04:00
|
|
|
HOOK(i_client, HUD_Redraw);
|
2023-07-24 10:17:57 -04:00
|
|
|
HOOK(i_studiomodelrenderer, StudioRenderModel);
|
2023-07-20 11:44:04 -04:00
|
|
|
|
2023-07-25 08:20:38 -04:00
|
|
|
GL_HOOK(glColor4f);
|
|
|
|
|
2023-07-25 14:36:44 -04:00
|
|
|
void* clmove_ptr = dlsym(hw, "CL_Move");
|
|
|
|
if (!clmove_ptr)
|
|
|
|
return false;
|
|
|
|
|
2023-07-25 17:03:04 -04:00
|
|
|
/* Initialize detour_data_clmove struct for detour, and add the hook */
|
|
|
|
detour_init(&detour_data_clmove, clmove_ptr, (void*)h_CL_Move);
|
|
|
|
detour_add(&detour_data_clmove);
|
2023-07-25 14:36:44 -04:00
|
|
|
|
2023-07-20 11:44:04 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-07-25 14:36:44 -04:00
|
|
|
void hooks_restore(void) {
|
2023-07-25 17:03:04 -04:00
|
|
|
detour_del(&detour_data_clmove);
|
2023-07-25 14:36:44 -04:00
|
|
|
}
|
|
|
|
|
2023-07-25 08:20:38 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
2023-07-20 11:44:04 -04:00
|
|
|
void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) {
|
|
|
|
ORIGINAL(CL_CreateMove, frametime, cmd, active);
|
2023-07-20 17:21:01 -04:00
|
|
|
|
2023-07-23 09:50:01 -04:00
|
|
|
vec3_t old_angles = cmd->viewangles;
|
|
|
|
|
2023-07-20 17:30:44 -04:00
|
|
|
/* Declared in globals.c */
|
|
|
|
localplayer = i_engine->GetLocalPlayer();
|
|
|
|
|
2023-07-20 17:21:01 -04:00
|
|
|
bhop(cmd);
|
2023-07-23 09:50:01 -04:00
|
|
|
|
|
|
|
correct_movement(cmd, old_angles);
|
2023-07-24 04:15:03 -04:00
|
|
|
vec_clamp(cmd->viewangles);
|
2023-07-20 11:44:04 -04:00
|
|
|
}
|
2023-07-21 09:42:01 -04:00
|
|
|
|
2023-07-25 08:20:38 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
2023-07-21 09:42:01 -04:00
|
|
|
int h_HUD_Redraw(float time, int intermission) {
|
|
|
|
int ret = ORIGINAL(HUD_Redraw, time, intermission);
|
|
|
|
|
|
|
|
/* Watermark */
|
2023-07-25 16:50:52 -04:00
|
|
|
engine_draw_text(5, 5, "8dcc/hl-cheat", (rgb_t){ 255, 255, 255 });
|
2023-07-22 10:06:18 -04:00
|
|
|
|
|
|
|
esp();
|
|
|
|
|
2023-07-21 09:42:01 -04:00
|
|
|
return ret;
|
|
|
|
}
|
2023-07-24 10:17:57 -04:00
|
|
|
|
2023-07-25 08:20:38 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
2023-07-24 10:17:57 -04:00
|
|
|
void h_StudioRenderModel(void* this_ptr) {
|
2023-07-24 11:03:22 -04:00
|
|
|
if (!chams(this_ptr))
|
|
|
|
ORIGINAL(StudioRenderModel, this_ptr);
|
2023-07-24 10:17:57 -04:00
|
|
|
}
|
2023-07-25 08:20:38 -04:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
|
2023-07-25 08:46:37 -04:00
|
|
|
/* This visible_mode variable is changed inside the chams() function, which
|
|
|
|
* is called from the StudioRenderModel hook.
|
|
|
|
*
|
|
|
|
* Depending on the type of entity we are trying to render from there, and
|
|
|
|
* depending on its visibility, we change this visible_mode variable. */
|
|
|
|
switch (visible_mode) {
|
|
|
|
case VISIBLE:
|
|
|
|
r = 0.40f;
|
|
|
|
g = 0.73f;
|
|
|
|
b = 0.41f;
|
|
|
|
break;
|
|
|
|
case NOT_VISIBLE:
|
|
|
|
r = 0.90f;
|
|
|
|
g = 0.07f;
|
|
|
|
b = 0.27f;
|
|
|
|
break;
|
2023-07-26 10:34:14 -04:00
|
|
|
case HANDS:
|
2023-07-26 11:25:50 -04:00
|
|
|
/* Multiply by original func parameters for non-flat chams.
|
|
|
|
* Credits: @oxiKKK */
|
|
|
|
r *= 0.94f;
|
|
|
|
g *= 0.66f;
|
|
|
|
b *= 0.94f;
|
2023-07-26 10:34:14 -04:00
|
|
|
break;
|
2023-07-25 08:46:37 -04:00
|
|
|
default:
|
|
|
|
case NONE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-07-25 08:20:38 -04:00
|
|
|
ORIGINAL(glColor4f, r, g, b, a);
|
|
|
|
}
|
2023-07-25 14:36:44 -04:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
void h_CL_Move() {
|
2023-07-25 16:10:26 -04:00
|
|
|
if (cv_clmove->value != 0) {
|
|
|
|
for (int i = 0; i < (int)cv_clmove->value; i++)
|
2023-07-25 17:03:04 -04:00
|
|
|
CALL_ORIGINAL(detour_data_clmove, clmove_type);
|
2023-07-25 16:10:26 -04:00
|
|
|
}
|
|
|
|
|
2023-07-25 17:03:04 -04:00
|
|
|
CALL_ORIGINAL(detour_data_clmove, clmove_type);
|
2023-07-25 14:36:44 -04:00
|
|
|
}
|