Tile Randomization

If your custom tileset doesn't replace an already existing one, you'll likely have issues with the tiles being repetitive, like the image below. This is how you want it to be, randomized and non-repetitive. This page will help you create randomized tilesets for both Newer Super Mario Bros Wii and Reggie.

= Using Puzzle Next =

Requirements
- Puzzle Next

Credits: Nin0

If you use a NewerSMBW based mod you can edit a file in the  folder named , which adds tileset randomizations in-game (retail tileset randomization is done in the game's code). If you are not using Newer as a base, you will only be able to use tile randomization with Reggie.

With Puzzle Next you can open both  file, and Reggie's equivalent, the file in   named. With Puzzle Next, you can edit both these files in the XML format and save it to both Newer's  file and also Reggie's   file (note that you can edit this file in any text editor, as it is in XML format).

= Making Tileset Randomizations = NOTE: If your tileset is similar enough to another tileset, you can simply add the tileset to the group with the tileset it is similar to.

This applies for both the  file and Reggie's   file. Both the  file and Reggie's   are in the same format, so no conversions/edits need to be made to the randomization code when putting it in the files. Reggie's  file is in the   folder. If you're using Reggie Next, and want to edit a Game Patch's randomizations, it can be found in, and the file will have the same name.

Step 1 - Beginning Group Listing
To save space, tileset randomizations are defined in groups with the randomization rules inside. This is so tilesets that have similar setups can get randomization from the same group.

This is how a group is defined. The randomization rules go inside the empty space. in the names section (where "TILESETNAME, ANOTHERTILESETNAME" are at), you can define the name of your tileset. To do so, use the name of the tileset file, but leave the .arc extension off. The tileset name in the randomization file must be identical to the tileset file's name, or it will not work. Here's an example of a group with the  tileset defined.

Step 2 - Choosing Tiles to Randomize (Finding Tile Positions)
When choosing the tiles you want to randomize, you need to get the X and Y position of them. These positions are in hexadecimal (0 through F, which is 1 through 16), and are above the tileset pane, in the image below.

The X-position is referred to as the Column, and the Y-position is referred to as the Row.

Step 3 - Adding Randomization Rules
Now it's time to actually start adding randomization. Randomization rules start with this tag: After that, we will want to define the type of randomization that will be used: The first is the range randomization. The last is the list randomization.

Range Randomization Type
The range randomization type works by selecting a range of tiles to be randomized. It can be done like so: In most cases, this is used for the top ground (grass), bottom ground (ceilings), and inner ground tiles (middle ground).

Let's say we want to apply it to the  tileset's grass tiles. We can do that by getting the XY positions of the leftmost tile, and the rightmost tile. To get the position of these tiles, hover over them to get the Row and Column position. The leftmost tile is Row 0, Column 2, while the rightmost tile is Row 0, Column 7.

When putting the tiles into the randomization rule code, you want to start with, then put the Row number and the Column number, without any spaces. For example, the leftmost tile would be.

Once you have your tile's positions, you can insert them into the randomization rule:

List Randomization Type
The list randomization type works by listing the tiles to be randomized, which is for when the tiles aren't in left-right order. It can be done like so: In most cases, this is used for the left/right wall tiles, which are usually arranged vertically in the tileset.

For this example, we'll randomize the left wall tiles in the  tileset. To begin, we'll want to get the positions of our tiles (the inner wall tiles, not the grass or ceiling corners). The topmost tile is Row 1, Column 0, while the bottommost tile is Row 4, Column 0.

When putting the tiles into the randomization rule code, you want to start with, then put the Row number and the Column number, without any spaces. For example, the topmost tile would be.

For lists, you need to also put in the positions of every tile you want to include.

Once you have your tile's positions, you can insert them into the randomization rule: The values field is where you can define the tiles that will be used, whereas the actual tile position in the list field is what tile these randomizations are applied to.

Randomization Direction
After the randomization type, there is another field titled direction, which is used for defining which direction the tile will be stretched.

There are three directions that can be used, vertical, horizonal, and both.


 * Vertical is for tiles that go up-down, such as wall tiles.
 * Horizontal is for tiles going left-right, such as grass or ceiling tiles.
 * Both is for tiles going both ways, such as the inner-ground tiles.

They can be defined like this:

= Using the 'randtilegen.rb ' Script (Old Method) = This method is outdated. It involves using a Ruby script to generate a  file. The method of directly editing it in Puzzle Next is much more recommended.

Requirements
- Newer Source Code

- Puzzle

- Ruby

- A text editor of choice like Notepad++

In-game tile randomization
'''NOTE: This part of the tutorial was originally written by CLF78 on the HorizonWII.net forums before they were shut down. Some parts were rewritten because not everything was mentioned before.'''

Pre Steps
- Go to  and open the code in your text editor

- Open your tileset in Puzzle, to better visualize what tiles you want to randomize

Step 1 - Adding your tileset to the script
- This will add your tileset to the randomization list. For this example we'll be using the tileset Pa1_nohara. - Scroll until the end of the file (before the directory), then paste the following and don't forget the PaX_ prefix - Edit this template as you wish (remove the second tileset, if you don't need it) - When you're done it should look like this:

Step 2 - Choosing the tiles to randomize
- These steps will allow you to find what tiles will be randomized

- Go back to Puzzle

- Now you have to find the tiles' coordinates. You have to count the tiles from left to right in hexadecimal which goes like this:

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

Step 3 - Adding randomization to the code
- It is now time to add the randomization code for the newly-added tileset!

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

If you have many tiles that are next to each other, like in the example above, you can do that in a quicker way by using the following template:

Note that a parameter is not necessary. For example if we want to randomize the tiles from X=2 and Y=0 to X=7 and Y=0 it would look like this:

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

-   is for tiles that are only expanded horizontally

-   is for tiles that are only expanded vertically

-   is for tiles that are expanded in both directions

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

Examples
- For example 1 we'll randomize the top tiles. The code would be: - For example 2, we'll randomize the inside ground (which gets expanded in both directions), so this time the code will be: - 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: 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 of:

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

- Open the terminal window from the folder, and type the following:

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