Tips on a puzzle that includes placing 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!)
Post Reply
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Tips on a puzzle that includes placing items

Post by Hidden Hands »

Is there an effective way to use ACS to make a puzzle where the player searches the map for 2 or 3 items that they need to place on plinths (and the items actually appear on the plinths and leave the players inventory) and activate a secret door by doing so? I've been trying a few days but I'm really struggling with this one. I'm not even sure it is possibe. Is IT?

Thank in advance!
User avatar
Enjay
 
 
Posts: 26535
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Tips on a puzzle that includes placing items

Post by Enjay »

Definitely possible.

There are a few ways to do it but is your plinth is made from a sector, then I'd probably make the lines of the plinths run a script when you use them.

Set up the script to spawn the item on the plinth (it might be an idea to make a dummy item that looks like the pickup version but which is purely a decoration - so it can't be accidentally picked up again, depends on your exact setup really) and use [wiki]TakeInventory[/wiki] in your script to take away the one that the player is carrying.

[edit]
Meh! I was at a loose end so, have an example.
SkullPuzzle.pk3
(5.98 KiB) Downloaded 33 times
Just run with Doom2.

The scripting is probably messy (not my strong area) but it works (I think).
User avatar
Dan_The_Noob
Posts: 872
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Tips on a puzzle that includes placing items

Post by Dan_The_Noob »

basically a switch that takes the item and switches from a nothing to a something?
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Tips on a puzzle that includes placing items

Post by Player701 »

It is also possible to leverage the puzzle item mechanic from Hexen. Hexen itself has a few puzzles like those, where you have to find a puzzle item and place it on a wall or a decoration.

To do that, you will first need to create your own puzzle item by subclassing it from the PuzzleItem class (the wiki article has an example) and a decoration actor subclassed from SwitchingDecoration with both Spawn and Active states defined. The Spawn state sprite should depict the decoration without any item placed on it, and the Active state sprite should include the item.

In the map editor, assign the UsePuzzleItem special to your decoration, and it should automatically switch to its Active state when the player uses it and has the correct puzzle item in their inventory (be sure to match the value of the 1st argument with the number of your puzzle item as defined in your item class via PuzzleItem.Number). The item will be removed from the inventory automatically. UsePuzzleItem can also be made to run a script on success, so you should also assign a script number (2nd argument) to run your custom logic (e.g. increment a counter and open the secret door when enough puzzle items have been used).
User avatar
Enjay
 
 
Posts: 26535
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Tips on a puzzle that includes placing items

Post by Enjay »

Yup, as I said, there are a few ways to do it. :)

Personally, I find the way that I used in the example PK3 the simplest because almost everything is handled via the ACS script, but I've also used puzzle items, switchable decorations etc. Basically, I use whatever I feel works best for a particular situation.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Tips on a puzzle that includes placing items

Post by Hidden Hands »

Absolutely amazing, everyone thank you so much. I eventually went for something similar to Enjays example, and now it all works perfectly. This is beyond awesome, thank you so much.
Post Reply

Return to “Scripting”