# The Ultimate Stunts track editor (ustuntstrackedit)

### Introduction

The Ultimate Stunts track editor will allow you to make new tracks and edit existing tracks. Currently (version 0.7.5), the track editor is still very limited: it is only possible to place/remove tiles on the track, and to import tracks from the original Stunts game.

### Contents

- Basic navigation
- Track editing
- Managing the tiles collection
- Importing Stunts tracks

# Basic navigation

Currently, the user interface is still quite simple. In the main window, the following items are visible:

- A 3D view of the track
- The name of the track on top of the 3D view
- A Statusbar below the 3D view
- A toolbar on the top of the screen
- The edit tool on the left

The toolbar contains buttons for things like loading and saving tracks.

Most items can be used with the mouse. For moving around in the 3D view, the following controls can be used:

- "Dragging" with the left mouse button: rotate the camera view
- "Dragging" with the right mouse button: zoom in / zoom out
- Arrow keys: move the cursor left/right/forward/backward
- PgUp/PgDn keys: move the cursor up/down

The "cursor" position is visible as the position of the blinking tile. The vertical column of tiles on the cursor position is also visible as a white box of lines:

# Track editing

The "blinking" of the cursor shows two states of the track: the current state, and what it will look like when you press the Enter key. Sometimes there will be no difference, and in those cases, you won't see the blinking.

Ultimate Stunts will support multiple editing tools, but currently (version 0.7.5) there is only one tool, which allows you to insert/remove individual tiles. The user interface of that tool can be seen in the left part of the screen, but there are also keyboard shortcuts.

The default mode of this tool is to replace the tile on the cursor position with the selected tile. So, when you click on the OK button in the tool interface (or press Enter), the selected tile is placed on the cursor position. Any existing tile on that position will be removed in the action.

The "+"-button is similar to the OK-button, but it does not replace the tile on the cursor position. Instead, it Combines the existing and selected tile. The other two buttons can be used for rotating the selected tile, and for erasing the existing tile on the cursor position.

The following keys can be used as shortcuts:

- Enter: place the tile (like the OK button).
- Insert: place the tile (like the "+"-button).
- Delete: remove tiles on the cursor position (like the eraser button).
- Tab: select another tile model.
- Shift+Tab: select another tile model (browses tile models in opposite direction).
- r: rotate the tile model (like the rotate button).
- Ctrl+z: undo the last action.
- Ctrl+Shift+z: redo the last undone action.

When you place tiles on the track, you can see that the route information is automatically updated. Whenever the program detects a problem in the route, it will display a question mark at the last correct tile of the route.

Currently, the sizes of the track cannot be changed, and environment settings (background, lighting etc.) cannot be edited. With the current version (0.7.5), all those things need to be done manually in the track file.

# Managing the tiles collection

Sooner or later, you'll want to use a certain tile type, but you can't find it in the tile collection of your track. In this section, you can read how to add and remove tiles to/from your tile collection. The tile collection tool can be accessed by clicking on its button in the toolbar (see image).

The main screen of the tiles collection tool looks like the image below. All tiles currently available in your collection are visible, and you have several options for changing this collection:

- You can change the settings of an existing tile by clicking on it
- You can add a new tile to your collection
- You can remove all unused tiles. It's a smart thing to do this once your track is finished, because it will make the track load faster.
- Finally, you can leave the tile collection tool and return to the main menu

Removing a single tile from the collection can be done by clicking on that tile, and then choose the option to delete it.

# Importing Stunts tracks

One of the options in the track editor toolbar is to import a track from the original "Stunts" (4D Sports Driving) game. If you feel like the current track editor is still too limited, you can make your tracks in Stunts and import them in Ultimate Stunts. You can also use this function to import your large collection of Stunts tracks.

### Configuring the Stunts import function

The Stunts import function can be configured by modifying a file that is located in the Ultimate Stunts data directory: misc/trackedit.conf. In this configuration file, almost the entire track import process can be customized with the variables in the [trkimport] section. This import process has the following steps:

##### 1: Load a template track

Ultimate Stunts loads an ordinary Ultimate Stunts track file, which will act as a starting point for the converted track. This track will be modified later depending on the contents of the .trk file. The filename of this template track can be set with the templatefile variable, for instance:

    templatefile = misc/trackedit.template

The template track has to be at least 30*30 tiles wide and long, and at least 2 tiles high, or more, depending on the configuration of the rest of the import process. All the tiles and textures that will ever be used in the rest of the process should be present in the template track. The initial state of the tiles should be a flat, horizontal ground.

##### 2: Load the terrain

next, the terrain and tile item bytes in the .trk file are processed. All the byte values here are hexadecimal values, but without the usual 0x prefix. What happens here, depends first on the terrain:

- If the terrain byte is 00 (flat ground), only the item byte is processed
- If the terrain byte is is between (including) 01 and 05 (water), then first a water tile is placed by processing the terrain byte, and then the item byte is processed.
- If the terrain byte is 06 (high flat ground), then the item byte is processed, and afterwards the tile height is increased.
- If the terrain byte is between (including) 07 and 0a (diagonal ground), then a tile is placed depending on the combination of terrain and tile byte
- For other tiles, only the terrain byte is processed (on other tiles a Stunts track never has any item

When a terrain byte with the hexadecimal value xy is processed, it is done according to the variable terrain_xy in the conf file. When an item byte with the value pq is processed, it is done according to the variable tile_pq. Finally, for the terrain bytes between 07 and 0a, processing a combination of terrain byte xy and item byte pq is done according to the variable terrain_xy_pq.

All values of the variables terrain_xy, terrain_xy_pq and tile_pq have the same format. This value contains zero or more units of the following form:

    x,y,z:tileID/rotation/altitude;

Every of these units causes one tile to be changed. The values x,y,z tell which tile will be changed. tileID/rotation/altitude are the new settings of the tile, with the same meaning as the three values in the track file format. x,y and z are a position relative to the tile that is being processed. x and y are the relative horizontal position in the track, and z is the layer in the track (the vertical position). So, 0,0,0 is the lowest tile on the processed position, 0,0,1 is the second-layer tile on that position, etc.. Positions like 1,0,0 or 0,1,2 are outside the tile that is being processed, but changing them is allowed to support for large tiles.

The "large tile" item values fd, fe and ff are not processed.