Help with timed triggers and random numbers in map.

Help with timed triggers and random numbers in map.

Re: Help with timed triggers and random numbers in map. Posted by jpwanabe on Thu Apr 7th 2011 at 10:08pm
jpwanabe
4 posts
Posted 2011-04-07 10:08pm
jpwanabe
member
4 posts 0 snarkmarks Registered: Apr 7th 2011
What I am trying to do is not so simple, and I'm not even sure possible. What I want is that after X seconds a random number will be selected, and a sound file, that corresponding to that number, will be played, along with another timer, that matches the length of the sound file, starting. Then I would like to have that number be disabled from being selected again.

For example;
Timer and sound 1 are 10 seconds long.
Timer and sound 2 are 15 seconds long.
Timer and sound 3 are 20 seconds long.
Timer and sound 4 are 25 seconds long.

Lets say that the first sound to be randomly trigged is sound 3. So after 20 seconds, the sound stops, and a new number, 1, is randomly selected. Now the numbers 1 and 3 are disabled from being selected. So after 10 seconds, the sound stops, and now number 4 is selected. So only number 2 is left to be randomly chosen.

What I'm asking for is this,
Is this even possible? And if so can someone tell me how or make a small example in a map and send it to me?
Re: Help with timed triggers and random numbers in map. Posted by Riven on Fri Apr 8th 2011 at 3:51am
Riven
1640 posts
Posted 2011-04-08 3:51am
Riven
Wuch ya look'n at?
super admin
1640 posts 1266 snarkmarks Registered: May 2nd 2005 Occupation: Architect Location: Austin, Texas, USA
Short answer: this is totally achievable!

Quick Answer: I have done it before and could maybe wrap it up in a .vmf for you to check out.

Long Answer: I appreciate you having abstracted the idea into inputs and outputs. My example incorporates a radio playing 3 different barks until the player "communicates" with the other end.

The three 'barks' play randomly, but they don't repeat until all the barks are played. So what that means is it makes sure you don't hear the same bark twice in a row, or even after two are played. Keeps it a little interesting.

The entites you'll want to use are a:
  • logic_timer
  • logic_case
  • logic_relay
The logic_case will link all your sounds as outputs. That is, use the first four case values each to link to one of your sounds. And set their value to:
-OnCase01| sound 1 | play sound
-OnCase02| sound 2 | play sound
ETC...

Use the logic_timer to use the random time option and give it a min and max value to pick within. When it fires, have it output towards the logic_case to 'PickRandomShuffle" this is the feature that makes sure it will not repeat that case until all cases have been picked.

After all four triggers from the logic_timer have been fired, then you can simply disable the timer after the last one so it doesn't pick any cases any more.

To prevent another sound playing while one is still playing, be sure to toggle the timer off for the specified amount of time (the duration of that particular sound) and then re-enable it after the sound is done. The best way I've found to do this, is use the |delay| field in the I/O system of your logic_case to make a trigger that hits the same time as the sound, but is delayed the length of the sound before actually triggering.

You can use a logic_relay to help keep things organized. it would be optional though.

I may not be able to upload a file for another day or two until I can get it out of the current map.

Does that help any?
Blog: www.playingarchitecture.net
LinkedIn: Eric Lancon
Twitter:@Riven202
Re: Help with timed triggers and random numbers in map. Posted by jpwanabe on Fri Apr 8th 2011 at 5:27am
jpwanabe
4 posts
Posted 2011-04-08 5:27am
jpwanabe
member
4 posts 0 snarkmarks Registered: Apr 7th 2011
It sorta helped, but some went over my head. I'll mess around with those and try to see what I can do on my own. But a .vmf would help me very much. I learn best from examining what has already been done.
Re: Help with timed triggers and random numbers in map. Posted by omegaslayer on Thu Apr 14th 2011 at 6:03pm
omegaslayer
2481 posts
Posted 2011-04-14 6:03pm
2481 posts 595 snarkmarks Registered: Jan 16th 2004 Occupation: Sr. DevOPS Engineer Location: Seattle, WA
jpwanabe said:
It sorta helped, but some went over my head. I'll mess around with those and try to see what I can do on my own. But a .vmf would help me very much. I learn best from examining what has already been done.
Did the problem get resolved? If so please mark Riven's answer correct :)
Re: Help with timed triggers and random numbers in map. Posted by jpwanabe on Fri Apr 15th 2011 at 5:14am
jpwanabe
4 posts
Posted 2011-04-15 5:14am
jpwanabe
member
4 posts 0 snarkmarks Registered: Apr 7th 2011
I'm not able to get it to work right. If I could get an example I would be able to do it better.
Re: Help with timed triggers and random numbers in map. Posted by Riven on Sat Apr 23rd 2011 at 9:22am
Riven
1640 posts
Posted 2011-04-23 9:22am
Riven
Wuch ya look'n at?
super admin
1640 posts 1266 snarkmarks Registered: May 2nd 2005 Occupation: Architect Location: Austin, Texas, USA
Ok, here is the example map I created for you and anyone else looking for this kind of example. Mind you it's probably not exactly what you're looking for, but I imagine it's quite similar, and once you understand the way in which it was achieved, you'll be able to mutate it into doing exactly what you want it to.

Check out the discussion page here: http://www.snarkpit.net/index.php?s=forums&f=7&t=12115

Download page here: http://www.snarkpit.net/index.php?s=downloads&game=46&cat=1

I hope this helps, and enjoy! :)
Blog: www.playingarchitecture.net
LinkedIn: Eric Lancon
Twitter:@Riven202
Re: Help with timed triggers and random numbers in map. Posted by jpwanabe on Tue Apr 26th 2011 at 5:57pm
jpwanabe
4 posts
Posted 2011-04-26 5:57pm
jpwanabe
member
4 posts 0 snarkmarks Registered: Apr 7th 2011
Well after a day and a half of examining the example and trying it on my own, I've discovered that this task, is beyond my skills. Sorry to have caused you problems.
Re: Help with timed triggers and random numbers in map. Posted by Riven on Tue Apr 26th 2011 at 6:09pm
Riven
1640 posts
Posted 2011-04-26 6:09pm
Riven
Wuch ya look'n at?
super admin
1640 posts 1266 snarkmarks Registered: May 2nd 2005 Occupation: Architect Location: Austin, Texas, USA
Not a problem, If it doesn't help you, I imagine it'll help someone else somewhere.

But basically if you want to do any kind of neat interactive or autonomous 'machinery' or connectivity in Source you'll need to learn the ropes of the I/O (Input/Output) system.

If you haven't already found this yet, here's a good primer:
http://developer.valvesoftware.com/wiki/I/O

Good luck in your mapping endeavors. :)
Blog: www.playingarchitecture.net
LinkedIn: Eric Lancon
Twitter:@Riven202