Add chams code

No custom colors yet
This commit is contained in:
8dcc 2023-07-24 17:03:22 +02:00
parent 5858a2e4ec
commit 9627989304
3 changed files with 53 additions and 3 deletions

48
src/features/chams.c Normal file
View File

@ -0,0 +1,48 @@
#include "features.h"
#include "../include/globals.h"
#include "../include/cvars.h"
#include "../include/util.h"
#include <GL/gl.h>
enum visible_flags {
NONE = 0,
VISIBLE = 1,
NOT_VISIBLE = 2,
/* TODO: HANDS */
};
static visible_flags visible_mode;
bool chams(void* this_ptr) {
if (!CVAR_ON(chams))
return false;
cl_entity_t* ent = i_enginestudio->GetCurrentEntity();
if (ent->index == localplayer->index) {
/* TODO: Hand chams (set var, check in gl hook, return true) */
return false;
} else if (!valid_client(ent) || !is_alive(ent)) {
return false;
}
/* If we got here it means we are rendering a valid player */
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST); /* Ignore depth (walls between target) */
visible_mode = NOT_VISIBLE;
i_studiomodelrenderer->StudioRenderFinal(this_ptr);
glEnable(GL_DEPTH_TEST); /* Don't ignore depth, different color chams */
visible_mode = VISIBLE;
i_studiomodelrenderer->StudioRenderFinal(this_ptr);
/* Reset for future calls to glColor4f (from here or somewhere else) */
visible_mode = NONE;
glEnable(GL_TEXTURE_2D);
/* StudioRenderModel hook doesn't need to call original */
return true;
}

View File

@ -11,4 +11,7 @@ void bhop(usercmd_t* cmd);
void esp(void); void esp(void);
void correct_movement(usercmd_t* cmd, vec3_t old_angles); void correct_movement(usercmd_t* cmd, vec3_t old_angles);
/* src/features/chams.c */
bool chams(void* this_ptr);
#endif /* FEATURES_H_ */ #endif /* FEATURES_H_ */

View File

@ -55,7 +55,6 @@ int h_HUD_Redraw(float time, int intermission) {
} }
void h_StudioRenderModel(void* this_ptr) { void h_StudioRenderModel(void* this_ptr) {
ORIGINAL(StudioRenderModel, this_ptr); if (!chams(this_ptr))
ORIGINAL(StudioRenderModel, this_ptr);
printf("Hi from StudioRenderModel!\n");
} }