Jump to navigation Jump to search

Tile Randomization

Introduction[edit | edit source]

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:

Without Randomization.png

This is how you want to let it look like:

With Randomization.png

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.

Requirements[edit | edit source]

- Newer Sources

- Puzzle

- Ruby

- Notepad++

Ingame tile randomization[edit | edit source]

Pre Steps[edit | edit source]

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

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

Step 1 - Adding your tileset to the Script[edit | edit source]

- This will add your tileset in the randomization list. For this example, i'll use Pa1_nohara. (This tileset is already randomized but i want to use it as an example)

- Scroll until the end of the file in Notepad++ (before the directory), then paste the following (DON'T forget the PaX_ prefix)


- 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


Step 2 - Choosing the tiles to randomize[edit | edit source]

- 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[edit | edit source]

- 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) :


Note that the parameter is not necessary.

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


Parameters[edit | edit source]

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

- none is for tiles that aren't expanded, and here the game will choose a random one between the given ones

- 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[edit | edit source]

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[edit | edit source]

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

- After editing the code, go back to Puzzle, and remove/shrink the objects which are going to be randomized, or randomization won't work properly

- 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[edit | edit source]

This part is still work in progress and will be made / written by B1_Gaming. Thanks for your Attention.