Skip to content

Commit

Permalink
cgame: add cg_deadBodyDarken
Browse files Browse the repository at this point in the history
  • Loading branch information
yumirak committed Mar 4, 2024
1 parent 97147b1 commit b3f7455
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions code/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@ extern vmCvar_t cg_enemyModel;
extern vmCvar_t cg_enemyColors;
extern vmCvar_t cg_teamModel;
extern vmCvar_t cg_teamColors;
extern vmCvar_t cg_deadBodyDarken;
//

//
Expand Down
2 changes: 2 additions & 0 deletions code/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ vmCvar_t cg_enemyModel;
vmCvar_t cg_enemyColors;
vmCvar_t cg_teamModel;
vmCvar_t cg_teamColors;
vmCvar_t cg_deadBodyDarken;
//
typedef struct {
vmCvar_t *vmCvar;
Expand Down Expand Up @@ -392,6 +393,7 @@ static cvarTable_t cvarTable[] = {
{ &cg_enemyColors, "cg_enemyColors", "", CVAR_ARCHIVE},
{ &cg_teamModel, "cg_teamModel", "", CVAR_ARCHIVE},
{ &cg_teamColors, "cg_teamColors", "", CVAR_ARCHIVE},
{ &cg_deadBodyDarken, "cg_deadBodyDarken", "0", CVAR_ARCHIVE},
// { &cg_pmove_fixed, "cg_pmove_fixed", "0", CVAR_USERINFO | CVAR_ARCHIVE }
};

Expand Down
23 changes: 14 additions & 9 deletions code/cgame/cg_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,7 @@ void CG_Player( centity_t *cent ) {
float angle;
vec3_t dir, angles;
#endif
qboolean darken;

// the client number is stored in clientNum. It can't be derived
// from the entity number, because a single client may have
Expand Down Expand Up @@ -2535,6 +2536,10 @@ void CG_Player( centity_t *cent ) {
}
}

if ( cg_deadBodyDarken.integer && cent->currentState.eFlags & EF_DEAD )
darken = qtrue;
else
darken = qfalse;

memset( &legs, 0, sizeof(legs) );
memset( &torso, 0, sizeof(torso) );
Expand Down Expand Up @@ -2579,9 +2584,9 @@ void CG_Player( centity_t *cent ) {
VectorCopy (legs.origin, legs.oldorigin); // don't positionally lerp at all

// colored skin
legs.shaderRGBA[0] = ci->legsColor[0] * 255;
legs.shaderRGBA[1] = ci->legsColor[1] * 255;
legs.shaderRGBA[2] = ci->legsColor[2] * 255;
legs.shaderRGBA[0] = darken ? 85 : ci->legsColor[0] * 255;
legs.shaderRGBA[1] = darken ? 85 : ci->legsColor[1] * 255;
legs.shaderRGBA[2] = darken ? 85 : ci->legsColor[2] * 255;
legs.shaderRGBA[3] = 255;

CG_AddRefEntityWithPowerups( &legs, &cent->currentState, ci->team );
Expand Down Expand Up @@ -2609,9 +2614,9 @@ void CG_Player( centity_t *cent ) {
torso.renderfx = renderfx;

// colored skin
torso.shaderRGBA[0] = ci->bodyColor[0] * 255;
torso.shaderRGBA[1] = ci->bodyColor[1] * 255;
torso.shaderRGBA[2] = ci->bodyColor[2] * 255;
torso.shaderRGBA[0] = darken ? 85 : ci->bodyColor[0] * 255;
torso.shaderRGBA[1] = darken ? 85 : ci->bodyColor[1] * 255;
torso.shaderRGBA[2] = darken ? 85 : ci->bodyColor[2] * 255;
torso.shaderRGBA[3] = 255;

CG_AddRefEntityWithPowerups( &torso, &cent->currentState, ci->team );
Expand Down Expand Up @@ -2841,9 +2846,9 @@ void CG_Player( centity_t *cent ) {
head.renderfx = renderfx;

// colored skin
head.shaderRGBA[0] = ci->headColor[0] * 255;
head.shaderRGBA[1] = ci->headColor[1] * 255;
head.shaderRGBA[2] = ci->headColor[2] * 255;
head.shaderRGBA[0] = darken ? 85 : ci->headColor[0] * 255;
head.shaderRGBA[1] = darken ? 85 : ci->headColor[1] * 255;
head.shaderRGBA[2] = darken ? 85 : ci->headColor[2] * 255;
head.shaderRGBA[3] = 255;

CG_AddRefEntityWithPowerups( &head, &cent->currentState, ci->team );
Expand Down

0 comments on commit b3f7455

Please sign in to comment.