From Frictional Wiki
Jump to navigation Jump to search

Adding custom sounds

Preparing the sounds

First you'll need a sound-editting program, you can do this by using [1]] (Recommended) [2] or [Sony Vegas (Not free)

The sounds need to be in .ogg format, If your soundfiles are formatted as .MP3, .WAV or anything else, you may use one of the said above programs to convert your soundfile of choice to an .ogg file format.

For my example, my script file is called tutorial.txt, and the sound is door.ogg.

Icon tip.png Tip: It is recommended to use mono files. Stereo should only be used (but is not required) for music and ambient tracks.

Managing sound files

In your mod's (FC or CS, doesn't matter) folder, create a folder for sounds. It can be called however you want, but sounds would probably be the best.

Icon tip.png Tip: If your mod has a lot of custom sounds, make sure to organise them into subfolders!

Place the tutorial.ogg file in the created (sub)folder.

Creating the sound entity file

Create a .txt file and name it the name of your sound's Script, open it with any Text Editor you use. I use [=notepad Notepad++]. I named my file tutorial.txt.

Icon tip.png Tip: .txt might work, but it is recommended to give sound files the .snt extension used by the main game. This will allow your sound to be placed in a level without scripting. If using Notepad++, right-click them and pick Notepad++ to edit these files.

In the file, you can edit quite a few things, and among them is..Adding your sound-file into the script! And since my sound file is door.ogg, It shall go to the MAIN section. Random soundfiles will be covered later on.

      <Sound File="door.ogg" />
   <PROPERTIES Volume="5" MinDistance="1" MaxDistance="50" Random="0" Interval="0" FadeEnd="False" FadeStart="False" Stream="False" Loop="False" Use3D="false" Blockable="False" BlockVolumeMul="0.7" Priority="5" />

Format explanation:

<SOUNDENTITY> is the start marker of the sound file

<SOUNDS> indicates the sound list

<Main> is the list of sounds the file will play. It is unsure if other categories exist.

<Sound File="YourFileName.ogg" /> is the way to add a file to the sound. Adding multiple files will play them randomly.

<PROPERTIES> Are all the options you may use to decide how the sound will behave in-game. Most important ones are:

  • MinDistance is what distance you have to be in to hear it, since 1 is the players exact size, You will hear the sound perfectly if you stand on it. The sound will be heard with less and less volume until getting further than the distance specified in MaxDistance.
  • If you have multiple sounds, changing the Random="0" parameter to the number of sound files might be needed.[Confirm]
  • Loop="False" - Make sure to change this to true if your sound should loop.
  • Use3D="false" - Setting this as true will make the sound fade if the player rotates right and left from the sound origin. Using false will only use the distance to fade the sound.[Confirm]
Alert icon.png Warning: Stereo files will never work with this! The file needs to be mixed into a mono track to use this parameter. Also keep in minds stereo doesn't fade with distance.

Well thats it! You now created your very own sound! Use it with PlaySoundAtEntity(); in your level script (check Engine scripts for details).

Adding custom music

Custom music needs exactly the same steps as the custom sounds. However, they won't need an .snt file to be created as long as the music is to be played with PlayMusic(); or at the credits.

Prepare your .ogg file with the same steps as the Custom Sounds.

Just like with sounds, it is good to create a folder for music in the mod's main folder, e.g. music. Put the .ogg file there.

Now, use PlayMusic(); in a script. (check Engine scripts to know what syntax to use)

Keep in mind that only one music file can play at a time. For ambients, it is better to create a sound file (like described earlier).