KMP Editing

From Custom Mario Kart
Jump to navigation Jump to search

This part of the Custom Track Tutorial will tell you all the basics of editing the KMP file in SZS Modifier. Editing the KMP is part of making a custom track, as it contains data for start position, CPU routes, object placement and much more.



Introduction

This tutorial is covered with images from the KMP of The Hole Cave, a custom track. It's good to know, for this tutorial, that the track goes in a clockwise direction when looking at the map from the editor. That track was chosen for the tutorial because of it's relatively simple design. It shares many similarities with the KMP file of N64 Bowser's Castle.

The KMP Modifier program is mentioned several times in this page, and it's use is to increase or decrease the amounts explained later.

Note that the Objects section of this guide makes use of object names, not object numbers. By default, the numbers are displayed. To get the names to be displayed, you have to download and extract this XML into your SZS Modifier install directory: http://www.mediafire.com/?0tzr49x0gq51gx9 or use http://www.mediafire.com/?b6k2j8892gmxq8p to dislplay the needed files along. xB means that there are x brres files needed and xE means there are x Effect pairs needed.

If you're an experienced hacker and want to look further into the KMP, such as hex editing, you can take a look at the KMP (File Format) page.

Hexadecimal Numbers

KMP Editing will require some acknowledged about hexadecimal numbers; these are numbers used to write values stored in a KMP. One byte of hex can go up to 0xFF, this is 255 in decimals. This makes using hexadecimals more efficient since you can have up to 255 possible values instead of 99 when using decimals. Most times hexadecimals will be prefixed with 0x (like 0x00 for 0 or 0xff for 255). It's a way to distinguish between decimal and hexadecimal numbers. But in the SZS Modifier don't use this prefix because he expect always hexadecimal numbers (except for floating point numbers).

A decimal numbering system needs 10 digits, usually 0..9. A hexadecimal numbering system needs 16 digits. Therefor the first 6 letters A..Z (or a..z) are used as digits with value 10..15.

The positional meaning of hexadecimal numbers (base=16) is similar to decimal numbers (base=10).

  • Decimal number 123 means: 1*100 + 2*10 + 3*1
  • Hexadecimal number 0x123 means: 1*0x100 + 2*0x10 + 3*0x1 == 1*256 + 2*16 + 3*1 == 291 (decimal)

You can convert hex to decimal by using your windows calculator, click on view and change the check (by default standard is checked) to the other options, if letters appear you're good. Then search for multiple radio buttons having Hex, Dec, Oct (Octal numbers, base=8, digits=0..7), Bin (binary numbers, base=2, digits=0..1); When Dec is checked and you enter a number it's just the number you entered, but if you check Hex the number gets converted to hex.

KMP Editing

The KMP editor open, editing the start position of The Hole Cave.

The KMP editor displays an image based off from the minimap of the course, not it's actual model, so you have to create that before editing the KMP.

General Info

  • To move a point around, click on it and drag it around. The only section that doesn't involve points is the checkpoint one, which will be discussed later.
  • When moving points, you'll notice that you can only move the dots in the X and Z axis, that means right/left and foward/backward. To change the height, which is the Y axis, you have to double-click the value in the box in the bottom part of the window. To know what to input, you have three choices:
    • Guess the value by yourself, by trial and error.
    • If you created the model using Paint, you can use the formula: (MaxY - MinY) / 255 * GrayscaleValue + MinY
      • To find the MaxY and MinY, you have to look in the box that appears in the Model Editor while only the polygon of the road is selected
    • If you created the model in a 3D modeler: most modelers can tell the X, Y and Z coordinates of any point in the model. That doesn't apply to Google Sketchup - if you're using it, you can discover the Y position of a certain road section by drawing a simple square on top of the model, exporting it as OBJ, and looking inside the OBJ file using a text editor, where the data for positions is stored.
  • The angles used for start, object, AREA, camera, respawn, cannon and MSPT positions' rotations start with 0 for the bottom (pointing south), and follow this setup:
Kmp-anglewheel.jpg

Notice that upwards (pointing north) can be either 180 or -180.

  • The KMP Editor allows to edit up to 3 rotations; X-angle is Pitch, Y-angle is Yaw and Z-angle is Roll
File:YawPitchRoll.jpg
The angles explained with a plane

Start Position

The KMP editor open, editing the start position of The Hole Cave.

This is the position where the players start at at the beginning of the race. It's rather easy to edit this, since you simply move the dot to it's position and set it's Y value and rotation (explained how above). To prevent the camera under the ground bug, change its Y value to something slightly higher than other objects directly on the track. Changeable settings:

KTPT
Setting name Comment
Position (X, Y, Z) The location where you're placed in a time trial, in VS races the players are placed in back of it.
Angle (X, Y, Z) The way players are placed, it can be turned around and placed on a slope.
Player Only used in battles; the player that starts at that point, if unsure enter -127 (-1)

There are 2 related settings int the STGI section:

  • The byte at offset 0x01 decides, if the first player (pole position) starts on the left (=0) or right (=1) side.
  • Is the byte at offset 0x02 set to 1, then the player are closer together.

Enemy Routes

The editor open in The Hole Cave's CPU routes

The routes that the CPU characters follow are set by lines of points. To edit then, you drag then to the new position and set the Y, but you don't need to set rotation for a CPU route point. The points must be kept in the same order than the original layout, since the CPU will follow the points in order.

  • ID Column: Use this to know the order
  • ? Column: Unknown function
  • Settings Column: Specific point settings

When the players are supposed to split in two different routes, as shown in the picture (where they split in two directions, near the end of the track), the cpu routes are split in multiple "Sections", as also shown in the picture. To know what order the CPU will follow all the sections, you can open the KMP file in the KMP Modifier and look. A split in up to 6 routes is possible. Some or all splitted routes can be splitted again. A good way to sort and manage the sections is the KMP decoder+compiler of Wiimms SZS Tools.

Sometimes, the CPU are only allowed to follow a specific section in certain conditions. For example, in SNES Mario Circuit 3 the path splits in two at a point, but the CPU only follow the lower one if they have a mushroom item. This is controlled by the ENPT Settings.

ENPT
Settingname Comment
Position (X, Y, Z) The center of the area computers will reach, they always follow the order of the points.
Pointsize (?) The size of the area, use a low value for narrow sections of the track and a big value for big sections
Settings The settings for that routepoint, see ENPT Settings


Item Routes

The Item routes

The Item routes set the paths that the Bullet Bill and the Red/Blue shells will take. They have the exact same format of the CPU routes section and are edited the exact same way, so every information that applies to them apply here as well. But they are usually more complex, having more points and sections than the CPU do. That's because the CPU have an AI to help then following the routes, but the shells and bullet bill don't, so they follow the routes exactly as they are set.


ITPT
Settingname Comment
Position (X, Y, Z) The center of the area items will reach, they always follow the order of the points.
Pointsize (?) The size of the area, use a low value for narrow sections of the track and a big value for big sections
Settings The settings for that routepoint, see ITPT Settings


Checkpoint Positions

The Checkpoint editor

The basics of editing the checkpoints are the same of editing CPU and Item routes, so most of their information also apply here. To move a checkpoint, drag the end of the line as if it was a dot. There are no Y positions in the checkpoints, so you only have to drag then to their positions. To know the correct direction of a checkpoint, tick the "Show Arrow" option. There is an option to draw a line showing which parts of the track are controlled by checkpoints and which parts aren't. Part's that aren't controlled can cause positionjumping. (Positionjumping is: you're last but for a few seconds the screen says you're 4th)

  • Respawn Column: It tells which respawn the player will appear at after falling from that checkpoint's area, check Respawn Positions for more info
  • ? Column: This is actually known:
    • 00: First checkpoint, it makes the lap count work
    • FF: Normal checkpoint, only used for placement and respawn
    • 01, 02, 03 etc: Key (or mandatory) checkpoint, you must pass through each of those in order, you can't skip any of those and cross another Key checkpoint unlike the normal FF ones, use to prevent ultra shortcuts
  • Last and Next Columns: This ones make the checkpoints get "linked". When you add more sections, you have to write -127 in the "last" column of the first checkpoint and -127 in the "next" column of the last checkpoint in EVERY section you add. This is necessary and required if, for example, your track has a shortcut. If one of the checkpoints in a section is not linked to the next and the past, your track will not work; and if you select back your section and -1s appear as -127s, just write up -127 instead of -1.

Some hints how to place the mandatory check points:

  1. Place the first mandatory check point 500-1000 units behind the lap count, so that the driver must cross both. This is the best possibility to activate the mandatory check point system and to avoid tricks to ignore them.
  2. Place the checkpoint after the last mandatory check point on a place that can't be reached without hitting another checkpoint after the start, the same counts for all other mandatory check points.
  3. Place more mandatory check point around the track. Best is to place them at the extreme points of the track. It is important the the check point covers the whole lane including offroad. Bit it must not cover any other lane or part of the track.

Global Objects

KMP Objects.png

Global objects are predefined objects. They can be placed anywhere on the map. Most objects needs additional files (BRRES, BREFF, BREFT, KCL and/or BRASD → see »Object Table« for details). As recommendation for the SZS Modifier download KMPItems.xml. It contains all known objects with hints about the needed files (→ Details).

Each section entry defines:

  • The unique ID (number) of the object. See »Object Table« for an overview or try »KMP Object Query« to search for objects.
  • An unknown 16 bit value (perhaps alignment filler).
  • The object's position (X, Y, Z) as 32 bit floating point number.
  • The object's rotation (Roll, pitch, yaw) as 32 bit floating point number. The object rotates around the given axis.
  • The object's scale, compared to the BRRES model (X, Y, Z) as 32 bit floating point number. Some objects (e.g. itemboxes) can't be scaled.
  • A route index (-1 or 0xff for no route).
  • Settings 1 to 8: depending on the object. (For exact settings, see the objects page)
  • presence flags.

The SZS Modifier shows the route index, the 8 settings and the presence flags as five 32-bit numbers instead of ten 16-bit numbers (→ details).

Routes

→ see Object Routes are used by multiple things, like Cameras and objects. The settings are XXXXYYYY, where X is mosttimes the speed or time and Y is an option which can have multiple functions.

Cameras (AREA+CAME)

→ see Cameras

Respawn Positions

These are the places where you are set back, after you fall of the course.

To link check points to respawn positions, use the Respawn setting in the checkpoints settings, and enter the ID of the respawn point you want (First column).

The second ID column is from an early stage of the game and is unused.

Do not place respawn points on narrow sections of track (2500m or less), especially if there are walls or drop offs on either side. This is because the game moves players to either side of the respawn point when respawning two or more players at the same time, and they can become stuck in an endless respawning loop.

Note: Do not place respawns just after a mandatory checkpoint. This way you might skip the checkpoint resulting laps not to count.

Cannon Positions

These are the places where the cannon shoots you to. This is explained in the Creating a Cannon section of the tutorial.

MSPT

After battles and competitions have ended, the players are placed on these points. Used only when making custom battle arenas and competitions; placement is similar to Start Position.

Advanced

If a course model was scaled, the position, size and perhaps rotation values if the KMP must be scaled too. This may be 1000 or more single values. Wiimms SZS Tools are able to shift, scale and rotate horizontally all KMP values → more transformation details

Links