Tutorial: Setting up a Mod: Part 4, Customised HUD colour Last edited 14 years ago2004-06-24 04:00:00 UTC by m0p m0p

This article was converted from a previous version of TWHL and may need to be reviewed

  1. The formatting may be incorrect due to differences in the WikiCode processing engine, it needs to be revised and reformatted
  2. Some information may be out of date
  3. After the article is re-formatted and updated, remove this notice and the Review Required category.
  4. Some older tutorials 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.
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.

6 Comments

Commented 10 years ago2008-07-13 08:42:20 UTC Comment #100669
How About adding or Removing weapons?
Commented 10 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 9 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 9 years ago2010-03-05 20:02:53 UTC Comment #100672
where do I get the programs from
Commented 6 years ago2012-06-27 12:38:18 UTC Comment #100673
Er, there's no "cl_util" file anywhere in the SDK.
Commented 6 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)

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