How to add new subtitles for L4D2

From Valve Developer Community
Revision as of 16:41, 30 August 2025 by Lt.Mori (talk | contribs)
Jump to navigation Jump to search

Creating Custom Subtitles in Left 4 Dead 2

This guide explains how to create custom subtitles for your own campaigns in **Left 4 Dead 2**.

Step 1: Create a sound script

First, create a file named: your_campaign_level_sounds.txt

Inside, define the sound event you want to subtitle. Example:

"npc.command_intro"
{
    "channel"    "CHAN_VOICE"
    "volume"     "1.0"
    "pitch"      "PITCH_NORM"
    "soundlevel" "SNDLVL_90dB"
    "wave"       "sblitz/command_radio0.wav"
}
  • The identifier (e.g. npc.command_intro) will later be referenced in your subtitles.*

Step 2: Reference the sound name

Copy the name you defined (e.g. npc.command_intro). This will be used inside your subtitle file.

Step 3: Create a closecaption file

Now create a new file named: closecaption_english.txt (or closecaption_spanish.txt, depending on the language).

    • Important:** the word closecaption must be present in the filename, otherwise it will not work.

Step 4: Subtitle file structure

The file should follow this format:

"lang"
{
    "Language" "Latam"
    "Tokens"
    {
        "testcommands" "<clr:255,0,0>This is red<I> and italics<B> and <cr>bold<B><I><clr:255,255,255> white again."

        "ambient.nocopyrightxmas" "<sfx><norepeat:15><clr:204,0,0>[Playing 'Christmas Spirit' by Shane Ivers.]"
    }
}
  • Each line starts with the sound event identifier.
  • After that, write the text to display.
  • You can use formatting codes like:
 * <clr:R,G,B> = text color.  
 * <sfx> = marks sound effects.  
 * <norepeat:15> = avoid repeating subtitles too often.  
 * <B>, <I> = bold/italic.

Example: linking sound and subtitle

Sound script file:

"ambient.elev_music"
{
    "channel"    "CHAN_STATIC"
    "volume"     "1"
    "soundlevel" "SNDLVL_NONE"
    "pitch"      "PITCH_NORM"
    "wave"       "maps/mymap/elevator_music.wav"
}

Subtitle file:

"ambient.elev_music" "<sfx><norepeat:15><clr:255,158,71>[Elevator Music]"

Step 5: Place files

  • Place your .txt subtitle file inside:
 resource\ (either in your map folder or a custom addon folder).  
  • Make sure your gameinfo.txt references the folder correctly.

Step 6: Compile subtitles

Finally, subtitles must be compiled with **captioncompiler**.

Open Command Prompt and run:

cd "C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2"
"../bin/captioncompiler" "../../<your_folder>/resource/closecaption_english.txt"

Example:

cd "C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2"
"../bin/captioncompiler" "../../bts_patch/resource/subtitles_english.txt"

Notes

  • Always close your braces { } properly in both files.
  • If the game does not display your subtitles, check encoding (UTF-8 without BOM) and paths.
  • You can add multiple languages by creating multiple files (e.g. closecaption_spanish.txt).