VERC: Customizable Hud Color Last edited 3 years ago2021-11-20 03:37:41 UTC

You are viewing an older revision of this wiki page. The current revision may be more detailed and up-to-date. Click here to see the current revision of this 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.

Replace
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)
{
     r = (ulRGB & 0xFF0000) >>16;
     g = (ulRGB & 0xFF00) >> 8;
     b = ulRGB & 0xFF;
}
with
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.

Replace
FillRGBA(x, y, iWidth, iHeight, 255, 160, 0, a);
with
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.

1 Comment

Commented 2 years ago2022-09-30 07:37:57 UTC Comment #104819
how do i open the these files
i don't have a program for it

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