VERC: Customizable Hud Color Last edited 15 years ago2003-07-02 22:30:00 UTC by Penguinboy Penguinboy

This article was recovered from an archive and needs to be reviewed

  1. The formatting may be incorrect as it was automatically converted to WikiCode from HTML, it needs to be revised and reformatted
  2. Some information may be out of date as it was written before Half-Life was available on Steam
  3. After the article is re-formatted and updated for Steam HL, remove this notice
  4. Please do not remove the archive notice from the bottom of the article.
  5. Some archive articles are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.
Take a good look at the HUD of half-life. Bored with that ol' dull dank orangey yellow? Well if you are then, this tutorial will allow you and your friends to choose any colour for the HUD regardless. Now you can have the greenish blue HUD of your dreams, or show your true colours with a lovely bright red HUD and if you get bored of your new HUD you can change it whenever you want, even in game !

How do you do this? Well you have to open up the cl_dll project.

We are going to store the HUD colour for the client in three cvars, one for each RGB component. These are 'hud_red', 'hud_green' and 'hud_blue'. We need to initialize these first so open up hud.cpp and open up init() (line 306).

You will find two CVAR_CREATE s, add these three after them.

     CVAR_CREATE( "hud_red","255", FCVAR_ARCHIVE );     CVAR_CREATE( "hud_green", "160", FCVAR_ARCHIVE );     CVAR_CREATE( "hud_blue", "0", FCVAR_ARCHIVE );
The FCVAR_ARCHIVE ensures that they will be remembered when you quit Half-Life.

Now to business, load up cl_util.h and go to UnpackRGB() (line 153). We are going to 'hijack' the processing of the HUD colour as it is being separated from its hex value to its RGB components.


inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB){     r = (ulRGB & 0xFF0000) >>16;     g = (ulRGB & 0xFF00) >> 8;     b = ulRGB & 0xFF;}

inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB){     if ( ulRGB == RGB_YELLOWISH )     {          r = CVAR_GET_FLOAT( "hud_red" );          g = CVAR_GET_FLOAT( "hud_green" );          b = CVAR_GET_FLOAT( "hud_blue" );     }     else     {          r = (ulRGB & 0xFF0000) >>16;          g = (ulRGB & 0xFF00) >> 8;          b = ulRGB & 0xFF;     }}
What this does is it sees if the colour is the default yellow color of the HUD and if it is it replaces it with the our cvar's values.

This will ensure that all of the orange colored graphics will be coloured in your custom colour. This will work for all the graphics with one annoying exception (there's always one, isn't there?) The little bar between the health and the armor values has hard-coded values. This is an infamous problem for anyone whose tried to change the HUD's colour. To fix, open up health.cpp and scroll down to line 233.


FillRGBA(x, y, iWidth, iHeight, 255, 160, 0, a);

FillRGBA(x, y, iWidth, iHeight, r, g, b, a);
That's it, now recompile the DLL and run the game. You can now edit the three cvars to get the desired color of your choice.

Be forewarned though, the HUD is transparent so if you set all the cvars to 0, in order to get black, the HUD becomes totally transparent so use relatively high values and you'll be fine.

Additional Feature

You may have people who want to change their HUD but unfortunately they haven't a clue how to use the console. To fix this unavoidable problem you can add the cvars to the menu, under Multiplayer->Customize->Advanced Options. To do this open up user.scr in a text editor, scroll down to

     "mp_decals"     {          "Multiplayer decal limit"          { NUMBER 0.000000 4096.000000 }          { "300.000000" }     }
and add the following

     "hud_red"     {          "Hud Red"          { NUMBER 0 255 }          { "255" }     }     "hud_green"     {          "Hud Green"          { NUMBER 0 255 }          { "160" }     }     "hud_blue"     {          "Hud Blue"          { NUMBER 0 255 }          { "0" }     }
Close and Save.

There you are, now anyone and everyone can have the power to personalize their games. Power to the People!
This article was originally published on the Valve Editing Resource Collective (VERC).
TWHL only archives articles from defunct websites. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.


You must log in to post a comment. You can login or register a new account.