First, an overview. Our health bar is actually going to consist of two health bars drawn on top of each other; one with interpolation, and one without. Interpolation, as it applies to DrawBar, simply means that the bar will slowly increase and decrease, rather than instantly change to the new position.
To start, we need graphics. For simplicity's sake, I'm using Doom's medkit sprite (MEDIA0). We'll also need three more; a transparent sprite, and MEDIA0 as a full red sprite and full black sprite. These four sprites will form the foreground and background images for our bars. Rather than edit MEDIA0 externally in an image editing program and then import it, we'll save time and define these sprites in the TEXTURES lump.
Code: Select all
sprite MEDIT0, 28, 19 // transparent sprite
{
offset 13, 19
patch TNT1A0, 0, 0
}
sprite MEDIR0, 28, 19 // red sprite
{
offset 13, 19
patch MEDIA0, 0, 0
{
translation "0:255=176:176"
}
}
sprite MEDIB0, 28, 19 // black sprite
{
offset 13, 19
patch MEDIA0, 0, 0
{
translation "0:255=0:0"
}
}
Now, for the SBARINFO editing. For simplicity's sake, we're just going to import the base ZDoom HUD, and edit it to display our new health bar.
Code: Select all
statusbar fullscreen, fullscreenoffsets
{
//health
drawimage "MEDIA0", 20, -2, centerbottom;
drawnumber 2147483647, HUDFONT_DOOM, untranslated, health, drawshadow, 82, -20;
The first bar we're defining will be the one that has interpolation, and it will be rendered below the one without interpolation. Remember, any HUD elements that are defined in HUD definition will be rendered beneath elements defined after it!
Code: Select all
drawbar "MEDIR0","MEDIB0",health,horizontal,interpolate(2),20,-2;
Next is the bar without interpolation.
Code: Select all
drawbar "MEDIA0","MEDIT0",health,horizontal,20,-2;
Code: Select all
statusbar fullscreen, fullscreenoffsets
{
drawbar "MEDIR0","MEDIB0",health,horizontal,interpolate(2),20,-2;
drawbar "MEDIA0","MEDIT0",health,horizontal,20,-2;
drawnumber 2147483647, HUDFONT_DOOM, untranslated, health, drawshadow, 82, -20;

Success! Our healthbar has a chunk highlighted in red as the player takes damage. It really is that easy.
You can also take this technique and reverse it, rendering the bar without interpolation on the bottom and the bar with interpolation on top, to highlight a portion of your health bar when you've picked up a health-restoring item.
Attached below is a example of the HUD effect we created, ready for you to test out in-game.