Custom Hud

From ZDoom Wiki
Jump to navigation Jump to search
Warning: While still supported, this method of creating a custom HUD is no longer preferred. See SBARINFO for the preferred method to create custom HUDs.

Assumed Knowledge

It is assumed that before you begin this tutorial, you are familiar with the following concepts:

Understanding these concepts is vital to understanding the following tutorial.

Scripting a Custom Hud

You can disabled the built-in HUD by first using SBARINFO and set the height to 0. You can have your script work around the existing HUD, but unless you intend to reuse parts, this is not recommended. To make your HUD more user-friendly you should watch the value of the screenblocks CVAR (using GetCVar) and alter the HUD accordingly (try not to draw anything when the value is 12). The values correspond to the HUD as follows:[1]

  • 3-9: There is a border around the player's view, and the status bar is displayed
  • 10: Fullscreen with status bar
  • 11: Fullscreen without status bar, ZDoom HUD enabled
  • 12: Fullscreen with no HUD whatsoever

The Graphics

1) Create a graphic or graphics you want to use for the HUD. Keep in mind the size of the average users' screen resolution, e.g. 640x480 or 800x600. This is important because a 1024x768 HUD graphic does not scale down well.

2) Load all the graphics you just made into your wad file using a lump management tool. Make note of each graphics name as you will need them in the ACS script.


1) If you use Doom Builder, open MAP01 of your wad and select "Edit" from the "Scripts" menu. To display the new HUD bar, you use something like this:

   Script 1 ENTER
       SetHudSize (800, 600, TRUE);
       HudMessage (s: "a";HUDMSG_PLAIN,1000,CR_UNTRANSLATED,400.1,550.1,0.0);

In this script, SetFont tells Doom that the font to use is actually the lump name of your custom stat-bar graphic ("HUDLUMP"), and printing "a" in the HudMessage, as above, will display that graphic. Notice that it is also an "ENTER" script, because it needs to be activated by the player so that you can easily access their inventory and health information.[2]

2) Next comes displaying the player information. We'll start with health:

       SetHudSize (320, 200, TRUE);
       HudMessage (i: GetActorProperty(0,APROP_HEALTH);

Notice I've changed the sethudsize to accomodate the font "BIGFONT", and the HudMessage coordinates will vary as a result. Finally, notice that the HudMessage ID is lower than that of the stat-bar HudMessage ID so that the health count will display infront of the stat-bar.

NB: I've deliberately left the HudMessage coordinates slightly unaligned in order to encourage people to find the correct offsets for themselves.

Using other HudMessages such as:

        HudMessage (i: CheckInventory("Armor");

        HudMessage (i: CheckInventory("Clip");
                      HUDMSG_PLAIN,999,CR_UNTRANSLATED,175.1,175.1,0.0); will also be able to figure out how to display the armor and ammo counts.

3) And finally, while this may sound tricky, it's actually very straightforward - turning your custom stat-bar on and off according to how the player has their HUD displayed, as discussed earlier.

       if (GetCVar ("screenblocks") <= 10) 
           {   /*Do your Custom Hud Stuff here*/}
           {   /*Turn it off with HudMessages that print nothing*/}

These are obviously the very basic concepts you need to be familiar with in order to script your own custom hud. Use what you've learnt here, and have a look through the example scripts posted below to try and understand more about it.

Example scripts


  1. Information obtained from Hotwax.
  2. Information obtained from Cyrez.

See Also