Monster Death Counter 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
Bunnelby64
Posts: 4
Joined: Tue Feb 27, 2024 4:40 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Monster Death Counter on HUD

Post by Bunnelby64 »

Hello!

I've come to ask for some help regarding something that I've been wanting to implement on my small project, a monster kill counter that displays somewhere around the player's hud and of course, increases every time a monster dies.
For this project I been working on it's based around being some kind of arcade-y kind of mod, where the player is set on an arena to duke it out against monsters and the more the player kills and the counter rises, special messages appear next to the kill counter, similar to something like Devil May Cry's combos or Ultrakill's.

The issue is, I am quite unsure of how to properly do something like this, at first, I thought of every time a monster dies, on their death state use [wiki]https://zdoom.org/wiki/A_GiveToTarget[/wiki] and give the player a CustomInventory item that works to increase the counter via maybe ACS, by constantly checking the player's inventory and if they have the CustomInventory item, the counter will keep increasing respectively, every time it reaches a certain amount (ie. 5, 15, 30), a different message will appear on the screen, encouraging the good work of the player.

I am unfortunately not that good at ACS scripting since for the most part of my own personal projects I've made, I've only worked with DECORATE and very little with ZScript, but I still hope anyone can help me or point me towards the right direction to accomplish this kind of effect!

Cheers and have a very nice day! :D
User avatar
SPZ1
Posts: 387
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois

Re: Monster Death Counter on HUD

Post by SPZ1 »

For a counter all you would have to do is make the monster trigger an ACS script (upon death) that increments a map scope variable. Then it could be displayed through HudMessage: https://zdoom.org/wiki/HudMessage
User avatar
Bunnelby64
Posts: 4
Joined: Tue Feb 27, 2024 4:40 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Re: Monster Death Counter on HUD

Post by Bunnelby64 »

Excuse the late answer, got busy with life and kinda pushed this aside :P

Once I got back to this project I managed to make a counter working, it properly displays and increments a kill counter on the player's HUD, which is great! However, now I am struggling with making the script display a message once a certain number of kills has been achieved (I.e: 10 kills, 20, 30, so on).

I've tried to approach this issue by making the script check if the kill count required has been reached, if it has then displays the 1st message, which is something like "Nice!", then it should check if another amount has been reached to display the second message, however this doesn't happen and is the 1st message the one that keeps displaying on the screen regardless of how many amounts of monsters the player has killed.

Is there any workarounds for this? Thanks for your reply btw!
Blue Shadow
Posts: 5039
Joined: Sun Nov 14, 2010 12:59 am

Re: Monster Death Counter on HUD

Post by Blue Shadow »

Order the if statements so that checking for the bigger values comes first:

Code: Select all

if (kills >= 30)
{
}
else if (kills >= 20)
{
}
else if (kills >= 10)
{
}
User avatar
Bunnelby64
Posts: 4
Joined: Tue Feb 27, 2024 4:40 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Re: Monster Death Counter on HUD

Post by Bunnelby64 »

Aha! That is what I was missing all along! I did try something similar but didn't knew I had to check for the biggest value first to the lowest one and started to get a little frustrating not understanding why it wasn't properly working.

After implementing it and giving it a proper test I can say it's working the way I've been wanting it, thanks fellas! :D

Return to “Scripting”