Tutorial: Customising the HUD colour Last edited 2 years ago2022-09-01 11:19:34 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.
For this tutorial you will need:
  1. MSVC++ .net
  2. Some C++ knowledge
  3. The HL SDK 2.3
  4. Time and patience! (important)
When you first open up the SDK folder, either go to Single-Player Source, or Multiplayer Source (depending on which your mod is). Then, open up cl_dll and open the cl_dll.dsp file up. In the solution explorer, goto the hud.cpp source file and browse down to line 306. There should be two CVARs that look like this:
CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO );
CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE );
Now add these 3 CVARs underneath them:
CVAR_CREATE( "hud_red","0", FCVAR_ARCHIVE );
CVAR_CREATE( "hud_green", "200", FCVAR_ARCHIVE );
CVAR_CREATE( "hud_blue", "0", FCVAR_ARCHIVE );
With hudcolor1 being red, 2 being green and 3 being blue (so 0, 200, 0 is a green color). Just make sure the number is between 0 and 255.

Now, open up the header file, cl_util.h. Goto line 153 and replace this:
inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)
{
    r = (ulRGB & 0xFF0000) >>16;
    g = (ulRGB & 0xFF00) >> 8;
    b = ulRGB & 0xFF;
}
With this:
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;
    }
}
This part tells the engine to take the default color, but have the rgb values as the CVARs which we set earlier. Now, if we delete the CVARs, it will goto the default orange. Build this project and replace the cl_dll in the valve folder (MAKE A BACKUP FIRST!) and play Half-Life. Looks good huh? Except from one problem, the lil bar between the health and the rest of the HUD. But, there is a fix! Open up health.cpp and goto line 233.

Replace:
FillRGBA(x, y, iWidth, iHeight, 255, 160, 0, a);
With this:
FillRGBA(x, y, iWidth, iHeight, r, g, b, a);
This will tell the engine to read the health color from our CVARs.

NOTE: There is always one problem with compiling cl_dll under VC++.net though. If you get a build error about hud_spectator.cpp, goto line 1079 of the that file and replace:
i = sqrt (i);
With this:
i = float sqrt (i);
Warning: I haven't tested this with multiplayer, but as most mods are SP, it shouldnt matter.

I hope this helps with your mods! Recommend it to anyone who needs help with this.

9 Comments

Commented 16 years ago2008-07-13 08:42:20 UTC Comment #100669
How About adding or Removing weapons?
Commented 16 years ago2008-07-18 09:35:08 UTC Comment #100670
:( when i go to load HL it says couldnt load client.dll what to do?
Commented 15 years ago2009-06-17 01:12:49 UTC Comment #100671
Nice tutorial, very specific and easy to follow. You just saved me a few hours of work :)
Commented 14 years ago2010-03-05 20:02:53 UTC Comment #100672
where do I get the programs from
Commented 12 years ago2012-06-27 12:38:18 UTC Comment #100673
Er, there's no "cl_util" file anywhere in the SDK.
Commented 12 years ago2012-06-27 12:42:10 UTC Comment #100674
Wait nevermind. I totally overlooked it. I'm just unable to open it. (vc++ 2008)
Commented 3 years ago2020-11-22 18:16:09 UTC Comment #103081
Didn't work
Commented 2 years ago2022-04-07 09:19:45 UTC Comment #104318
in my visual studio (using solokiller's hl updated sdk) i replaced if ( ulRGB == RGB_YELLOWISH ) with if (ulRGB == 0x00FFA000) and that seemed to do the trick as i was getting errors for some reason
Commented 2 years ago2022-04-15 21:48:06 UTC Comment #104330
Can i get a way where i can edit it withouth having to program stuff? I had to change to a potato PC and it just doesnt runs Visual Studio without crashing.
EDIT: Nvm i got i used cmake to compile and notepad++ to edit

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