Two inventory bars - one for items, one for puzzle items?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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!)
Post Reply
User avatar
Enjay
 
 
Posts: 27203
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Two inventory bars - one for items, one for puzzle items?

Post by Enjay »

I'm trying to figure out how (or if) there is some way to distinguish between normal inventory items and puzzle items, and then draw them in separate inventory bars in a ZScript status bar.

Why?
I want the general inventory bar to be for things that the player often wants quick access to - health items, grenades/bombs, activatable powerups etc.
By default, puzzleItems appear in the inventory but they can't really be used from there, and all that usually happens is that the player gets told as much if they try to use them. So, they kind of get in the way when the player is trying to pick a usable item, particularly if it's in the heat of combat.

What I thought might be a solution would be to have the inventory bar exclude puzzleitems somehow. However, I would still want an on-screen indication to let the player know that any given puzzle item is indeed in their inventory. So, I thought one bar for regular, usable items and another that appears only when puzzle items are being carried. Of course, that also has implications for new and separate key bindings for the additional bar too.

It's just a "nice to have" and I'm open to other suggestions. e.g. I only ever use puzzle items sparingly and I think the most I have ever put on one map is two, so perhaps simply drawing their icon somewhere on screen would be suitable - but then how to make puzzle items appear in position X, unless an item is already there, then make it appear in Y? (Also, bear in mind that advanced ZScript and me are not entirely compatible.)

So, yeah, it'd be nice if it could be done, and I'd appreciate some input/help, but if it can't be done, or if it is too convoluted, it's by no means a "must have" thing either. The current system works. It'd just be nice to separate out the usable and the not usable items into separate places.
User avatar
Zhs2
Posts: 1303
Joined: Fri Nov 07, 2008 3:29 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Maryland, USA, but probably also in someone's mod somewhere
Contact:

Re: Two inventory bars - one for items, one for puzzle items?

Post by Zhs2 »

The Inventory.INVBAR flag controls whether an inventory item displays in the usable inventory. It would be easier and make a lot more sense to design a map where pressing use on a line checks for a puzzle item and reacts accordingly, contrasting to the Hexen method of "the item must be used while looking at the controlling line". I have definitely had the same thoughts as you about wanting two inventory bars for consumables and key items while playing Dynamite Duchess, but the biggest caveat I can think of to controlling two bars is that GZDoom doesn't support chorded binds to simplify the process (e.g. can't do modifier key plus regular key, aka Shift+[/] to control a second bar much less needing a whole other hotkey to USE items from that bar...) It's very possible to do all this and bind them to another set of keys, but overkill for gameplay purposes. Just toss the whole Hexen methodology entirely imo and let the line specials react.

As for drawing these items on screen, the basic GZDoom example to learn from is DrawPowerup in gzdoom.pk3:zscript/ui/statusbar/statusbar.zs, which draws individual powerups outward from the top right corner of the screen based on how many you have. Simple enough to take this code, cast to PuzzleItem instead of Powerup, and use in either: the Draw function of a ZScripted status bar if you went the whole mile to do a ZScripted status bar, or a RenderOverlay event otherwise - there is a global variable simply named "StatusBar" from which you can call HUD drawing functions (for example, DrawTexture - full list here).
User avatar
Enjay
 
 
Posts: 27203
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Two inventory bars - one for items, one for puzzle items?

Post by Enjay »

Thanks. That's very useful.

As it happens, the items in question probably don't need to be PuzzleItems for the most part (if at all). I tend to use them with standard scripts and "check inventory", or sometimes they are just there to acknowledge that the player has picked up an item that is the MacGuffin for the map, and the item doesn't actually even need to be used at all. The only reason I inherit from PuzzleItem is because that's what I did with the first ones when I was trying to figure stuff out, and I never really revisited the idea. I also gave a few custom messages from the inventory, appropriate to the type of item, but I could easily forgo that if necessary.

So, yeah, I could just remove the +INVENTORY.INVBAR flag and draw them. I'll take a look at that code and see if I can get it to work in my HUD (which is already a ZScript one - thanks to Ed the Bat).
Post Reply

Return to “Scripting”