Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Random sounds
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#1
Random sounds

I'm trying to get random sounds to play but I must be doing something wrong because they wont. Before trying this I didnt even know you could do random sounds, so I started by simply copying the script from the Prison map from the base game and changed the sound file and script area names to match, but nothing plays.

Here is what I have:

Quote: /*creaks
*/
void TimerCreaky(string &in asTimer)
{
PlaySoundAtEntity("Creaks", "afx_mansion_gallery_creak", "AreaCreaks_"+RandInt(1,8), 0.0, false);

AddTimer("TimerCreaky", RandInt(10, 20), "TimerCreaky");
}


//===========================================
// This runs when the map first starts
void OnStart()



{

AddTimer("TimerCreaky", RandInt(18, 40), "TimerCreaky");

}

In the map I have script areas named AreaCreaks_1, AreaCreaks_2, etc up to 8. What did I do wrong?

(This post was last modified: 05-20-2016, 09:29 AM by serbusfish.)
05-20-2016, 09:26 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Random sounds

First off, the way you've set it up makes so that after a random time between 18 and 40 seconds after starting the map for the first time, it will play a sound ONCE. Do you want random sounds to keep playing? If so you gotta change a few things. Most importantly create a looping timer.

The AreaCreaks_x should be fine.

Your afx_mansion_gallery_creak sound... can you confirm it works? I think this one is from AMFP, is it not? Also, I don't remember if you need to include .snt in there, but perhaps not.

05-20-2016, 09:44 AM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#3
RE: Random sounds

(05-20-2016, 09:44 AM)Mudbill Wrote: First off, the way you've set it up makes so that after a random time between 18 and 40 seconds after starting the map for the first time, it will play a sound ONCE. Do you want random sounds to keep playing? If so you gotta change a few things. Most importantly create a looping timer.

The AreaCreaks_x should be fine.

Your afx_mansion_gallery_creak sound... can you confirm it works? I think this one is from AMFP, is it not? Also, I don't remember if you need to include .snt in there, but perhaps not.

Yes I want the sound to keep looping randomly. That sound is from AMFP and does play fine, in fact using the inspector mode I just found that the game is loading and playing the file once, but obviously if im not near the script area the game decided to play it at I wont hear it.

Now I know that the sound is playing what would I need to do to make it loop randomly? I was under the impression the script I had would work as this is the same one Frictional used and theirs loops?

05-20-2016, 10:04 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Random sounds

Ah, right, didn't see that recall you had. Yes it should loop. Maybe...

Remember that the parameters of AddTimer uses a float, not an int. So use RandFloat instead. Also, try adding 'f' behind your 0.0 values, so that they look like 0.0f. This is a best practise for floats.

But your timer only loops every 10 to 20 seconds.

05-21-2016, 12:38 AM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#5
RE: Random sounds

For testing purposes I would change those RandInt(x,x) for a plain RandInt(1,1), so you can note in-game how it loops and how it sounds. When you're done with that part you can then adjust the frequency (RandInt).

05-21-2016, 01:24 AM
Find




Users browsing this thread: 1 Guest(s)