goldsrc-cheat/src/features/chams.c

59 lines
1.7 KiB
C
Raw Normal View History

2023-07-24 11:03:22 -04:00
#include "features.h"
#include "../include/globals.h"
#include "../include/cvars.h"
#include "../include/util.h"
#include <GL/gl.h>
2023-07-26 10:34:14 -04:00
enum chams_settings {
DISABLED = 0,
PLAYER_CHAMS = 1,
HAND_CHAMS = 2,
/* ALL is 3, but we can OR player and hands */
};
2023-07-25 08:46:25 -04:00
visible_flags visible_mode;
2023-07-24 11:03:22 -04:00
bool chams(void* this_ptr) {
2023-07-26 10:34:14 -04:00
const int setting = cv_chams->value;
if (setting == DISABLED)
2023-07-24 11:03:22 -04:00
return false;
cl_entity_t* ent = i_enginestudio->GetCurrentEntity();
2023-07-26 10:34:14 -04:00
if (ent->index == localplayer->index && setting & HAND_CHAMS) {
/* If we are rendering hands and setting is on, render them */
glDisable(GL_TEXTURE_2D);
visible_mode = HANDS; /* Set for this call */
i_studiomodelrenderer->StudioRenderFinal(this_ptr);
visible_mode = NONE; /* Reset for future calls */
glEnable(GL_TEXTURE_2D);
return true;
} else if (!(setting & PLAYER_CHAMS) || !valid_player(ent) ||
!is_alive(ent)) {
/* If we don't want player chams, or this is not a player, stop */
2023-07-24 11:03:22 -04:00
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;
}