This is client-side code. It displays a meter next to the health meter that tells you how much “air” you have left. When it gets empty you start drowning (only if you’re still in the water). The bar does not contain anything until you go under.
cg_draw.c
Find:
static void CG_DrawPlayerHealthBar( rectDef_t *rect ) {
vec4_t bgcolour = { 1.f, 1.f, 1.f, 0.3f };
vec4_t colour;
int flags = 1|4|16|64;
float frac;
CG_ColorForHealth( colour );
colour[3] = 0.5f;
if( cgs.clientinfo[ cg.snap->ps.clientNum ].cls == PC_MEDIC ) {
frac = cg.snap->ps.stats[STAT_HEALTH] / ( (float) cg.snap->ps.stats[STAT_MAX_HEALTH] * 1.12f );
} else {
frac = cg.snap->ps.stats[STAT_HEALTH] / (float) cg.snap->ps.stats[STAT_MAX_HEALTH];
}
CG_FilledBar( rect->x, rect->y + (rect->h * 0.1f), rect->w, rect->h * 0.84f, colour, NULL, bgcolour, frac, flags );
trap_R_SetColor( NULL );
CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.hudSprintBar );
CG_DrawPic( rect->x, rect->y + rect->h + 4, rect->w, rect->w, cgs.media.hudHealthIcon );
}
Below add:
// bacon - draw the breath bar!
static void CG_DrawBreathBar( rectDef_t *rect ) {
vec4_t bgcolour = { 1.f, 1.f, 1.f, 0.3f };
vec4_t colour = { 0.1f, 0.1f, 1.0f, 0.5f };
vec4_t colourlow = { 1.0f, 0.1f, 0.1f, 0.5f };
vec_t* color = colour;
int flags = 1|4|16|64;
float frac = cg.pmext.airleft / (float)HOLDBREATHTIME;
if( frac < 0.25 ) {
color = colourlow;
}
CG_FilledBar( rect->x, rect->y + (rect->h * 0.1f), rect->w, rect->h * 0.84f, color, NULL, bgcolour, frac, flags );
trap_R_SetColor( NULL );
CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.hudSprintBar );
}
Now find:
// ==
rect.x = 4;
rect.y = 480 - 92;
rect.w = 12;
rect.h = 72;
CG_DrawStaminaBar( &rect );
// ==
Below add:
// ==
rect.x = 44;
rect.y = 480 - 92;
rect.w = 12;
rect.h = 72;
CG_DrawBreathBar( &rect );
// ==
Now to prevent it from being over the stupid head, we’ll removing the head!
Find:
CG_DrawPlayerStatusHead();
Replace with:
//CG_DrawPlayerStatusHead();
All done!