From 3a107737b9f37d08c7fcbcc15bec257082e01f28 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Thu, 27 Jul 2023 21:28:40 +0200 Subject: [PATCH] Add friendly and enemy chams Add 2 new chams settings (friendly only and all players) Add 2 new colors to visible_flags enum (friend_visible and friend_not_visible) Add friendly colors to glColor4f hook --- src/features/chams.c | 26 ++++++++++++++++++-------- src/features/features.h | 10 ++++++---- src/hooks.c | 14 ++++++++++++-- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/features/chams.c b/src/features/chams.c index 793e618..d6fca54 100644 --- a/src/features/chams.c +++ b/src/features/chams.c @@ -8,15 +8,17 @@ enum chams_settings { DISABLED = 0, - PLAYER_CHAMS = 1, - HAND_CHAMS = 2, - /* ALL is 3, but we can OR player and hands */ + 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 */ }; visible_flags visible_mode; bool chams(void* this_ptr) { - const int setting = cv_chams->value; + const int setting = cv_chams->value == 5.0f ? 7 : cv_chams->value; if (setting == DISABLED) return false; @@ -32,21 +34,29 @@ bool chams(void* 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)) { + } else if (!valid_player(ent) || !is_alive(ent)) { /* If we don't want player chams, or this is not a player, stop */ 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; + /* 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; + visible_mode = friendly ? FRIEND_NOT_VISIBLE : ENEMY_NOT_VISIBLE; i_studiomodelrenderer->StudioRenderFinal(this_ptr); glEnable(GL_DEPTH_TEST); /* Don't ignore depth, different color chams */ - visible_mode = VISIBLE; + visible_mode = friendly ? FRIEND_VISIBLE : ENEMY_VISIBLE; i_studiomodelrenderer->StudioRenderFinal(this_ptr); /* Reset for future calls to glColor4f (from here or somewhere else) */ diff --git a/src/features/features.h b/src/features/features.h index 28b37ba..cdd525c 100644 --- a/src/features/features.h +++ b/src/features/features.h @@ -5,10 +5,12 @@ #include "../include/sdk.h" enum visible_flags { - NONE = 0, - VISIBLE = 1, - NOT_VISIBLE = 2, - HANDS = 3, + NONE = 0, + ENEMY_VISIBLE = 1, + ENEMY_NOT_VISIBLE = 2, + FRIEND_VISIBLE = 3, + FRIEND_NOT_VISIBLE = 4, + HANDS = 5, }; /*----------------------------------------------------------------------------*/ diff --git a/src/hooks.c b/src/hooks.c index 63dcd2d..64b9d56 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -90,16 +90,26 @@ void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { * 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: + case ENEMY_VISIBLE: r = 0.40f; g = 0.73f; b = 0.41f; break; - case NOT_VISIBLE: + case ENEMY_NOT_VISIBLE: r = 0.90f; g = 0.07f; b = 0.27f; break; + case FRIEND_VISIBLE: + r = 0.16f; + g = 0.71f; + b = 0.96f; + break; + case FRIEND_NOT_VISIBLE: + r = 0.00f; + g = 0.53f; + b = 0.81f; + break; case HANDS: /* Multiply by original func parameters for non-flat chams. * Credits: @oxiKKK */