Half-Life Decay HUD Problems Created 1 year ago2023-06-07 01:23:39 UTC by AbsoluteModding AbsoluteModding

Created 1 year ago2023-06-07 01:23:39 UTC by AbsoluteModding AbsoluteModding

Posted 1 year ago2023-06-07 01:23:39 UTC Post #347586
Recently I have been attempting to fix the HUD for the 2008 Decay port, as the colors are incorrect and it has the yellow HUD divider issue. I got the custom colors themselves working, but I can't figure out how to get the Health divider to change with it. This is the code used to decide what color the HUD is.

int CHud::MsgFunc_ChangePlayer(const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
int m_iDecayId = READ_BYTE();

if (m_iDecayId == 1)
uColor = RGB_SILVERISH;
else
uColor = RGB_ORANGEISH;

return 1;
}

This system is what is used in the hud.cpp file, which changes the color depending on what character you are playing as. (m_iDecayId being 1 = Gina, any other number = Colette), this system works with no flaws and can easily detect what character is being played as, but this is where the problem arises. Not knowing much about C++ causes quite a few issues when trying to make code (obviously) so I hacked together this code which does not fully work.

int m_iDecayId = READ_BYTE();
if (m_iDecayId == 1)
FillRGBA(x, y, iWidth, iHeight, 160, 160, 192, a);
else
FillRGBA(x, y, iWidth, iHeight, 255, 128, 64, a);
}

It never counts "m_iDecayId" as being 1 and is always "255, 128, 64" even though the rest of the HUD is the "160, 160, 192" color, which clearly shows that "m_iDecayId" is at 1. It seems the main issue is the health.cpp file doesn't detect what number "m_iDecayId" is at, meaning there must be a way to cache it into the file, but as shown I have no idea how to do that. Any clue how to?
Posted 1 year ago2023-06-21 13:52:27 UTC Post #347637
READ_BYTE is used to read data from an incoming network message. It's only valid inside the message handler for the message. You can't just call it whenever and get the value you want; you'll get -1 instead since there's no data to read. There are plenty of examples on how to cache the values received in a message in existing handlers, so look at those to get an idea on how to do that.
Posted 1 year ago2023-06-21 21:37:17 UTC Post #347641
Hey, thanks for letting me know. I really should of thought of that.
You must be logged in to post a response.