Difficulty: Difficulty-2
Clock: 5 to 10 minutes

Introduction Edit

This tutorial will teach you how to add custom sound effects for items and monsters. This process is driven by .ini files. This tutorial will cover how to add sound first to an item, and then to an NPC.

Requirements Edit

  • This tutorial assumes you already know how to work with mods.
  • tConfig must be installed correctly.
  • You require at least tConfig v0.17.0 or later, although it is recommended you have the latest version, available here: v0.36
  • If you are creating your own sounds, you will need some form of audio editor.

Place the Sound Edit

The very first step, as usual, is to create your mod's folder in the ModPack directory, or alternatively, use an existing mod. In either case, create a folder in the mod folder called "Sound". Your folder structure should look like:

  • C:\My Documents\My Games\Terraria\ModPacks\<mymod>\Sound\

Next, place the sound effects in this folder. They MUST be saved as a "PCM 44,100kHz 16-bit Stereo .wav" file, otherwise the game will not recognize it! If you are unsure, you should be able to check the encoding and other details in one of the audio programs listed above. For the sake of this tutorial, let's assume your file is called "mySoundName.wav"

Adding Your Sound to the Game Edit

To add your sound to an item:

  • Open the item's ini file and add the line useSoundName=mySoundName
  • Do not add ".wav" to the end, "mySoundName" will work, "mySoundName.wav" will not.
  • Please note that you should have useSound or useSoundName, but not both.

To add sound to an NPC:

  • Open the NPC's ini file
    • For the sound played on hit, add soundHitName=mySoundName
    • For the sound played on death, add soundKilledName=mySoundName
    • Do not add ".wav" to the end, "mySoundName" will work, "mySoundName.wav" will not.

If, upon hearing your sound in game, it seems to be playing at the wrong speed (likely too fast) this means you need to adjust the sound's sample rate (also known as 'bit rate'). In Audacity, this is displayed in the lower left hand corner. If the sound is too fast, the sample rate is too low and needs to be raised. Choose one of the higher options from the list.

Calling Sounds from CodeEdit

You should be able to call your custom sounds programatically, so you can play them whenever you want. This is accomplished in the same way you get other custom types that don't have a "byName" method (tiles,walls); the sound has to be used by an item or NPC (specified in their .ini) to be loaded at all. This may require "dummy" items or NPCs to be used to load sounds you will only play outside of these contexts.

Let's assume that after putting a sound on an item earlier, you know want to play the sound somewhere else (randomly when NPCs are wandering around, for example). For this, we will call PlaySound():


The "2" is because item sounds are of type 2, and our sound has been loaded with the item sounds. If our sound had been attached to an NPC, the number would be "3" or "4". See List of Sounds for more information. The second and third argument specify the location at which to play the sound. "-1" will play the sound at full volume, not localizing it to game space.

Final Words Edit

That's pretty much all there is to it! Just remember to save the files, recompile the mod and enable it ingame.