Demo

From SRB2 Wiki
Jump to navigation Jump to search
This article is about files that contain recorded replay data for SRB2. For demo releases of SRB2, see Versions.

Demos, also known as replays, are a type of file format that store recordings of a player's input and position data for a particular level, which can be played back by the game. These are mainly created and used by the Record Attack and NiGHTS Mode game modes. The Metal Sonic race in Black Core Zone Act 1 also relies on a special replay in order for Metal Sonic to move about and jump in the level.

Demo format

Every demo for SRB2 starts with the following information:

Position Length (bytes) Description
0x00 12 A header of twelve bytes shared by all SRB2 demos: the hexadecimal number F0, followed by the string "SRB2Replay" encoded in ASCII, followed by the hexadecimal number 0F.
0x0C 1 A constant representing the version of SRB2 the demo was recorded for; for v2.2, this is 202.
0x0D 1 A constant representing the sub-version of SRB2 the demo was recorded for; for v2.2.8, this is 8.
0x0E 2 The demo format version number; this may be updated by later versions of SRB2 if changes are made to the format. As of v2.2.8, this is 12.
0x10 16 The demo's checksum.
0x20 4 An ASCII-encoded string representing the type of replay the demo is:
  • "PLAY" – Player replay
  • "METL" – Metal Sonic replay

Following this, the format of demos varies depending on the type of replay and the part of the game the demo was recorded for; the different formats will not be outlined in detail here.

Recording and playback

Demos can be recorded by starting SRB2 with the -record demoname command line parameter, where demoname is the name of the file that the demo should be saved as. By default, the game will warp to MAP01 and record the demo there. To record the demo in a different map, the -warp command line parameter must be used as well. The demo recording continues until the game is closed or the size limit for recorded demos is reached. The default size limit is 1,024 kilobytes, but it can be changed with the -maxdemo command line parameter. Note that when a level is completed, the recording will continue through the next level. However, the level change will not be properly executed when playing back the demo, so it is recommended to stop the recording after finishing a level.

Recorded demos can be played back with the playdemo console command or the -playdemo command line parameter. A demo is played back by loading the level it was recorded in and moving the player according to the recorded input and position data. All other events in the level besides the player's movement are simulated normally – if the level is different from the one the demo was recorded in (for example because a loaded WAD file replaces the level) or if the level contains randomized events, the demo may become desynchronized during playback. If a demo becomes desynchronized, playback will continue, but the events shown onscreen may become incoherent. For example, if the player bounced off an enemy during recording but the enemy is now in a different position during playback, the player will appear to bounce through the air. Similarly, if the player runs into an enemy during playback that was in a different position during recording, the player will be damaged. In demos that involve significant interaction with enemies or bosses whose behavior is randomized (for example demos recorded in Black Core Zone Act 3), this may cause the player to die and the playback to abort midway through. When playing back a demo in third-person view, the camera will move along with the player, but it will not rotate according to the player's movements. Instead, the camera can be rotated manually by the user viewing the demo.

The playback of a demo can be stopped with the stopdemo console command. The speed at which demos are played back can be adjusted with the playbackspeed console variable; this is useful for speeding up the playback of long demos or watching particularly interesting sections in slow motion. The timedemo console command or -timedemo command line parameter can be used to play back a demo as fast as possible, which is useful for benchmarking the game's performance.

Record Attack/NiGHTS Mode

Main article: Record Attack

Demos are used in Record Attack and NiGHTS Mode to save and play back the user's records. For each map and character, the best attempt in each category as well as latest attempt are saved as a replay. Additionally, a guest replay can be saved for each map as well. The recording of demos in Record Attack and NiGHTS Mode can be disabled with the console variable autorecord.

Recorded demos can be played back via the "Replay..." entry in the Record Attack/NiGHTS Mode menu. Additionally, demos can be displayed as ghosts while playing in Record Attack/NiGHTS Mode, allowing the player to compete directly against their own previous attempts or those of other players. The "Ghost..." menu entry allows the user to set which replays will be displayed as ghosts. Alternatively, the following console variables can be used:

Title screen demos

Demos can also be played back at the title screen. This feature can be turned on or off using the rollingdemos console variable. Some time after the music has finished playing, SRB2 automatically starts playing back a demo; after it has finished playing, the game returns to the title screen. If there are multiple title screen demos, the game will alternate between playing each successive demo in order and returning to the title screen; i.e., the game plays back the first demo, returns to the title screen, then plays back the second demo, returns to the title screen, then plays back the third demo, and so on. After the last demo has been played and the game has returned to the title screen, the game's intro is replayed.

As of the current release of SRB2, the title screen cycles through a set of four demos, demonstrating gameplay of SRB2 as all three characters:

Demo name Description
DEMO_001 A replay of Sonic playing through Greenflower Zone Act 1 (MAP01).
DEMO_002 A replay of Tails playing through Techno Hill Zone Act 1 (MAP04).
DEMO_003 A replay of Knuckles playing through Deep Sea Zone Act 1 (MAP07).
DEMO_004 A replay of Sonic playing through the first Special Stage, Floral Field Zone (MAP50).

Custom demos can be played back at the title screen in place of SRB2's own demos, if needed. See MainCfg > Title screen demos for more information. If any levels in a custom modification use the same map slots as the levels above (thereby replacing the levels), it is recommended to either provide title screen demos for the new levels, or otherwise disable title screen demos for the modification by setting NumDemos to 0. This is so that the game does not attempt to play SRB2's own title screen demos in the levels now taking up the above map slots.

Metal Sonic replays

Races against Metal Sonic, such as the one in Black Core Zone Act 1, use a recorded demo to control Metal Sonic's movement during the race. Demos for the Metal Sonic race can be recorded by launching SRB2 with the -metal command line parameter, which works like the -record parameter but saves the demo as MAPxxMS.LMP, where xx is the number of the map that the demo was recorded in. This lump can then be imported into a WAD or PK3 file to act as the input data for the Metal Sonic race. See the Metal Sonic race tutorial for more information.