From 7ad62b0fc43086e83eff3f51f93a41b8a273c596 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Wed, 26 Jul 2023 16:34:14 +0200 Subject: [PATCH] Add hand chams --- src/features/chams.c | 27 ++++++++++++++++++++++----- src/features/features.h | 2 +- src/hooks.c | 5 +++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/features/chams.c b/src/features/chams.c index 40edfb3..793e618 100644 --- a/src/features/chams.c +++ b/src/features/chams.c @@ -6,18 +6,35 @@ #include +enum chams_settings { + DISABLED = 0, + PLAYER_CHAMS = 1, + HAND_CHAMS = 2, + /* ALL is 3, but we can OR player and hands */ +}; + visible_flags visible_mode; bool chams(void* this_ptr) { - if (!CVAR_ON(chams)) + const int setting = cv_chams->value; + if (setting == DISABLED) 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_player(ent) || !is_alive(ent)) { + 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 */ return false; } diff --git a/src/features/features.h b/src/features/features.h index 06811ba..041d694 100644 --- a/src/features/features.h +++ b/src/features/features.h @@ -8,7 +8,7 @@ enum visible_flags { NONE = 0, VISIBLE = 1, NOT_VISIBLE = 2, - /* TODO: HANDS */ + HANDS = 3, }; /*----------------------------------------------------------------------------*/ diff --git a/src/hooks.c b/src/hooks.c index e1ff338..dc97058 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -99,6 +99,11 @@ void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { g = 0.07f; b = 0.27f; break; + case HANDS: + r = 0.94f; + g = 0.66f; + b = 0.94f; + break; default: case NONE: break;