# Custom Subtitled Dialogue and Sound

If your heist or mod needs custom dialogue that includes subtitles follow the following steps.

1. Add your Sounds, for this example I will add sounds to a level for a custom map.
```xml
		<sounds directory="assets">
			<sounds directory="sounds">
				<sound id="cus_rex_test_1" path="cus_rex_test_1.ogg" subtitle_id="cus_rex_test_1"/>
				<sound id="cus_rex_test_2" path="cus_rex_test_2.ogg" subtitle_id="cus_rex_test_2"/>
			</sounds>
		</sounds>
```

2. Set up the Dialogue Script Data, this will add the dialogue to the dialogue element in editor.

	In the Main.xml file add this to your levels script data:
```xml
		<script_data_mods directory="scriptdata">
			<mod replacement="new_dialogue.dialogue" replacement_type="custom_xml" target_ext="dialog" target_path="gamedata/dialogs/rex">
				<options merge_mode="add" mode="add"/>
			</mod>
			<mod replacement="index.dialog_index" replacement_type="custom_xml" target_ext="dialog_index" target_path="gamedata/dialogs/index">
				<options merge_mode="add" mode="add"/>
			</mod>
		</script_data_mods>
```
In your Scriptdata folder in the Project add 2 txt files: ('new_dialogue' can be renamed to anything you wish)

index.dialogue_index:
```xml
<table>
	<include name="new_dialogue"/>
</table>
```

new_dialogue.dialogue:
```xml
<table>
	<dialog id="cus_rex_test_1" priority="1" sound="cus_rex_test_1"/>
	<dialog id="cus_rex_test_2" priority="1" sound="cus_rex_test_2"/>
</table>
```

3. From there your Dialogue should be added to the game!


Additional Notes!
If you want your sound to play in 3D space (from a speaker or character) make sure its a mono-sound.
If you instead want your sound to play as if in the players ears (like Bain dialogue) make sure its in stereo-sound.
Make sure you localise your subtitles or players will see 'ERROR:text' ingame.