# Game flow specification
In the original Tomb Raider 1, the game flow was completely hard-coded,
including the levels, limiting the builders' flexibility. Tomb Raider 2
improved upon this by introducing a tombpc.dat binary file for game
configuration, although it remained cryptic and required builders to use
dedicated tooling. TR1X and TR2X have transitioned away from these earlier
methods, choosing to manage game flow with a JSON file that provides a unified
structure for both games. This document details the elements that can be
modified using this updated format.
Jump to:
- [Global properties](#global-properties)
- [Level properties](#level-properties)
- [Sequences](#sequences)
- [Bonus levels](#bonus-levels)
- [Item drops](#item-drops)
- [Injections](#injections)
- [User configuration](#user-configuration)
## Global properties
The following properties are in the root of the game flow document and control
various pieces of global behaviour. Currently, the majority of this section
remains distinct for each game.
#### TR1
Show snippet
```json5
"main_menu_picture": "data/titleh.png",
"savegame_fmt_legacy": "saveati.%d",
"savegame_fmt_bson": "save_tr1_%02d.dat",
"demo_delay": 16,
"water_color": [0.45, 1.0, 1.0],
"fog_start": 22.0,
"fog_end": 30.0,
"injections": [
"data/global_injection1.bin",
"data/global_injection2.bin",
// etc
],
"convert_dropped_guns": false,
"enforced_config": {
"enable_save_crystals": false,
},
"levels": [
{
"path": "data/gym.phd",
// etc
},
],
"cutscenes": [
{
"path": "data/cut1.phd",
// etc
},
],
"demos": [
{
"path": "data/gym.phd",
// etc
},
],
"fmvs": [
{"path": "data/snow.rpl"},
// etc
},
```
Property |
Type |
Description |
convert_dropped_guns
|
Boolean |
Forces guns dropped by enemies to be converted to the equivalent ammo
if Lara already has the gun. See Item drops
for full details.
|
demo_delay |
Double* |
The number of seconds to pass in the main menu before playing the demo.
|
fog_start
|
Double |
The distance (in tiles) at which objects and the world start to fade into
blackness.
- The default value in OG TR1 is hardcoded to 12.
- The default (disabled) value in TombATI is 72.
|
fog_end
|
Double |
The distance (in tiles) at which objects and the world are clipped away.
- The default value in OG TR1 is hardcoded to 20.
- The default (disabled) value in TombATI is 80.
|
enable_killer_pushblocks
|
Boolean |
If enabled, when a pushblock falls from the air and lands on Lara, it will
kill her outright. Otherwise, Lara will clip on top of the block and
survive.
|
enable_tr2_item_drops
|
Boolean |
Forces enemies who are placed in the same position as pickup items to
carry those items and drop them when killed, similar to TR2+. See
Item drops for full details.
|
enforced_config |
String-to-object map |
This allows any regular game config setting to be overriden. See
User configuration for full details.
|
injections |
String array |
Global data injection file paths. Individual levels will inherit these
unless inherit_injections is set to false on
those levels. See Injections for full details.
|
levels |
Object array* |
This is where the individual level details are defined - see
Level properties for full details.
|
main_menu_picture |
String* |
Path to the main menu background image. |
savegame_fmt_bson |
String* |
Path pattern to look for the savegame files. |
savegame_fmt_legacy |
String* |
Path pattern to look for the old TombATI savegame files. |
water_color
|
Float array |
Water color (R, G, B) or `#RRGGBB`. 1.0 or `FF` means pass-through, 0.0
or `00` means completely black color.
See this table for reference values.
|
**\*** Required property.
#### TR2
Property |
Type |
Description |
cmd_init |
Object |
The command to run when the game is first launched. See Game flow commands for full details.
|
cmd_title |
The command to run when the main menu is to be shown. |
cmd_death_in_game |
The command to run when Lara dies. |
cmd_death_in_demo |
The command to run when Lara dies during a demo (not used in the original game). |
cmd_demo_interrupt |
The command to run when the player interrupts a demo. |
cmd_demo_end |
The command to run when a demo finishes playback. |
cheat_keys |
Boolean |
Whether to enable original game cheats (the ones where Lara turns around
three times).
|
load_save_disabled |
Boolean |
Whether to disable saving and loading the game. |
play_any_level |
Boolean |
Whether to show a full list of all levels in place of the New Game
passport page.
|
lockout_option_ring |
Boolean |
Whether to disallow the players to use control ring while ingame. |
gym_enabled |
Boolean |
Whether to enable Lara's Home. |
demo_version |
Boolean |
Legacy setting scheduled for removal at a later time. |
single_level |
Integer |
Force the player to only play this one level. |
demo_delay |
Double |
The number of seconds to pass in the main menu before playing the demo.
|
main_menu_picture |
String* |
Path to the main menu background image. |
savegame_fmt_legacy |
String* |
Path pattern to look for the original savegame files. |
secret_track |
Integer |
Music track to play when a secret is found. -1 to not play anything.
|
sfx_path |
String |
The path to the sound effects (.sfx) file to use in the game.
|
fog_start
|
Double |
The distance (in tiles) at which objects and the world start to fade into
blackness. The default value in OG TR2 is hardcoded to 12.
|
fog_end
|
Double |
The distance (in tiles) at which objects and the world are clipped away.
The default value in OG TR2 is hardcoded to 20.
|
water_color
|
Float array or hex string |
Water color (R, G, B) or `#RRGGBB`. 1.0 or `FF` means pass-through, 0.0
or `00` means completely black color.
See this table for reference values.
|
## Game flow commands
The command allows you to modify the original game flow, but please note that
deviations from the original script may result in unexpected behavior. If you
encounter any bugs, we encourage you to report your experience by opening an
issue on GitHub. The overall structure is as follows:
```json5
{
"command": "play_level",
"param": 5,
}
```
Currently the following commands are available.
Command |
Description |
Parameter |
noop |
Continue the flow as normal. |
N/A |
play_level |
Play a specific level. |
Level to play. |
load_saved_game |
Load a specific savegame. |
Save slot number to use |
play_cutscene |
Play a specific cutscene. |
Cutscene number to play |
play_demo |
Play a specific demo. |
Demo number to play. |
play_fmv |
Play a specific movie. |
Movie number to play. |
exit_to_title |
Return the game to the title screen. |
N/A |
level_complete |
End the current sequence inside level sequences, do nothing otherwise.
|
N/A |
exit_game |
Exit the game to desktop. |
N/A |
select_level |
Play a specific level (and reset inventory). |
Level number to play. |
restart_level ¹ |
Restart the currently played level. |
N/A |
story_so_far ¹ |
Play the movies and cutscenes up until the currently played level. |
Save slot number to use |
**¹** Tomb Raider 1 only.
Additional notes:
- All numbers (levels, cutscenes, ...) start with 0.
## Level properties
The `levels` section of the document defines how the game plays out. This is an
array of objects and can be defined in any order. The flow is controlled using
the correct [sequencing](#sequences) within each level itself.
Following are each of the properties available within a level.
Property |
Type |
Description |
path |
String* |
The path to the level's data file. |
type
|
String |
The level type, which must be one of the following values.
Defaults to normal level.
|
Type |
Description |
normal |
A standard level. |
gym |
At most one of these can be defined. Accessed from the photo option
(object ID 73) on the title screen. If omitted, the photo option is not
displayed.
|
bonus |
Only playable when all secrets are collected. See
Bonus levels for full details.
|
current |
One level of this type is necessary to read TombATI's save files. OG has a
special level called LV_CURRENT to handle save/load logic.
TR1X does away with this hack. However, the existing save games expect the
level count to match, otherwise the game will crash.
|
dummy |
A placeholder level necessary to read TombATI's save files. |
sequence |
Object array* |
Instructions to define how a level plays out. See
Sequences for full details.
|
music_track |
Integer* |
The ambient music track ID. |
fog_start |
Double |
Can be customized per level. See above
for details.
|
fog_end |
Double |
Can be customized per level. See above
for details.
|
injections |
String array |
Injection file paths. See Injections for full
details.
|
inherit_injections |
Boolean |
A flag to indicate whether or not the level should use the globally
defined injections. See Injections for full
details.
|
item_drops ¹ |
Object array |
Instructions to allocate items to enemies who will drop those items when
killed. See Item drops for full details.
|
lara_type ¹ |
Integer / string |
Used only in cutscene levels to link the braid (if enabled) to the
relevant cutscene actor object ID.
|
sfx_path ² |
String |
The path to the sound effects (.sfx) file to use in this level. If this
property is not defined, the default global file will be used.
|
unobtainable_kills ¹ |
Integer |
A count of enemies that will be excluded from kill statistics.
|
unobtainable_pickups ¹ |
Integer |
A count of items that will be excluded from pickup statistics.
|
unobtainable_secrets ¹ |
Integer |
A count of secrets that will be excluded from secret statistics. Useful for level demos.
|
water_color ¹ |
Float array |
Can be customized per level. See above for
details.
|
**\*** Required property.
**¹** Tomb Raider 1 only.
**²** Tomb Raider 2 only.
## Sequences
The following describes each available game flow sequence type and the required
parameters for each. Note that while this table is displayed in alphabetical
order, care must be taken to define sequences in the correct order. Refer to the
default game flow for examples.
Sequence |
Parameter |
Type |
Description |
loop_game |
N/A |
Plays the main game loop. |
level_complete |
N/A |
Ends the current level and plays the next one, if available. |
exit_to_title |
N/A |
Returns to the title level. |
level_stats |
N/A |
Displays the end of level statistics for the current level. In a Gym
level, this fades the screen to black.
|
total_stats |
path |
String |
Displays the end of game statistics with the given picture file shown as
a background.
|
display_picture
|
path |
String |
Displays the specified picture for a fixed time.
Files that are needed to function only with a specific aspect ratio can
be placed in a directory adjacent to the main image, named according to
the aspect ratio – for example, 4x3/title.png or 16x10/title.png. The
game won't attempt to match these precisely; instead, it will select the
file with the aspect ratio closest to the game's viewport. The main image
designated by path is presumed to have a 16:9 aspect ratio
for this purpose, and as such there's no need for 16x9-specific
directory.
This logic applies to all images.
|
display_time |
Double |
Number of seconds to display the picture for (default: 5). |
fade_in_time |
Double |
Number of seconds to do the fade-in animation, if enabled (default: 1).
|
fade_out_time |
Double |
Number of seconds to do the fade-out animation, if enabled (default: 0.33).
|
loading_screen ¹ |
path |
String |
Shows a picture prior to loading a level. Functions identically to
display_picture , except these pictures can be
enabled/disabled by the user with the loading screen option in the config
tool.
|
display_time |
Double |
fade_in_time |
Double |
fade_out_time |
Double |
play_cutscene |
cutscene_id |
Integer |
Plays the specified cinematic level (from the cutscenes ).
|
play_fmv |
fmv_id |
String |
Plays the specified FMV. fmv_id must be a valid index into
the fmvs root key.
|
flip_map ¹ |
N/A |
Triggers the flip map. |
give_item
|
object_id |
Integer / String |
Adds the specified item and quantity to Lara's inventory.
|
quantity |
Integer |
add_secret_reward ² |
object_id |
Integer / String |
Adds the specified item to the current level's list of rewards for
collecting all secrets.
|
quantity |
Integer |
mesh_swap ¹ |
object1_id |
Integer |
Swaps the given mesh ID between the given objects. |
object2_id |
Integer |
mesh_id |
Integer |
play_music |
music_track |
Integer |
Plays the given audio track. |
remove_ammo |
N/A |
Any combination of these sequences can be used to modify Lara's
inventory at the start of a level. There are a few simple points to note:
-
remove_weapons does not remove the ammo for those guns,
and equally remove_ammo does not remove the guns. Each
works independently of the other.
-
These sequences can also work together with
give_item - so, item removal is
performed first, followed by addition.
|
remove_weapons |
N/A |
remove_medipacks |
N/A |
remove_flares ² |
N/A |
remove_scions ¹ |
N/A |
set_cutscene_pos ¹ |
x
|
Integer |
Sets the camera's position. |
y
|
Integer |
z
|
Integer |
set_cutscene_angle |
value |
Integer |
Sets the camera's angle. |
setup_bacon_lara ¹ |
anchor_room |
Integer |
Sets the room number in which Bacon Lara will be anchored to enable
correct mirroring behaviour with Lara.
|
enable_sunset ² |
N/A |
Enables the sunset effect, like in Bartoli's Hideout. At present, this
feature is hardcoded to gradually darken the game 40 minutes into playing
a level.
|
set_lara_start_anim ² |
value |
Integer |
Applies the selected animation to Lara when the level begins. This is
used, for example, in the Offshore Rig of Tomb Raider II.
|
disable_floor |
value |
Integer |
Configures a specific height (with 256 representing 1 click and 1024
representing 1 sector) to define an abyss that will invariably lead to
Lara's death if she falls into it. Additionally, it employs special
rendering to ensure it isn't treated as solid ground. This is used, for
example, in the Floating Islands of Tomb Raider II.
|
**¹** Tomb Raider 1 only.
**²** Tomb Raider 2 only.
## Cutscenes
The `cutscenes` section contains all the cinematic levels, used with the
`play_cutscene` sequence. Its structure is identical to the `levels` section.
## Demos
The `demos` section contains all the levels that can play a demo when the player
leaves the main inventory screen idle for a while or by using the `/demo`
command. For the demos to work, these levels need to have demo data built-in.
Aside from this requirement, this section works just like the `levels` section.
## Bonus levels
The game flow supports bonus levels, which are unlocked only when the player
collects all secrets in the game's normal levels. These bonus levels behave just
like normal levels, so you can include FMVs, cutscenes in-between and so on.
Statistics are maintained separately, so normal end-game statistics are shown
once, and then separate bonus level statistics are shown on completion of those
levels.
Following is a sample level configuration with three normal levels and two bonus
levels. After the end-game credits are played following level 3, if the player
has collected all secrets, they will then be taken to level 4. Otherwise, the
game will exit to title.
Injection file |
Usage |
Purpose |
*_cameras.bin
|
TR1 |
Injects positional adjustments for cameras that can otherwise cause visual
issues, such as in Temple of the Cat.
|
*_fd.bin
|
TR1, TR2 |
Injects fixes for floor data issues in the original levels. Refer to the
README for a full list of fixes.
|
*_itemrots.bin
|
TR1, TR2 |
Injects rotations on pickup items so they make more visual sense when
using the 3D pickups option.
|
*_meshfixes.bin
|
TR1 |
Injects miscellaneous mesh adjustments for objects, such as in Obelisk of
Khamoon to avoid z-fighting.
|
*_pickup_meshes.bin
|
TR1, TR2 |
Injects mesh edits to change the scale of various pickup models, such as
the keys in St. Francis' Folly or the Prayer Wheel in Barkhang Monastry.
|
*_sfx.bin
|
TR1, TR2 |
Injects various SFX fixes or additions, such as the PSX Uzi SFX in TR1, or
fixing the silent enemies in TR2's water levels.
|
*_skybox.bin
|
TR1 |
Injects a predefined skybox model into specific levels.
|
*_textures.bin
|
TR1 |
Injects fixes for texture issues in the original levels, such as gaps in
the walls or wrongly colored models. Refer to the README for a full list
of fixes.
|
boat_bits.bin
|
TR2 |
Injects a model in slot `O_BOAT_BITS` (221) which is used to show the boat
exploding when it crosses mines.
|
backpack.bin
|
TR1 |
Injects mesh edits for Lara's backback, such that it becomes shallower.
This is only applied when the braid is enabled, to avoid the braid
merging with the backpack. The different files are needed to address mesh
structure differences between cutscene and normal levels.
|
backpack_cut.bin
|
braid.bin
|
TR1 |
Injects a braid when the option for it is enabled. This also edits Lara's
head meshes (object 0 and object 4) to make the braid fit better. A golden
braid is also provided for the Midas Touch animation. Again, different
files are needed to cater for mesh differences between cutscene and normal
levels. The Lost Valley file comprises a head mesh edit for object 5 only.
|
braid_cut1.bin
|
braid_cut2_cut4.bin
|
braid_valley.bin
|
bubbles.bin
|
TR1 |
Injects replacement sprite textures for Lara's underwater bubble sprites,
which are cut off in OG.
|
cistern_plants.bin
|
TR1 |
This disables the animation on sprite ID 193 in The Cistern and Tomb of
Tihocan.
|
khamoon_mummy.bin
|
TR1 |
Injects the mummy in room 25 of City of Khamoon, which is present in the
PS1 version but not the PC.
|
lara_animations.bin
|
TR1 |
Injects several animations, state changes and commands for Lara, such as
responsive jumping, jump-twist, somersault, underwater roll, and wading.
|
lara_gym_guns.bin
|
TR1 |
Injects all of Lara's weapons and weapon animations in TR1's gym level.
|
explosion.bin
|
TR1 |
Injects explosion sprites for certain console commands.
|
font.bin
|
TR1, TR2 |
Injects replacement font sprites to support more characters than OG.
|
guardian_death_commands.bin
|
TR2 |
Injects an animation command for the bird guardian to end the level on the
final frame of its death animation. The original hard-coded end-level
behaviour is removed in TR2X.
|
mines_pushblocks.bin
|
TR1 |
Injects animation command data for pushblock types 2, 3 and 4 to restore
the missing scraping SFX when pulling these blocks.
|
pickup_aid.bin
|
TR1 |
Injects a sprite sequence similar to the Midas twinkle effect, which is
used when the option for pickup aids is enabled. Custom levels should
define a suitable sprite sequence in slot 185.
|
photo.bin
|
TR1, TR2 |
Injects camera shutter sound effect for the photo mode, needed only for
the cutscene levels.
|
purple_crystal.bin
|
TR1 |
Injects a replacement savegame crystal model to match the PS1 style.
|
scion_collision.bin
|
TR1 |
Increases the collision radius on the (targetable) Scion such that it can
be shot with the shotgun.
|
seaweed_collision.bin
|
TR2 |
Fixes the seaweed in Living Quarters blocking Lara from exiting the water.
|
## FMVs
The FMVs section of the document defines how to play video content. This is an
array of objects and can be defined in any order. The flow is controlled using
the correct sequencing within each level itself.
Following are each of the properties available within an FMV.