Skip to content

Commit

Permalink
cgame: Add a counter of number of connected clients in the HUD, place…
Browse files Browse the repository at this point in the history
… stuff in the HUD correctly like BFP does originally and decrease particle bubble time on rocket trail
  • Loading branch information
LegendaryGuard committed Jan 12, 2025
1 parent 09a2286 commit 37cbccc
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 31 deletions.
91 changes: 63 additions & 28 deletions source/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ static void CG_DrawStatusBarHead( float x ) {
angles[YAW] = cg.headStartYaw + ( cg.headEndYaw - cg.headStartYaw ) * frac;
angles[PITCH] = cg.headStartPitch + ( cg.headEndPitch - cg.headStartPitch ) * frac;

CG_DrawHead( x, 480 - size, size, size,
// BFP - Place the head HUD at the corner leaving a bit of margin
CG_DrawHead( x + 7, 472 - size, size, size,
cg.snap->ps.clientNum, angles );
}

Expand All @@ -314,7 +315,7 @@ CG_DrawStatusBarFlag
================
*/
static void CG_DrawStatusBarFlag( float x, int team ) {
CG_DrawFlagModel( x, 480 - ICON_SIZE, ICON_SIZE, ICON_SIZE, team, qfalse );
CG_DrawFlagModel( x + 147, 480 - ICON_SIZE - 63, ICON_SIZE, ICON_SIZE, team, qfalse ); // BFP - Before Q3: x: x, y: 480 - ICON_SIZE
}

/*
Expand Down Expand Up @@ -471,17 +472,17 @@ static void CG_DrawStatusBar( void ) {
// stretch the health up when taking damage
// CG_DrawField ( 185, 432, 3, value);

string = va( "HP: %d%%", value ); // %% is a percentage sign
CG_DrawBigString( spacer, SCREEN_HEIGHT - ( SMALLCHAR_HEIGHT * 2 ), string, 1.0f );
string = va( "%d%%", value ); // %% is a percentage sign
CG_DrawBigString( 107, -18 + SCREEN_HEIGHT - ( SMALLCHAR_HEIGHT * 2 ), string, 1.0f );
CG_ColorForHealth( hcolor );
trap_R_SetColor( hcolor );

// BFP - draw ki amount
if ( ps->ammo[WP_KI] <= 0 ) // BFP - If ki is less than 0, adjust to 0
ps->ammo[WP_KI] = 0;
value = ps->ammo[WP_KI];
string = va( "KI: %d", value );
CG_DrawBigString( spacer, SCREEN_HEIGHT - SMALLCHAR_HEIGHT, string, 1.0f );
string = va( "%d", value );
CG_DrawBigString( 107, -12 + SCREEN_HEIGHT - SMALLCHAR_HEIGHT, string, 1.0f );
if (value >= 100) {
trap_R_SetColor( colors[3] ); // white
} else {
Expand Down Expand Up @@ -880,6 +881,14 @@ static float CG_DrawScores( float y ) {
vec4_t color;
float y1;
gitem_t *item;
const int POS_STR_Y = -19; // BFP - Before Q3: 4
const int POS_FLAG_X = 6; // BFP - Before Q3: (nothing)
const int POS_FLAG_Y = 34; // BFP - Before Q3: 4

// BFP - Don't show small two score display when spectating
if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) {
return 0;
}

s1 = cgs.scores1;
s2 = cgs.scores2;
Expand All @@ -890,19 +899,19 @@ static float CG_DrawScores( float y ) {

// draw from the right side to left
if ( cgs.gametype >= GT_TEAM ) {
x = 640;
x = 630; // BFP - Before Q3: 640
color[0] = 0.0f;
color[1] = 0.0f;
color[2] = 1.0f;
color[3] = 0.33f;
s = va( "%2i", s2 );
w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
x -= w;
CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
CG_FillRect( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, color );
if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {
CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
CG_DrawPic( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
}
CG_DrawBigString( x + 4, y, s, 1.0F);
CG_DrawBigString( x + 4, y - POS_STR_Y, s, 1.0F );

if ( cgs.gametype == GT_CTF ) {
// Display flag status
Expand All @@ -911,7 +920,7 @@ static float CG_DrawScores( float y ) {
if (item) {
y1 = y - BIGCHAR_HEIGHT - 8;
if( cgs.blueflag >= 0 && cgs.blueflag <= 2 ) {
CG_DrawPic( x, y1-4, w, BIGCHAR_HEIGHT+8, cgs.media.blueFlagShader[cgs.blueflag] );
CG_DrawPic( x - POS_FLAG_X, y1-POS_FLAG_Y, w, BIGCHAR_HEIGHT+8, cgs.media.blueFlagShader[cgs.blueflag] );
}
}
}
Expand All @@ -922,11 +931,11 @@ static float CG_DrawScores( float y ) {
s = va( "%2i", s1 );
w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
x -= w;
CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
CG_FillRect( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, color );
if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED ) {
CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
CG_DrawPic( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
}
CG_DrawBigString( x + 4, y, s, 1.0F);
CG_DrawBigString( x + 4, y - POS_STR_Y, s, 1.0F);

if ( cgs.gametype == GT_CTF ) {
// Display flag status
Expand All @@ -935,7 +944,7 @@ static float CG_DrawScores( float y ) {
if (item) {
y1 = y - BIGCHAR_HEIGHT - 8;
if( cgs.redflag >= 0 && cgs.redflag <= 2 ) {
CG_DrawPic( x, y1-4, w, BIGCHAR_HEIGHT+8, cgs.media.redFlagShader[cgs.redflag] );
CG_DrawPic( x - POS_FLAG_X, y1-POS_FLAG_Y, w, BIGCHAR_HEIGHT+8, cgs.media.redFlagShader[cgs.redflag] );
}
}
}
Expand All @@ -949,13 +958,13 @@ static float CG_DrawScores( float y ) {
s = va( "%2i", v );
w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
x -= w;
CG_DrawBigString( x + 4, y, s, 1.0F);
CG_DrawBigString( x + 4, y - POS_STR_Y, s, 1.0F);
}

} else {
qboolean spectator;

x = 640;
x = 630; // BFP - Before Q3: 640
score = cg.snap->ps.persistant[PERS_SCORE];
spectator = ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR );

Expand All @@ -972,16 +981,16 @@ static float CG_DrawScores( float y ) {
color[1] = 0.0f;
color[2] = 0.0f;
color[3] = 0.33f;
CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
CG_FillRect( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, color );
CG_DrawPic( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
} else {
color[0] = 0.5f;
color[1] = 0.5f;
color[2] = 0.5f;
color[3] = 0.33f;
CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
CG_FillRect( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, color );
}
CG_DrawBigString( x + 4, y, s, 1.0F);
CG_DrawBigString( x + 4, y - POS_STR_Y, s, 1.0F);
}

// first place
Expand All @@ -994,23 +1003,23 @@ static float CG_DrawScores( float y ) {
color[1] = 0.0f;
color[2] = 1.0f;
color[3] = 0.33f;
CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
CG_FillRect( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, color );
CG_DrawPic( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
} else {
color[0] = 0.5f;
color[1] = 0.5f;
color[2] = 0.5f;
color[3] = 0.33f;
CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
CG_FillRect( x, y-POS_STR_Y, w, BIGCHAR_HEIGHT+8, color );
}
CG_DrawBigString( x + 4, y, s, 1.0F);
CG_DrawBigString( x + 4, y - POS_STR_Y, s, 1.0F);
}

if ( cgs.fraglimit ) {
s = va( "%2i", cgs.fraglimit );
w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
x -= w;
CG_DrawBigString( x + 4, y, s, 1.0F);
CG_DrawBigString( x + 4, y - POS_STR_Y, s, 1.0F);
}

}
Expand Down Expand Up @@ -1181,7 +1190,8 @@ static void CG_DrawLowerLeft( void ) {
y = CG_DrawTeamOverlay( y, qfalse, qfalse );
}


// BFP - Put the pickup item icon a bit up
y = 480 - ICON_SIZE - 32;
y = CG_DrawPickupItem( y );
}

Expand Down Expand Up @@ -1471,7 +1481,7 @@ static void CG_DrawLagometer( void ) {
// draw the graph
//
x = 640 - 48;
y = 480 - 48;
y = 480 - 200; // BFP - Put the lagometer at the center/a bit up. Before Q3: 480 - 48

trap_R_SetColor( NULL );
CG_DrawPic( x, y, 48, 48, cgs.media.lagometerShader );
Expand Down Expand Up @@ -1557,6 +1567,30 @@ static void CG_DrawLagometer( void ) {
CG_DrawDisconnect();
}

/*
==================
CG_DrawNumConnectedClients
==================
*/
static void CG_DrawNumConnectedClients( void ) { // BFP - Show number of connected clients for the player itself
// if the player is the only one playing, the counter won't be shown
short i, connectedClients = 0;
for ( i = 0; i < MAX_CLIENTS; ++i ) {
if ( cg_entities[i].currentValid ) {
if ( cgs.gametype >= GT_TEAM
&& cg.snap->ps.persistant[PERS_TEAM] == cgs.clientinfo[i].team ) {
++connectedClients;
} else {
++connectedClients;
}
}
}
// don't show number of connected clients when spectating and when there's only one client
if ( connectedClients > 0 && cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR ) {
CG_DrawBigString( 608, 255, va( "%d", connectedClients ), 1.0F );
}
}



/*
Expand Down Expand Up @@ -2302,6 +2336,7 @@ static void CG_Draw2D( void ) {
CG_DrawTeamVote();

CG_DrawLagometer();
CG_DrawNumConnectedClients(); // BFP - Number of connected clients
CG_DrawUpperRight();

CG_DrawLowerRight();
Expand Down
6 changes: 3 additions & 3 deletions source/cgame/cg_weapons.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ static void CG_RocketTrail( centity_t *ent, const weaponInfo_t *wi ) {
if ( ( contents & lastContents & CONTENTS_WATER )
&& cg.frametime > 0.0f ) { // BFP - If paused, don't spawn bubble particles (cg_paused.integer < 1 is another solution, but not good enough for server responses)
// BFP - Apply particle bubble effect in that case
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 1200, 10 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 1200, 10 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 1200, 10 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 900, 10 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 900, 10 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 900, 10 );
// CG_BubbleTrail( lastPos, origin, 8 );
}
return;
Expand Down

0 comments on commit 37cbccc

Please sign in to comment.