ZDoom / gzdoom

GZDoom is a feature centric port for all Doom engine games, based on ZDoom, adding an OpenGL renderer and powerful scripting capabilities
http://zdoom.org
GNU General Public License v3.0
2.33k stars 528 forks source link

`NOTCONSUMABLE` inventory flag #2563

Open Blue-Shadow opened 2 months ago

Blue-Shadow commented 2 months ago

An item with this flag isn't consumed upon a successful use.

In my mod, I have powerups which are meant to be used infinitely but require the player to have enough "energy" to be successfully used/activated. So I propose this flag.

RicardoLuis0 commented 1 month ago

that can already be done with zscript, no need for new flags

Blue-Shadow commented 1 month ago

The flag is more convenient than overriding UseInventory and adding an exception for an item or item class that I want to have this mechanic.

MajorCooke commented 1 month ago

Agreed, I think it'd be better to have an actual flag. This prevents some special cases from breaking consumption otherwise that I have to perform for some inventory items.

Boondorl commented 1 month ago

I think my big issue is that there's not really a use case for this in vanilla meaning you'll inherently have to be making your own class. If that's the case it's probably better to throw this behavior into either a base class or mixin in your mod rather than adding an engine-wide flag. Flags and properties are rare to add nowadays because ZScript allows working around the old issues DECORATE had by essentially letting you write your own engine-level code. The only time they tend to be added is when it's something that cannot be trivially done from a mod and requires some level of cooperation with the core ZScript and the engine (especially for the latter). For instance, this snippet would do the same thing in the item classes:

override bool Use(bool pickup)
{
    Super.Use(pickup);
    return false;
}
Blue-Shadow commented 1 month ago

That code snippet tells the engine the use has failed, even if didn't in reality, which means no use sound is played. I know, you're gonna tell me next to manually play the use sound in Use, but that's jumping through hoops just to get the behavior I want.

RicardoLuis0 commented 1 month ago

That code snippet tells the engine the use has failed, even if didn't in reality, which means no use sound is played. I know, you're gonna tell me next to manually play the use sound in Use, but that's jumping through hoops just to get the behavior I want.

you can just override UseInventory to return true instead of Use, it's a virtual as well