Creating enemy routes of battle arenas with Wiimm's tools/code examples

From Custom Mario Kart
Jump to: navigation, search

This page is part of the tutorial »Creating enemy routes of battle arenas with Wiimm's tools« and contains code examples for the KMP compiler of Wiimms SZS Tools.


General Settings

If you create the text version of a KMP (for example by wkmpt cat old_CookieLand_gc), you get the following information in the heading part of section [ENPT]:

#KMP
[ENPT]
....
# AUTO-CONNECT is one of the following AC$* symbols:
# For racing tracks and for battle areenas with manual links setup:
#   AC$OFF
#	Do not any auto connection. Route connection are fully under control
#	of the user. This is the default for check points.
#   AC$PREV
#	Setup PREV links by NEXT links of other routes. Existing PREV links
#	are cleared before. This is the default for enemy and item routes and
#	the behavior of all versions before v1.60a.
#
# Modes for automatic route connection in battle arenas:
#   AC$DISPATCH
#	Find dispatch points and create links automatically if not already
#	set manually. This is the default for enemy routes, if dispatch
#	points detected.
#
# Flags: The modes of above can be combined with the following options by
# the OR operator '|' (example: AC$PREV | ACF$FIX)
#   ACF$FIX_PREV
#	Add self-links, if a PREV list is empty.
#   ACF$FIX_NEXT
#	Add self-links, if a NEXT list is empty.
#   ACF$FIX
#	Abbreviation for: ACF$FIX_PREV | ACF$FIX_NEXT
#	This is the default for item routes to avoid a freeze.
#
@AUTO-CONNECT = AC$DISPATCH

The command @AUTO_CONNECT = selects a main mode for the automatic route connections. The classic definition is AC$PREV, which means, that only PREV links are created automatic by analyzing the NEXT links. This is the behavior of all versions before v1.60a.

Battle arenas, that use Dispatch Points, should use the setting AC$DISPATCH.

Syntax of the new commands

The following syntax overview is printed by the text creator too. A complete syntax description will be added to szs.wiimm.de later.

# Syntax of new command with impact to all following $GROUP commands:
#  "$DEF-CLASS" [":"] class_name

# Syntax of new route commands (placed behind $GROUP command):
#  "$PREV"      [":"] [group_name]...
#  "$SETTINGS"  [":"] setting1 setting2 [ "AUTO" | "ROUTE" | "DISPATCH" ]
#  "$CLASS"     [":"] class_name_prev [class_name_next]
#  "$AC-PREV"   [":"] class_name
#  "$AC-NEXT"   [":"] class_name
#  "$ONEWAY"    [":"] "NONE" | "PREV" | "NEXT" | "BOTH"

Track example: Luigi Circuit

ENPT routes of Luigi Circuit

Luigi Circuit is a simple racing track. It is used here to show the differences between racing tracks and battle arenas.

At the right you find an image with the visualization of the following code. The code is created by the KMP text creator of Wiimms SZS Tools. PREV links are suppressed, because they are not needed as input for this mode. Flags and some comments removed manually.

#KMP
[ENPT]
#....
@AUTO-CONNECT = AC$PREV

#ENPT#
#-----------------------------------------------------------------
#      _____________position_____________    width     properties 
#idx         x           y           z       factor     #1     #2 
#-----------------------------------------------------------------

 # zero based index: 0,  prev: 1,  next: 4 5
 $GROUP G1,  next: G2A G2B

   0   -20100.000     512.635   22000.000   25.000     0x3      0 
   1   -20100.000     636.432   16980.418   25.000       0      0 
   2   -20100.000     797.666   11986.639   27.000     0x4      0 
   3   -19010.008    1019.835    5433.119   20.000       0      0 
   4   -17811.693    1073.134    3950.059   15.000       0      0 
   5   -16326.664    1135.828    3000.000   15.000       0      0 
   6   -10000.000    1576.168    1000.000   25.000       0      0 
   7    -3640.870    2117.703   -1108.698   20.000     0x3      0 
   8     4063.073    2916.057   -5315.689   20.000     0x4      0 
   9     6184.966    3080.382   -5723.592   20.000       0      0 
  10     8273.014    3189.490   -5330.971   20.000       0      0 
  11    12263.215    3301.372   -3141.631   30.000       0      0 
  12    14540.544    3181.466     982.562   20.000       0      0 
  13    14498.519    3056.876    2911.369   15.000       0      0 
  14    14085.271    2930.513    4450.000   15.000       0      0 
  15    11711.629    2535.937    8308.469   25.000       0   0x80 
  16     9000.000    2123.556   12000.000   25.000     0x3   0x80 

 # zero based index: 1,  prev: 2 3,  next: 0
 $GROUP G4,  next: G1

  17   -20059.904     503.322   38176.215   20.000       0  0x100 
  18   -20075.275     489.000   33055.125   25.000     0x3      0 
  19   -20000.000     477.391   28500.000   25.000       0      0 

 # zero based index: 2,  prev: 4 5,  next: 1
 $GROUP G3A,  next: G4

  20    -4000.000     796.038   41500.000   10.000       0      0 
  21    -4143.467     912.076   43953.387    8.000       0  0x300 
  22    -4766.977     922.610   46240.094    8.000       0  0x300 
  23    -6588.950     922.161   48725.625    8.000       0  0x300 
  24    -9324.496     923.282   50462.387    8.000       0  0x300 
  25   -12497.214     938.054   51075.895    8.000       0  0x300 
  26   -15666.517     930.711   50465.996    8.000       0  0x300 
  27   -18414.359     943.018   48740.887    8.000       0  0x300 
  28   -20208.539     924.077   46206.660    8.000       0  0x300 
  29   -20867.574     937.713   43950.000    8.000       0  0x300 

 # zero based index: 3,  prev: 4 5,  next: 1
 $GROUP G3B,  next: G4

  30    -5945.141     502.322   41999.148   10.000       0  0x100 
  31    -6113.494     516.066   44500.000    9.000       0  0x300 
  32    -6913.494     510.116   46151.355    9.000       0  0x300 
  33    -8057.005     509.827   47488.828    9.000       0  0x300 
  34    -9335.633     507.826   48362.910    9.000       0  0x300 
  35   -10921.282     509.959   49002.066    9.000       0  0x300 
  36   -12505.494     510.057   49177.129    9.000       0  0x300 
  37   -14100.012     514.967   49001.480    9.000       0  0x300 
  38   -15719.476     519.499   48374.238    9.000       0  0x300 
  39   -17012.898     520.801   47394.891    9.000       0  0x300 
  40   -18134.811     526.684   46092.539    9.000       0  0x300 
  41   -19051.674     535.258   43517.348    9.000       0  0x100 

 # zero based index: 4,  prev: 0,  next: 2 3
 $GROUP G2A,  next: G3A G3B

  42     5176.636    1597.956   16345.912   25.000     0x3      0 
  43      500.000     997.560   21500.000   25.000       0      0 
  44    -3289.936     573.829   25600.246   25.000     0x4      0 
  45    -4800.000     474.342   28800.000   27.000       0      0 
  46    -4853.532     465.042   33981.555   27.000       0      0 
  47    -4896.699     486.310   38159.902   27.000       0      0 

 # zero based index: 5,  prev: 0,  next: 2 3
 $GROUP G2B,  next: G3A G3B

  48     5291.333    1597.507   16442.049   15.000     0x1   0x80 
  49     1931.158    1107.562   20884.963   12.000       0      0 
  50      479.574     875.750   23759.658   12.000     0x2      0 
  51     -378.226     709.943   26439.178   12.000     0x3      0 
  52    -1166.926     702.084   28902.848   10.000     0x3      0 
  53    -2999.872     484.860   33950.590   15.000       0      0 
  54    -3850.000     518.291   38129.637   12.000     0x4  0x100 

Arena example: GCN Cookie Land

ENPT routes of GCN Cookie Land

Battle arena GCN Cookie Land has the simplest enemy route layout.

At the right you find an image with the visualization of the following code. The code is created by the KMP text creator of Wiimms SZS Tools. Flags and some comments removed manually.

#KMP
[ENPT]
#....
@AUTO-CONNECT = AC$DISPATCH

#ENPT#
#-----------------------------------------------------------------
#      _____________position_____________    width     properties 
#idx         x           y           z       factor     #1     #2 
#-----------------------------------------------------------------

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

   0    -3600.000    8915.478     300.000   27.875       0      0 
   1    -3150.000    8919.220   -1800.000   28.125       0      0 
   2    -1550.000    8914.084   -3250.000   28.750       0      0 

 # zero based index: 1,  prev: 11,  next: 9
 $GROUP G2,  next: DP1
 $PREV: DP3

   3    -1500.000    9545.223   -7400.000   21.625       0      0 
   4    -3900.000    9550.359   -6500.000   20.625       0      0 
   5    -6400.000    9544.316   -4000.000   20.750       0      0 
   6    -7500.000    9542.847    -850.000   20.875       0      0 
   7    -7100.000    9536.079    2400.000   20.250       0      0 

 # zero based index: 2,  prev: 11,  next: 13
 $GROUP G3,  next: DP5
 $PREV: DP3

   8     1300.000    9539.489   -7400.000   22.000       0      0 
   9     3700.000    9533.851   -6500.000   21.500       0      0 
  10     6200.000    9540.485   -4300.000   21.750       0      0 
  11     7400.000    9539.489   -1300.000   21.250       0      0 
  12     7100.000    9519.140    2100.000   21.000       0      0 

 # zero based index: 3,  prev: 9,  next: 10
 $GROUP G4,  next: DP2
 $PREV: DP1

  13    -5200.000    9290.206    3000.000   32.125       0      0 
  14    -3700.000    9009.714    2200.000   27.750       0      0 

 # zero based index: 4,  prev: 13,  next: 9
 $GROUP G5,  next: DP1
 $PREV: DP5

  15     5800.000    9531.372    4700.000   20.375       0      0 
  16     3200.000    9535.469    6800.000   20.250       0      0 
  17     -250.000    9537.290    7500.000   20.125       0      0 
  18    -3400.000    9537.681    6700.000   20.250       0      0 
  19    -5600.000    9537.915    5000.000   20.125       0      0 

 # zero based index: 5,  prev: 13,  next: 14
 $GROUP G6,  next: DP6
 $PREV: DP5

  20     5500.000    9341.353    3100.000   32.375       0      0 
  21     4400.000    9134.558    2500.000   28.375       0      0 

 # zero based index: 6,  prev: 14,  next: 12
 $GROUP G7,  next: DP4
 $PREV: DP6

  22     3600.000    8881.299     300.000   26.875       0      0 
  23     3150.000    8882.148   -1800.000   28.250       0      0 
  24     1500.000    8884.924   -3250.000   28.125       0      0 

 # zero based index: 7,  prev: 10,  next: 14
 $GROUP G8,  next: DP6
 $PREV: DP2

  25    -2050.000    8900.004    2950.000   26.250       0      0 
  26        0.000    8915.478    3600.000   27.875       0      0 
  27     2050.000    8910.668    2950.000   28.125       0      0 

 # zero based index: 8,  prev: 12,  next: 11
 $GROUP G9,  next: DP3
 $PREV: DP4

  28      100.000    9124.568   -5000.000   27.750       0      0 
  29        0.000    9372.201   -6500.000   32.000       0      0 

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

  30    -6400.000    9511.299    3600.000   21.750       0      0 

  30    -6400.000    9511.299    3600.000   21.750       0      0 

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

  31    -3100.000    8920.116    1900.000   27.875       0      0 

 # zero based index: 11,  prev:,  next: 1 2 8
 $GROUP DP3,  next: G2 G3 G9
 $PREV:
 $SETTINGS: 1 0x00 AUTO

  32        0.000    9553.799   -7450.000   21.750       0      0 

 # zero based index: 12,  prev:,  next: 0 6 8
 $GROUP DP4,  next: G1 G7 G9
 $PREV:
 $SETTINGS: 0 0xc0 AUTO

  33      100.000    8942.231   -3800.000   28.750       0      0 

 # zero based index: 13,  prev:,  next: 2 4 5
 $GROUP DP5,  next: G3 G5 G6
 $PREV:
 $SETTINGS: 0 0x40 AUTO

  34     6500.000    9525.596    3600.000   21.750       0      0 

 # zero based index: 14,  prev:,  next: 5 6 7
 $GROUP DP6,  next: G6 G7 G8
 $PREV:
 $SETTINGS: 1 0x40 AUTO

  35     3200.000    8925.013    1800.000   28.750       0      0 

Minimized text with auto-connect support

The following ENPT code is based on the code above, but all not needed commands are removed. The auto-connect functionality of the KMP compiler will find the connections automatically and will produce the same data as the original.

Changing names doesn't change the output, because names are only needed for manual links. The code doesn't use any link. So it's possible to remove all names (but not the complete $GROUP line) to make the code even smaller.

#KMP
[ENPT]
#....
@AUTO-CONNECT = AC$DISPATCH

#ENPT#
#-----------------------------------------------------------------
#      _____________position_____________    width     properties 
#idx         x           y           z       factor     #1     #2 
#-----------------------------------------------------------------

 $GROUP G1

   0    -3600.000    8915.478     300.000   27.875       0      0
   1    -3150.000    8919.220   -1800.000   28.125       0      0
   2    -1550.000    8914.084   -3250.000   28.750       0      0

 $GROUP G2

   3    -1500.000    9545.223   -7400.000   21.625       0      0
   4    -3900.000    9550.359   -6500.000   20.625       0      0
   5    -6400.000    9544.316   -4000.000   20.750       0      0
   6    -7500.000    9542.847    -850.000   20.875       0      0
   7    -7100.000    9536.079    2400.000   20.250       0      0

 $GROUP G3

   8     1300.000    9539.489   -7400.000   22.000       0      0
   9     3700.000    9533.851   -6500.000   21.500       0      0
  10     6200.000    9540.485   -4300.000   21.750       0      0
  11     7400.000    9539.489   -1300.000   21.250       0      0
  12     7100.000    9519.140    2100.000   21.000       0      0

 $GROUP G4

  13    -5200.000    9290.206    3000.000   32.125       0      0
  14    -3700.000    9009.714    2200.000   27.750       0      0

 $GROUP G5

  15     5800.000    9531.372    4700.000   20.375       0      0
  16     3200.000    9535.469    6800.000   20.250       0      0
  17     -250.000    9537.290    7500.000   20.125       0      0
  18    -3400.000    9537.681    6700.000   20.250       0      0
  19    -5600.000    9537.915    5000.000   20.125       0      0

 $GROUP G6

  20     5500.000    9341.353    3100.000   32.375       0      0
  21     4400.000    9134.558    2500.000   28.375       0      0

 $GROUP G7

  22     3600.000    8881.299     300.000   26.875       0      0
  23     3150.000    8882.148   -1800.000   28.250       0      0
  24     1500.000    8884.924   -3250.000   28.125       0      0

 $GROUP G8

  25    -2050.000    8900.004    2950.000   26.250       0      0
  26        0.000    8915.478    3600.000   27.875       0      0
  27     2050.000    8910.668    2950.000   28.125       0      0

 $GROUP G9

  28      100.000    9124.568   -5000.000   27.750       0      0
  29        0.000    9372.201   -6500.000   32.000       0      0


 $GROUP DP1
 $SETTINGS: 1 0x40

  30    -6400.000    9511.299    3600.000   21.750       0      0

 $GROUP DP2
 $SETTINGS: 0 0x80

  31    -3100.000    8920.116    1900.000   27.875       0      0

 $GROUP DP3
 $SETTINGS: 1 0x00

  32        0.000    9553.799   -7450.000   21.750       0      0

 $GROUP DP4
 $SETTINGS: 0 0xc0

  33      100.000    8942.231   -3800.000   28.750       0      0

 $GROUP DP5
 $SETTINGS: 0 0x40

  34     6500.000    9525.596    3600.000   21.750       0      0

 $GROUP DP6
 $SETTINGS: 1 0x40

  35     3200.000    8925.013    1800.000   28.750       0      0

Links