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

A noob question here...

Question

As the title says I'm new in this world of doom mapping, my only experience designing levels was with RPG Maker back in the day.

I have learned a lot these days, however there is something that I have not been able to do, I want to know if it is possible to make a linedef active after getting a key card or something like that. I am using Ultimate Doom Builder by the way.

 

Thanks and sorry for my broken english. its not my native language...

Share this post


Link to post

18 answers to this question

Recommended Posts

  • 3

here's the way I have usually been handling this with ACS when working in UDMF format:

 

  1. Set up the line to activate the trap. This line will call a script, be triggered when player walks over, and be repeatable
    Spoiler

    loEQAaR.png

     

  2. Set up some lines around the key, which will activate another script to signify that the player has gotten the key

     
    Spoiler

    IMIbgR1.png

     

  3. Set up the scripts using the script editor in UDB (F10 is the default hotkey I think)

    1. If you're not familiar with scripting or any sort of coding yet, it might be helpful to just write out the logic in plain language first, like so:

      1. Spoiler
        
        start trap script:
        	if the player did not pick up the key, do nothing
        	if the player has already tried to activate the trap, do nothing
            
        
        	otherwise, trigger the trap by lowering a floor or something
            and make sure we note that we successfully triggered the trap this time
        
        pickup key script:
        	somehow mark that the player has picked up the key,
        	so that the trap script can make use of that info

         

         

    2. Then, turn that plain stuff into real scripts

      1. Spoiler
        
        // You'll always want this line at the top of your scripts; it
        // gives you access to all the built in zdoom stuff, like
        // all the actions (Floor_LowerToLowest and all that jazz) that
        // you would otherwise just use on lines directly
        #include "zcommon.acs"
        
        // Boolean variable (boolean means it's either true or false,
        // it's not a number or anything) to track whether the player
        // has picked up the key or not. Because this variable is
        // defined _outside_ of any specific scripts, all scripts
        // here will have access to the variable.
        bool picked_up_key = false;
        
        // This variable will track whether the trap has been activated
        // once or not. The line that triggers the start_trap script
        // needs to be repeatable (so that the trap can still trigger
        // with the key even if it failed to trigger once _without_
        // the key). Because of that, we need a way to know if the
        // trap has already been triggered so we don't do it twice.
        bool activated_trap = false;
        
        script "start_trap" (void)
        {
        	// Do nothing if the player hasn't picked up the key
        	if (picked_up_key == false) terminate;
        	// Do nothing if the trap already activated in the past
        	if (activated_trap == true) terminate;
          
        	// If we made it this far, then this is the first time
          	// activating the trap, so we need to make a note of that
          	// by setting the activated_trap variable to true:
          	activated_trap = true;
        
        
        	// Do stuff here to start the trap; one example
        	// would be to lower some floor like this:
        	Floor_LowerToLowest(10, 32);
        	// This lowers the floor of the sector with a tag 10 to
        	// the lowest adjacent floor, and does it at a speed
        	// of 32, which is decently fast; 8 is slow, 16 medium,
        	// but you don't have to stick to these numbers and can
        	// do any arbitrary number you want really
        	// More info here: https://zdoom.org/wiki/Floor_LowerToLowest
        }
        
        script "pickup_key" (void)
        {
        	picked_up_key = true;
        }

         

         

Edited by Tango

Share this post


Link to post
  • 0

For GZDoom, you could create a script that activates when the linedef is crossed, but with ScriptWait you could delay execution of that script until some other script has finished its execution(and that script could be set to run when you pick up the card or something similar). There are some examples on the linked page.

Share this post


Link to post
  • 0

Sorry, let me explain. I want that after getting a key card when the player "walks over" a linedef a certain event is triggered, for example a trap, but only after getting the key card, not before.

Edited by KermyDM

Share this post


Link to post
  • 0

You can put lines around the card and make an event happen when you walk over those lines.

 

I can elaborate further if you tell me what game configuration you're using

Share this post


Link to post
  • 0

In ZDoom, you could write an ACS script that does what you want, but only if an inventory check for the key (I think it's called CheckInventory() but I'm not sure) returns true. Without ACS, it would be much harder, although you could probably forcethe player to go a different way with some raised floors after they get the key.

Share this post


Link to post
  • 0
10 minutes ago, KermyDM said:

Sorry, let me explain. I want that after getting a key card when the player "walks over" a linedef a certain event is triggered, for example a trap. but only after getting the key card, not before.

 

Easily done even in vanilla format - just find the appropriate line action (a W1 (walk-over, once only) action is what you'll most likely want) and assign it to the desired line(s). No need for ZDoom ACS trickery.

Share this post


Link to post
  • 0
2 minutes ago, MFG38 said:

 

Easily done even in vanilla format - just find the appropriate line action (a W1 (walk-over, once only) action is what you'll most likely want) and assign it to the desired line(s). No need for ZDoom ACS trickery.

The problem with that is that it will execute regardless of whether you have the key. I suppose this is a problem of clarity; is the trap in the same place as the key? If so, yeah, a walk-once line will work. If not, then ACS is necessary.

Share this post


Link to post
  • 0

Yeah the trap is in the same place. It seems like I'll need ACS sooner or later, perhaps is a great idea to start learning a bit of scripting.

 

Thanks people!

Share this post


Link to post
  • 0

If this was Boom-only, you could jerry-rig something with raise / lower to nearest floor / ceiling actions, and grabbing the key moves a sector in such a way that only after grabbing the key there's a height difference to move to.

 

Since you're not limited to that, use ACS. It's way cleaner if you need to change it later.

Share this post


Link to post
  • 0
38 minutes ago, Tango said:

Set up some lines around the key, which will activate another script to signify that the player has gotten the key

 

If you're using UDMF, can't you just assign this script action to the key itself? This avoids the possibility of a player grabbing the key without actually hitting the triggers around it

Share this post


Link to post
  • 0
1 hour ago, KermyDM said:

Sorry, let me explain. I want that after getting a key card when the player "walks over" a linedef a certain event is triggered, for example a trap, but only after getting the key card, not before.

Yes this is possible. The easiest way is to use scripting. Set up the action the way you want it but don't assign a use type flag (walk over, switch etc). Keep that blank. Then when you pick up the key you can have a script that sets the line activation type (linked to the key itself). "SetLineActivation" is the action you want for that (there is a list of the use types on the wiki). Then the line will activate in a normal fashion after the key has been picked up.

https://zdoom.org/wiki/SetLineActivation


You can do the same thing in boom using voodoo doll logic gates but it's a bit less intuitive.

Share this post


Link to post
  • 0

You want lockedExecute:

 

https://zdoom.org/wiki/ACS_LockedExecute

 

Have a line action of 83, and the script that you specify will only be executed if you have key(s) specified in 'lock'. If you need it to only execute the script once, make sure you include a 'hasExecuted=true/false' boolean variable that is set and subsequently checked on second crossing. Note - I have never used this so I don't know if W1 also works, or whether it counts to walk and fail if you don't have the key...

 

Share this post


Link to post
  • 0

 

5 minutes ago, smeghammer said:

You want lockedExecute:

 

https://zdoom.org/wiki/ACS_LockedExecute

 

Have a line action of 83, and the script that you specify will only be executed if you have key(s) specified in 'lock'. If you need it to only execute the script once, make sure you include a 'hasExecuted=true/false' boolean variable that is set and subsequently checked on second crossing. Note - I have never used this so I don't know if W1 also works, or whether it counts to walk and fail if you don't have the key...

 

 

I think that will show you-need-key message when you walk over it and you do not have key... which might make it suspicious.

Share this post


Link to post
  • 0

Yup that will activate every time you walk over it saying you need a key. The method I showed will stop any activation of the line until you set the use type. I do this a lot. 

Share this post


Link to post
  • 0
26 minutes ago, Bridgeburner56 said:

Yup that will activate every time you walk over it saying you need a key. The method I showed will stop any activation of the line until you set the use type. I do this a lot. 

 

Good tip, thank you. That will save me trying it and shouting 'oh, bollocks!' when I got the 'you need key x' message :-)

Share this post


Link to post
  • 0
1 hour ago, SMG_Man said:

 

If you're using UDMF, can't you just assign this script action to the key itself? This avoids the possibility of a player grabbing the key without actually hitting the triggers around it 

 

you definitely can do it this way yeah! but, it is prone to getting borked with gameplay mods. it's not too difficult to inadvertently make a replacement Thing in a gameplay mod replace the old one without properly transferring any pickup/death actions. most mods probably do it properly, I reckon, but it still feels like a safer bet to go with lines for me

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
×