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

Multiple triggers at once

Recommended Posts

Hello :)

Images that will help explain - http://imgur.com/a/4y6c8

I'm building a path with lights on it, and I want the lights to be off initially, but be able to be turned on with a switch. The problem is I want different sectors to change to different light values - brighter for the sectors around the lights and not so bright on the path.

I'm trying to do it with "Light Changes to Brightest Adjacent" but I can't do this with one trigger, because it changes everything to the same brightness, even though some sectors are next to brighter sectors. The current workaround is having a walkover trigger before the switch so that I can have two triggers.

The order of the triggers is important - if the sectors next to the "bright" sectors get triggered first, the whole corridor will be very bright.

Is there a way to do this better? I've looked briefly into scripting but it's way too complicated for me. I'm building my level in Doom in zDoom format in doom builder.

Thanks for any help :)

Share this post


Link to post

You should totally use scripting as it will perform exactly what you want it to. You can copy and paste the script below into your scripts and just adjust the values.

#include "zcommon.acs" // For every map with scripts you need this small description on the very top of the script list. It tells Doom the scripting you're using is ACS.

Script 1 (Void) // Basically which script this will be numbered as. The Void part means the script shouldn't execute unless you make something do it, like the switch for example.

{
Light_Fade (1, 256, 0); // First value = tagged sector. Second value = how much darker or brighter you want the sector to be. Third value = In what duration do you want the lights to change? I think 0 is instant, the higher number the slower it is.
}

Finally in your switch linedef, set action special as Execute Script (might be 80 for you), make sure to select script 1 in the drop down box and then tick the appropriate box to activate like 'when player presses'. Oh and don't forget to press the little compile button in the script menu after you place and adjust it otherwise the action special may not recognize script 1 yet.

With this technique you can do multiple lights in one action just as you wanted.

#include "zcommon.acs"

Script 1 (Void)

{
Light_Fade (1, 256, 0);
Light_Fade (2, 206, 0);
Light_Fade (3, 156, 0);
Light_Fade (4, 106, 0); // Tag 1 turns really bright and tag 2, 3 and 4 gets less so.
}

Share this post


Link to post

Awesome thank you :)

Some questions if you may.

How do I create the script? Do I just open the script editor? What type of script do I make? ZDoom ACS? It asks me to then save the script, so do I have to use Slade or something to put it in the level?

I can't see the Execute Script special action. Do I need to be using Hexen format? If so, will I break anything by changing from Doom in Doom to Doom in Hexen format?

Share this post


Link to post

I tried it in hexen format and it works great. Being able to fade the lights in is amazing. As hexen format uses different effects I can't really change older levels over to this format can I?

Can you have a wad with maps in different formats?

Share this post


Link to post

All sorted both from a scripting and converting to hexen format standpoint. Thank you Chezza and Kappes Buur :)

Share this post


Link to post
Quineotio said:

Can you have a wad with maps in different formats?

Yes, there is no problem with that. Loading a map is a process that happens just before you try to play any map, and assuming you're using a source port that supports all of the map formats that maps in your wad are made in, the source port will always detect just the current map's format and load it properly.

Share this post


Link to post

Unless you wasting to keep compatibility for something specific, I would recommend using UDMF, not doom in hexen. It's the most robust format to use

Share this post


Link to post

My question to your first question (which I suppose has been answered implicitly) is "what port(s) are you targetting?" It seems Zdoom, as you've gone for a Zdoom-specific solution (although it might work in Eternity, I don't know).

If you were targetting Boom, you would have to do something with boom conveyors and voodoo dolls.

Share this post


Link to post

You could also accomplish this without scripting using a few separate lines 1 unit apart at the switch all set to "Player presses use (PassThru)", except the switch itself (the rearmost line), which would the the normal "Player presses use". In Doom-in-Hexen format, use action 112 Light Change and specify the light level you want, so it won't matter that all the lines activate at once. This could also be done in Boom format, except I don't remember if you could change a sector to a specified light level.

Share this post


Link to post
Empyre said:

This could also be done in Boom format, except I don't remember if you could change a sector to a specified light level.

Not directly, but there are functions to change the target sector's brightness to darkest adjancent sector or brightest adjancent sector to the target sector, so if the mapper joined the target sectors with dummy sectors outside the map and made more dummy sectors adjancent to these dummy sectors with different brightnesses, the effect could be achieved, although perhaps not in all cases, depending on brightnesses of the target sector's adjancent sectors inside the actual map.

Share this post


Link to post
scifista42 said:

Not directly, but there are functions to change the target sector's brightness to darkest adjancent sector or brightest adjancent sector to the target sector, so if the mapper joined the target sectors with dummy sectors outside the map and made more dummy sectors adjancent to these dummy sectors with different brightnesses, the effect could be achieved, although perhaps not in all cases, depending on brightnesses of the target sector's adjancent sectors inside the actual map.


I've used this technique in boom. The main difficulty I found was that it only worked if the sector numbers were in numerical order from darkest to lightest, I'm guessing the game lights them in that order. It would work in vanilla too, if you used a walkover trigger rather than a switch.

Share this post


Link to post
Empyre said:

You could also accomplish this without scripting using a few separate lines 1 unit apart at the switch all set to "Player presses use (PassThru)", except the switch itself (the rearmost line), which would the the normal "Player presses use". In Doom-in-Hexen format, use action 112 Light Change and specify the light level you want, so it won't matter that all the lines activate at once. This could also be done in Boom format, except I don't remember if you could change a sector to a specified light level.


That's a good trick. I've been playing around with scripting though and it seems way more useful. The way I had to do it before was create lots of little sectors inside the sectors I wanted lit so that I could get them all to change to the correct brightness. With a script I don't need to do that. Seems like scripting is just the best way to trigger multiple events at once.

About what port I'm targeting, Zdoom. I don't know that much about this stuff, I'm fairly new to mapping. I like how Zdoom looks like I remember doom looking, and I love the lighting.

Share this post


Link to post
mouldy said:

I've used this technique in boom. The main difficulty I found was that it only worked if the sector numbers were in numerical order from darkest to lightest, I'm guessing the game lights them in that order. It would work in vanilla too, if you used a walkover trigger rather than a switch.


On my TODO list for WadC is a library to automate this. I also found it a bit sensitive to sector order (I tried to make a room-gradually-lights-up-when-you-open-the-door a la Hexen)

I thought someone might be interested to see what I've done with the lighting. This is just the very beginning of the level and I haven't really done anything else, but I think the lights look cool.


Just to confirm it doesn't work in Eternity. I've downloaded Zdoom to try it out and it looks pretty good!

Share this post


Link to post
Jon said:

Just to confirm it doesn't work in Eternity. I've downloaded Zdoom to try it out and it looks pretty good!


Is the incompatibility with Eternity something I can fix, or are there just fundamental differences between engines? I originally started making the level in doom in zdoom format, but switched to doom in hexen to get the script working, then to UDMF on advice from Trusty_McLegit (did you change your name?) . Maybe something got screwed up along the way?

Thank you for the compliment. I'm planning on making lighting a focus on this map. I think there's a lot of cool stuff that can be done.

Share this post


Link to post
Quineotio said:

Is the incompatibility with Eternity something I can fix, or are there just fundamental differences between engines?

Don't worry too much about it, Eternity's support for ACS and UDMF/Hexen format maps is kind of a work-in-progress at this point.

Share this post


Link to post
Gez said:

Don't worry too much about it, Eternity's support for ACS and UDMF/Hexen format maps is kind of a work-in-progress at this point.


Ok cool, thanks :)

Share this post


Link to post

I have another noob ACS question... I have two switches in my level which control the light levels in two connected areas. Both switches turn on multiple lights. The sectors bordering the first area light up a little bit when you press the first switch to emulate real life light transfer and get rid of the hard border between light and dark, then light up completely when you click the second switch.

I've used a script with multiple Light_Fade functions to make the changes to the different sectors' light levels, and it all works fine when you press the first switch first. But when you press the second switch first, the first switch lowers the light level of the border sectors, which I don't want it to do.

I have some images to help explain. The first image is with the first switch pressed only. The second is with both pressed in correct order. The third is with the second switch pressed first.

http://imgur.com/a/NEPv3

I assume that what I need to do is use an "if" in the first script that checks the light level of the border sectors with "GetSectorLightLevel" and only activates the light change in those sectors when the light level is the unlit value (i.e. when the player hasn't activated the second switch). But I can't figure out how to do it - where to place the "if", how to call the light value... I'm a noob. Can anyone help me with this?

I've uploaded an updated version of the level if you want to look - http://crutherfordmusic.com/toxin_refinery_3.wad

The scripts I'm using for the lights in question are below. Note that the sectors tagged 14 are the border sectors I'm having problems with. Also note that even if the second script is activated first, I still need the light changes in the first script other than 14 to occur.

Script 1 (Void)

{
Light_Fade (2, 172, 250);
Light_Fade (3, 240, 150);
Light_Fade (4, 240, 350);
Light_Fade (5, 172, 250);
Light_Fade (14, 128, 350);
}

Script 2 (Void)

{
Light_Fade (6, 168, 220);
Light_Fade (7, 240, 180);
Light_Fade (8, 168, 350);
Light_Fade (9, 240, 250);
Light_Fade (10, 148, 300);
Light_Fade (11, 160, 300);
Light_Fade (12, 130, 350);
Light_Fade (14, 168, 220);
}


Let me know if anything is unclear. Thanks in advance for any help :)

Share this post


Link to post

Try this:

int i = 0;

Script 1 (Void) {
    Light_Fade (2, 172, 250);
    Light_Fade (3, 240, 150);
    Light_Fade (4, 240, 350);
    Light_Fade (5, 172, 250);
    if(!i) { Light_Fade (14, 128, 350); }
}

Script 2 (Void) {
    i = 1;
    Light_Fade (6, 168, 220);
    Light_Fade (7, 240, 180);
    Light_Fade (8, 168, 350);
    Light_Fade (9, 240, 250);
    Light_Fade (10, 148, 300);
    Light_Fade (11, 160, 300);
    Light_Fade (12, 130, 350);
    Light_Fade (14, 168, 220);
}
Where "i" is a map scope variable and "!i" checks if the value of "i" is equal to zero.

Share this post


Link to post

Awesome thanks it worked and I learned some things :)

Is there somewhere I can read up on how the exclamation mark works? I don't know what I'd even search for.

Share this post


Link to post

Thank you so much. I've been surfing the ACS pages but it's difficult to figure out. Every bit of knowledge seems to require other bits of knowledge. I would like to learn C - maybe ACS is a good way to start getting familiar while I figure out how to turn on lights :P

I'm enjoying learning and I'm starting to see the power of scripting. I really appreciate the help you and others have given me - it makes a huge difference.

Share this post


Link to post

You could even have this:

int i = 0;

Script 1 (Void)
{
    Light_Fade (2, 172, 250);
    Light_Fade (3, 240, 150);
    Light_Fade (4, 240, 350);
    Light_Fade (5, 172, 250);
    if (i == 0)
    {
        i = 1;
        Light_Fade (14, 128, 350);
    }
    else if (i == 1)
    {
        i = 2;
        Light_Fade (14, 168, 350);
    }
}

Script 2 (Void)
{
    Light_Fade (6, 168, 220);
    Light_Fade (7, 240, 180);
    Light_Fade (8, 168, 350);
    Light_Fade (9, 240, 250);
    Light_Fade (10, 148, 300);
    Light_Fade (11, 160, 300);
    Light_Fade (12, 130, 350);
    if (i == 0)
    {
        i = 1;
        Light_Fade (14, 128, 350);
    }
    else if (i == 1)
    {
        i = 2;
        Light_Fade (14, 168, 350);
    }
}
What happens then: in sector 14, if you hit only one switch, the light fades to 128, if you hit both switches, the light fades to 168, and this is regardless of the order in which switch are hit.

In fact, you could also do it this way, to remove code duplication and experiment with using functions:
function void LightInSec14 (void)
{
    if (i == 0)
    {
        i = 1;
        Light_Fade (14, 128, 350);
    }
    else if (i == 1)
    {
        i = 2;
        Light_Fade (14, 168, 350);
    }
}

Script 1 (Void)
{
    Light_Fade (2, 172, 250);
    Light_Fade (3, 240, 150);
    Light_Fade (4, 240, 350);
    Light_Fade (5, 172, 250);
    LightInSec14();
}

Script 2 (Void)
{
    Light_Fade (6, 168, 220);
    Light_Fade (7, 240, 180);
    Light_Fade (8, 168, 350);
    Light_Fade (9, 240, 250);
    Light_Fade (10, 148, 300);
    Light_Fade (11, 160, 300);
    Light_Fade (12, 130, 350);
    LightInSec14();
}

Share this post


Link to post

Thanks Gez :) The first bit of code works. The second one has an error on line 4 (if i == 0;) that says "Identifier has not been declared". I assumed it needed a map scope variable like the first bit of code, so I put "int i = 0;" above the top line and it worked. So:

int i = 0;
function void LightInSec14 (void)
{
    if (i == 0)
    {
        i = 1;
        Light_Fade (14, 128, 350);
    }
    else if (i == 1)
    {
        i = 2;
        Light_Fade (14, 168, 350);
    }
}

Script 1 (Void)
{
    Light_Fade (2, 172, 250);
    Light_Fade (3, 240, 150);
    Light_Fade (4, 240, 350);
    Light_Fade (5, 172, 250);
    LightInSec14();
}

Script 2 (Void)
{
    Light_Fade (6, 168, 220);
    Light_Fade (7, 240, 180);
    Light_Fade (8, 168, 350);
    Light_Fade (9, 240, 250);
    Light_Fade (10, 148, 300);
    Light_Fade (11, 160, 300);
    Light_Fade (12, 130, 350);
    LightInSec14();
}
The problem with these two bit of code for my particular application is that one of the lights in the second area is next to "sector 14". Image below.

http://imgur.com/XCwFXrX

This shouldn't be a problem to fix - I think you've given me all the tools I need. I'll post the finished solution when I'm done.

I read somewhere that having more than 8 things happen at once can cause problems. Is this true? To make it work the way I want to, I'm going to need to have more groups of sectors under different tags - more than 8 functions in each script. Should I be concerned?

Share this post


Link to post
Quineotio said:

I read somewhere that having more than 8 things happen at once can cause problems. Is this true? To make it work the way I want to, I'm going to need to have more groups of sectors under different tags - more than 8 functions in each script. Should I be concerned?

Not really; it might have been true in the past where performances were lower but now?

Also keep in mind that in UDMF you can have sectors with multiple tags (moreid property).

Share this post


Link to post
Gez said:

Also keep in mind that in UDMF you can have sectors with multiple tags (moreid property).


I see the option in GZDB but not DB2 (which I'm currently using). Should I just be using GZdoom builder?

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
×