Tile Randomization
Introduction
After you have created your tileset you may have some problems with repeating tiles like this:
This is how you want it to look like:
This page will help you to create randomized tilesets for Newer Super Mario Bros Wii and Reggie.
New Version
Requirements
Tutorial (in-game & Reggie)
Credits: Nin0
If you use a Newer based mod you can edit a so called RandTiles.bin file to add randomizations in-game. Otherwise you will only be able to use tile randomization with the Reggie level editor.
With Puzzle Next you can open both RandTiles.bin files and tilesetinfo.xml files from Reggie. You can then edit the randomizations in the .xml format and save it to both RandTiles.bin and tilesetinfo.xml.
In a sense the RandTiles tab of Puzzle Next is a converter for both formats!
If you want to edit or add randomizations just follow the "Reggie tile randomization (old version)" section of this page. It is recommended that you edit the randomizations in Puzzle Next itself while you have opened the tileset for which the new randomizations are being created, as you can hover your mouse over the tiles to see their row and column.
Old Version
Requirements
- Puzzle
- Ruby
In-game tile randomization
NOTE: This part of the tutorial was originally written by CLF78 on HorizonWII.net so credit goes to him for this part. Some parts were rewritten because not everything was mentioned before.
Pre Steps
- Go in NEWERSOURCES > Kamek > tools and open randtilegen.rb
and open the code in Notepad++
- 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_chika.
- Scroll until the end of the file in Notepad++ (before the directory), then paste the following (If it doesn't exist already) 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 you're done it should 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
- Now you have to find the tiles' coordinates. You have to count the tiles from left to right in hexadecimal which goes like this:
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 first and then the X-position.
Step 3 - Adding randomization to the code
- It is 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 code of the tileset you want to randomize:
g.random([TILE1, TILE2, TILE3, TILE4], :PARAMETER)
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:
g.random(FIRSTTILE..LASTTILE, :PARAMETER)
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:
g.random(0x02..0x07, :horz)
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 only 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
- For example 1 we'll randomize the top tiles. The code would be:
g.random(0x02..0x07, :horz)
- For example 2, we'll randomize the inside ground (which gets 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 of: YOURPATH/NewerRes/RandTiles.bin
- 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:
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 whythis part of the tutorial exists as well.
- Head to the directory where your reggie folder is located and then go to reggiedata > patches > YOUR PATCH > tilesetinfo.xml
Step 1 - Adding your tileset to the Script
Because it is in XML this means it will also have a different listing method. The template below will help 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
- It's almost exactly like the method with Ruby. It's written in hexadecimal as well and you have to write down the Y-Position first 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:
<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" />
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
Top tiles
<random range="0x02, 0x07" direction="horizontal" />
Center tiles
<random range="0x12, 0x17" direction="both" />
Wall tiles
<random list="0x10, 0x20, 0x30, 0x40" direction="vertical" />
Use these examples as a Template for your Randomization.
When you're finished you just need to save the file and reload the tilesets. Then you're done with randomizing your tilesets in Reggie.