Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
ChrisVR

Closing the gate with a switch, and opening it back after 30 seconds?

Question

I'm getting closer to complete my map, but I want to make a switch that when pressed, it will close a gate nearby, but only for 30 seconds, then I want it to be opened again.

How do I get around that for UMDF gzDoom map?

Share this post


Link to post

16 answers to this question

Recommended Posts

  • 2

ACS. I'm not sure how familiar you are with ACS Scripting but assuming you're a complete newbie to it, here's a little helping hand!

 

Assuming you're working in GZDoom Builder or a similar editor such as Doom Builder X or Doom Builder 2, you can press F10 to open the scripts window. In this window, we're going to be adding the following scripts:

 

#include "ZCommon.acs"

Script "S_Gateway" (void) {
    Floor_RaiseByValue(1, 64, 128); // Raise gate floor (sector tag 1) by 128 units, at a speed of 64.
  	Delay(1050); // 30 seconds
    Floor_LowerByValue(1, 64, 128); // Lower gate floor (sector tag 1) by 128 units, at a speed of 64.
}

 

Above is a relatively basic script but if this is your first time working with stuff like this it may be intimidating. Let's break it down so you understand it:

 

#include "ZCommon.acs"

So, what does this mean? This is what all script files tend to start with, this line includes the common ACS functions available to you, which means your compiler knows what things like "Floor_LowerByValue" actually mean. You don't really need to understand this, just know that this should be at the top of your script file on line one. :)

 

 

Script "S_Gateway" (void) {
}

This defines a new script. You can either give scripts a number, or a name. For the sake of clarity, I recommend using named scripts, so when you return to work on your map you understand what the script is doing. Everything between the curly braces ( "{" and "}" ) will be run, from top to bottom.

 

 

Floor_RaiseByValue(1, 64, 128); // Raise gate floor (sector tag 1) by 128 units, at a speed of 64.
Delay(1050); // 30 seconds
Floor_LowerByValue(1, 64, 128); // Lower gate floor (sector tag 1) by 128 units, at a speed of 64.

 

Finally, the meat of the script. We have three lines - the functions we're using are very obvious what they do based on their names, but it's still a good idea to check the Wiki so you know what you're doing with them. I'll link to the wiki below.

 

The first line will raise the floor of your gateway. The numbers mean the following:

 

Floor_RaiseByValue(sector tag, speed, height);

 

I've assumed the sector(s) of your gateway are tagged 1, but if they're not you simply need to change the 1.

 

I've made the gate move at a speed of 64, which is relatively fast. This should hopefully stop the player running out quickly and avoiding the trap.

 

The second line is a delay. This tells the script to wait for n tics before proceeding to the next line. A tic in Doom is 1/35th of a second. I won't go into why, that's a little history lesson for another day. So, you wanted it to wait for 30 seconds, and we know there's 35 tics in a second, so we simply do the math (30 * 35) and punch in the number this results in, 1050. You can use maths inside of there, so if you couldn't be bothered to work it out, 30*35 would have worked as well as 1050. :)

 

The third line is very similar to the first, but I've changed the Raise to a Lower. "What goes up must come down", as they say!

 

You may have noticed I've added comments. If you want something to be easy to understand later, it's a good idea to comment your code. This can be done by placing a double forward slash before the comment, as seen.

 

All that's left is to trigger this in the map itself. Once you're done adding the scripts, click on the compile button, then close the scripts window. You trigger scripts the same way you trigger anything else - by applying the action to a linedef. It can be walkover, switch based, etc etc. the action you're looking for is Line action 80:ACS_Execute. You'll notice when you select this 5 arguments become available. The first of which is script number - next to this is a tickbox saying "named", click this then look for S_Gateway, select it. The rest of the options can remain as zero. If you want further explanation of what they're for let me know, but for the sake of keeping things simple, they should all be zero for now.

 

Test it, with any luck, you've got it working!

 

Below are the promised wiki links:

 

https://zdoom.org/wiki/ACS

 

The below are links to the individual script functions we used:

https://zdoom.org/wiki/Floor_LowerByValue

https://zdoom.org/wiki/Floor_RaiseByValue

https://zdoom.org/wiki/Delay

 

I hope this helps. Any further issues, let me know!

Share this post


Link to post
  • 1

I think you might have overcomplicated this, Dragonfly. There exists a lindef function in UDMF that does this with doors (249: Door_CloseWaitOpen).

Assign your switch linedef action 249, then give it tag whatever your door/gate is, give it whatever speed you want (64 would be as fast as a vanilla fast door), and give it a delay of 240.

Linedef Action: 249 Door Close Wait Open
Sector tag: <Your tag>
Speed: 64
Delay: 240
Light tag: 0

 

Share this post


Link to post
  • 0

Hah, that's funny, I've never used that action so it didn't come to mind. I'm no where near a computer which has GZDoom Builder on, so I couldn't look for myself before answering. Still, I guess my post works well as a primer to ACS. :P

Share this post


Link to post
  • 0

Thanks a bunch, this also helped me. I was reading about scripts already and even understand their syntax, etc. I was just wondering how the hell I am supposed to "spawn" something (in case of sparks for example) or actually make something happen (in case of this example in this very thread here). Thanks a lot, really helpful.

Share this post


Link to post
  • 0

I have followed the tip of @Aquila Chrysaetos.

I made a 3D floor switch (so that it floats) and gave it linedef 249 with delay 240, I assigned a tag to my gate, I can see an arrow pointing from the door to the switch, but it is not activated somehow.

 

What am I doing wrong?

Builder_2018-08-10_16-58-36.jpg

Share this post


Link to post
  • 0

I did just now, the gate did not seem top open, and I've got a sky glitch, 

 

I'm a total newbie, despite playing around for weeks with all the Doom apps now :)

gzdoom_2018-08-10_17-07-02.png

Share this post


Link to post
  • 0

Then you should use Dragonfly's suggestion, since he assumed you wanted a floor to raise whereas I assumed you wanted a door to close. This wasn't specified explicitly, so I couldn't be sure.

Share this post


Link to post
  • 0

I should have been more specific, but I really appreciate your time to put an answer.

I'll try the way of Dragonfly. Seems more complicated just by the length of the post, but I'll try :)

Share this post


Link to post
  • 0

If you want to move a floor, rather than a ceiling like the typical door, you can also look at these functions:

Both do a similar thing as the doors do -- move to a position, wait a bit, and then return to the original position. Use the one that makes sense for your setup, probably the UpWaitDownStay one if I understood what you're trying to do correctly.

Share this post


Link to post
  • 0

HOLY SH*T IT WORKS!

I have tried the scripting and it was much easier than I thought.

 

https://imgur.com/a/69b1n7e

 

Had to make few adjustments to the code but it was very easy to understand following your comments.

 

I can't thank you enough.

Share this post


Link to post
  • 0

So I tried to explore the idea of scripting further.

 

I have a 3D floor that I want to extend to the bottom, and then return back - and loop that motion.

 

I modified the script above to:

Script "S_Turbines" (void) {
    Floor_LowerByValue(28, 8, 104); // Lower turbine (sector tag 32) by 104 units, at a speed of 8.
    Delay(35); // 1 second
    Floor_RaiseByValue(28, 8, 104); // Raise turbine(sector tag 32) by 104 units, at a speed of 8.
   
}

I tried to apply that script using code 80 but I could not see changes in game.

 

I have attached two screenshot for visualization.

 

It is an underwater area, above this area there is rest of the playable level, so I'm using quite a lot of 3D floors.

Builder_2018-08-11_02-14-35.png

Builder_2018-08-11_02-14-49.png

Share this post


Link to post
  • 0

I forgot to edit the comment, but the values are correct, especially tag. I tried several different combinations, but could not to get it to work at all.

If anyone would be willing to look at the map file, I'm ready to upload it.

Just wanted to add small feature to the map, but it will work as well without it.

Share this post


Link to post
  • 0

I just noticed that you said it is a 3D floor. Are you wanting it to close like a door and then re-open? Make a sector next to the control sector with its floor level where you want it to lower to, and then have the control sector lower like a lift. No script needed.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×