I'm working on a custom hud and it's beeing going fairly well, but once again i'm reaching a wall to my knowledge.
I would like for when a specific weapon is selected for a hud element showing an integer value used by the weapon to appear, and I would like for it to only appear while the weapon is selected.
I have a vuage idea of what i might need to do, maybe an if statement using CPlayer.ReadyWeapon, but i'm not sure. Any input as always is greatly appriciated!
Weapon-Specific Hud elements
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
LolaHThicc
- Posts: 12
- Joined: Wed Dec 10, 2025 1:08 pm
- Preferred Pronouns: She/Her
-
Average Raven Fan
- Posts: 22
- Joined: Sat Oct 05, 2024 12:00 am
Re: Weapon-Specific Hud elements
Let's give this a go. I've copy-pasted the whole Doom status bar to a new class and added these two bits to it!
This is added to DrawMainBar, right after drawing the current weapon's ammo...
And this one is added to DrawFullScreenStuff, also right after the ammo display code!
This shows the amount of cells you have in light blue whenever you have the single shotgun selected in Doom. Give it a spin and see if that's what you wanted!
Code: Select all
if(CPlayer.ReadyWeapon is "Shotgun")
{
DrawString(mAmountFont, FormatNumber(CPlayer.mo.CountInv("Cell")), (44, 181), DI_TEXT_ALIGN_RIGHT, Font.CR_LIGHTBLUE);
}Code: Select all
if(CPlayer.ReadyWeapon is "Shotgun")
{
DrawString(mHUDFont, FormatNumber(CPlayer.mo.CountInv("Cell")), (-30, -40), DI_TEXT_ALIGN_RIGHT, Font.CR_LIGHTBLUE);
}This shows the amount of cells you have in light blue whenever you have the single shotgun selected in Doom. Give it a spin and see if that's what you wanted!
-
LolaHThicc
- Posts: 12
- Joined: Wed Dec 10, 2025 1:08 pm
- Preferred Pronouns: She/Her
Re: Weapon-Specific Hud elements
Yes, it does exactly that, Thank you!
Now, i have an integer stored in the weapon; whats the procedure to passing that number along to the hud?
Now, i have an integer stored in the weapon; whats the procedure to passing that number along to the hud?
-
Average Raven Fan
- Posts: 22
- Joined: Sat Oct 05, 2024 12:00 am
Re: Weapon-Specific Hud elements
Code: Select all
class RNGShotgun : Shotgun
{
int num;
override void Tick()
{
num = random(0,255);
Super.Tick();
}
}Code: Select all
if(CPlayer.ReadyWeapon is "RNGShotgun")
{
RNGShotgun weap = RNGShotgun(CPlayer.ReadyWeapon);
DrawString(mHUDFont, FormatNumber(weap.num), (-30, -40), DI_TEXT_ALIGN_RIGHT, Font.CR_LIGHTBLUE);
}-
LolaHThicc
- Posts: 12
- Joined: Wed Dec 10, 2025 1:08 pm
- Preferred Pronouns: She/Her
Re: Weapon-Specific Hud elements
works perfectly! thanks again for the help! 