Snarkpit Articles

Additive Triggers

Using Math_Counters To Trigger Single Events From Multiple Triggers

Additive Triggers

Sometimes you want the player to make something happen (eg. explosions, enemy invasions, etc.) but you want him to do more than just step into a cerain room, or push a certain button, to make it happen. Sometimes you want the player to hit multiple buttons, or step into multiple triggers; well that's where this tutorial comes in.

I am going to show you how to, in this case, release your rebel friends by doing a panoply of things, all by using a math_counter.

I made a map for this tutorial, without the part you care about completed. It's the rudimentary part of the example I will be showing you, so download it from here.

Everything in the map is set, except the ending sequence, which is triggered by a logic_relay. All we have to do is activate that, and then the ending sequence will begin.

Article image


The Example Map

Now that we have a basic setup, it's time to make something happen.
See the two hills? Put a func_button on each hill.
Name one button1, and the other button2.
Check the "don't move" flag for each of them
Change delay before reset: -1

Now make a math_counter, and name it counter
Maximum Legal Value: 2

Article image


Now give it this output:

Article image


Now give each of the func_button entities this output:

Article image


Now compile the map. What happens is that after you've pressed both buttons, the door opens, and the citizens inside walk out.

What happens is that when you press a button, it adds 1 to the math_counter (it starts out at 0). The math_counter's maximum value is two, so when both buttons are pressed, it fires its output, which opens the door and releases the citizens.

Now compile and run the map.

If you learned anything from the above, you don't need to continue

Now here's another example. Within the same map, place a game_text entity, an env_fade entity, and another math_counter entity.

Env_fade:
Name: fade.
Hold Fade(seconds): 10000.

Game_Text:
Name: text.
Message Text: Congratulations.
Hold Time: 10000.

Math_Counter:
Name: counter2.
Maximum Legal Value: 2.

Give your second math_counter these outputs:

Article image


Make two trigger_once entities around the scripted sequence entities already in the map.

Article image


Check the "only player ally NPCs" flag, and uncheck all the other flags.

Now give both triggers this output:

Article image


Normally I would use the output "OnEndSequence" from a scripted_sequence, but I've found it doesn't work the way I want it to(IE: at all), so I used the method I used

Now compile and run the map, and see the effects!

EDIT:
Due to popular demand, I have added an example map of the full-version of the map in this tutorial.

Linkage

Discussion

Posted by Stadric on Tue Feb 28th 2006 at 1:32am
[Author]

Oh phew, I'm glad that's over, I was really worried there for a minute.
Posted by Orpheus on Tue Feb 28th 2006 at 1:23am

All images loaded. Took a bit (about 1.5 minutes) but they're here.
Posted by Orpheus on Fri Feb 24th 2006 at 6:01pm

Dunno. Will have to see when I get home. I am on my nephews PC currently and he has DSL.

Take a moment and read my tutorial. It might help you on your next tutorial.
Thanx for trying.
Posted by Stadric on Fri Feb 24th 2006 at 4:57am
[Author]

Okay, I didn't get them down to 15K apiece, but I did drastically reduce the file size(by about eight tenths).
As for making them smaller, I am out of ideas. I used photoshop and it gave me these, and the only other image program I have is paint.
If the new pics aren't showing up, refresh your browser
Posted by Orpheus on Thu Feb 23rd 2006 at 10:24am

They should be 15k across the board.. You need a link to my tutorial?

No wonder I couldn't see them. :(
I am almost mad that no one else said anything about a couple megs worth of screens in one tut.
Posted by Stadric on Thu Feb 23rd 2006 at 2:27am
[Author]

Well the images are 15.98Kb, 483.96 Kb, 293.17Kb, 293.18Kb, 176.28Kb, 389.87Kb, and 290.56Kb, respectively.
Posted by Orpheus on Thu Feb 23rd 2006 at 12:47am

I am having serious troubles with the images. Something is wrong or... They're to big.
I cannot get any of them to finish on my browser.
Posted by Dark_Kilauea on Wed Feb 22nd 2006 at 7:15am

Good stuff :)
Posted by DrGlass on Tue Feb 21st 2006 at 9:50pm

I think the only thing this tutorial lacks is an explination on how to subtract from the counter (in case someone wanted to force the player to activate the two buttons before the first one reset).
Posted by rs6 on Tue Feb 21st 2006 at 5:23pm