Creating enemy routes of battle arenas with Wiimm's tools

From Custom Mario Kart
Jump to navigation Jump to search
Under Construction
This article is not finished. Help improve it by adding accurate information or correcting grammar and spelling.

This tutorial explains the creation of enemy routes in battle arenas using Wiimms SZS Tools. Be sure to understood the concept of Standard Routes and Dispatch Points!

The battle support of Wiimms SZS Tools is in development. At the moment there exists no public release of the tools that can handle the technics of this article. You have to wait for the release of v1.60a.


Introduction

As of v1.60a, Wiimms SZS Tools support an automatic connection of Standard Routes and Dispatch Points. All you need is to setup up the routes and points, edit some settings to advise the KMP compiler, and run the compiler.

Wiimm implemented the auto connection of enemy routes already and started a final test phase. See the change log for progress.

There is a second page with full code examples, which are used as reference from this page.

KMP Compiler

KMP conversions by Wiimms SZS Tools

If a tool of Wiimms SZS Tools reads a file, is does always the same: The file is read into memory and analyzed to find out the data format. If the file has an acceptable file format, a scan function is selected and the file data is scanned and translated into the internal data structures, which can held more data than the files.

In case of KMP (see image on the right), native KMP files and text KMP files are accepted for input. For SZS archives, file course.kmp is searched and scanned. Native are scanned by a binary scanner and text files by a KMP compiler.

Wiimms SZS Tools use a 2-pass compiler to translate KMP text files into the internal data structure. On each pass the complete text file is scanned. In the first pass the file is scanned for name definitions. This allows to use a name before it is defined. Error messages are suppressed. The second pass is used to setup the internal data structure. Error messages about syntax errors or missing names are printed.

The concept of the 2-pass compiler is important for this article, because route links are created by names that are defined later!

The internal data structure allows manipulations of the data on different ways independent of the external file format. Manipulations are for example transformations, but also automatic route connections.

At the end, the data is is stored as as binary (commands ENCODE, PATCH), as text (commands DECODE, PATCH, CAT), or dropped (command CHECK). aof

Standard routes only

ENPT routes of Luigi Circuit

All 32 original racing tracks, and all custom tracks too, uses standard routes. In this case, each end of the routes is linked to 1 to 6 beginnings of other routes. The NEXT links are used for this connections. To get bidirectional links, the PREV links of the destinations are set to the previous routes. The PREV links can be set automatically by analyzing all NEXT links. Wiimm's tools does it, if parameter @AUTO-CONNECT is set to AC$PREV.

Let's look the group headers of Luigi Circuit. You can find the full de-compiled enemy route definition here.

@AUTO-CONNECT = AC$PREV # == automatic calculation of PREV links

 # zero based index: 0,  prev: 1,  next: 4 5
 $GROUP G1,  next: G2A G2B
 ....
 # zero based index: 4,  prev: 0,  next: 2 3
 $GROUP G2A,  next: G3A G3B
 ....
 # zero based index: 5,  prev: 0,  next: 2 3
 $GROUP G2B,  next: G3A G3B

Lines beginning with »#« are comments. Here they show the numerical route index and the links in botth direction. For Wiimm's tool's, the »$GROUP« tells the compiler to start a new group. The group names are generic and the numbering of group names following the links. In this example, group G1 has 2 successors named G2A and G2B. The PREV links are not defined, because they are calculated automatically.

This concept works for battle arenas too. Nintendo used it for SNES Battle Course 4 (A21). Anyway, using dispatch points is the better concept for battle arenas.

Standard routes and dispatch points

ENPT routes of GCN Cookie Land

9 of 10 battle arenas by Nintendo use Dispatch Points. Here we use GCN Cookie Land as example. You can find the full de-compiled enemy route definition here.

The text creator of Wiimm's tools print the standard routes like this:

 # zero based index: 0,  prev: 10,  next: 12
 $GROUP G1,  next: DP4
 $PREV: DP2
 .... some points

Each group name begins with »G« like usual. The group name is followed by the NEXT list. This is the same as for racing tracks. In a second line the PREV links are listed. It is needed because the links are individual and not based on the NEXT links.

A Dispatch Point looks similar, but the names begin »DP«. This makes differentiation between both route types easier:

 # zero based index: 10,  prev:,  next: 0 3 7
 $GROUP DP2,  next: G1 G4 G8
 $PREV:
 $SETTINGS: 0 0x80 AUTO
 .... exact one point

The PREV list is empty. Because there are route setting with values other than zero, an additional $SETTINGS line is printed.

How to create a good ENPT setup

All above is an large introduction. And here begins the real tutorial.

The base tutorial consists of 3 parts:

  • How to create a KMP text file in text.
  • Editing and verifying the text file.
  • Creating the final KMP.

Creating a KMP text file

Wiimms SZS Tools are not good to insert routes. Here are graphical tools definitely better. This is not really a problem. Insert your routes and your dispatch points too. There is no need ti link them, the KMP compiler will do it for you.

If you have a binary KMP, just do one of:

wkmpt decode course.kmp --battle -od course.kmp.txt
wkmpt cat course.kmp --battle >course.kmp.txt

Both commands do the same: Load the binary KMP and write a text KMP.

If you KMP is part of a SZS file, you can use the same commands:

wkmpt decode ARENA.szs --battle -od course.kmp.txt
wkmpt cat ARENA.szs --battle >course.kmp.txt

It is also possible to extract the whole KMP and re-create the SZS later with the updates KMP:

 wszst extract ARENA.szs --battle

In this case, a directory named ARENA.d is created.

Some notes about options:

  • Option --battle disable the auto detection of battles and tells the tools, that the track file is definitely a battle arena.
  • The tools usually don't overwrite existing files. Option --overwrite or short -o disables this security mode.
  • Option --dest FILE or -d FILE selects another destination (output) file.
  • -od FILE is s short form of -o -d FILE is a short form of --overwrite --dest FILE.
  • >FILE redirect the output to FILE.

If you are unsure about using the command line, then read this. Windows users can also create batch files like:

@echo off
wszst extract ARENA.szs --battle
@pause

Edit the ENPT section

The next part is a loop of editing the text file and verifying the results.

To edit the text KMP you need a text editor, but not a document editor like Microsoft Word. A recommendation for Windows users is notepad++.

Open the KMP text file with the editor. In al cases of above, the filename is course.kmp.txt. The scroll to the {ENPT] section. Don't remove or edit other part, if you don't know, what you do. They are needed to re-create the complete KMP file.

Make the following setting (edit the line):

@AUTO-CONNECT = AC$DISPATCH

Below the marker #ENPT# (a comment) you find the decode routes. In case of GCN Cookie Land it looks like here listed.

First, we edit the standard routes. Change this ...

 # zero based index: 0,  prev: 10,  next: 12
 $GROUP G1,  next: DP4
 $PREV: DP2

... to this ...

 $GROUP G1

... for all standard routes to remove the manual links.

Dispatch points looks different. Change this ...

 # zero based index: 9,  prev:,  next: 1 3 4
 $GROUP DP1,  next: G2 G4 G5
 $PREV:
 $SETTINGS: 1 0x40 AUTO

... to this ...

 $GROUP DP1
 $SETTINGS: 1 0x40

and remove the PREV and NEXT links. Keep the $SETTINGS line, if you want to keep the settings.

Verify your edits

Create a new course.kmp

???

Fine Tuning

???

Route Classes

???

One-way links

???

Manual Links

???

Links