Tile Randomization

Introduction

NOTE: The ingame part of the tutorial was originally written by customlevelfan78 on HorizonWII.net so credit goes to him for this part. I have rewritten it a bit because there were some things that were not mentioned in his tutorial.

After you've created a tileset you may have some problems with repeating tiles like this:

This is how you want to let it look like:

Otherwise i don't know why you are here. ;)

This tutorial will help you to create a randomization for tiles inside Newer Super Mario Bros Wii and Reggie.

- Ruby

Ingame tile randomization

Pre Steps

- Go in NEWERSOURCES > Kamek > tools and open randtilegen.rb and open the code in Notepad++

- Open your tileset in Puzzle, to have it ready and choose the tiles

Step 1 - Adding your tileset to the Script

- This will add your tileset in the randomization list. For this example, i'll use Pa1_nohara. (This tileset is already randomized but it wille be the example now)

- Scroll until the end of the file in Notepad++ (before the directory), then paste the following ( If it doesn't already exist and DON'T forget the PaX_ prefix)

g.section('TILESETNAME', 'ANOTHERTILESETNAME') do

end

- Edit this template as you wish (remove the second tileset, if you don't need it)

- When filled, it will look like this :

g.section('Pa1_nohara') do

end

Step 2 - Choosing the tiles to randomize

- These steps will allow you to find what tiles will be randomized

- Go back to Puzzle (if it helps, toggle alpha by clicking on the related option in Tasks)

- Now you have to find the tiles' coordinates : to count the tiles you have to count the hexadecimal way which counts like the following:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

- Remember that you have to write the Y-postition and then the X-position.

Step 3 - Adding randomization to the code

- It's now time to add the randomization code to the newly-added tileset!

- Paste the following template in a new line inbetween the start and the end of the tileset code :

g.random([TILE1, TILE2, TILE3, TILE4], :PARAMETER)

If you have many tiles that are next to each other, like in the first and second example, you can make it in a quicker way, using the following template (the first and last tiles are included) :

g.random(FIRSTTILE..LASTTILE, :PARAMETER)

Note that the parameter is not necessary.

For example from X=2 and Y=0 to X=7 and Y=0 itwould look like this:

g.random(0x02..0x07)

Parameters

Parameters tell the game in which direction to randomize. Their usage depends on the tile's usage in Reggie

- horz is for tiles that are only expanded horizontally

- vert is for tiles that are expanded vertically

- both is for tiles that are expanded in both directions

- horz_vdouble_top and horz_vdouble_bottom are for couples of tiles, as they allow to apply randomization to both while matching each top tile (where horz_vdouble_top is applied) to the respective bottom one (where horz_vdouble_bottom is applied ).

Examples

A small information before the examples: I've written 0x** (** = Tilenumber) to make sure everything works. You could just leave the tilenumber.

- For example 1 we'll randomize the grass top. The code would be:

g.random(0x02..0x07,  :horz)

- For example 2, we'll randomize the inside ground (therefore expanded in both directions), so this time the code will be:

g.random(0x12..0x17,  :both)

- In example 3, the tiles are not next to each other, so they will have to be listed individually. This also applies to vertical walls. In this case the code will be:

g.random([0x10, 0x20, 0x30, 0x40],  :vert)

Use these examples as a Template for your Randomization.

Step 4

- At the very end of the file you'll find a directory. Change it to the NewerRes folder you want to have it inside.

- Make sure that you have a folder with the randtilegen.rb file and a shortcut of the terminal in it.

- Now open the terminal window from the foldeer, and type the following :

ruby randtilegen.rb

- This will generate a RandTiles.bin ready to be used in-game

Reggie tile randomization

Presteps and differences

There aren't many differences between the code of the randtilegen.rb file and this one except it's written in the XML language.

While the code of the Ruby file looks like this:

g.random(0x02..0x07)

the code of the XML file looks like this:

<random range="0x02, 0x05" direction="horizontal" />

As you can see there are some small differences which is why I am making a tutorial for this part as well.

- Head to the directory where your reggie folder is located and then go to reggiedata > patches > YOUR PATCH NAME > tilesetinfo.xml

Step 1 - Adding your tileset to the Script

Because it is in XML this means that it will also have another listing method. For that reason I will provide another template for you:

<group names="TILESETNAME,  ANOTHERTILESETNAME">

</group>

- Again edit this template as you wish (remove the second tileset, if you don't need it)

- When filled, it will look like this :

<group names="Pa1_nohrara">

</group>

Step 2 - Choosing the tiles to randomize

- This is literally the same as with the ruby part. It's written in hexadecimal as well as you have to list the Y-position first and then the X-positon

Step 3 - Adding randomization to the code

- It's now time to add the randomization code to the newly-added tileset!

- Paste the following template in a new line inbetween the start and the end of the tileset code :

<random list="TILE1, TILE2, TILE3, TILE4" direction="PARAMETER" />

If you have many tiles that are next to each other, like in the first and second example, you can make it in a quicker way, using the following template (the first and last tiles are included) :

<random range="FIRSTTILE, LASTTILE" direction="PARAMETER" />

Note that the parameter is not necessary.

For example from X=2 and Y=0 to X=7 and Y=0 it would look like this:

<random range="0x02, 0x07" />

Parameters

Parameters tell the game in which direction to randomize. Their usage depends on the tile's usage in Reggie :

- horizontal is for tiles that are only expanded horizontally

- vertical is for tiles that are expanded vertically

- both is for tiles that are expanded in both directions

- double_top and double_bottom are listed as special parameters and will be added behind the normal parameter:

<random range="0x02, 0x07" direction="horizontal" special="double-top" />

Examples

- For example 1 we'll randomize the grass top. The code would be:

<random range="0x02, 0x07" direction="horizontal" />

- For example 2, we'll randomize the inside ground (therefore expanded in both directions), so this time the code will be:

<random range="0x12, 0x17" direction="both" />

- In example 3, the tiles are not next to each other, so they will have to be listed individually. This also applies to vertical walls. In this case the code will be:

<random list="0x10, 0x20, 0x30, 0x40" direction="vertical" />

Use these examples as a Template for your Randomization.

You don't need to anything else than just to save it.

I hope this tutorial was helpful for you.

Good luck with creating randomized tiles now! ;)