Shootable switches -- actions....?

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, 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.
Post Reply
User avatar
Chipper35
Posts: 14
Joined: Mon Nov 11, 2019 12:22 pm
Location: Texas

Shootable switches -- actions....?

Post by Chipper35 »

I've tried to educate myself on shootable switches. I've read a few things and watched several videos. While I'm not a brand new mapper -- I am no expert, either.

Here is my plan (and I'm not asking for someone to write out every step needed -- just a nudge in the right direction) [please]:

I have the game ending switch out in the open on my final level. Players walks up to it, throw it -- game ends, with credit screen. Touchdown!
I want to modify the map, to have a shootable switch (far away from the game ending switch)that, both: Opens a hidden door, releasing a bunch of monsters nearby AND turns 'on' the level ending switch. e.g. A shootable switch that does TWO THINGS.

Cannot figure it out --- can a get a minor nudge? :D :?
User avatar
Enjay
 
 
Posts: 27306
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Shootable switches -- actions....?

Post by Enjay »

Generally speaking, if you want any switch to do more than one thing in ZDoom, it's best to do it via an ACS script where you can easily chain any number of different things to happen together in a single sequence as part of your script. For something relatively simple like just listing a few different actions in your script, very little programming skill is needed at all.

The caveat is that it's best if you are working with your map in ZDoomHexen format, or (even better) UDMF. It's also worth noting that many other source ports do not support ACS. So, if your map is intended for multiple ports, ACS might not be the best way forward. If it's for a ZDoom-based engine though, it will do exactly what you need.

In those map formats it's also very easy to tell the game that the switch should be activated by being hit. It's simply a flag in the editing dialogue for the line.

Opening a door via a script is straight forward. There is an ACS special specifically for that.

Activating the exit switch is slightly more involved (but only slightly). The two options that spring to mind are:
Make the exit switch also run a script. The script should check a variable and, if the variable is in one state, it does nothing (or maybe even puts a helpful message on screen), if the variable is in another state, the switch exits the level. Your first (shootable) switch would change the condition of the variable when it runs its script. If you are not familiar with working with variables, that may sound complicated, but I (or many others) can easily explain it if you need it.

The other option would be to have the shootable switch literally change the function of the exit switch directly using an ACS command called SetLineSpecial. So, your shootable script would literally be a simple list of two commands: one to open the door, the other to change your final switch so that it has an exit special attached to it.
User avatar
Chipper35
Posts: 14
Joined: Mon Nov 11, 2019 12:22 pm
Location: Texas

Re: Shootable switches -- actions....?

Post by Chipper35 »

Extremely helpful: Thank you!
User avatar
fakemai
Posts: 398
Joined: Mon Feb 12, 2018 12:26 am
Location: Australia

Re: Shootable switches -- actions....?

Post by fakemai »

Tangental, but make sure it is painfully obvious that you're supposed to shoot that line since many of the official IWADs fail that spectacularly, worst in TNT MAP18 (and Doom 2 for that matter), and a counter-example being SIGIL with the evil eyes. Also that you provide some kind of ammunition in case the player happens to be empty, softlocking is not something you want to happen!

Also if you want to keep it more compatible than using ACS what you could do is keep the switch in the open but block access to it via the same sector action your monster traps are linked to, which might also allow for some fun speedrun tricks like Doom 2 MAP07. Unfortunately vanilla Doom has very few shootable line specials, I think there's only two? You may at least want to use Boom line types. EDIT: Oh and one other thing, in vanilla Doom only hitscan and melee trigger impact switches, various source ports allow missiles to do it as well but you'll want to make sure it's pistol ammo. Also worth mentioning is Duke 3D tries to make it obvious you have to shoot switches by putting a pistol nearby.
User avatar
Enjay
 
 
Posts: 27306
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Shootable switches -- actions....?

Post by Enjay »

I'm going off memory here, but I think there might be 3.

There is, of course, the repeatable "OpenDoor (and stay open)" one that everyone knows. (Type 46?) Interestingly, it is a repeatable line, even though it opens the door and the door stays open (but something else could close it, obviously). The reason I say it's interesting is because there is one right at the start of Doom2 map18. You shoot the door (which has a lion switch texture on it) to open it and if you then stay in the little start room shooting the enemies outside, you can hear the switch clicking with every shot you fire through the open door.

Then I *think* there are also these two (both are non-repeatable):
Raise floor to the next highest (I think this one also changes floor texture and type) (Type47?)
Raise floor to lowest ceiling (Type24?)

I always found it weird that a pistol shot could activate switches, but being hit by a rocket couldn't. I'm glad most source ports addressed that - especially when a lot of uses for hit-activated lines are things like breaking windows, destroying computers and so on.

And, just to be clear and avoid potential confusion for Chipper35 - the above is only correct in the original Doom map format. In UDMF (and with slightly fewer options in ZDoomHexen), any line type can be activated by any activation type. So, if it's an action that can be allocated to a line, you can choose to have it activated by being shot (either impact or the shot crossing the line), using the line, pushing (bumping) the line, crossing the line, monsters doing any of those and so on, as well as deciding whether to make it repeatable or not, you can set it to be activated from behind or front only, to check a suitable height of activation in some circumstances, pass the activation through to something behind... It's much more flexible than having the line action tied to one specific activation type like in the original Doom.
User avatar
Kappes Buur
 
 
Posts: 4201
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: Shootable switches -- actions....?

Post by Kappes Buur »

On the subject of shootable switches, I seem to recall a discussion of a switch also being activated when shooting above or below the switch to trigger an action special, in this case a door opening.

Was it ever resolved that when only the switch texture is hit that the action is triggered?

https://ibb.co/Nn6v2n95

[edit]
I must have opened an old version of my map accidentally, because this was fixed a long time ago.

https://ibb.co/v6896Zqb
Post Reply

Return to “Mapping”