Count/Display Ammo Count on HUD

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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!)
User avatar
ReX
Posts: 1580
Joined: Tue Aug 05, 2003 10:01 am
Location: Quatto's Palace

Count/Display Ammo Count on HUD

Post by ReX »

I want to accomplish the following via ACS:

1. I want to count the player's available ammo, by ammo type, during a play-through of a given map. I believe I can do this by using CheckInventory
2. I want this to be displayed in the upper left-hand corner of the HUD
3. I want the ammo count to be updated each time the player expends ammo. This is where I am running into trouble. How to set up a script to check the inventory only when the player is expending ammo? Perhaps it might be better to have the script continuously check the ammo count and display it. But wouldn't this be a wasteful use of computational resources?

I have done a cursory search of the forums, but have found nothing. I'm guessing someone has already developed what I'm asking about, but I can't find anything.

I'd appreciate any help.
User avatar
m8f
 
 
Posts: 1447
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)

Re: Count/Display Ammo Count on HUD

Post by m8f »

I believe AmmoInfo from Simple HUD Add-ons does exactly what you want, and it continuously checks ammo. No one complained about performance issues yet.
User avatar
ReX
Posts: 1580
Joined: Tue Aug 05, 2003 10:01 am
Location: Quatto's Palace

Re: Count/Display Ammo Count on HUD

Post by ReX »

m8f wrote:I believe AmmoInfo from Simple HUD Add-ons does exactly what you want, and it continuously checks ammo. No one complained about performance issues yet.
Thank you, m8f. I looked over the contents of the pk3 file, and realized the scripting is far beyond my capabilities to adapt into my own mod. I don't wan't to simply merge AmmoInfo into my mod; rather, I had hoped to pull relevant parts of the code into it. Moreover, it appears that the HUD display for the ammo count needs to be enabled using the player's menu. I was hoping to make the display a default.

Still, thanks for pointing AmmoInfo out to me.

Return to “Scripting”