Threat Music File Format

From Rain World Modding
Jump to navigation Jump to search

Threat music utilizes a xx.txt file named after the region it plays in to define both the track layers and the order in which they play depending on the threat level.

This guide will go over adding custom threat music to a new region - if you want to replace the threat music in an existing region, the process is largely the same, however it will require an understanding of modification files and their format:

Downpour Reference/Modification_Files

To explain the format and its quirks, lets take a look at Chimney Canopy's threat file, cc.txt:

TH_CC - KICK : NEUTRAL <PA>
TH_CC - ARPS : NEUTRAL
TH_CC - BASS : DANGER <PA>
TH_CC - PERC1 : NEUTRAL
TH_CC - SNARE : NEUTRAL
TH_CC - PERC2 : NEUTRAL <PA>
TH_CC - NOISE : DANGER <PA>
TH_CC - VOX : HIGHKARMA


Layer : TH_CC - KICK, TH_CC - PERC1, TH_CC - NOISE
Layer : TH_CC - KICK, TH_CC - PERC2, TH_CC - PERC1, TH_CC - NOISE
Layer : TH_CC - KICK, TH_CC - PERC2, TH_CC - PERC1, TH_CC - NOISE, TH_CC - SNARE, TH_CC - BASS, TH_CC - VOX
Layer : TH_CC - KICK, TH_CC - ARPS, TH_CC - PERC1, TH_CC - NOISE, TH_CC - SNARE, TH_CC - BASS, TH_CC - PERC2, TH_CC - VOX
Layer : TH_CC - BASS, TH_CC - VOX

Defining Tracks

First, let's focus first on just the top section:

TH_CC - KICK : NEUTRAL <PA>
TH_CC - ARPS : NEUTRAL
TH_CC - BASS : DANGER <PA>
TH_CC - PERC1 : NEUTRAL
TH_CC - SNARE : NEUTRAL
TH_CC - PERC2 : NEUTRAL <PA>
TH_CC - NOISE : DANGER <PA>
TH_CC - VOX : HIGHKARMA

Here, the tracks that will be used are defined. First comes the file name of the track (without the extension), such as TH_CC - KICK.ogg, followed by a set of flags.

The flags themselves, for example NEUTRAL <PA>, are misleading - they are unused and do not affect how the track is played in any way.

For completeness, here are all of the possible flags:

NEUTRAL
HIGHKARMA
DANGER

Any flag may be followed by:
<PA>
...which internally sets 'remainInPanicMode', however this field is unused.
Likely intended to cause the target track to play for longer after the threat has gone down, but it is unimplemented.

For defining your tracks, you can simply use NEUTRAL.

Defining Layers

To see how to define layers, we can look at the second section:

Layer : TH_CC - KICK, TH_CC - PERC1, TH_CC - NOISE
Layer : TH_CC - KICK, TH_CC - PERC2, TH_CC - PERC1, TH_CC - NOISE
Layer : TH_CC - KICK, TH_CC - PERC2, TH_CC - PERC1, TH_CC - NOISE, TH_CC - SNARE, TH_CC - BASS, TH_CC - VOX
Layer : TH_CC - KICK, TH_CC - ARPS, TH_CC - PERC1, TH_CC - NOISE, TH_CC - SNARE, TH_CC - BASS, TH_CC - PERC2, TH_CC - VOX
Layer : TH_CC - BASS, TH_CC - VOX

Here, layers are defined in increasing level of threat, with minimum threat at the top and maximum threat at the bottom.

As the threat increases, more layers are added - there is no practical limit on the number of layers, so you can have as many as you like!

Let's take a look at just one layer:

Layer : TH_CC - KICK, TH_CC - PERC1, TH_CC - NOISE

Here, we can see this layer has the tracks TH_CC - KICK, TH_CC - PERC1, and TH_CC - NOISE.

  • When a layer has multiple tracks, one is chosen at random to play for that layer. Only one track may play for each layer at a time.
  • The track that is chosen is only randomly shuffled on region change, cycle change, etc.
  • Additionally, if a track is already playing due to being chosen in a previous layer, it cannot be chosen by the current layer.

Looking at the set of layers again:

Layer : TH_CC - KICK, TH_CC - PERC1, TH_CC - NOISE
Layer : TH_CC - KICK, TH_CC - PERC2, TH_CC - PERC1, TH_CC - NOISE
Layer : TH_CC - KICK, TH_CC - PERC2, TH_CC - PERC1, TH_CC - NOISE, TH_CC - SNARE, TH_CC - BASS, TH_CC - VOX
Layer : TH_CC - KICK, TH_CC - ARPS, TH_CC - PERC1, TH_CC - NOISE, TH_CC - SNARE, TH_CC - BASS, TH_CC - PERC2, TH_CC - VOX
Layer : TH_CC - BASS, TH_CC - VOX

...we could map out a potential selection of tracks from minimum to maximum threat:

1. (none)
Available: TH_CC - KICK, TH_CC - PERC1, TH_CC - NOISE

TH_CC - PERC1 is chosen.


2. (TH_CC - PERC1)
Available: TH_CC - KICK, TH_CC - PERC2, TH_CC - NOISE

TH_CC - NOISE is chosen.


3. (TH_CC - PERC1, TH_CC - NOISE)
Available: TH_CC - KICK, TH_CC - PERC2, TH_CC - SNARE, TH_CC - BASS, TH_CC - VOX

TH_CC - BASS is chosen.


4. (TH_CC - PERC1, TH_CC - NOISE, TH_CC - BASS)
Available: KICK, TH_CC - ARPS, TH_CC - SNARE, TH_CC - PERC2, TH_CC - VOX

TH_CC - ARPS is chosen.


5. (TH_CC - PERC1, TH_CC - NOISE, TH_CC - BASS, TH_CC - ARPS)
Available: TH_CC - VOX

TH_CC - VOX is chosen.


Final Route: (TH_CC - PERC1, TH_CC - NOISE, TH_CC - BASS, TH_CC - ARPS, TH_CC - VOX)
This will only be changed on region change, cycle change, etc.

Additional Layer Syntax

Some additional syntax exists for restricting when certain tracks within a layer may play:

  • Prefix an track in a layer with {D} to make it only play during the daytime (redundant/irrelevant if region doesn't use day-night cycles)
  • Prefix an track in a layer with {N} to make it only play during the nighttime (irrelevant if the region doesn't use day-night cycles)
  • Prefix an track in a layer with {M} to make it only play while the player is under the influence of mushrooms.
  • Prefix an track with a subregion name between {} to make it only play in that subregion. Multiple subregions can be specified by separating them with the pipe character (|).

For example:

Layer : {D}TH_CC - KICK
Layer : {N}TH_CC - PERC2
Layer : {M}TH_CC - SNARE
Layer : {Chimney Canopy|The Gutter}TH_CC - ARPS

Folder Structure

With your xx.txt file complete, you can move onto setting up the necessary folder structure to have your tracks be loaded and played in-game!

First, you will need the following file structure under your mod's root directory:

music/procedural

Place your xx.txt within procedural, ensuring xx matches your desired region's acronym.

Next, you must add the sound files themselves. There are only 2 conditions:

  • Sound files must be in .ogg format to be recognized and loaded by the game.
  • The base name of the sound file (without the extension) must match a track you defined in your xx.txt file.

After that, you should be done - warp to your custom region, get into some danger and enjoy your custom threat music in-game!