Changing HUD colors with Solokiller's halflife-op4-updated SDK Created 1 week ago2021-06-04 11:30:03 UTC by GeckoOrange GeckoOrange

Created 1 week ago2021-06-04 11:30:03 UTC by GeckoOrange GeckoOrange

Posted 1 week ago2021-06-04 11:30:03 UTC Post #345675
Hello,

I am following this tutorial and I run into the problem. I compile everything without errors, but hud remains green even if I try to change it's color via options.

Any ideas on how to resolve this problem? Maybe there are additional steps while working with op4 SDK?
Posted 1 week ago2021-06-04 13:00:12 UTC Post #345676
Opposing Force handles HUD colors a bit differently since the CTF gamemode requires changing colors.

To change the default color you need to change this code instead:
https://github.com/Solokiller/halflife-op4-updated/blob/bfafe3f22ed49a447d6650a5a499723a71b247f7/dlls/cdll_dll.h#L171-L175

Change RGB_HUD_COLOR to the color you want to use.

If you want to change it dynamically (e.g. with cvars) then you'll need to move this code:
https://github.com/Solokiller/halflife-op4-updated/blob/f4e0ed692fe47714e2bfc8097fd10c8ff5b7bbd7/cl_dll/cdll_int.cpp#L170-L171

To here:
https://github.com/Solokiller/halflife-op4-updated/blob/f4e0ed692fe47714e2bfc8097fd10c8ff5b7bbd7/cl_dll/cdll_int.cpp#L264-L269

Put the code before the voice manager code like this:
void DLLEXPORT HUD_Frame( double time )
{
//    RecClHudFrame(time);

    UnpackRGB(giR, giG, giB, RGB_HUD_COLOR);

    GetClientVoiceMgr()->Frame(time);
}
And change it so the RGB value is set to whatever you want it to be. If you're using separate cvars for the color then it should be like this:
giR = CVAR_GET_FLOAT( "hud_red" );
giG = CVAR_GET_FLOAT( "hud_green" );
giB = CVAR_GET_FLOAT( "hud_blue" );
Note that if you do this, CTF's HUD colors will no longer work since you're overriding the color every frame.

You may also want to cache the pointers to the cvars so avoid the costly lookup every frame.
Posted 5 days ago2021-06-08 10:09:46 UTC Post #345688
Thanks for the help! Everything works fine instead of crosshairs, they remain the same color. But I guess that's the reason of sprite itself, as it is already colored.
Posted 5 days ago2021-06-08 12:53:54 UTC Post #345689
Yeah the sprites have the color because autoaim has a red color, and sprite coloring done through code requires monochrome sprites that will be shades of the given color.
You must be logged in to post a response.