DECORATE String to force automatic use of items?

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!)
ichxg0
Posts: 27
Joined: Mon Nov 18, 2024 3:08 pm

DECORATE String to force automatic use of items?

Post by ichxg0 »

So I have a tiny Heretic weapons and items mod for Doom, but wanted to change its behavior slightly.

Is there a string you can include that will force say, a heretic quartz flash, to be used immediately on pickup? Browsing though the wiki I saw "+INVENTORY.KEEPDEPLETED" in a default entry, so I tried to copy paste it into into a this mod's existing decorate but for some reason that had no effect.

This is what the current code looks like:

Code: Select all

ACTOR ArtiHealth8 : ArtiHealth replaces Medikit
{
	+INVENTORY.KEEPDEPLETED
}
and that's it. It's a simple, but I must be using the string/defenition wrong? The mod only replaces weapons and items, and I think doesn't modify them any from the original Zdoom actors.

This must be a simple fix, I think. Can somebody tell me what I am doing wrong?
User avatar
Player701
 
 
Posts: 1694
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

Re: DECORATE String to force automatic use of items?

Post by Player701 »

ichxg0 wrote: Sun Dec 01, 2024 11:56 am Browsing though the wiki I saw "+INVENTORY.KEEPDEPLETED" in a default entry, so I tried to copy paste it into into a this mod's existing decorate but for some reason that had no effect.
It is typically not a good idea to copy-paste code if you don't fully understand what it does. The wiki page on Inventory explains the purpose of the KEEPDEPLETED flag:
ZDoom Wiki wrote:This item will remain in the player's inventory bar even after the last one is used. If the item also has an inventory icon, it will be drawn darkened when the quantity is 0.
Clearly, that's not what you want. But, there is another flag that suits your needs perfectly - aptly named AUTOACTIVATE:
ZDoom Wiki wrote:This item activates automatically when being picked up.
There is a catch, though. With health pickups like the Quartz Flask, if you just add the flag, they will be used on pickup only if the player's health is less than maximum. Otherwise, the item will still end up in the inventory. To avoid this, you should set MaxAmount to 0. Then, the item will not be picked up if it cannot be used.

Here is the final code:

Code: Select all

actor ArtiHealth8 : ArtiHealth replaces Medikit
{
    Inventory.MaxAmount 0
    +INVENTORY.AUTOACTIVATE
}
ichxg0
Posts: 27
Joined: Mon Nov 18, 2024 3:08 pm

Re: DECORATE String to force automatic use of items?

Post by ichxg0 »

Well, sometimes the wiki is a little overwhelming with the sheer amount of information and I get lost.. So I tend to experiment a bit on my own, I just always keep a backup of original files so in case I fubar something, I can easily reset. I am working on digesting the wiki a little better though, just can't always find what I'm looking for..

But in any case, this is perfect - quartz flasks now work just like medkits, thanks!

Return to “Scripting”