Searchable Containers

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!)
Posts: 1
Joined: Tue Dec 20, 2022 3:11 pm

Searchable Containers

Post by TheCowness »


I'm trying to create a map that has searchable containers like you might find in an RPG (treasure chests, dressers, giant jars), and am looking for advice on the best way to do this. I'm very new to ACS/ZScript, so if there's a completely different direction I should go in to accomplish this, I'm open to it.

The ideal flow would be:
1) Player interacts the 1st time, "You found ______" displays, and you collect the ammo or armor or key or whatever.
2) Player interacts the 2nd time, "But the chest was empty" displays

Currently, I've got a linedef with an action that calls an ACS script. My current draft of the script looks like this:

Code: Select all

//TID is basically a "container ID" in this version.  Place a Thing on the map and give it this tag to serve as a flag describing whether the container has been searched.
script 3 (int tid){
		//Branch based on TID to determine what's "inside" the container.
		if(tid == 5){
			Print(s:"You found Ten Armor Bonuses");
		Print(s:"Nothing special is found.");
I think this version is acceptable, but is there a better way to check if the linedef has been activated before than to create a dummy object and check for its existence? I couldn't find any ACS functions that would affect the linedef that's calling the script to change the script it calls, or return its tag(s) to stuff them into an array of "opened containers".

I was previously using Thing_Move to teleport invisible items onto the player so that I could see the item "inside the container" in the map editor, but that caused other problems - the item wouldn't be collected until you moved, and sometimes the Thing_Move would fail if you were standing against a wall (or the container itself).


Return to “Scripting”