Files
goldsrc-cheat/src/features/chams.c

69 lines
2.2 KiB
C
Raw Normal View History

2023-07-24 17:03:22 +02:00
#include "features.h"
#include "../include/globals.h"
#include "../include/cvars.h"
#include "../include/util.h"
#include <GL/gl.h>
2023-07-26 16:34:14 +02:00
enum chams_settings {
DISABLED = 0,
ENEMY_CHAMS = 1,
FRIEND_CHAMS = 2,
/* ALL_PLAYER is 3, but we can OR player and hands */
HAND_CHAMS = 4,
/* ALL is 5, but we will convert it to 7 so every setting can be OR'd */
2023-07-26 16:34:14 +02:00
};
2023-07-25 14:46:25 +02:00
visible_flags visible_mode;
2023-07-24 17:03:22 +02:00
bool chams(void* this_ptr) {
const int setting = cv_chams->value == 5.0f ? 7 : cv_chams->value;
2023-07-26 16:34:14 +02:00
if (setting == DISABLED)
2023-07-24 17:03:22 +02:00
return false;
cl_entity_t* ent = i_enginestudio->GetCurrentEntity();
2023-07-26 16:34:14 +02: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 (!valid_player(ent) || !is_alive(ent)) {
2023-07-26 16:34:14 +02:00
/* If we don't want player chams, or this is not a player, stop */
2023-07-24 17:03:22 +02:00
return false;
}
const bool friendly = is_friend(ent);
if (friendly && !(setting & FRIEND_CHAMS))
/* Friendly ent but we dont want to render friends */
return false;
else if (!friendly && !(setting & ENEMY_CHAMS))
/* Not friendly ent and we dont want to render enemies */
return false;
2023-07-24 17:03:22 +02:00
/* 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 = friendly ? FRIEND_NOT_VISIBLE : ENEMY_NOT_VISIBLE;
2023-07-24 17:03:22 +02:00
i_studiomodelrenderer->StudioRenderFinal(this_ptr);
glEnable(GL_DEPTH_TEST); /* Don't ignore depth, different color chams */
visible_mode = friendly ? FRIEND_VISIBLE : ENEMY_VISIBLE;
2023-07-24 17:03:22 +02:00
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;
}