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
This commit is contained in:
8dcc 2023-07-27 21:28:40 +02:00
parent 9743b58ae4
commit 3a107737b9
3 changed files with 36 additions and 14 deletions

View File

@ -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) */

View File

@ -6,9 +6,11 @@
enum visible_flags {
NONE = 0,
VISIBLE = 1,
NOT_VISIBLE = 2,
HANDS = 3,
ENEMY_VISIBLE = 1,
ENEMY_NOT_VISIBLE = 2,
FRIEND_VISIBLE = 3,
FRIEND_NOT_VISIBLE = 4,
HANDS = 5,
};
/*----------------------------------------------------------------------------*/

View File

@ -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 */